Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating symbol table for gdb using cmake

Is there any way to create only symbol table using cmake for gdb ?

like image 663
Vivek Goel Avatar asked Nov 03 '11 06:11

Vivek Goel


People also ask

How do I add a symbol table in 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.

What is gdb symbol table?

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 do I add a debug flag to Cmake?

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 .


2 Answers

Add this line to the file CMakeLists.txt:

set(CMAKE_BUILD_TYPE Debug) 
like image 89
Jespa Avatar answered Sep 28 '22 19:09

Jespa


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 ... 
like image 28
guilloptero Avatar answered Sep 28 '22 20:09

guilloptero