简体   繁体   English

在emacs(或DDD)中使用gdb时无法设置断点

[英]Can't set breakpoints when using gdb in emacs (or DDD)

I'm trying to use gdb with emacs. 我正在尝试将gdb与emacs一起使用。 The library that I'm trying to debug is loaded by a process and can't be run directly. 我要调试的库是由进程加载的,不能直接运行。 Hence I attach to the process by using the attach command inside gdb. 因此,我通过使用gdb内的attach命令来附加到进程。 Attaching to a process and setting breakpoints works fine when I use gdb from a shell, but when I use gdb in emacs (by pressing Mx gdb or Mx gud-gdb), it can't set breakpoints. 当我从外壳程序使用gdb时,附加到进程并设置断点的效果很好,但是当我在emacs中使用gdb时(通过按Mx gdb或Mx gud-gdb),则无法设置断点。 It shows me an error which says "Can't access memory at 0x7efb04". 它显示了一个错误,提示“无法访问0x7efb04处的内存”。 I'm using emacs 23.1.1. 我正在使用emacs 23.1.1。

Here is a breakdown of the process I follow: 这是我遵循的过程的分解:

  1. Press Mx gdb or Mx gud-gdb to launch gdb inside emacs. Mx gdbMx gud-gdb gdb在emacs中启动gdb。
  2. Enter the name of the executable built with debugging symbols. 输入使用调试符号构建的可执行文件的名称。
  3. Type "attach [PID]" to attach gdb to a running process. 键入“ attach [PID]”将gdb附加到正在运行的进程。
  4. Set a breakpoint by typing: filename:line number. 通过键入以下命令设置断点:filename:行号。

The last step gives me an error which says "Can't access memory at 0x7efb04". 最后一步给我一个错误,提示“无法访问0x7efb04的内存”。

Any ideas why this is happening? 任何想法为什么会这样?

EDIT : I get the same error when using DDD (UI for GDB). 编辑:使用DDD(GDB的用户界面)时出现相同的错误。 So I guess it's not an emacs specific issue. 所以我想这不是emacs的特定问题。

Have you compiled with debug-information? 您是否已使用调试信息进行编译? Do you have some code which shows the problem? 您是否有一些显示问题的代码? Does this happen in other IDEs also? 这也会在其他IDE中发生吗?

I figured it out. 我想到了。 The problem is with step 2. Entering the name of the executable built with debugging symbol causes the problem. 问题出在步骤2。输入用调试符号构建的可执行文件的名称会导致问题。 Instead, just launching GDB and attaching to process works fine. 相反,只需启动GDB并附加到进程即可。 I'm not sure if this is the expected behavior. 我不确定这是否是预期的行为。

In DDD, the executable with debugging symbols has to be opened first before we can attach to process. 在DDD中,必须先打开带有调试符号的可执行文件,然后才能附加到进程。 I don't know how to get around that in DDD. 我不知道如何在DDD中解决该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM