I came upon a struct (called ngx_http_variable_value_t
) in my GDB (debugger) session and I would like to print what fields it has in the console.
Is that possible?
The ptype [ARG] command will print the type. Show activity on this post. This question may be related: vtable in polymorphic class of C++ using gdb: (gdb) help set print object Set printing of object's derived type based on vtable info.
To get more information we use the "backtrace" command. The "backtrace" command tells gdb to list all the function calls (that leads to the crash) in the stack frame.
Enables automatic displaying of certain expressions each time GDB stops at a breakpoint or after a step.
In general, the list command expects you to supply zero, one or two locations. Locations specify source lines; there are several ways of writing them (see Specify Location), but the effect is always to specify some source line.
You can use the GDB command ptype
to print out the definition of a struct or class.
Additionally, use ptype /o
to print offsets and sizes of all fields in a struct (like pahole).
If you have debugging symbols built in, you should just be able to print the value: print variable
or print *variable
if it's a pointer to a struct.
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