CodeLite+TDM-GCC调试C++程序,断点无效问题

本文介绍了一个关于CodeLite环境下GDB无法正确捕获断点的问题,并详细记录了解决过程。通过调整调试器设置及更换GDB版本,最终解决了这一难题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

      最近使用CodeLite(我使用的TDM-GCC 5.1.0版本编译器)写了个简单的C++程序,调试的时候发现,程序不进断点运行完就退出了,可编译器和调试器的设置都是对的啊。更诡异的是在命令行使用CodeLite调用的GDB程序直接调试程序却能正确的捕捉到断点。于是上网搜索,在StackOverflow上得到了一个回答,是这样说的:

尝试打开Settings -> Debugger Settings -> GNU gdb debugger -> Misc -> Enable debugger full logging选项来获取更详细的CodeLite与GDB之间的交互信息,这样就可以知道GDB停止运行的原因。输出的日志会打印在"Debugger"面板的"Output"标签页。

于是去勾选上调试器设置的“Enable debugger full logging”选项

215524_KevT_1167407.png

F5调试源程序,在output标签中获得下面的日志输出

Debug session started successfully!
GNU gdb (GDB) 7.9.1
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.  Type "show copying"\nand "show warranty" for details.
This GDB was configured as "x86_64-w64-mingw32".\nType "show configuration" for configuration details.
\nFor bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:\n<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./CppTest...
done.
>> Debuggee process ID: 6956
[New Thread 6956.0x1b8]
Continuing...
[New Thread 6956.0x34cc]
\nTemporary breakpoint
1, main () at F:/codes/CodeLite/CppTest/main.cpp:18
18\t\tX x;
Internal breakpoint was hit (id=1), Applying user breakpoints and continuing
C:/crossdev/src/gdb-7.9.1/gdb/cp-namespace.c:341: internal-error: cp_search_static_and_baseclasses: Assertion `name[prefix_len + 1] == ':'' failed.\nA problem internal to GDB has been detected,\nfurther debugging may prove unreliable.\nQuit this debugging session?
(y or n) [answered Y; input not from terminal]
C:/crossdev/src/gdb-7.9.1/gdb/cp-namespace.c:341: internal-error: cp_search_static_and_baseclasses: Assertion `name[prefix_len + 1] == ':'' failed.\nA problem internal to GDB has been detected,\nfurther debugging may prove unreliable.\nCreate a core file of GDB?
(y or n) [answered Y; input not from terminal]
Debug session ended

      注意到错误信息 internal-error: cp_search_static_and_baseclasses: Assertion `name[prefix_len + 1] == ':'' failed.\n,根据这条错误信息我们查到了下面的相关的地址

https://github.com/eranif/codelite/issues/873

http://sourceware-org.1504.n7.nabble.com/PATCH-Fix-problem-handling-colon-in-linespec-PR-breakpoints-18303-td370027.html

224225_ZHnM_1167407.png

220409_PN5C_1167407.png

      通过这两个网页得到的信息,我们知道了是TDM-GCC 5.1.0带着的7.9.1版本的GDB的BUG,切换到以前的版本的GDB就行了。而且经试验当前最新的7.12版本也没有这个问题。至此,问题解决。

转载于:https://my.oschina.net/u/1167407/blog/817203

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值