Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Bin Chen <binary.chen@gmail.com>
To: gdb@sourceware.org
Subject: attach gdbserver to itself
Date: Wed, 24 Jan 2007 12:48:00 -0000	[thread overview]
Message-ID: <45B75585.2030900@gmail.com> (raw)

Hi,

Current I am doing a trick that attach the gdbserver to itself when the 
process encounter the segment fault, like this:

void segv_handler(int no)
{
    int pid, status;

    VoIPLog("segv_handler.");
    char buf[128];

    pid = getpid();

    sprintf(buf, "/usr/bin/gdbserver :9988 --attach %d", pid);

    pid = fork();
    if (pid == 0) {
        system(buf);
    } else
        ::wait((int *)&status);

    return;
}

But in most of time this can't get useful information, especially in 
multi threading env, most of time the result is wrong, of course, I am 
saying the backtrace.

But if I start program by gdbserver :9988 program, it can catch the 
error. What is the difference? How can I revise my code to make above 
code has same effect like starting the program by gdbserver?

I am debugging in ARM platform.

Any help appreciated!

Bin Chen


             reply	other threads:[~2007-01-24 12:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-24 12:48 Bin Chen [this message]
2007-01-24 12:51 ` Daniel Jacobowitz
2007-01-24 12:56   ` Bin Chen
2007-01-24 13:05     ` Daniel Jacobowitz
2007-01-24 13:20       ` Bin Chen
2007-01-24 13:27         ` Daniel Jacobowitz
2007-01-25  2:12           ` Bin Chen
2007-01-25  2:29           ` Bin Chen

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=45B75585.2030900@gmail.com \
    --to=binary.chen@gmail.com \
    --cc=gdb@sourceware.org \
    /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