no debugging symbols found when using gdb

C++Gdb

C++ Problem Overview


GNU gdb Fedora (6.8-37.el5) Kernal 2.6.18-164.el5

I am trying to debug my application. However, everytime I pass the binary to the gdb it says:

(no debugging symbols found)

Here is the file output of the binary, and as you can see it is not stripped:

vid: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped

I am compiling with the following CFLAGS:

CFLAGS = -Wall -Wextra -ggdb -O0 -Wunreachable-code

Can anyone tell me if I am missing some simple here?

C++ Solutions


Solution 1 - C++

The most frequent cause of "no debugging symbols found" when -g is present is that there is some "stray" -s or -S argument somewhere on the link line.

From man ld:

   -s
   --strip-all
       Omit all symbol information from the output file.

   -S
   --strip-debug
       Omit debugger symbol information (but not all symbols) from the output file.

Solution 2 - C++

The application has to be both compiled and linked with -g option. I.e. you need to put -g in both CPPFLAGS and LDFLAGS.

Solution 3 - C++

Some Linux distributions don't use the gdb style debugging symbols. (IIRC they prefer dwarf2.)

In general, gcc and gdb will be in sync as to what kind of debugging symbols they use, and forcing a particular style will just cause problems; unless you know that you need something else, use just -g.

Solution 4 - C++

You should also try -ggdb instead of -g if you're compiling for Android!

Solution 5 - C++

Replace -ggdb with -g and make sure you aren't stripping the binary with the strip command.

Solution 6 - C++

I know this was answered a long time ago, but I've recently spent hours trying to solve a similar problem. The setup is local PC running Debian 8 using Eclipse CDT Neon.2, remote ARM7 board (Olimex) running Debian 7. Tool chain is Linaro 4.9 using gdbserver on the remote board and the Linaro GDB on the local PC. My issue was that the debug session would start and the program would execute, but breakpoints did not work and when manually paused "no source could be found" would result. My compile line options (Linaro gcc) included -ggdb -O0 as many have suggested but still the same problem. Ultimately I tried gdb proper on the remote board and it complained of no symbols. The curious thing was that 'file' reported debug not stripped on the target executable.

I ultimately solved the problem by adding -g to the linker options. I won't claim to fully understand why this helped, but I wanted to pass this on for others just in case it helps. In this case Linux did indeed need -g on the linker options.

Solution 7 - C++

Hope the sytem you compiled on and the system you are debugging on have the same architecture. I ran into an issue where debugging symbols of 32 bit binary refused to load up on my 64 bit machine. Switching to a 32 bit system worked for me.

Solution 8 - C++

For those that came here with this question and who are using Qt: in the release config there is a step where the binary is stripped as part of doing the make install. You can pass the configuration option CONFIG+=nostrip to tell it not to:

Instead of:

qmake <your options here, e.g. CONFIG=whatever>

you add CONFIG+=nostrip, so:

qmake <your options here, e.g. CONFIG=whatever> CONFIG+=nostrip

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionant2009View Question on Stackoverflow
Solution 1 - C++Employed RussianView Answer on Stackoverflow
Solution 2 - C++Maxim EgorushkinView Answer on Stackoverflow
Solution 3 - C++geekosaurView Answer on Stackoverflow
Solution 4 - C++Kevin ParkerView Answer on Stackoverflow
Solution 5 - C++atxView Answer on Stackoverflow
Solution 6 - C++DaveView Answer on Stackoverflow
Solution 7 - C++Shankara NarayanaView Answer on Stackoverflow
Solution 8 - C++Martijn de MillianoView Answer on Stackoverflow