断点在GDB [英] breakpoints in GDB

查看:171
本文介绍了断点在GDB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为这可能早先被问过,但我找不到一个满足我的要求。

I think this may have been asked earlier but i can't find one that satisfied my requirements.

我通过尝试分析各种测试中的代码流来调试(试图理解)一个大项目。但是当我试图在一些文件中设置断点时,我得到错误没有源文件命名文件名找到。

所以我的问题是:

I am debugging(infact trying to understand) a large project by trying to analyze the code flow in various testsuites. But when i try to set breakpoints at some files, i get the error "no source file named filename found".
So my question is:


  1. gdb只能接受代码流进入的源文件的断点。

  2. 我可以在文件的整行上设置断点, c $ c> b filename:*

  3. 在头文件中的断点是否会被接受,因为头文件只是在编译时附加?

欢迎任何洞察力。

编辑

我检查了这些问题与一些hello世界代码,并发现相同的结果,指出在一个答案。但我的问题在实际项目中仍然保持。我仍然得到相同的错误,即使我可以看到同一行的编辑输出不被接受为断点。

Edit
I checked these issues with some hello world code and found same results as pointed out in one of the answers.but my issue in the actual project still remains on. I still get the same error even when i can see the edited output of the same line which is not accepted as a breakpoint.

编辑2

我得到它的工作,但不明白如何和为什么它的工作原理。

Edit 2
I got it working but don't understand how and why it works..??


(gdb) b /home/neeraj/BTP/trunk/include/header.h:872
No source file named /home/neeraj/BTP/trunk/include/header.h:872
Make breakpoint pending on future shared library load? (y or [n]) n
(gdb) b /home/neeraj/BTP/trunk/src/driver.cpp:2
Breakpoint 1 at 0x806c61a: file ../../../trunk/src/driver.cpp, line 2.
(gdb) b /home/neeraj/BTP/trunk/include/header.h:872
Breakpoint 2 at 0x8052fa0: file ../../../trunk/include/header.h:872, line 872.
(gdb)

任何更深入的见解...?

Any deeper insights..?

推荐答案

除了共享库, gdb 源文件名相对于编译代码的目录。如果没有使用绝对路径名编译,请使用 dir 命令将编译目录添加到位置列表 gdb 搜索源代码。

The other thing to beware of besides shared libraries is that gdb source file names are relative to the directory where the code was compiled. If you haven't compiled with absolute pathnames, use the dir command to add the compilation directory to the list of places gdb searches for source code.

并提示:当我使用数据显示调试器(DDD)图形前端到 gdb

And a hint: I find I am wildly more productive when I use the Data Display Debugger (DDD) graphical front end to gdb.

这篇关于断点在GDB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆