This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
attach gdbserver to itself
- From: Bin Chen <binary dot chen at gmail dot com>
- To: gdb at sourceware dot org
- Date: Wed, 24 Jan 2007 20:48:05 +0800
- Subject: attach gdbserver to itself
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