Debugging Variables in Hexadecimal with Eclipse

There are always hidden treasures in Eclipse, and here is one: By default, variables might look like which is not always what I want:

Variables View

Variables View

How to change the format to hexadecimal (or any other format)?

Changing Format in Variables View

A solution is to select multiple variables and to change the format to Hexadecimal:

Changing format to hexadecimal in variables view

Changing format to hexadecimal in variables view

Then I have it in the format I have selected:

Variables shown in hexadecimal format

Variables shown in hexadecimal format

But this only works for a few (I always have to select the variable(s) and change the format), and worse: I need to do this for every debug session.

Changing Format Globally

A better way is to set the default to what I need on a workspace level. For this there is a setting in the menu Window > Preferences > C/C++ > Debug where I can change the default format (not only for variables):

Eclipse Debugger Preferences for default format

Eclipse Debugger Preferences for default format

With this, all my variables are now in hexadecimal format:

Variables View in Hexadecimal

Variables View in Hexadecimal

Happy Formatting 🙂

Advertisements

22 thoughts on “Debugging Variables in Hexadecimal with Eclipse

  1. Excellent. This helps to establish a set of common knowledge FAQ’s for the toolset. Finding out all these issues one at a time for each person with the toolset is very frustrating and time consuming. Thank for posting this on a good spot for future reference.

    Like

      • Actually it’s stranger than I thought – I set the preferences to hexadecimal in Window > Preferences > C/C++ > Debug but in both the debug hover and variables window I still get decimal values for char and some but not all integer types. This is in eclipse bundled with NXP’s LXPExpresso. It’s funny because I can’t imagine anyone in embedded wanting decimal.

        Like

  2. Hi ,
    I tried Changing Format Globally in eclipse juno in Ubuntu 12.04 version with CDT 8.1.2 .But it doesn’t effect any changes in variables, registers or in expressions but Changing Format in Variables View works fine . please help me as i tried the similar scenarios in Windows platform too but there also doesn’t work.

    Like

    • Hi,
      yes, this is broken with CDT 8.1 (not sure since when). I noticed that this is not working any more in my Eclipse Kepler. So it is not platform specific. I think it is caused by another feature of CDT 8.1 which in my view at least makes it not such a big problem. Now you can click the small triangle on the right side of the views and then select Number Format > Hex. This will change the format for the whole view.

      Like

  3. Pingback: Show Floating Point Variable Bytes in Eclipse CDT | MCU on Eclipse

  4. Frankly, I don’t think that numbers should be displayed in decimal by default in an IDE. Decimal format is as non-native to programmers, as Mandarin Chinese is to Minnesota Norwegians. And taking the time to find out how to change the format…is a big waste of time.

    Like

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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