Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » Debug my own class - How to display a variable/function value('Display' the expression value in a human readable way)
Debug my own class - How to display a variable/function value [message #1769184] Thu, 27 July 2017 06:34 Go to next message
Eclipse UserFriend
If I have a class ...

class X
{
public:
  int val;
};

int main(int argc, char** argv)
{
  X xx;
  xx.val = 20;
  ...


And, when I debug my code, I want to see what the value of "xx", what I want to actually display is "xx.val"

Is it possible to define how to display the value of my own class?

In my case I have a "std::string ToString()" function and I would like that value to be displayed.
Is something like that possible?

Thanks

S.
Re: Debug my own class - How to display a variable/function value [message #1769186 is a reply to message #1769184] Thu, 27 July 2017 07:11 Go to previous messageGo to next message
Eclipse UserFriend
The handling of this type of display is delegated to GDB. In this case you want to install a pretty printer for the X type.

See https://sourceware.org/gdb/onlinedocs/gdb/Pretty-Printing.html#Pretty-Printing
Re: Debug my own class - How to display a variable/function value [message #1769198 is a reply to message #1769186] Thu, 27 July 2017 10:10 Go to previous message
Eclipse UserFriend
Jonah Graham wrote on Thu, 27 July 2017 11:11
The handling of this type of display is delegated to GDB. In this case you want to install a pretty printer for the X type.

See https://sourceware.org/gdb/onlinedocs/gdb/Pretty-Printing.html#Pretty-Printing


Perfect, thanks "Pretty print" was the part I was missing.

Thanks
Previous Topic:ESP8266
Next Topic:install qusetion on linux
Goto Forum:
  


Current Time: Sun Mar 16 23:02:13 EDT 2025

Powered by FUDForum. Page generated in 0.03697 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top