Page 1 of 2
Debugging using LLDB on FreeBSD
Posted: Sat May 02, 2020 3:09 pm
by karl_bsd
Hello!
It's my first message in this forum. I installed FreeBSD 12.1 on a laptop computer just for playing with some different OS. I also like to try out some C++ Code or write small programs. For that, I choose Codelite as working environment. In FreeBSD there are ports or packages to install software. Since the Codelite port and the Codelite package install only Version 12.0 of Codelite, I decided to compile the current Version (14.0) by myself. The were some linker errors, but with manual intervention it worked. The systems C++ compiler is clang 8.0.1, lldb is also installed in version 8.0.1.
After Codelite was running, I tried to debug some Code, but I could not configure lldb for debugging. In the project settings there is only the option "GNU gdb debugger" for debugging. Somewhere in the wiki I read, that there should be an executable named "codelite-lldb". But this executable was not built on my system.
Just as described, I unpacked the Codelite Sourcecode and made a build-release directory and changed into that directory. From there I startet CMake for configuration: cmake .. -DMAKE_BUILD_TYPE=Release
Then I started cmake for building: cmake --build .
Installing: cmake --build . --target install
Did I do something wrong? Is there a special option for building codelite-lldb? Do I abolutely need codelite-lldb for debugging?
karl
Re: Debugging using LLDB on FreeBSD
Posted: Sat May 02, 2020 5:15 pm
by DavidGH
Hi,
Be warned: I know almost nothing about FreeBSD
. However:
Is there a special option for building codelite-lldb?
No, but you need to have the appropriate -dev file(s) installed. Even in Linux, that's sometimes an issue, as the name varies between distros, and CodeLite/cmake doesn't necessarily search for each name. Anyway, check you have the FreeBSD's lldb-dev (or liblldb-dev or...) installed. If you don't, install it and try rebuilding. (If you add VERBOSE=1 to your cmake line, and look at the build output messages, you should see what happens for lldb; e.g. '--LIBLLDB_INCLUDE is set to /usr/include/.')
Do I abolutely need codelite-lldb for debugging?
No, not at all. lldb and gdb are
alternative debuggers. You only need one, and most people use gdb anyway.
Regards,
David
Re: Debugging using LLDB on FreeBSD
Posted: Sun May 03, 2020 10:20 pm
by karl_bsd
Hello,
thanks for you answer, it was a push in the right direction.
I found out, that in FreeBSD there is one package, called llvm80, which contains the complete LLVM-Suite (with clang, lldb, liblldb.so, etc.). This package is installes in /usr/local/llvm80 and I guess that cmake does not look there for liblldb.so.
Running the command:
Code: Select all
cmake .. -DCMAKE_BUILD_TYPE=Release
creates the file CMakeCache.txt. There were predefined variables for liblldb.so and i filled in the path to the lib and to the include files:
Code: Select all
LIBLLDB_INCLUDE_T:PATH=/usr/local/llvm80/include
LIBLLDB_T:FILEPATH=/usr/local/llvm80/lib/liblldb.so
Then I ran again:
Code: Select all
cmake .. -DCMAKE_BUILD_TYPE=Release
(I don't know if it is necessary) and then:
Built codelite, including support for lldb.
But now I have the problem, that F5 doesn't start debugging and Ctrl+F5 doesn't run the program...
regards,
karl
Re: Debugging using LLDB on FreeBSD
Posted: Sun May 03, 2020 11:43 pm
by DavidGH
First guess: you're using the same workspace/project but, when you originally ran the setup wizard, lldb wasn't available. I suggest you re-run it (see the Help menu).
Also, check your project settings to see what (if any) debugger is currently set.
Alternatively, start a new project and/or workspace.
Re: Debugging using LLDB on FreeBSD
Posted: Tue May 05, 2020 1:21 pm
by karl_bsd
I was not successful. I even made a new workspace/project, but I could not start or debug a program.
I made a very small "Hello World" program. Starting a programm (pressing ctrl-F5) starts a terminal window, that only shows "Hit any key to continue...", no "Hello World" message. The codelite output window shows:
Code: Select all
Working directory is set to: /home/karl/Projekte/CPU6503/build-Debug/bin
Executing: /usr/bin/codelite-terminal --working-directory=/home/karl/Projekte/CPU6503/build-Debug/bin --file=/tmp/CodeLite.karl_schmalle.1588668250/codelite-terminal.txt --wait
In .codelite/codelite.log and .codelite/codelite-stdout-stderr.log are no messages which seem to be related to the problem.
If I set a breakpoint and press just F5 for debugging, the screen flashes and the breakpoint disappears. Nothing else.
Is there a possibility to have more logging or to get other information?
regards,
karl
Re: Debugging using LLDB on FreeBSD
Posted: Tue May 05, 2020 2:33 pm
by DavidGH
Is there a possibility to have more logging or to get other information?
Settings > Preferences > Misc: Log
and changing the Verbosity dropdown to 'Developer', will give maximal logging of most things.
For gdb debugging there's a separate dialog, Settings > GDB settings, that has Misc: Enable full debugger logging. AFAIK there's no lldb equivalent.
Have you tried using gdb instead?
Starting a programme (pressing ctrl-F5)
Are you sure that's starting the debugger? IIUC the standard ctrl-F5 binding is to Run in Terminal.
I suggest you use the toolbar (View > Show Toolbar) where the Debug tool is unmistakable (it's a bug!)
Re: Debugging using LLDB on FreeBSD
Posted: Tue May 05, 2020 4:49 pm
by karl_bsd
Are you sure that's starting the debugger?
No, I just wanted to say, that both features...
1. Simply starting a compiled program by Ctrl-F5 (Menu: Build -> Run)
2. Starting debugging by F5 (Menu: Debugger -> Start / Continue Debugger)
...don't work. I thought, both problems could be related, but maybe I should concentrate on the main problem, the debugger.
So, lets have a look at the logfiles.
regards,
karl
Re: Debugging using LLDB on FreeBSD
Posted: Tue May 05, 2020 5:50 pm
by karl_bsd
I found something in the Logfiles! :
Code: Select all
[14:38:01:713 DBG] [Main] LLDB_DEBUGSERVER_PATH is set to
(and a bit later...)
[14:38:02:006 DBG] [Main] codelite-lldb: LLDB_DEBUGSERVER_PATH environment does not exist or contains a path to a non existent file
[14:38:02:006 DBG] [Main] codelite-lldb: NotifyExited called
So LLDB_DEBUGSERVER_PATH is not set. To what should it be set? I guess it is set outside Codelite?
regards,
karl
Re: Debugging using LLDB on FreeBSD
Posted: Tue May 05, 2020 6:23 pm
by DavidGH
I don't know. There's a Runtime/debugserver in the CodeLite source, but that might not have anything to do with lldb.
Re: Debugging using LLDB on FreeBSD
Posted: Tue May 05, 2020 6:31 pm
by karl_bsd
If I start a shell, set LLDB_DEBUGSERVER_PATH to /usr/bin/lldb (just a guess) and then start codelite from this shell, the following line shows again in the logfile:
Code: Select all
[16:09:36:096 DBG] [Main] LLDB_DEBUGSERVER_PATH is set to
So, codelite deletes the content of this environment variable. Or there is no value predefined in codelite and it is set with an undefined (=empty) value.
regards,
karl