【gdb】为exec调用设置catchpoint
为exec调用设置catchpoint
1. 例子:
#include <unistd.h>
int main(void) {
execl("/bin/ls", "ls", NULL);
return 0;
}
使用gdb调试程序时,可以用catch exec
命令为exec
系列系统调用设置catchpoint
,以上面程序为例:
[root@node01 demo]# gcc demo.c -g
[root@node01 demo]# gdb a.out -q
Reading symbols from /root/demo/a.out...done.
(gdb) catch exec
Catchpoint 1 (exec)
(gdb) r
Starting program: /root/demo/a.out
process 3232124 is executing new program: /usr/bin/ls
Catchpoint 1 (exec'd /usr/bin/ls), 0x00007ffff7ddc140 in _start () from /lib64/ld-linux-x86-64.so.2
Missing separate debuginfos, use: debuginfo-install coreutils-8.22-24.el7_9.2.x86_64
(gdb) bt
#0 0x00007ffff7ddc140 in _start () from /lib64/ld-linux-x86-64.so.2
#1 0x0000000000000001 in ?? ()
#2 0x00007fffffffe7df in ?? ()
#3 0x0000000000000000 in ?? ()
(gdb)