Hovering and Debugging

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:

Macro Expansion Hover in Editor View

Macro Expansion Hover in Editor View

But if I’m debugging, I get “No value available”:

'No value available' while debugging

‘No value available’ while debugging

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):

Hover Preferences

Hover Preferences

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 :-):

Hover while Debugging with Shift key pressed

Hover while Debugging with Shift key pressed

Happy Hovering 🙂

5 thoughts on “Hovering and Debugging

  1. 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.

    Like

    • 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.

      Like

  2. Pingback: Top 10 Customization of Eclipse Settings | MCU on Eclipse

  3. 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.

    Like

What do you think?

This site uses Akismet to reduce spam. Learn how your comment data is processed.