That would be the usual way. I never thought about it, but perhaps GDB from Lazarus would do too? For my understanding, GDB should be GDB, no matter where it comes from, and I know GDB is part of Lazarus, Sourceforge even offers it as a separate download out of the Lazarus-Package, that link starts the download directly:
Yay! It works! Thank you so much!
(I’ve hit a snag trying to build it myself, apparently simply building under msys2 and running outside results in missing dlls so I’m glad to be able to get an executable and not worry about making it work!)
Hi, in my experience debugging on Windows with QtCreator has been a bit of the pain. It’s better if you compile a Debug config rather than RelWithDebInfo, but I often get weird hangs when stepping.
On Windows we are supposed to use the specific LLVM toolchain and then it’s best to use the bundled llvm debugger instead. You don’t need gdb.
For my development setup, I followed Dmitry’s Qt tutorial and use QtCreator. I wish it was possible to use Visual Studio, but I never had enough mental fortitude and spare time to try to make it work.
I was able to run Krita under gdb but not really debug. I ended up unable to set any breakpoints, I’m getting errors:
C:\env3>C:\gdb\gdb.exe i\bin\krita.exe
GNU gdb unicode (GDB) 9.2
[...]
(gdb) break 1
Breakpoint 1 at 0x140001476: file C:\env3\krita\krita/windows_stub_main.cpp, line 13.
(gdb) run
Starting program: C:\env3\i\bin\krita.exe
[New Thread 26668.0x66dc]
[New Thread 26668.0x40f8]
[New Thread 26668.0x6fcc]
Warning:
Cannot insert breakpoint 1.
Cannot access memory at address 0x140001476
Command aborted.
The llvm-mingw has bin/lldb.exe, I’ll try and see if I can make it work.
As a first test I’ve tried:
C:\env3>C:\llvm-mingw\llvm-mingw-20220906-ucrt-x86_64\bin\lldb.exe i\bin\krita.exe
(lldb) target create "i\\bin\\krita.exe"
Current executable set to 'C:\env3\i\bin\krita.exe' (x86_64).
(lldb) run
And I’m not seeing any output after that, it’s either stuck or very slow or I’m doing something wrong.
To compile a Debug config I’m assuming I need to find a way to replace “-DCMAKE_BUILD_TYPE=Debug”?
I found a line in build.cmd
set CMAKE_BUILD_TYPE=RelWithDebInfo
I’ll try just replacing it with “set CMAKE_BUILD_TYPE=Debug”
Debug will work with the default build. However, yes, for better experience you can replace it with Debug in that line. That’s what I do.
However, a true debug build will be very slow, so maybe don’t do it unless you need to see every variable. Breakpoints and stepping should work with RelWithDebInfo as well.
Yay! I finally have the debugger working!
Thank you everyone for your advice!
For posterity: I used the lldb.exe that is in the bin/ directory of the MingW distribution referenced in the bulid docs.
I ended up using QtCreator.
VS Code does not have built-in support for LLDB, and the extension I installed (CodeLLDB) kept crashing as soon as I reached a breakpoint
I did follow Dmitry’s amazing tutorial for setting up Krita https://www.youtube.com/watch?v=jxIhFlGbPbs (I did end up breaking the build, but rebuilding Krita under QtCreator isn’t that bad)
I did encounter an issue with QtCreator saying “Unable to create a debugging engine”.
Following advice in this thread I started QtCreator from a terminal with an empty path and it worked.