nginx模块开发(二) 使用gdb-dashboard调试

13 篇文章 0 订阅
gdb-dashboard或者 gdbgui
或者gdb自带的tui(ctl x + a )

gdb-dashboard这个样子
[img]http://dl2.iteye.com/upload/attachment/0126/4893/5f21001a-8bc9-3f1d-81a4-fee1ac3bee4e.png[/img]
[url]https://github.com/cyrus-and/gdb-dashboard[/url]

[url]https://metricpanda.com/tips-for-productive-debugging-with-gdb[/url]


如果报错
[code="java"]# gdb
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-94.el7
Copyright (C) 2013 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 "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "<string>", line 387, in start
File "<string>", line 290, in load_modules
File "<string>", line 493, in __init__
File "<string>", line 523, in add_subcommands
File "<string>", line 1402, in commands
AttributeError: 'module' object has no attribute 'COMPLETE_EXPRESSION'
/root/.gdbinit:1432: Error in sourced command file:
Error while executing Python code.
>>>
[/code]


[url]https://github.com/cyrus-and/gdb-dashboard/issues/1#issuecomment-176717956[/url]


Actually, overcoming the lack of gdb.COMPLETE_EXPRESSION is quite easy, just add:

python gdb.COMPLETE_EXPRESSION = gdb.COMPLETE_SYMBOL
as the first line in .gdbinit.


gdbgui
[url]https://reverseengineering.stackexchange.com/questions/1392/decent-gui-for-gdb[/url]
[url]https://github.com/cs01/gdbgui[/url]
gdb dashboard
[url]https://github.com/cyrus-and/gdb-dashboard[/url]

gdbgui
pip install gdbgui --upgrade
gdbgui -r


为了gdb-dashboard 只有7.7以上支持 默认centos7不行
安装gdb-8.0
dashboard -layout


######################
#################################
★★项目.gdbinit
[url]http://blog.csdn.net/hejinjing_tom_com/article/details/42490771[/url]
gdb -iex "set auto-load safe-path /"
或者
项目的gdbinit文件
vim ~/.gdbinit
set auto-load safe-path /
set history save on


每个目录内的.gdbinit就起作用了
查验:

info auto-load

readelf -S /usr/local/nginx/sbin/nginx

前面的几个是全局符号, 其中重要的有一个源代码绝对根路径

readelf -p .debug_str /usr/local/nginx/sbin/nginx |grep opt

##########################
l
查看当前代码路径
info source
查看全部
info sources

list 是显示源码
(gdb) list # 查看代码执行位置的10行
(gdb) list # 再显示10行
(gdb) list - # 查看上一个list命令之前的10行
(gdb) list 3,19 # 查看3-19行
(gdb) list main # 查看main函数开始的10代码
(gdb) list hello.c:23 # 查看hello.c文件第23行后的10行
(gdb) list hello.c:main # 查看hello.c文件中函数main开始的10行
(gdb) list *0x1000000 # 查看地址为 0x1000000 的10行代码,


查找
search ngx_stri
reverse-search ngx_stri


set history save on
set history filename <fname>
By default the history file (.gdb_history) is saved in the current


run之后
record
可以回退
reverse-next
reverse-有很多
record stop

设置变量
set var a=6

删除断点
info b
delete b
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值