GDB does not load symbols from libraries

1

I try to debug some native code on Android with GBD. The code wasn't created by me and is not in an Android project, so I can't use the ndk-gdb tool. I use gdbserver on the android machine and connect to it from my mac with the normal GDB program. I try to load all the libraries (which should have symbols according to objdump tool), but gdb tells me that it does not load the symbols (according to the gdb command “info sharedLibrary”). These are the steps I took:

  1. start gdbserver on Android machine
  2. start GDB with the debug version of the binary

    gdb symbols/system/bin/mediaserver

the following commands are executed in gdb itself

  1. tell gdb where to look for the libraries with symbols

    (gdb) set solib-search-path symbols/system/lib

  2. tell gdb where to find the source files

    (gdb) directory /sources

  3. connect to remote target (Android machine)

    (gdb) target remote 192.168.1.10:5039

GDB connects successfully to the running binary and I can pause and continue the execution. But it does not show me any debug information like function names or line numbers. It only shows adresses. When I check the status of the used libraries, I see that gdb thinks, they don’t have any symbols:

  1. command in gdb:

(gdb) info sharedLibrary From To Syms Read Shared Object Library 0x00003700 0x0000ff0c Yes /symbols/system/bin/linker No libc.so No libstdc++.so No libm.so No liblog.so No libcutils.so No libspeexresampler.so No libaudioutils.so No libgccdemangle.so No libamplayer.so

Now for example the last library. When I check with the file command (not in gdb), it tells me that it is a not stripped library (the library is located in the "symbols/system/lib" folder).

file libamplayer.so

Output:

libamplayer.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked, not stripped

objdump command shows a lot of symbols in it (I don’t show the output because it’s very long). So why does gdb not recognise the symbols in this libraries? I thought, at least line numbers and function names are present in not stripped versions of libraries. Or am I wrong? It would be very nice if someone could give me more insight.

Thanks!

System info:

GDB Version: 7.3.1-gg2 on Mac OS X Mavericks

c
android-ndk
gdb
gdbserver
asked on Stack Overflow Mar 22, 2014 by Dude

1 Answer

0

The code wasn't created by me and is not in an Android project, so I can't use the ndk-gdb tool.

Your conclusion does not at all follow. ndk-gdb should be able to debug any Android program, whether created as a "project" or via other means.

I use gdbserver on the android machine and connect to it from my mac with the normal GDB program.

The normal GDB is likely not configured for cross-debugging, and thus doesn't understand ARM binaries at all. I am surprised you get as far using it as you do.

answered on Stack Overflow Mar 23, 2014 by Employed Russian

User contributions licensed under CC BY-SA 3.0