I recently discovered a nice feature in Eclipse CDT: the ability to show the return value of a function:
That feature exists 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 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 doing 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.
- Step into the function for which you are interested to see the return value. Or set a breakpoint inside that function.
- From there, perform a ‘step-return’ action:
- 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.
π‘ 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 a 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 π
Links
- List of new features in Eclipse CDT 8.4: https://wiki.eclipse.org/CDT/User/NewIn84
Thx for sharing π
LikeLiked by 1 person
It’s all about the tiny things which sum up and matter π
LikeLiked by 1 person
Hi Erich,
I would not complain. Itβs free $$$$ after all.
π€
LikeLiked by 1 person
Did I complain about anything?
LikeLiked by 1 person
Thanks for that when nested function inside if condition using. In Code Warrior for MCU 11.0 I see Step Return function as well, however It using Eclipse CDT 8.1.1
LikeLiked by 1 person