Reputation: 3619
I am interested in displaying a struct / class object in a specific way using Netbean's default GDB debugger for C and C++ projects so I can step through the code quicker. For Java there is an easy way to do this using the "Variable Formatters" section under Tools -> Options -> Misc -> Variable Formatters. I am looking for something similar for C / C++. Does this method exist?
EDIT: To clarify my question, in the debugger variables tag there is a "Value" column. I wish to represent this as a call from an object, for example printf("%s", MyObject.getHeight());
Upvotes: 0
Views: 1035
Reputation: 21
I believe what you're looking for can be accomplished using the Python pretty printing feature of gdb, as explained at the following:
https://sourceware.org/gdb/current/onlinedocs/gdb/Pretty-Printing.html#Pretty-Printing https://sourceware.org/gdb/current/onlinedocs/gdb/Pretty-Printing-API.html#Pretty-Printing-API
Using the Python pretty printing mechanism, you can control how gdb will present the value of a given type to NetBeans. I've used this myself to customize the display, in the Variables tab, for my own classes. It takes a bit of reading and a tiny bit of Python knowledge, but it's wonderfully powerful once you get the hang of it, and definitely worth learning.
Upvotes: 2
Reputation: 16
I don't know Netbeans enough to help you with a macro to do that but there is an easier solution, either:
or
Things are usually done by simplifying a problem.
Upvotes: 0