diff options
author | Doug Evans <dje@google.com> | 2011-10-11 03:31:59 +0000 |
---|---|---|
committer | Doug Evans <dje@google.com> | 2011-10-11 03:31:59 +0000 |
commit | 0838fb575ec286250d500871c0a078e6bd25eacc (patch) | |
tree | b6a69b5f042414edf107215fbb04b954362f0f43 /gdb/linux-thread-db.c | |
parent | 0344e8789041c41c4561cfd54c4b04e512983fb4 (diff) | |
download | gdb-0838fb575ec286250d500871c0a078e6bd25eacc.zip gdb-0838fb575ec286250d500871c0a078e6bd25eacc.tar.gz gdb-0838fb575ec286250d500871c0a078e6bd25eacc.tar.bz2 |
* linux-thread-db.c (thread_db_new_objfile): Only try to load
libthread_db when we load libpthread or the main symbol file.
(thread_db_inferior_created): New function.
(_initialize_thread_db): Attach inferior_created observer.
* linux-nat.c (linux_child_post_attach): Remove call to
check_for_thread_db.
(linux_child_post_startup_inferior): Ditto.
* objfiles.h (OBJF_MAINLINE): Define.
* symfile.c (symbol_file_add_with_addrs_or_offsets): Pass it to
allocate_objfile when appropriate.
Diffstat (limited to 'gdb/linux-thread-db.c')
-rw-r--r-- | gdb/linux-thread-db.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index 8dd766b..d9380fd 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -1077,16 +1077,37 @@ check_for_thread_db (void) return; } +/* This function is called via the new_objfile observer. */ + static void thread_db_new_objfile (struct objfile *objfile) { /* This observer must always be called with inferior_ptid set correctly. */ - if (objfile != NULL) + if (objfile != NULL + /* Only check for thread_db if we loaded libpthread, + or if this is the main symbol file. + We need to check OBJF_MAINLINE to handle the case of debugging + a statically linked executable AND the symbol file is specified AFTER + the exec file is loaded (e.g., gdb -c core ; file foo). + For dynamically linked executables, libpthread can be near the end + of the list of shared libraries to load, and in an app of several + thousand shared libraries, this can otherwise be painful. */ + && ((objfile->flags & OBJF_MAINLINE) != 0 + || libpthread_name_p (objfile->name))) check_for_thread_db (); } +/* This function is called via the inferior_created observer. + This handles the case of debugging statically linked executables. */ + +static void +thread_db_inferior_created (struct target_ops *target, int from_tty) +{ + check_for_thread_db (); +} + /* Attach to a new thread. This function is called when we receive a TD_CREATE event or when we iterate over all threads and find one that wasn't already in our list. Returns true on success. */ @@ -1845,4 +1866,9 @@ When non-zero, libthread-db debugging is enabled."), /* Add ourselves to objfile event chain. */ observer_attach_new_objfile (thread_db_new_objfile); + + /* Add ourselves to inferior_created event chain. + This is needed to handle debugging statically linked programs where + the new_objfile observer won't get called for libpthread. */ + observer_attach_inferior_created (thread_db_inferior_created); } |