C++ 使用 Eclipse CDT 和 GDB 进行调试
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1587748/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Debugging with Eclipse CDT and GDB
提问by Algirdas
I have Eclipse CDT C++ application project that uses shared library. This library is compiled with debug info and its source is available at the right path.
我有使用共享库的 Eclipse CDT C++ 应用程序项目。这个库是用调试信息编译的,它的源代码在正确的路径上可用。
Now I try to debug my application with Eclipse and GDB. If I put breakpoints in my application source code, everything is fine. Then I open a source file of the included shared lib and put the breakpoint there. When launching the debug session I am warned that "No source file named xxx.cpp in loaded symbols"and execution isn't stoped at that point. If I put the same breakpoint in the same file when debugging session is already running, everything works fine. What is wrong?
现在我尝试使用 Eclipse 和 GDB 调试我的应用程序。如果我在我的应用程序源代码中放置断点,一切都很好。然后我打开一个包含共享库的源文件并将断点放在那里。启动调试会话时,我被警告说“加载的符号中没有名为 xxx.cpp 的源文件”,并且此时不会停止执行。如果我在调试会话已经运行时将相同的断点放在同一个文件中,则一切正常。怎么了?
Thanks for your help.
谢谢你的帮助。
回答by Algirdas
I found one topic that may answer this question:Why does Eclipse CDT ignore breakpoints?
我找到了一个可以回答这个问题的主题:为什么 Eclipse CDT 会忽略断点?
Could it be that you are trying to set breakpoints in a shared library that has not been loaded yet. That won't work until the library has loaded. Newer gdb allow to set deferred breakpoints, but that may not (yet) be supported by CDT. A workaround is to set a breakpoint in a place that is available from the beginning that will be reached when the shared library in question is already loaded. Then set the other breakpoint in the shared library. Now it should work. It's a bit more tedious, but usually works.
可能是您试图在尚未加载的共享库中设置断点。在库加载之前这将不起作用。较新的 gdb 允许设置延迟断点,但 CDT 可能(还)不支持。一种解决方法是在从一开始就可用的位置设置断点,当相关共享库已加载时,该位置将到达。然后在共享库中设置另一个断点。现在它应该可以工作了。这有点乏味,但通常有效。
coud it be the answear? I am using CDT v6.0.0.200906161748 and GDB v6.8
它可以是答案吗?我正在使用 CDT v6.0.0.200906161748 和 GDB v6.8
回答by PhysicalEd
I had this same problem, trying set breakpoints in Qt plugins (which are based on Windows DLL,s).
我遇到了同样的问题,尝试在 Qt 插件(基于 Windows DLL)中设置断点。
I found this discussion and the solution worked perfectly for me, though I am using a newer version of Eclipse than you were it sounds like much the same problem.
我发现这个讨论和解决方案对我来说完美无缺,尽管我使用的 Eclipse 比你使用的版本更新,但这听起来很像同样的问题。
Basically, it is to use an older gdb protocol that supports deferred breakpoints. Using the "Standard Create Process Launcher" instead of "GDB (DSF) Create Process Launcher" from Debug Configurations and I get all my DLL breakpoints set now.
基本上,它是使用支持延迟断点的旧 gdb 协议。使用调试配置中的“标准创建进程启动器”而不是“GDB(DSF)创建进程启动器”,我现在设置了所有的 DLL 断点。
Version: Helios Release Build id: 20100617-1415
版本:Helios 发布版本 ID:20100617-1415
CDT and GDB version 7.0.0.
CDT 和 GDB 版本 7.0.0。
Good luck!
祝你好运!