One thing I commonly use GDB for is getting a stack trace after a program I am working on sigfaults
I added this to my .bashrc
gcatch(){
gdb -ex 'r' -ex 'back' -ex 'q' --args $*
}
So if my program segfaults I can press up and prepend gcatch to the command and voila! Stack trace.
The name gcatch comes from the frysk command line utility fcatch which performs the same job.
Advertisement
April 22, 2010 at 10:48 pm |
Nice tip! The $* will have issues if the command needs quoting though. I think “$@” will work better, or just use an alias so the args are implicitly appended as originally quoted:
alias gcatch=’gdb -ex r -ex back -ex q –args’
April 22, 2010 at 11:54 pm |
Cool… alias it is
April 23, 2010 at 12:41 am |
Nice! I’d actually wondered how to do this. We should just stick this in the gdb package =)
April 23, 2010 at 5:26 am |
you could also type gcatch !! instead of the press up/prepend dance.