gdb useful tidbits/bookmarks
Some of these are hard to google for and I've used more than once now, so to save time I'm bookmarking them here.
- Setting watch points in gdb
- Displaying the whole string in gdb
- Setting gdb to break at a particular file/line
- Setting the coredump limit of a running process to catch a core
None of this is rocket science, but still useful.
1) Watchpoints
Setting a watchpoint;
(gdb) watch mm_dictionary.mmdict_head->index
Hardware watchpoint 3: mm_dictionary.mmdict_head->index
(gdb) cont
Continuing.
[Switching to Thread 0x7ffff565c700 (LWP 15147)]
Hardware watchpoint 3: mm_dictionary.mmdict_head->index
Old value = 20
New value = 0
reporter_thread () at x_reporter.c:148
watch -l didn't seem to work on my gdb, so I had to set the watch on the global scope variable.
Listing and removing watchpoints
(gdb) info watchpoints
Num Type Disp Enb Address What
2 hw watchpoint keep y *current->index
(gdb) clear
No breakpoint at this line.
(gdb) clear 2
No breakpoint at 2.
(gdb) delete 2
(gdb) info watchpoints
No watchpoints
reference:
https://sourceware.org/gdb/onlinedocs/gdb/Delete-Breaks.html#Delete-Breaks
https://sourceware.org/gdb/onlinedocs/gdb/Set-Watchpoints.html#Set-Watchpoints
2) Viewing the whole string
(gdb) set print elements 0
3) Setting GDB to break at a file:line number
This is obvious, in hindsight;
(gdb) break x_symdict.c:149
Breakpoint 5 at 0x402038: file x_symdict.c, line 149.
(gdb) info breakpoints
Num Type Disp Enb Address What
3 hw watchpoint keep y mm_dictionary.mmdict_head->index
breakpoint already hit 1 time
5 breakpoint keep y 0x0000000000402038 in add_mmdict at x_symdict.c:149
(gdb) delete 5
(gdb) info breakpoints
Num Type Disp Enb Address What
3 hw watchpoint keep y mm_dictionary.mmdict_head->index
breakpoint already hit 1 time
4) Setting a core limit on a running process dynamically
echo -n "Max core file size=unlimited:unlimited" >/proc/12345/limits
Thank you; http://blogs.kent.ac.uk/unseenit/2013/06/06/changing-ulimit-for-running-processes/
You were hard to find, so I'm putting you here for safe keeping.