Over a million developers have joined DZone.

Eclipse CDT: Showing the Return Value of a Function With Step-Return

DZone's Guide to

Eclipse CDT: Showing the Return Value of a Function With Step-Return

Eclipse CDT has a nifty feature that lets you see the return values of functions after step-returns. Learn how to set it up and make use of it.

· IoT Zone ·
Free Resource

Digi-Key Electronics’ Internet of Things (IoT) Resource Center Inspires the Future: Read More

I recently discovered a nice feature in Eclipse CDT: the ability to show the return value of a function:

Return Value shown as Variable

That feature has existed since Eclipse CDT 8.4, but it is easy to miss.

It solves the problem that usually it is not possible to ‘see’ the function's return value if it is not assigned to a local variable.

Consider the following example:

int computeValue(int i) {
    return i*3;

int foo(int i) {
    if (computeValue(i)!=0) {
        return 1;
    } else {
        return 1;

In the above (simplified) case, the return value of computeValue() is returned in a register and not stored as a local variable. That way, I cannot inspect the local variable view while stepping through the code. What I did in the past was assembly stepping and inspecting the Registers view, knowing that the return value will be passed back in register R0. Which is really painful.

Eclipse CDT 8.4 has added the nice feature to show the return value after a step-return in the Variables view.

Here is how it works.

  1. Step into the function for which you are interested to see the return value. Or set a breakpoint inside that function.
  2. From there, perform a ‘step-return’ action:inside returning function
  3. Eclipse CDT now shows the return value to the caller function as a pseudo-local variable inside the Variables view, at the beginning of the variables list.
    Return Value shown as Variable

In my case (NXP MCUXpresso IDE 10.2 (Eclipse Oxygen with CDT 9.4.3), it shows the variable with a ‘$’ and a number, while the Eclipse help page indicates that it could show more descriptive text (e.g. ‘computeValue() returned’), and I’m not sure why this is not the case for me.

With this, I’m able to see the function return value without checking the Registers view!

Happy Step-Returning.

Digi-Key’s IoT Component Selector is your one-stop-shop for the IoT

iot ,step-return ,eclipse cdt ,return value ,function ,tutorial

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}