diff options
author | Doug Evans <dje@google.com> | 2011-05-16 02:22:39 +0000 |
---|---|---|
committer | Doug Evans <dje@google.com> | 2011-05-16 02:22:39 +0000 |
commit | 290351b813cfeeebe7414683c4bd7eeca87d4761 (patch) | |
tree | 2a9a0778d8f599058589a01a9f55dac1d83c9069 /gdb/linux-thread-db.c | |
parent | cd6eee13dff4086441a722998577207ef9d2a2c5 (diff) | |
download | gdb-290351b813cfeeebe7414683c4bd7eeca87d4761.zip gdb-290351b813cfeeebe7414683c4bd7eeca87d4761.tar.gz gdb-290351b813cfeeebe7414683c4bd7eeca87d4761.tar.bz2 |
* linux-thread-db.c (try_thread_db_load_from_pdir_1): New function.
(try_thread_db_load_from_pdir): Call it. If unable to find
libthread_db in directory of libpthread, see if we're looking at
the separate-debug-info copy.
Diffstat (limited to 'gdb/linux-thread-db.c')
-rw-r--r-- | gdb/linux-thread-db.c | 63 |
1 files changed, 41 insertions, 22 deletions
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index aa8e2c7..179986f 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -812,6 +812,38 @@ try_thread_db_load (const char *library) return 0; } +/* Subroutine of try_thread_db_load_from_pdir to simplify it. + Try loading libthread_db from the same directory as OBJ. + The result is true for success. */ + +static int +try_thread_db_load_from_pdir_1 (struct objfile *obj) +{ + char path[PATH_MAX], *cp; + + gdb_assert (strlen (obj->name) < sizeof (path)); + strcpy (path, obj->name); + cp = strrchr (path, '/'); + + if (cp == NULL) + { + warning (_("Expected absolute pathname for libpthread in the" + " inferior, but got %s."), path); + return 0; + } + else if (cp + 1 + strlen (LIBTHREAD_DB_SO) + 1 > path + sizeof (path)) + { + warning (_("Unexpected: path to libpthread in the inferior is" + " too long: %s"), path); + return 0; + } + else + { + strcpy (cp + 1, LIBTHREAD_DB_SO); + return try_thread_db_load (path); + } +} + /* Handle $pdir in libthread-db-search-path. Look for libthread_db in the directory of libpthread. The result is true for success. */ @@ -824,28 +856,15 @@ try_thread_db_load_from_pdir (void) ALL_OBJFILES (obj) if (libpthread_name_p (obj->name)) { - char path[PATH_MAX], *cp; - - gdb_assert (strlen (obj->name) < sizeof (path)); - strcpy (path, obj->name); - cp = strrchr (path, '/'); - - if (cp == NULL) - { - warning (_("Expected absolute pathname for libpthread in the" - " inferior, but got %s."), path); - } - else if (cp + 1 + strlen (LIBTHREAD_DB_SO) + 1 > path + sizeof (path)) - { - warning (_("Unexpected: path to libpthread in the inferior is" - " too long: %s"), path); - } - else - { - strcpy (cp + 1, LIBTHREAD_DB_SO); - if (try_thread_db_load (path)) - return 1; - } + if (try_thread_db_load_from_pdir_1 (obj)) + return 1; + + /* We may have found the separate-debug-info version of + libpthread, and it may live in a directory without a matching + libthread_db. */ + if (obj->separate_debug_objfile_backlink != NULL) + return try_thread_db_load_from_pdir_1 (obj->separate_debug_objfile_backlink); + return 0; } |