Eclipse provides in the Editor view great tool tips (called ‘hovers’) which shows what is behind a macro: I can move my mouse over it, and it shows me the content behind it:
But if I’m debugging, I get “No value available”:
Obviously, the debugger queries the value of that macro, and as there is no variable with that name, there is no value. Makes sense. But: how can I see the macro value while debugging?
The solution is to configure different hover keys in the preferences (menu Window > Preferences > C/C++ > Editor > Hovers):
The above dialog shows as well that there are different Hovers available. By default, the ‘Combined Hover’ is used. And it is using the Debugger Hover, which cannot provide a value, thus the ‘No value available’ result. The Hover Preferences has as well the possibility to assign a modifier key: with this, a selected hover can be used.
And indeed: if I use the ‘Shift’ key pressed while hovering in the debugger, I get what I want :-):
Happy Hovering 🙂
Erich,
You might want to enable “Macro Expansion” hover as well. It is a very powerful tool-tip that often would help to catch different macro declaration, usage as well. “Source” hovering just display the line where macro has been declared. The macro expansion will actually rezolve the macro.
e.g.
=========================
#define min(X, Y) ((X < Y) ? X : Y)
/// then lately in the source
int val = min(7, 9);
=========================
Then "Source" hover will give you exact declaration of "min" define, while "Macro Expansion" hover will give you the value of macro after preprocessing, i.e. "((7 < 9) ? 7 : 9)".
You can also "debug" macro expansion by pressing "F2" while hover dialog is active and is very useful for convoluted macros that depend on other macros.
LikeLike
Teo, thanks, that’s a useful tip. I see that Macro Expansion is indeed in the ‘non-debug’ mode automatically for me, but for debugging it is indeed good to have another shortcut assigned to it.
LikeLike
Pingback: Top 10 Customization of Eclipse Settings | MCU on Eclipse
Hi Erich
This is very useful, thank you.
Do you know if there is any way to display the value of a local variable in Hex in the Variables window? I know we can hover and get the decimal value at the point of execution of the variable but that is not very helpful sometimes. I often build the code with static variables just to easily trace problems, but that can also introduce other problems.
LikeLike
Hi Robert,
have a look at https://mcuoneclipse.com/2012/10/01/debugging-variables-in-hexadecimal-with-eclipse/
LikeLike