tags:

views:

97

answers:

1

Hi,

I'm using Debian x64 2.6.26 to host a server application we've written in C++. Sometimes GDB gets activated on its own and it uses 100% CPU time giving no room for other processes to run. The GDB version is 6.8-debian. I don't know why this happens and how may i prevent this. It seems that it only happens when out server application is running. I need to know how to stop this from happening or if there is something wrong in our application then how may i find it. Any help is much appreciated.

Thanks

+2  A: 

I am inclined to believe that GDB is getting called by a signal handler in some code. Another suspect is some system monitoring daemon like 'monit'. When there is a rogue process eating too much memory or CPU, it might be trying to take a backtrace or dump using GDB. On way to troubleshoot is to use 'lsof' on the GDB process and see what files are opened by GDB and see if it gives you any clue. Using 'ps -ef -o cmd,pid,ppid | grep -i gdb', you can figure out how GDB was launched and if it gives you the PID of the attached process, you will know which process is being inspected.

A sledge hammer approach to stub such automatic execution is replacing 'GDB' with a stub 'GDB' which does nothing. Non existence of GDB might signal an error though. I have done such dirty tricks when I had no time to dig deeper into the problem. In the stub GDB, you can log all the command line arguments and the calling process name.

A sample stub in 'C':

#include <stdio.h>

int
main(int argc, char *argv[]) {
    size_t sz;
    FILE *fp = 0;
    fp = fopen("/tmp/gdbstub.log", "a");
    if (fp) {
        fprintf(fp, "\n%s invoked:", argv[0]);
        for (sz = 0; sz < argc - 1; sz++) {
            fprintf(fp, "%s ", argv[sz]);
        }
        fclose(fp);
    }
    return 0;
}
hackworks