Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* attach gdbserver to itself
@ 2007-01-24 12:48 Bin Chen
  2007-01-24 12:51 ` Daniel Jacobowitz
  0 siblings, 1 reply; 8+ messages in thread
From: Bin Chen @ 2007-01-24 12:48 UTC (permalink / raw)
  To: gdb

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


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

end of thread, other threads:[~2007-01-25  2:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-24 12:48 attach gdbserver to itself Bin Chen
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

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