public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Kegel <dank@kegel.com>
To: tmh@nothing-on.tv,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: just-in-time debugging?
Date: Sat, 28 Apr 2001 13:42:00 -0700	[thread overview]
Message-ID: <3AEB2B18.F1EC31DE@kegel.com> (raw)

 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);   
...

             reply	other threads:[~2001-04-28 20:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-28 20:42 Dan Kegel [this message]
  -- strict thread matches above, loose matches on Subject: below --
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3AEB2B18.F1EC31DE@kegel.com \
    --to=dank@kegel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tmh@nothing-on.tv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox