Tuesday, July 16, 2013

gdb catchpoints

Not sure how the hell didn't know about this until now, but these gdb catchpoints are pretty nifty.


You can do something like "catch load libbfd.so" and you'll hit a breakpoint in dl-debug.c when that .so is loaded.

(gdb) catch load libbfd.so
Catchpoint 1 (load)
(gdb) r
Starting program: /home/mikesart/data/src/blah_dyldrendezvous_crash/build/blah
hello world

Catchpoint 1
  Inferior loaded /usr/lib/libbfd.so
__GI__dl_debug_state () at dl-debug.c:77
(gdb) bt
#0  __GI__dl_debug_state () at dl-debug.c:77
#1  in dl_open_worker
#2  _dl_catch_erroroperate
#3  in _dl_open
#4  in dlopen_doit
#5  in _dl_catch_error
#6  in _dlerror_run
#7  in __dlopen
#8  in main

There are catchpoints for calls to exec, fork, syscalls, and signals that could all be useful as well.

I don't see anything like this in lldb - adding to the task list...

No comments:

Post a Comment