48

I've compiled my C program using gcc 4.4.1 using the flag -g, but when I try to step through one of my functions in gdb version 7.0, I get the message:

"Single stepping until exit from function _DictionaryTree_getNodeList, 
which has no line number information."

Can someone tell me why this is happening?

Waqar
  • 8,558
  • 4
  • 35
  • 43
Steven Oxley
  • 6,563
  • 6
  • 43
  • 55

7 Answers7

42

Just guessing, but is _DictionaryTree_getNodeList in another file that wasn't compiled with -g?

Arthur Kalliokoski
  • 1,627
  • 12
  • 12
  • 1
    Yes, I figured it out before I even read your answer. Good guess ;) – Steven Oxley Jan 31 '10 at 02:06
  • 10
    If you are compiling multiple files, it's better to use a Makefile and add -ggdb in the gcc option flags. – manav m-n Jan 31 '10 at 09:07
  • @Manav MN yeah, that's what I have, but I have two different commands - one for compiling and one for linking and I forgot to add the flag to the one for compiling (which is actually the only one I needed it for, I guess). – Steven Oxley Jan 31 '10 at 23:54
14

I had the same problem but in my case adding -g to the compiler wasn't enough so I used -ggdb as suggested by Manav.

Arild
  • 694
  • 6
  • 18
  • I commented out almost all the code from my main. After the last line in main, gdb went to the first line of main, then got this strange message. I tried with this CXXFLAG="-ggdb -O0", still got the same error message. Tried gdb gcc 7.3 and 8.2 both got the same problem. – Kemin Zhou Dec 22 '18 at 18:30
8

In my case, the problem was version skew between gcc and gdb.

After landing here from search and none of these answers fit my situation, I figured out that (because of aliases / symlinks / Makefile / environment variables) I was accidentally using a newer GCC (4.8.x) and an older GDB (7.2). Stepping up to a newer version of GDB (7.8) fixed the problem. For some reason, using a newer GCC and older GDB didn't work.

hoc_age
  • 1,945
  • 2
  • 18
  • 28
  • 3
    ... but (only) now I see that previous answers to other nearly-identical questions have this answer -- e.g., [this](http://stackoverflow.com/a/20493816/3562032) and [this](http://stackoverflow.com/a/18408197/3562032). The latter includes information on *why* (DWARF incompatibility). Upvotes all around! – hoc_age Jun 01 '15 at 10:22
0

I had this error message too but the source of my problem was different. If anyone is still having any problems, make sure you have #include <stdio.h> in your file, with the the appropriate brackets around stdio.h (the text message would not show up if I had it around stdio.h).

Uyghur Lives Matter
  • 18,820
  • 42
  • 108
  • 144
user3916997
  • 81
  • 1
  • 12
0

I had this issue because I was debugging a shared library without pointing LD_LIBRARY_PATH to correct location with debug endstates.

you can use

export LD_LIBRARY_PATH=<location of the debug build of the .so file>:$LD_LIBRARY_PATH

Hopefully this is helpful to someone

Hans
  • 1,846
  • 3
  • 14
  • 19
-1

I had the same issue, when I compiled a file using -g option and without -g option. For one of the file, the gdb showed line number without any issues(even when it was compiled without -g option).. And for the other file, I had to explicitly mention -g flag...

Any ideas as to whether the source file could be loaded at run time in GDB with cross referencing would be good solution... by mapping the lines to the addresses :D.

ravi.zombie
  • 1,482
  • 1
  • 20
  • 23
-1

I had the same trouble despite I was already compiling with -g2. Changing it to -g3 did the trick.

richar8086
  • 177
  • 4
  • 13