Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I view different representations of integers in the Eclipse watch window?

I would like to view binary (or hex) representations of integers in my watch window in Eclipse when debugging. How do I do this?

like image 230
jcartano Avatar asked May 02 '10 19:05

jcartano


People also ask

How do I view variables in Eclipse?

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.

How do I add a variable to my watch in Eclipse?

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.

How do I open expression view in Eclipse?

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.

How can you see variable references while debugging in Eclipse?

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.


1 Answers

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.

like image 79
Joshua McKinnon Avatar answered Oct 01 '22 19:10

Joshua McKinnon