Debug symbols not created when using cmake - c++

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?

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")

Related

after gdb read symbols from python3.11 done,gdb is stuck, not responding to whatever command is entered

### this is gdb's output.
***
gdb python3.11
GNU gdb (Debian 7.12-6) 7.12.0.20161007-git
Copyright (C) 2016 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 "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from python3.11...done.
***
I can't enter any commands after this.
### this is gcc and gdb version.
***
gcc --version
gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
gdb --version
GNU gdb (Debian 7.12-6) 7.12.0.20161007-git
Copyright (C) 2016 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 "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
***
### this is linux version
***
uname -a
Linux xxxxxxxx.net 4.9.0-6-amd64 #1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07) x86_64 GNU/Linux
cat /etc/debian_version
9.13
***
### python3.11 configure.ac
only add "-gdwarf-4" to OPT , because my gdb does not support dwarf5
### build command
***
./configure --prefix="MY_PATH" -enable-optimizations LLVM_PROFDATA="/usr/lib/llvm-14/bin/llvm-profdata" --with-lto --with-openssl="MY_PATH" --with-openssl-rpath="MY_PATH"
make && make install
***
I Compile Python3.11 without any changes, but GDB does not support DWARF5, so I added "-gdwarf-4" to build. Then I use gdb, gdb gets stuck。 I want use gdb to debug my program 。 I have tried build python2.7 with '-gdwarf-4' ,and the result is same。
Before command 'make install' , gdb is not stuck when I use command 'gdb python3.11'

Getting GDB 8.0.1 to work in CLion on OSX High Sierra 10.13.4

Long story short - LLDB doesn't debug my program properly, so I need to use GDB on my Mac to debug a c++ project. Steps I've taken:
Install GDB 8.0.1 and 8.1 via brew/macports (ie try all options)
Codesign the binary properly.
Start the mac in restart mode and typing csrutil enable --without debug
Choose the custom GDB executable in Clion.
Write in the .gdbinit file located in the home directory set startup-with-shell off
When I go to debug in Clion, in the debugger window it reads:
GNU gdb (GDB) 8.0.1
Copyright (C) 2017 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 "x86_64-apple-darwin17.2.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
[New Thread 0x2203 of process 1208]
warning: unhandled dyld version (15)
In the console window it just prints the path of the executable and then hangs there until eventually it says 'command timed out'.
Any ideas would be massively appreciated.

Can't step into shared library, symbols not loaded

I have an app that I have developed using QT Creator. The project builds and references a couple shared libraries that are in the build tree. When I try to debug my project using the remote debugger, I can't step into or break on any of the library code.
I have tried fixing it by setting LD_LIBRARY_PATH, using set-solib-search-path, etc.
More detailed info:
Host machine is a VM running Ubuntu 16.04
Target machine is a BeagleBone Black running Jessie
Everything is compiled as debug (with the -g flag)
My executable is in /home/debian
My library files are in /home/debian/lib
ls $LD_LIBRARY_PATH shows all of my library files, as expected
Start up command for GDB:
set solib-search-path /home/debian/lib
running gdb /home/debian/lib/mylib.so.1 yields the following:
GNU gdb (Debian 7.7.1+dfsg-5) 7.7.1
Copyright (C) 2014 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".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from lib/mylib.so.1...done.
which implies that gdb is able to read the symbols.
However, running info shared library in the debugger console in qt yields
>~"From To Syms Read Shared Object Library\n"
>~" No /home/debian/lib/mylib.so.1\n"
Running sharedlibrary /home/debian/lib/mylib.so.1 doesn't seem to do anything; it just says "done".
Running add-symbol-file /home/debian/lib/mylib.so.1 fails with
The address where /home/debian/lib/mylib.so.1 has been loaded is missing
The application output screen says "Could not load shared library symbols" when it starts, and says "Do you need "set solib-search-path" or "set sysroot"?" but show solib-search-path prints out
The search path for loading non-absolute shared library symbol files is /home/debian/lib. as expected.
How can I resolve this so that I can debug my libraries?
EDIT:
If I debug on the target device, instead of remote debugging from Qt Creator, gdb can load the symbols, step into library code, and set breakpoints just peachily. Anyone have an idea as to why I can't remote debug?

GDB not able to recognise executable which is unstripped

I am using GDB executable in my linux machine to debug my executable(rild).
My Executable details are as below :-
rild: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked (uses shared libs), BuildID[md5/uuid]=d100d90599eb3764018356c9ef3e1840, not stripped
however when I am running the command
./arm-linux-androideabi-gdb ~/android_gdb/system_bin/rild
I am getting follwing error:-
GNU gdb (GDB) 7.6
Copyright (C) 2013 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 "--host=x86_64-linux-gnu --target=arm-linux-android".
For bug reporting instructions, please see:
<http://source.android.com/source/report-bugs.html>...
"/home/user/android_gdb/system_bin/rild": not in executable format: File format not recognized
I can see that GDB is also 64 bit version and the executable ELF is also unstripped, 64 bit. but still its not working.
rild: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV),
This is an aarch64 64-bit ARM binary.
This GDB was configured as "--host=x86_64-linux-gnu --target=arm-linux-android"
This GDB is a 64-bit x86_64 binary, configured to debug 32-bit ARM binaries.
The fact that GDB itself is a 64-bit binary is irrelevant. What matters is what target it is configured to debug. You need a different GDB, configured with --target=aarch64-linux-android.

Eclipse - remote debugging and segfault in dl_main at rtld.c

I want to debug my application written in C++ in Eclipse via network. I followed this tutorial http://janaxelson.com/eclipse5.htm but when debugging starts it gives me strange segmentation fault. Full log:
GNU gdb (Ubuntu 7.9-1ubuntu1) 7.9
Copyright (C) 2015 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 "i686-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
0xb7fdf0d0 in print_statistics (rtld_total_timep=<optimized out>) at rtld.c:2594
2594 rtld.c: No such file or directory.
Program received signal SIGSEGV, Segmentation fault.
0xb7fe129f in dl_main (phdr=0x8048034, phnum=9, user_entry=0xbffff6ec, auxv=0xbffff7e0) at rtld.c:2182
2182 in rtld.c
I can't figure out what's wrong.
My setup is
Ubuntu 15.04, gcc version 4.9.2, gdb 7.9, Eclipse Mars
Target machine:
Ubuntu 14.04.2 LTS, gdb 7.7.1, gdbserver 7.7.1