public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* just-in-time debugging?
@ 2001-04-28 20:17 Tony Hoyle
  2001-04-28 20:44 ` Davide Libenzi
  2001-05-01  7:25 ` Sean Hunter
  0 siblings, 2 replies; 6+ messages in thread
From: Tony Hoyle @ 2001-04-28 20:17 UTC (permalink / raw)
  To: linux-kernel

Is there a way (kernel or userspace... doesn't matter) that gdb/ddd
could be invoked when a program is about
to dump core, or perhaps on a certain signal (that the app could deliver
to itself when required).  The latter case
is what I need right now, as I have to debug an app that breaks
seemingly randomly & I need to halt when
certain assertions fail.  Core dumps aren't much use as you can't resume
them, otherwise I'd just force a segfault
or something.

I had a look at the do_coredump stuff and it looks like it could be
altered to call gdb in the same way that
modprobe gets called by kmod... however I don't sufficiently know the
code to work out whether it'd work properly
or not.  

A patch to glibc would perhaps be better, but I know that code even
less!

Something like responding to SIGTRAP would probably be ideal.

Tony

-- 

"Two weeks before due date, the programmers work 22 hour days cobbling an
 application from... (apparently) one programmer bashing his face into the
 keyboard." -- Dilbert

tmh@magenta-netlogic.com                http://www.nothing-on.tv 


^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: just-in-time debugging?
@ 2001-04-28 20:42 Dan Kegel
  0 siblings, 0 replies; 6+ messages in thread
From: Dan Kegel @ 2001-04-28 20:42 UTC (permalink / raw)
  To: tmh, linux-kernel@vger.kernel.org

 Tony Hoyle (tmh@nothing-on.tv) wrote:
> Is there a way that gdb/ddd could be invoked when a program is about 
> to dump core...?

Yes, I use that to get a symbolic stack dump after a crash,
although I find that the gdb so invoked doesn't accept interactive
commands, and I have to use 'kill -9' afterwards.
Here's the code I use:

void dump_stack(int signum)
{
    (void) signum;
    char s[160];
    // The right command to execute depends on the program.  Adjust to taste.
    system("echo 'info threads\nbt\nthread 3\nbt\nthread 4\nbt\nthread 5\nbt\n' > gdbcmd");
 
    sprintf(s, "gdb -batch -x gdbcmd %s %d", argv0, (int) getpid());
    printf("Crashed!  Starting debugger to get stack dump.  You may need to kill -9 this process afterwards.\n");
    system(s);
    exit(1);
 
} 

main() {
   signal(SIGSEGV, dump_stack);
   signal(SIGBUS, dump_stack);   
...

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2001-05-01  7:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-04-28 20:17 just-in-time debugging? Tony Hoyle
2001-04-28 20:44 ` Davide Libenzi
2001-04-28 21:00   ` Tony Hoyle
2001-04-28 21:06     ` Davide Libenzi
2001-05-01  7:25 ` Sean Hunter
  -- strict thread matches above, loose matches on Subject: below --
2001-04-28 20:42 Dan Kegel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox