gdb info line : ... but contains no code

1.9k views Asked by At

I'm getting a strange gdb error off of info line.

 gdb) info line
Line 252 of "main.c" is at address 0x7f29e979c987 <main+314> but contains no code.

But on the other hand, I can successfully list code:

    (gdb) l main.c:254
249               batch_mode = 1;
250             case 'd':
251               daemon_mode = 1;
252               break;
253             case 'k':
254               keep_kernel_mode = 1;
255               break;
256             case 'C':
257               dryrun = 1;
258               break;
(gdb)

And gdb seems to be clearly aware of the source file:

(gdb) info source
Current source file is main.c
Compilation directory is /home/charletr/src/quagga/zebra
Located in /home/charletr/src/quagga/zebra/main.c
Contains 414 lines.
Source language is c.
Compiled with DWARF 2 debugging format.
Does not include preprocessor macro info.

But again, on the other hand, I cannot get info line to say reasonable things: (this is attempting to print info line from the address listed for frame #1 where I am super confident I have source code)

(gdb) bt
#0  0x00007f29e88431f3 in __select_nocancel () from /home/charletr/src/aries-uprevquagga/debug/lib/libc.so.6
#1  0x00007f29e8f309eb in ?? ()
#2  0x00007fffef3b58c0 in ?? ()
#3  0x00007fffef3b5a70 in ?? ()
#4  0x00007fffef3b5a60 in ?? ()
#5  0x00007f29e99d68b8 in ?? ()
#6  0x00007f29e99d6a28 in ?? ()
#7  0x00007f29e99d69a8 in ?? ()
#8  0x00007f29e99d6928 in ?? ()
#9  0x00007f29e99d69a8 in ?? ()
#10 0x00007fffef3b58e0 in ?? ()
#11 0x00007fffef3b5960 in ?? ()
#12 0x0000000000000000 in ?? ()
(gdb) info line *0x00007f29e8f309eb
No line number information available for address 0x7f29e8f309eb

What might be some reasons that gdb:info line can find source but cannot fine line numbers??

Note: I do have a very odd build system/target system setup. I build on the build system and copy the objects to the target system. Then I run gdbserver on the target system. Then I run gdb on the build system and use the target remote command to connect to the gdbserver on the target system.

Hopefully, Ricky

1

There are 1 answers

0
Armali On

I figured it out. I'll just post here in case it happens to anyone else. So my build system and target system have different linux kernel versions and therfore, different libc (glibc) versions. What I needed to do was instruct my local gdb on the build system to use a differnet sysroot so as to match what would be found on the remote target. I did this through the .gdbinit file like so:

set sysroot /opt/6WIND/contrib/toolchain/gcc-4.3.2-glibc-2.7/x86_64-pc-l‌​inux-gnu/sys-root/
set sysroot remote:/

– user3101167