欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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

程序员文章站 2022-07-08 16:44:51
...
gdb-dashboard或者 gdbgui
或者gdb自带的tui(ctl x + a )

gdb-dashboard这个样子
nginx模块开发(二) 使用gdb-dashboard调试
            
    
    博客分类: gdbnginx nginx 
https://github.com/cyrus-and/gdb-dashboard

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


如果报错
[root@mcompute705 ~]# 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.
>>> 




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


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
https://reverseengineering.stackexchange.com/questions/1392/decent-gui-for-gdb
https://github.com/cs01/gdbgui
gdb dashboard
https://github.com/cyrus-and/gdb-dashboard
gdbgui
 pip install gdbgui --upgrade
gdbgui -r


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





######################
#################################
★★项目.gdbinit
http://blog.csdn.net/hejinjing_tom_com/article/details/42490771
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





  • nginx模块开发(二) 使用gdb-dashboard调试
            
    
    博客分类: gdbnginx nginx 
  • 大小: 135.9 KB
相关标签: nginx