Is there any way to create only symbol table using cmake for gdb ?
To add additional symbols you might use add-symbol-file . The add-symbol-file command reads additional symbol table information from the file filename. You would use this command when filename has been dynamically loaded (by some other means) into the program that is running.
The symbol table contains debugging information that tells a debugger what memory locations correspond to which symbols (like function names and variable names) in the original source code file. The symbol table is usually stored inside the executable, yes. gdb is telling you that it can't find that table.
How to enable debugging with cmake? If we use cmake to build the project, we may want to enabling the debuging mode that cmake invoke gcc with the -g so that we can debug the compiled program with gdb. This can be enabled by adding the CMAKE_BUILD_TYPE parameter to cmake: cmake -DCMAKE_BUILD_TYPE=Debug .
Add this line to the file CMakeLists.txt:
set(CMAKE_BUILD_TYPE Debug)
compile in Release mode optimized but adding debug symbols, useful for profiling :
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ...
or compile with NO optimization and adding debug symbols :
cmake -DCMAKE_BUILD_TYPE=Debug ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With