From: Doug Evans Date: Mon, 16 May 2011 02:22:39 +0000 (+0000) Subject: * linux-thread-db.c (try_thread_db_load_from_pdir_1): New function. X-Git-Tag: sid-snapshot-20110601~179 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=290351b813cfeeebe7414683c4bd7eeca87d4761;p=external%2Fbinutils.git * 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. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index df50481..438be9b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2011-05-15 Doug Evans + * 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. + * python/py-autoload.c (print_script): Print "Missing" instead of "No" for missing scripts. (info_auto_load_scripts): Tweak "Loaded" column to fit "Missing". 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; }