How to use debug libraries on ubuntu

后端 未结 4 1463
孤城傲影
孤城傲影 2020-12-08 17:38

My current problem is with libwebkitgtk-3.0-0, but I guess this problem is generic enough.

My application is crashing somewhere in the webkit code. My assumption is

4条回答
  •  情话喂你
    2020-12-08 18:07

    In order to debug against dynamic libraries you can add the dgb gears with symbol and source distro packages as suggested. Then it's necessary to check if the compilation directories of the debug symbol table matches the paths of the installed source, if it's not you should mapping the paths in gdb. Following the commands to enable debugging of glibc

    $ objdump -g /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.27.so | sed -n '/<.*>\s\+DW_AT_comp_dir/ {s/\s\+<.*>\s\+//; p;}' | sort | uniq
    DW_AT_comp_dir : (indirect string, offset: 0x1127a): /build/glibc-OTsEL5/glibc-2.27/malloc
    ...
    DW_AT_comp_dir : (indirect string, offset: 0xd139): /build/glibc-OTsEL5/glibc-2.27/stdio-common
    DW_AT_comp_dir : (indirect string, offset: 0xef40): /build/glibc-OTsEL5/glibc-2.27/libio
    $ ls -ld glibc-2.27/{stdio-common,libio}
    drwxrwxr-x 3 fusillator fusillator 12288 feb 1 2018 glibc-2.27/libio
    drwxrwxr-x 3 fusillator fusillator 4096 feb 1 2018 glibc-2.27/stdio-common
    $ gdb ./hello
    Reading symbols from ./hello...done.
    (gdb) set substitute-path /build/glibc-OTsEL5/glibc-2.27 glibc-2.27
    (gdb) b main
    Breakpoint 1 at 0x63e: file hello.c, line 10.
    (gdb) run
    Starting program: hello
    Breakpoint 1, main () at hello.c:10
    10 printf("hello world\n");
    (gdb) s
    _IO_puts (str=0x5555555546e4 "hello world") at ioputs.c:33
    33 {
    (gdb) backtrace
    #0 _IO_puts (str=0x5555555546e4 "hello world") at ioputs.c:33
    #1 0x000055555555464a in main () at hello.c:10
    

提交回复
热议问题