Like in
for((;;)) {
gdb -batch -n -ex 'set pagination off' -ex 'thread apply all bt' ffplay_g `pidof ffplay_g` >> /tmp/qq;
}
, but faster, without reloading GDB and symbols every time?
Backtraces need to be taken by timer, not by triggering some breakpoints.
As recommended by the comment
If you want to stick with gdb, then why not script a gdb session? Your controller process can sleep for 50 ms, then wake up, send a ^C, t a a bt, c, and then go back to sleep. – Jeremy W. Sherman
http://vi-server.org/vi/bin/gdbdriver.pl
Attach, set the breakpoint, set commands on that breakpoint that include
continue
, and then continue:If you are asking how to have gdb break in regularly, well, you could just loop calling step and then backtrace, but you're not going to get very far very fast:
If you're trying to profile your process, this is the wrong way. Look into gprof or (under Mac OS/iOS) Shark.
Use system sleep, this
gdb
command should do the trick: