Qt Creator 4.12.1 - gdb does not hit breakpoints (CMake project)
-
Hello.
I have some issues with debugging my CMake application in Qt Creator 4.12.1. I managed to reproduce following problem on 2 different computers, also with the very basic C++ "Hello World" application.When I compile my application using CMake with Mingw64 g++ compiler and start it in debug mode with breakpoints set, seems like all breakpoints are ignored and none of them is hit.
I am using MinGW-W64 GCC-8.1.0 x86_64-posix-seh compiler. The CMake version is 3.17.3.
Seems like everything, in Kits configuration is set properly - Mingw compiler and debugger were detected automatically.
This is my CMakeLists.txt file:
cmake_minimum_required(VERSION 3.5) project(MingwDebuggerTest LANGUAGES CXX) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall") set(CMAKE_VERBOSE_MAKEFILE ON) add_executable(MingwDebuggerTest main.cpp)
When compiling the application I can see that "-g" option is passed as argument:
21:07:28: Running steps for project MingwDebuggerTest... 21:07:28: Starting: "C:\CMake\bin\cmake.exe" --build . --target all jom: parallel job execution disabled for Makefile C:\CMake\bin\cmake.exe -SD:\Projects\C-Cpp\QuickTests\MingwDebuggerTest -BD:\Projects\C-Cpp\QuickTests\build-MingwDebuggerTest-Desktop_x86_windows_mingw810_64bit-Debug --check-build-system CMakeFiles\Makefile.cmake 0 C:\CMake\bin\cmake.exe -E cmake_progress_start D:\Projects\C-Cpp\QuickTests\build-MingwDebuggerTest-Desktop_x86_windows_mingw810_64bit-Debug\CMakeFiles D:\Projects\C-Cpp\QuickTests\build-MingwDebuggerTest-Desktop_x86_windows_mingw810_64bit-Debug\CMakeFiles\progress.marks C:\Qt\qtcreator-4.12.1\bin\jom.exe -f CMakeFiles\Makefile2 /nologo -L all C:\Qt\qtcreator-4.12.1\bin\jom.exe -f CMakeFiles\MingwDebuggerTest.dir\build.make /nologo -L CMakeFiles\MingwDebuggerTest.dir\depend C:\CMake\bin\cmake.exe -E cmake_depends "NMake Makefiles JOM" D:\Projects\C-Cpp\QuickTests\MingwDebuggerTest D:\Projects\C-Cpp\QuickTests\MingwDebuggerTest D:\Projects\C-Cpp\QuickTests\build-MingwDebuggerTest-Desktop_x86_windows_mingw810_64bit-Debug D:\Projects\C-Cpp\QuickTests\build-MingwDebuggerTest-Desktop_x86_windows_mingw810_64bit-Debug D:\Projects\C-Cpp\QuickTests\build-MingwDebuggerTest-Desktop_x86_windows_mingw810_64bit-Debug\CMakeFiles\MingwDebuggerTest.dir\DependInfo.cmake --color= C:\Qt\qtcreator-4.12.1\bin\jom.exe -f CMakeFiles\MingwDebuggerTest.dir\build.make /nologo -L CMakeFiles\MingwDebuggerTest.dir\build [ 50%] Building CXX object CMakeFiles/MingwDebuggerTest.dir/main.cpp.obj C:\mingw64\bin\g++.exe --sysroot=C:/mingw64 -g -Wall -std=gnu++11 -o CMakeFiles\MingwDebuggerTest.dir\main.cpp.obj -c D:\Projects\C-Cpp\QuickTests\MingwDebuggerTest\main.cpp [100%] Linking CXX executable MingwDebuggerTest.exe C:\CMake\bin\cmake.exe -E rm -f CMakeFiles\MingwDebuggerTest.dir/objects.a C:\mingw64\bin\ar.exe cr CMakeFiles\MingwDebuggerTest.dir/objects.a @CMakeFiles\MingwDebuggerTest.dir\objects1.rsp C:\mingw64\bin\g++.exe --sysroot=C:/mingw64 -g -Wall -Wl,--whole-archive CMakeFiles\MingwDebuggerTest.dir/objects.a -Wl,--no-whole-archive -o MingwDebuggerTest.exe -Wl,--out-implib,libMingwDebuggerTest.dll.a -Wl,--major-image-version,0,--minor-image-version,0 @CMakeFiles\MingwDebuggerTest.dir\linklibs.rsp [100%] Built target MingwDebuggerTest C:\CMake\bin\cmake.exe -E cmake_progress_start D:\Projects\C-Cpp\QuickTests\build-MingwDebuggerTest-Desktop_x86_windows_mingw810_64bit-Debug\CMakeFiles 0 21:07:30: The process "C:\CMake\bin\cmake.exe" exited normally. 21:07:30: Elapsed time: 00:02.
Despite of that, when I start application in debug mode, no breakpoint is hit. I've tried to run "gdb" directly from console on compiled exe, set the breakpoint manually and run the debugger - breakpoint is correctly hit.
Here is the log from my Global Debugger Log window:
21show version 22show debug-file-directory 23set print object on 24set breakpoint pending on 25set print elements 10000 26set unwindonsignal on 27set width 0 28set height 0 Setting up inferior... 29set sysroot C:/mingw64 30set substitute-path /usr/src C:/mingw64/usr/src 31python sys.path.insert(1, 'C:/Qt/qtcreator-4.12.1/share/qtcreator/debugger/') 32python sys.path.append('C:/mingw64/bin/data-directory/python') 33python from gdbbridge import * 34python theDumper.loadDumpers({"token":34}) 35-interpreter-exec console "set target-async off" Setting breakpoints... 36-break-insert -f "\"main.cpp\":7" 37attach 10012 Thread group i1 created. Thread 1 created. [New Thread 10012.0x3e50] Thread 2 created. [New Thread 10012.0x51cc] Stopped. Run requested... Running requested... 38-exec-continue Running. Library C:\WINDOWS\SYSTEM32\ntdll.dll loaded. Library C:\WINDOWS\System32\kernel32.dll loaded. Library C:\WINDOWS\System32\KernelBase.dll loaded. Library C:\Program Files\Bitdefender\Bitdefender Security\atcuf\264661658822597182\atcuf64.dll loaded. Library C:\WINDOWS\System32\msvcrt.dll loaded. Library C:\mingw64\bin\libstdc++-6.dll loaded. Library C:\WINDOWS\System32\user32.dll loaded. Library C:\WINDOWS\System32\win32u.dll loaded. Library C:\WINDOWS\System32\gdi32.dll loaded. Library C:\WINDOWS\System32\gdi32full.dll loaded. Library C:\WINDOWS\System32\msvcp_win.dll loaded. Library C:\WINDOWS\System32\ucrtbase.dll loaded. Library C:\mingw64\bin\libgcc_s_seh-1.dll loaded. Library C:\mingw64\bin\libwinpthread-1.dll loaded. Library C:\WINDOWS\System32\imm32.dll loaded. [Thread 10012.0x51cc exited with code 0] Thread 2 in group i1 exited. Thread 1 in group i1 exited. Thread group i1 exited. 39python theDumper.exitGdb({"token":39}) Debugger finished.
Not sure what am I doing wrong or is this an issue with Qt Creator? Can somebody help me with this? I was unable to find the issue. Application still runs as if no breakpoints were set at all.
Not sure if this can mean something but also if I run the application in debug mode I'll get following output (however I believe I should still be able to debug my application even without symbols loaded from dependencies, but maybe it can cause the problems for Qt Creator?):
21:15:46: Debugging starts Could not load shared library symbols for 15 libraries, e.g. C:\WINDOWS\SYSTEM32\ntdll.dll. Use the "info sharedlibrary" command to see the complete listing. Do you need "set solib-search-path" or "set sysroot"? 21:15:47: Debugging has finished