GDB structure output
c, gdb
Solution
A nice approach is to set a breakpoint with associated commands, e.g:
break main.c:100
commands 1
print data_structure
continue
end
This runs the two commands `print data_structure` and `continue` whenever breakpoint 1 is reached.
Problem
I haven't worked with gdb for a long time and this feels like a basic question. I am trying to observe a structure as it changes but rather than break at a specific point and print it out I'd rather let the application run as normal and give me a snapshot of the structure at a specific point. Think a breakpoint that performs an action (print struct) rather than pausing execution. I am interested in looking at the changes to the structure all at once rather than incrementally. I can get what I want through printf, but gdb is much more elegant. Update: Thank you for all the responses. I want to watch one struct at a particular point and the commands solution is just what I needed. This has been very helpful.