- 论坛徽章:
- 0
|
新建程序从内核返回时,执行入口是在ld-linux.so.2中,如何在该入口处下断点?我想用hbreak却不行。
b _start有的机器行,有的不行.
后来发现attach的进程可以hbreak.
[root@mail ~]# gdb /bin/ls
GNU gdb (GDB) 7.0
(gdb) hbreak *0x4000be0
No hardware breakpoint support in the target.
(gdb) b _start
Function "_start" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (_start) pending.
(gdb) r
Starting program: /bin/ls
gcc.txt Mail
(gdb) q
[root@mail ~]# uname -a
Linux mail 2.4.20-8smp #1 SMP Thu Mar 13 17:45:54 EST 2003 i686 i686 i386 GNU/Linux
这个不行
[root@ssq_pppoe ~]# gdb /bin/ls
GNU gdb (GDB) 7.0
(gdb) b _start
Function "_start" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (_start) pending.
(gdb) r
Starting program: /bin/ls
Breakpoint 1, 0x0000003dad000a80 in _start () from /lib64/ld-linux-x86-64.so.2
(gdb) q
A debugging session is active.
Inferior 1 [process 26735] will be killed.
Quit anyway? (y or n) y
[root@ssq_pppoe ~]# uname -a
Linux ssq_pppoe 2.6.9-42.ELsmp #1 SMP Wed Jul 12 23:32:02 EDT 2006 x86_64 x86_64 x86_64 GNU/Linux
这个又可以
[root@mail ~]# pgrep ftp
21880
[root@mail ~]# gdb
GNU gdb (GDB) 7.0
(gdb) attach 21880
Attaching to process 21880
Reading symbols from /usr/bin/ftp...(no debugging symbols found)...done.
Reading symbols from /usr/lib/libreadline.so.4...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libreadline.so.4
Reading symbols from /usr/lib/libncurses.so.5...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libncurses.so.5
Reading symbols from /lib/tls/libc.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib/tls/libc.so.6
Reading symbols from /lib/ld-linux.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /lib/libnss_files.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib/libnss_files.so.2
0xffffe002 in ?? ()
(gdb) hbreak *0x4000be0
Hardware assisted breakpoint 1 at 0x4000be0
(gdb) q
A debugging session is active.
Inferior 1 [process 21880] will be detached.
Quit anyway? (y or n) y
Detaching from program: /usr/bin/ftp, process 21880
调试运行中的进程可以使用hbreak |
|