实验平台: linux + gcc + gdb
调试正在运行的进程。
多次 fork(),exec()的程序,从头开始跟踪非常麻烦。可以使程序停在我们感兴趣的地方,然后用 gdb 去 attach。
printf( "___I am waiting for being attached by gdb. my pid :_%d_________%s_%d__\n", getpid(), __FILE__ , __LINE__ );
pause();
pause();
Reading symbols from /lib/libnss_files.so.2done.
Loaded symbols for /lib/libnss_files.so.2
0x00a047a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
(gdb) b Main.cpp:1220
Breakpoint 1 at 0x8054e85: file Main.cpp, line 1220.
(gdb) signal 0
Continuing with signal 0.
[Switching to Thread -1207969568 (LWP 24761)]
Breakpoint 1, CAAA_App::SendSubProc (sock_handle=6) at Main.cpp:1220
1220 printf( "_____被信号唤醒了\n" );
(gdb)
Loaded symbols for /lib/libnss_files.so.2
0x00a047a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
(gdb) b Main.cpp:1220
Breakpoint 1 at 0x8054e85: file Main.cpp, line 1220.
(gdb) signal 0
Continuing with signal 0.
[Switching to Thread -1207969568 (LWP 24761)]
Breakpoint 1, CAAA_App::SendSubProc (sock_handle=6) at Main.cpp:1220
1220 printf( "_____被信号唤醒了\n" );
(gdb)