I would like to view binary (or hex) representations of integers in my watch window in Eclipse when debugging. How do I do this?
Variables/Expression view – Shows the declared variables and their values. Press Ctrl+Shift+d or Ctrl+Shift+i on a selected variable or expression to show its value. You can also add a permanent watch on an expression/variable that will then be shown in the Expressions view when debugging is on.
Solution. Highlight the variable or expression while debugging, right-click it, and select Watch, or select Run→ Watch. The variable or expression, along with its value, will appear in the Expressions view from then on.
To manually open the Expressions view, go to Window | Show View | Debug | Expressions. The Expressions view allows you to monitor certain variables which you have decided to 'watch' during the debugging process. Selecting a variable will display details in the detail pane below the view.
While debugging you can use the "Display" window where you can write pieces of code and "execute" them with inspect (highlight the code -> right click -> inspect). In that window you have access to all variables of the breakpoint's context.
You can do this from Window->Preferences.
For primitives, browse to Java->Debug->Primitive Display Options
Here there is a checkbox for 'Display Hexadecimal values'. Check this, and you will see both decimal & hexadecimal representations for primitives in the 'value' column under Variables view when debugging.
For objects (Integer, Long, etc), browse to Java->Debug->Detail Formatters
For each type you care about, create a detail formatter that formats the value how you like. For java.lang.Integer, you could use the detail formatter: Integer.toHexString(this)
Make sure your detail formatter is enabled, and you should see the hexadecimal representation in the 'details' area when you select a variable from the Variables view.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With