This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]