最近使用CodeLite(我使用的TDM-GCC 5.1.0版本編譯器)寫了個簡單的C++程序,調試的時候發現,程序不進斷點運行完就退出了,可編譯器和調試器的設置都是對的啊。更詭異的是在命令行使用CodeLite調用的GDB程序直接調試程序卻能正確的捕捉到斷點。因而上網搜索,在StackOverflow上獲得了一個回答,是這樣說的:html
嘗試打開Settings -> Debugger Settings -> GNU gdb debugger -> Misc -> Enable debugger full logging選項來獲取更詳細的CodeLite與GDB之間的交互信息,這樣就能夠知道GDB中止運行的緣由。輸出的日誌會打印在"Debugger"面板的"Output"標籤頁。git
因而去勾選上調試器設置的「Enable debugger full logging」選項github
F5調試源程序,在output標籤中得到下面的日誌輸出redis
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,根據這條錯誤信息咱們查到了下面的相關的地址session
https://github.com/eranif/codelite/issues/873ui
經過這兩個網頁獲得的信息,咱們知道了是TDM-GCC 5.1.0帶着的7.9.1版本的GDB的BUG,切換到之前的版本的GDB就好了。並且經試驗當前最新的7.12版本也沒有這個問題。至此,問題解決。spa