Tuesday, November 02, 2004

getting a backtrace from a KUniqueApplication (like kicker or kmail)

reading Chris Howell's blog on getting a backtrace, i though i'd add a note on how to get a backtrace on a special class of KDE apps: unique apps. these are the applications that you can only run one instance of; starting them again results in the currently running instance to be activated instead. these include applications like kmail, kicker, kscd, kjots and many others. now, if you try Chris' recipe on a KUniqueApplication you'll get something like this:


aseigo@linux:~> gdb `which kjots`
GNU gdb 6.1
(gdb) run
Starting program: /opt/kde3/bin/kjots
[New Thread 1096345472 (LWP 26469)]
Program exited normally.
(gdb)


and then the application window will appear. but you won't be able to get a backtrace. notice the "Program exited normally" line, even though the application is still running! what happens is that the real application is forked off of the initial process as part of the "unique application" magic. unfortunately, this makes gdb lose track of the program. the fix is, thankfully, very simple:


(gdb) run --nofork
Starting program: /opt/kde3/bin/kjots --nofork
[New Thread 1096345472 (LWP 27257)]


notice the --nofork parameter, and notice that the application no longer exits immediately. huzzah! backtrace here we come.

now, what if the application just hangs, but doesn't actually crash? you can get a backtrace easily enough by loading it up in gdb and then hitting Ctrl-C. this will interupt the program wherever it is and allow you to ask for a backtrace.

1 comment:

Anonymous said...
This comment has been removed by a blog administrator.