GDB——使用GDB动态链接到进程

GDB支持链接到一个正在运行的进程。一遍检测它的运行状态。

这里写图片描述

示例过程:

Bakuman@Shaw-vm:~$ su
密码: 
root@Shaw-vm:/home/delphi# cd workspace/
root@Shaw-vm:/home/delphi/workspace# ls
ClearRTOS  embedded  func.c  test.c  test.out
root@Shaw-vm:/home/delphi/workspace# gdb  < ----- 启动gdb
GNU gdb (GDB) 7.2-ubuntu
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) quit
root@Shaw-vm:/home/delphi/workspace# ps aux  < ---------- 查询系统中进程

Bakuman   8518  0.0  0.0   1684   248 pts/0    S+   16:07   0:00 ./test.out Shaw
root      8522  0.0  0.1   4584  1104 pts/1    R+   16:07   0:00 ps aux
root@Shaw-vm:/home/delphi/workspace# gdb
GNU gdb (GDB) 7.2-ubuntu
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) attach 8518    < ----------- 链接到目标进程
Attaching to process 8518
Reading symbols from /home/delphi/workspace/test.out...done.
Reading symbols from /lib/libc.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib/ld-linux.so.2
0x00dac416 in __kernel_vsyscall ()   < -------- 目标进程停止执行
(gdb) continue
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x08048431 in func () at func.c:7
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值