码迷,mamicode.com
首页 > 数据库 > 详细

gdb注意事项

时间:2017-01-03 21:50:39      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:循环   next   bug   libstdc++   bar   error:   没有   shell   执行文件   

假设我当前有文件test.cpp,要gdb调试,先shell上执行:g++ test.cpp -o test -g

1. gdb调试针对的文件是debug模式的可执行文件。

上面-g参数即加上debug选项,-o生成可执行文件。

2. 一般使用步骤:

gdb
file test
l
break
run
next s

file+文件名指导入可执行文件,不导入则调试没有对象;l是显示代码(默认十行,且循环往下显示);break设断点;run运行;next执行下一行;s进入调用的函数(亦可用于多文件里的函数调用)。。。

3. error:ImportError: No module named ‘libstdcxx‘

出现错误

"/usr/share/gdb/auto-load/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19-gdb.py", line 63, in <module>
    from libstdcxx.v6.printers import register_libstdcxx_printers
ImportError: No module named libstdcxx

系统 ubuntu14.02LTS

 
$ gcc --version
gcc (Ubuntu/Linaro 4.4.7-8ubuntu1) 4.4.7
$ gdb --version
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
$ python --version
Python 2.7.6
 

创键.gdbinit初始文件,这样每次gdb启动时都会自动调用。

加入如下代码

python sys.path.append("/usr/share/gcc-4.8/python")

 

参考http://stackoverflow.com/questions/31062010/ubuntu-14-04-gcc-4-8-4-gdb-pretty-printing-doesnt-work-because-of-python-issu

gdb注意事项

标签:循环   next   bug   libstdc++   bar   error:   没有   shell   执行文件   

原文地址:http://www.cnblogs.com/jiu0821/p/6246404.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!