0

In Eclipse's watch window ("Expressions"), is there a way to have eclipse interpret the contents of a class/structure, rather than having to open the tree? Currently the "value" for any class/structure is {...}, and opening it consumes multiple lines in the Expressions window.

i.e, suppose I have a class complex with real and imag.

class complex_t {
    double real, imag;
}

Is there an XML file somewhere in eclipse to indicate that complex_t should display the values for .real and .imag instead of {...}? I've been searching on Visualizers, but I think that is something else.

Visual Studio, had this functionality say 10 years ago or so and I found it very handy (autoexp.dat). I don't use VS anymore but I think it might now be called Native Visualizer (NatVis). I even found that that Boost provides these XML files to visualizing objects in their library. (https://svn.boost.org/trac/boost/wiki/DebuggerVisualizers). No mention of Eclipse, which is an indication that the answer is no.


Edit: I'm looking for a solution for C/C++ (specifically for Code Composer Studio actually).

Below josivan does have a solution for Java though.

Community
  • 1
  • 1
Michael
  • 2,118
  • 1
  • 19
  • 25

1 Answers1

2

If you want to show details during debug you can do something like

Window > Preferences > Java > Debug > Detail Formatters

Click in Add, Choose your class. In area "Detail formatter code snippet" you define what you want. For example:

enter image description here

return "[r: " + real + ", i: " + imag + "]";

On debug Perpective you can see details of your class.

Take a look in the imagem bellow.

enter image description here

In eclipse help you can get more details. And here are a good article about it.

josivan
  • 1,963
  • 1
  • 15
  • 26
  • That looks pretty good for Java. I don't have that option in C though... +1, but I'm going to reword the question for C. Thanks though. – Michael Mar 02 '16 at 18:10
  • If you are using the eclipse for C development. I believe you can do the same and get the same result. – josivan Mar 02 '16 at 18:12
  • I've looked all over the debug tabs, and for anything named "Formatter". Only found the code style formatter. – Michael Mar 02 '16 at 18:15