What do I need to debug pthreads?

后端 未结 2 1144
悲&欢浪女
悲&欢浪女 2021-02-15 13:23

I want to debug pthreads on my custom linux distribution but I am missing something. My host is Ubuntu 12.04, my target is an i486 custom embedded Linux built with a crosstool-N

相关标签:
2条回答
  • 2021-02-15 13:49

    This:

    dlopen failed on 'libthread_db.so.1' - /lib/libthread_db.so.1: undefined symbol: ps_lgetfpregs
    GDB will not be able to debug pthreads.
    

    means that the libthread_db.so.1 library was not able to find the symbol ps_lgetfpregs in gdb.

    Why?

    Because I built gdb using Crosstoolg-NG with the "Build a static native gdb" option and this adds the -static option to gcc.

    The native gdb is built with the -rdynamic option and this populates the .dynsym symbol table in the ELF file with all symbols, even unused ones. libread_db uses this symbol table to find ps_lgetfpregs from gdb.

    But -static strips the .dynsym table from the ELF file.

    At this point there are two options:

    1. Don't build a static native gdb if you want to debug threads.
    2. Build a static gdb and a static libthread_db (not tested)

    Edit:

    By the way, this does not explain why Breakpad in unable to debug multithreaded applications on my target.

    0 讨论(0)
  • 2021-02-15 14:00

    Just a though... To use the gdb debugger, you need to compile your code with -g option. For instance, gcc -g -c *.c.

    0 讨论(0)
提交回复
热议问题