[英]how to attach a child process in gdb?
我的程序使用execvp產生一個子線程,以在xterm中運行另一個程序:
char *argv[] = {"xterm",
"-e",
"./anotherProgram",
0
};
execvp("xterm", argv);
我知道另一個程序正在運行,但是在gdb中,“信息線程”沒有顯示它。 如何附加子線程並進行調試? 謝謝。
也許使用ps aux | grep anotherProgram
找出孩子的進程ID就足夠了ps aux | grep anotherProgram
ps aux | grep anotherProgram
,然后使用這樣的新gdb實例將其附加到它? gdb ./anotherProgram <pid>
如果沒有,您可以像這樣修補源代碼並重新編譯:
char *argv[] = {"xterm",
"-e",
"gdb",
"./anotherProgram",
0
};
execvp("xterm", argv);
我不知道更干凈的方法可以做到這一點。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.