it wrongly assumes that any system out there has the same internals as glibc.
if it uses those internals at all, it should at least check if they are available and if not choose an alternate implementation that doesn't rely on those internals (even it if its just a "sorry, this function is not available" implementation).
tested against musl libc 0.7.2
linux-thread-db.c: In function `dladdr_to_soname':
linux-thread-db.c:618: error: `Dl_info' undeclared (first use in this function)
linux-thread-db.c:618: error: (Each undeclared identifier is reported only once
linux-thread-db.c:618: error: for each function it appears in.)
linux-thread-db.c:618: error: syntax error before "info"
linux-thread-db.c:620: warning: implicit declaration of function `dladdr'
linux-thread-db.c:620: error: `info' undeclared (first use in this function)
linux-thread-db.c: In function `try_thread_db_load_1':
linux-thread-db.c:717: error: `LIBTHREAD_DB_SO' undeclared (first use in this function)
linux-thread-db.c: In function `thread_db_load_search':
linux-thread-db.c:803: error: `LIBTHREAD_DB_SO' undeclared (first use in this function)
linux-thread-db.c: In function `thread_db_load':
linux-thread-db.c:890: error: `LIBTHREAD_DB_SO' undeclared (first use in this function)
linux-thread-db.c: In function `thread_db_pid_to_str':
linux-thread-db.c:1488: warning: long unsigned int format, thread_t arg (arg 4)
linux-thread-db.c: In function `thread_db_find_thread_from_tid':
linux-thread-db.c:1597: warning: comparison between pointer and integer
linux-thread-db.c: In function `_initialize_thread_db':
linux-thread-db.c:1676: error: `LIBTHREAD_DB_SEARCH_PATH' undeclared (first use in this function)
This doesn't have anything to do with glibc internals -- dladdr() is a published *external* glibc interface.
It's true that it's a published external interface, but gdb should not use it without testing for its existence. FYI we now provide dladdr in musl, but I have not seen any good documentation on how to provide the thread debugging hooks gdb wants, and it seems highly nontrivial. It would be helpful to have this fixed, and for gdb to provide some minimal level of thread debugging support without including half of the debugger in the program being debugged...
gdb and gdbserver build with musl now.
gdb requires a couple of minor patches, but they're not libthread_db related.
There's still a plethora of other issues of course.