1

My program spawns a child thread with execvp to run another program in xterm:

char *argv[] = {"xterm",
        "-e",
                "./anotherProgram",
        0
};

execvp("xterm", argv);

I know anotherProgram is running but in gdb, "info thread" doesn't show it. How can I attach the child thread and debug it? Thanks.

4

1 回答 1

0

Maybe it's sufficient for you to just find the process id of the child using ps aux | grep anotherProgram and then attach to it using a new gdb instance like this? gdb ./anotherProgram <pid>

If not, you could just patch the source code like this and recompile:

char *argv[] = {"xterm",
                "-e",
                "gdb",
                "./anotherProgram",
                0
};

execvp("xterm", argv);

I don't know a cleaner way to do this.

于 2013-03-30T21:37:09.990 回答