Is there any way to create only symbol table using cmake for gdb ?
The usual way to produce debugging information for gdb
is to pass -g
to the gcc
or g++
compiler (and also at linking time).
Look into the Cmake FAQ for how to get a debuggable executable.
cmake
specific question. I think that they are some Linux utilities (perhaps binutils related) to extract debugging information from an ELF executable, but I never used them. moythreads.com/wordpress/2009/08/31/… –
Neuro Add this line to the file CMakeLists.txt:
set(CMAKE_BUILD_TYPE Debug)
-g
which flag for adding debug symbols. –
Abigail 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're using QtCreator, remove (or comment out) any line containing CMAKE_BUILD_TYPE
:
# set(CMAKE_BUILD_TYPE Debug)
# set(CMAKE_BUILD_TYPE Release) <- comment out such lines
Reason: if you explicitly set CMAKE_BUILD_TYPE in your CmakeLists.txt, QtCreator will not allow you to set any other target.
If you need the debug symbols for profiling then paste this into CMakeLists.txt
:
set(CMAKE_BUILD_TYPE RelWithDebInfo)
The usual way to produce debugging information for gdb
is to pass -g
to the gcc
or g++
compiler (and also at linking time).
Look into the Cmake FAQ for how to get a debuggable executable.
cmake
specific question. I think that they are some Linux utilities (perhaps binutils related) to extract debugging information from an ELF executable, but I never used them. moythreads.com/wordpress/2009/08/31/… –
Neuro © 2022 - 2024 — McMap. All rights reserved.