Search code examples
linuxarmgdbglibcbuildroot

Generating libc6-dbg package from glibc source code


I am having a custom ARM Board. It uses buildroot for generating all the images. We are using glibc .. I need to debug inside the C Library calls. When I run the code under gdb, with "Set Verbose On" , it reads out the symbols from the libc6.so, but when I keep a breakpoint on the C Library call ( e.g. fork ), and run info locals/args, it says "No symbol Info Table".

Do I need to rebuild GLibc or any other settings is required..

Reading symbols from /lib/ld-linux-armhf.so.3...done.
Loaded symbols for /lib/ld-linux-armhf.so.3
Reading symbols from /lib/libpthread.so.0...done.
warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
Loaded symbols for /lib/libpthread.so.0
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6


(gdb) bt full
#0  0x76e19af0 in fork () from /lib/libc.so.6
No symbol table info available.
#1  0x76dded80 in _IO_proc_open@@GLIBC_2.4 () from /lib/libc.so.6
No symbol table info available.
#2  0x76ddf04c in popen@@GLIBC_2.4 () from /lib/libc.so.6

My libc.so has all the debug symbols. Following is snippet of readelf -S libc.so

[71] .debug_info       PROGBITS        00000000 1277e0 00106b 00      0   0  1
  [72] .debug_abbrev     PROGBITS        00000000 12884b 0003f7 00      0   0  1
  [73] .debug_line       PROGBITS        00000000 128c42 0003e2 00      0   0  1
  [74] .debug_frame      PROGBITS        00000000 129024 002a78 00      0   0  4
  [75] .debug_str        PROGBITS        00000000 12ba9c 000360 01  MS  0   0  1
  [76] .debug_loc        PROGBITS        00000000 12bdfc 00162a 00      0   0  1
  [77] .debug_ranges     PROGBITS        00000000 12d426 0000c0 00      0   0  1
  [78] .shstrtab         STRTAB          00000000 12d4e6 000528 00      0   0  1
  [79] .symtab           SYMTAB          00000000 12da10 031700 10     80 10452  4
  [80] .strtab           STRTAB          00000000 15f110 018ed1 00      0   0  1

Solution

  • In addition to what albfan says, you also need to enable BR2_ENABLE_DEBUG to get debugging symbols.

    In fact, what albfan says is not entirely correct: you can perfectly have binaries stripped in your target (no debugging symbols) and keep the binaries with debugging symbols only in the staging area. This is particularly useful when doing remote debugging.

    Since our Buildroot training at http://free-electrons.com/doc/training/buildroot/buildroot-slides.pdf, slide 267 and following.