Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug symbols not created when using cmake

Tags:

c++

gdb

cmake

I compiled the c++ code library at github.com/RainerKuemmerle/g2o using cmake after adding

set(CMAKE_BUILD_TYPE Debug)

so as to be able to debug the application. Then it created a build file named "g2o". But when I try debugging with gdb, this is the output I get.

user2@arm_machine:~/g2o/trunk/bin$ gdb g2o
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "arm-linux-gnueabihf".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>...
Reading symbols from /scratch/mbaxkms7/ARM_Programs_mbaxkms7/g2o/trunk/bin/g2o...(no debugging symbols found)...done.
(gdb)

Is there any other way to generate debug information while using cmake?

like image 495
User1234321232 Avatar asked Jul 20 '14 09:07

User1234321232


People also ask

How do I set Cmake debug mode?

We can use CMAKE_BUILD_TYPE to set the configuration type: cd debug cmake -DCMAKE_BUILD_TYPE=Debug .. cmake --build . cd ../release cmake -DCMAKE_BUILD_TYPE=Release ..

Can you debug Cmake?

You can also start a debug session from Solution Explorer. First, switch to CMake Targets View in the Solution Explorer window. Then, right-click on an executable and select Debug. This command automatically starts debugging the selected target based on your active configuration.

How do you know if a binary symbol is debugging?

To check if there's debug info inside the kernel object, you can add the following at the end of the objdump command: | grep debug . If this string is found, you know the kernel object contains debug information. If not, then it's a "clean" kernel object.

What is Dcmake_build_type?

Specifies the build type on single-configuration generators (e.g. Makefile Generators or Ninja ). Typical values include Debug , Release , RelWithDebInfo and MinSizeRel , but custom build types can also be defined.


1 Answers

Your approach with adding set(CMAKE_BUILD_TYPE Debug) works fine.

But g2o is the program which was build with Release options. Debug version of g2o is called g2o_d. Thus to debug you need launch debugger in the following way:

user2@arm_machine:~/g2o/trunk/bin$ gdb g2o_d

Note
Different names isn't common feature of CMake but only of the g2o project:

# postfix, based on type
SET(CMAKE_DEBUG_POSTFIX "_d" CACHE STRING "postfix applied to debug build of libraries")
SET(CMAKE_RELEASE_POSTFIX "" CACHE STRING "postfix applied to release build of libraries")
like image 135
Gluttton Avatar answered Sep 17 '22 15:09

Gluttton