User forums > Help
Debugger lldb.exe exits without running target executable
(1/1)
MadDavid:
I'm trying to get LLVM CLANG working with Code::Blocks.
I've got basic compilation working, now I'm trying to get debugging working.
So I set up a test project called "TestConsoleDebugger", which has the following code
--- Quote ---#include <iostream>
#include <cstdio>
int main()
{
int iterations = 0;
FILE* fp;
while (iterations < 1000000)
{
iterations++;
}
fp = fopen("Debug.txt", "a+");
fprintf(fp, "Iterations = %i\n", iterations);
fflush(fp);
fclose(fp);
return 0;
}
--- End quote ---
and breakpoints on "iteration++;" and "fp = fopen("Debug.txt", "a+");
When I click the red "Debug / Continue" arrow, I get
--- Quote ---Active debugger config: GDB/CDB debugger:LLVM 64
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: E:\Development\TestConsoleDebugger\
Adding source dir: E:\Development\TestConsoleDebugger\
Adding file: E:\Development\TestConsoleDebugger\bin\Debug\TestConsoleDebugger.exe
Changing directory to: E:/Development/TestConsoleDebugger/.
Set variable: PATH=.;E:\Compilers\LLVM\bin;E:\Compilers\LLVM;[bunch of irrelevant paths]E:\Compilers\CodeBlocks;\;E:\Compilers\TDM-GCC-64\bin;E:\Compilers\WinSDK\Windows Performance Toolkit;E:\Compilers\Python310\Scripts;E:\Compilers\Python310;E:\Compilers\CodeBlocks\MinGW\bin;E:\Compilers\VisualStudio\VC\Tools\MSVC\14.31.31103\bin\Hostx64\x64;E:\Compilers\Zip
Starting debugger: E:\Compilers\LLVM\bin\lldb.exe -G -lines -2 -y E:/Development/TestConsoleDebugger/; -srcpath E:/Development/TestConsoleDebugger/; E:/Development/TestConsoleDebugger/bin/Debug/TestConsoleDebugger.exe
done
Debugger finished with status 1
Selecting target:
Debug
Adding source dir: E:\Development\TestConsoleDebugger\
Adding source dir: E:\Development\TestConsoleDebugger\
Adding file: E:\Development\TestConsoleDebugger\bin\Debug\TestConsoleDebugger.exe
Changing directory to: E:/Development/TestConsoleDebugger/.
Set variable: PATH=.;E:\Compilers\LLVM\bin;E:\Compilers\LLVM;[bunch of irrelevant paths]E:\Compilers\CodeBlocks;\;E:\Compilers\TDM-GCC-64\bin;E:\Compilers\WinSDK\Windows Performance Toolkit;E:\Compilers\Python310\Scripts;E:\Compilers\Python310;E:\Compilers\CodeBlocks\MinGW\bin;E:\Compilers\VisualStudio\VC\Tools\MSVC\14.31.31103\bin\Hostx64\x64;E:\Compilers\Zip
Starting debugger: E:\Compilers\LLVM\bin\lldb.exe -G -lines -2 -y E:/Development/TestConsoleDebugger/; -srcpath E:/Development/TestConsoleDebugger/; E:/Development/TestConsoleDebugger/bin/Debug/TestConsoleDebugger.exe
done
Debugger finished with status 1
--- End quote ---
Code::Blocks does not stop at any breakpoints, the console does not appear, and notably, "Debug.txt" does not appear. When I click the green "Run" arrow, in contrast, it pops up the console and "Debug.txt" appears in the project directory.
Is there any advice for how to get lldb to actually debug from Code::Blocks? E.g., do I need to put anything in for "Debugger initialization commands" in the debugger setting?
Miguel Gimenez:
--- Quote ---Debugger finished with status 1
--- End quote ---
This means the debugger found an error and quit without executing your program at all. C::B expects GDB or CDB as debugger, not LLDB, and it uses commands specific for them that LLDB does not understand. Also, it parses answers using regex that will fail with LLDB.
MadDavid:
Thanks for your reply. As I understand it, there's no way to get the LLVM debugger to work with code::blocks (barring going into the C::B source code and implementing support). Is that correct?
Pecan:
--- Quote from: MadDavid on July 29, 2026, 07:29:23 pm ---Thanks for your reply. As I understand it, there's no way to get the LLVM debugger to work with code::blocks (barring going into the C::B source code and implementing support). Is that correct?
--- End quote ---
There is already a debugger being developed for CodeBlocks that supports llvm.
The debugger_DAP source is at https://github.com/pecanh/debugger_DAP.
The setup for the debugger is the same as for debugger_gdb or debugger_gdbmi.
Once the plugin is loaded by CodeBlocks, a settings/debugger entry will appear and you will have
to set the location of your debugger (see attachment).
You also have to decide what flavor of breakpoint.symbols to use.
The ususal -g flag alone will not work for llvm.
You have to match the compiler with the gdb symbol types expected.
Look into the compiler setup for the llvm flag types.
Place the source of the debugger_DAP into the contrib plugin folder.
Review the .cbp file to fit your environment.
Compile and place the plugin into the output32_xx.plugin folder or into the devel32_xx folder to test.
You can use the regular debugger_gdb or debugger_gdbmi to debug debugger_DAP if necessary.
everSome:
You can always check to see what your clang installation defaults to via
--- Code: ---clang -### -x c /dev/null
--- End code ---
or
--- Code: ---clang -### -x c++ /dev/null
--- End code ---
. If you see something other than
--- Code: ---"-debugger-tuning=gdb"
--- End code ---
, you can override you installation's default via the options
--- Code: ----ggdb
--- End code ---
, or one of the other gdb variants
--- Code: ----ggdb1, -ggdb2, ggdb3, etc
--- End code ---
. If using an MSYS2 environment on Windows, you'll find that clang in these environments is setup to use gdb by default.
Navigation
[0] Message Index
Go to full version