aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver/thread-db.c
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2012-08-08 19:48:19 +0000
committerDoug Evans <dje@google.com>2012-08-08 19:48:19 +0000
commite6712ff1b5f9f440889f298b326a12325d919680 (patch)
tree19a392fd5da376b4950d15664c0485b497a90744 /gdb/gdbserver/thread-db.c
parentab854e54510727ba4db85875159f796e652e0b54 (diff)
downloadgdb-e6712ff1b5f9f440889f298b326a12325d919680.zip
gdb-e6712ff1b5f9f440889f298b326a12325d919680.tar.gz
gdb-e6712ff1b5f9f440889f298b326a12325d919680.tar.bz2
* gdb_string.h: Moved to ...
* common/gdb_string.h: ... here. * common/vec.h: Remove #ifndef GDBSERVER conditional inclusion of gdb_string.h and gdb_assert.h. gdbserver/ * configure.ac: Add check for strstr. * config.in: Regenerate. * configure: Regenerate. * linux-thread-db.c: #include "gdb_vecs.h". (try_thread_db_load_from_pdir_1): New arg "subdir". All callers updated. (try_thread_db_load_from_pdir): New arg "subdir". All callers updated. (thread_db_load_search): Use a vector to iterate over path elements. Handle text appearing after "$pdir". gdbserver/ * Makefile.in (SFILES): Add gdb_vecs.c. (OBS): Add gdb_vecs.o. (gdb_vecs_h, host_defs_h): New variables. (thread-db.o): Add $(gdb_vecs_h) dependency. (gdb_vecs.o): New rule. * thread-db.c: #include "gdb_vecs.h". (thread_db_load_search): Use a vector to iterate over path elements. Handle text appearing after "$pdir".
Diffstat (limited to 'gdb/gdbserver/thread-db.c')
-rw-r--r--gdb/gdbserver/thread-db.c34
1 files changed, 14 insertions, 20 deletions
diff --git a/gdb/gdbserver/thread-db.c b/gdb/gdbserver/thread-db.c
index 795f926..4a59df6 100644
--- a/gdb/gdbserver/thread-db.c
+++ b/gdb/gdbserver/thread-db.c
@@ -28,6 +28,7 @@ static int thread_db_use_events;
#include "gdb_proc_service.h"
#include "gdb_thread_db.h"
+#include "gdb_vecs.h"
#ifndef USE_LIBTHREAD_DB_DIRECTLY
#include <dlfcn.h>
@@ -741,39 +742,31 @@ try_thread_db_load_from_dir (const char *dir, size_t dir_len)
static int
thread_db_load_search (void)
{
- const char *search_path;
- int rc = 0;
+ VEC (char_ptr) *dir_vec;
+ char *this_dir;
+ int i, rc = 0;
if (libthread_db_search_path == NULL)
libthread_db_search_path = xstrdup (LIBTHREAD_DB_SEARCH_PATH);
- search_path = libthread_db_search_path;
- while (*search_path)
+ dir_vec = dirnames_to_char_ptr_vec (libthread_db_search_path);
+
+ for (i = 0; VEC_iterate (char_ptr, dir_vec, i, this_dir); ++i)
{
- const char *end = strchr (search_path, ':');
- const char *this_dir = search_path;
+ const int pdir_len = sizeof ("$pdir") - 1;
size_t this_dir_len;
- if (end)
- {
- this_dir_len = end - search_path;
- search_path += this_dir_len + 1;
- }
- else
- {
- this_dir_len = strlen (this_dir);
- search_path += this_dir_len;
- }
+ this_dir_len = strlen (this_dir);
- if (this_dir_len == sizeof ("$pdir") - 1
- && strncmp (this_dir, "$pdir", this_dir_len) == 0)
+ if (strncmp (this_dir, "$pdir", pdir_len) == 0
+ && (this_dir[pdir_len] == '\0'
+ || this_dir[pdir_len] == '/'))
{
/* We don't maintain a list of loaded libraries so we don't know
where libpthread lives. We *could* fetch the info, but we don't
do that yet. Ignore it. */
}
- else if (this_dir_len == sizeof ("$sdir") - 1
- && strncmp (this_dir, "$sdir", this_dir_len) == 0)
+ else if (strcmp (this_dir, "$sdir") == 0)
{
if (try_thread_db_load_from_sdir ())
{
@@ -791,6 +784,7 @@ thread_db_load_search (void)
}
}
+ free_char_ptr_vec (dir_vec);
if (debug_threads)
fprintf (stderr, "thread_db_load_search returning %d\n", rc);
return rc;