From: Tom Tromey <tromey@redhat.com>
To: dje@google.com (Doug Evans)
Cc: gdb-patches@sourceware.org
Subject: Re: [RFA] Add support for $sdir and $pdir to libthread-db-search-path
Date: Wed, 18 May 2011 15:28:00 -0000 [thread overview]
Message-ID: <m3zkmkcav3.fsf@fleche.redhat.com> (raw)
In-Reply-To: <m3zkmrk7ag.fsf@fleche.redhat.com> (Tom Tromey's message of "Thu, 12 May 2011 14:12:07 -0600")
Tom> Well, actually, I think the pre-existing code has some problems, but
Tom> they aren't introduced by your patch. I will clean them up separately.
I am checking this in on the trunk.
This removes PATH_MAX from linux-thread-db.c. It also fixes the check
for an absolute file name, which was incorrect in the earlier code.
Built and regtested by the buildbot.
Tom
2011-05-18 Tom Tromey <tromey@redhat.com>
* linux-thread-db.c (try_thread_db_load_from_pdir_1): Fix absolute
path check. Use xmalloc and cleanups.
(try_thread_db_load_from_dir): Use xmalloc and cleanups.
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
index 179986f..f43efc7 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -819,29 +819,29 @@ try_thread_db_load (const char *library)
static int
try_thread_db_load_from_pdir_1 (struct objfile *obj)
{
- char path[PATH_MAX], *cp;
+ struct cleanup *cleanup;
+ char *path, *cp;
+ int result;
- gdb_assert (strlen (obj->name) < sizeof (path));
- strcpy (path, obj->name);
- cp = strrchr (path, '/');
-
- if (cp == NULL)
+ if (obj->name[0] != '/')
{
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);
+ " inferior, but got %s."), obj->name);
return 0;
}
- else
- {
- strcpy (cp + 1, LIBTHREAD_DB_SO);
- return try_thread_db_load (path);
- }
+
+ path = xmalloc (strlen (obj->name) + 1 + strlen (LIBTHREAD_DB_SO) + 1);
+ cleanup = make_cleanup (xfree, path);
+
+ strcpy (path, obj->name);
+ cp = strrchr (path, '/');
+ /* This should at minimum hit the first character. */
+ gdb_assert (cp != NULL);
+ strcpy (cp + 1, LIBTHREAD_DB_SO);
+ result = try_thread_db_load (path);
+
+ do_cleanups (cleanup);
+ return result;
}
/* Handle $pdir in libthread-db-search-path.
@@ -888,24 +888,20 @@ try_thread_db_load_from_sdir (void)
static int
try_thread_db_load_from_dir (const char *dir, size_t dir_len)
{
- char path[PATH_MAX];
+ struct cleanup *cleanup;
+ char *path;
+ int result;
- if (dir_len + 1 + strlen (LIBTHREAD_DB_SO) + 1 > sizeof (path))
- {
- char *cp = xmalloc (dir_len + 1);
-
- memcpy (cp, dir, dir_len);
- cp[dir_len] = '\0';
- warning (_("libthread-db-search-path component too long,"
- " ignored: %s."), cp);
- xfree (cp);
- return 0;
- }
+ path = xmalloc (dir_len + 1 + strlen (LIBTHREAD_DB_SO) + 1);
+ cleanup = make_cleanup (xfree, path);
memcpy (path, dir, dir_len);
path[dir_len] = '/';
strcpy (path + dir_len + 1, LIBTHREAD_DB_SO);
- return try_thread_db_load (path);
+ result = try_thread_db_load (path);
+
+ do_cleanups (cleanup);
+ return result;
}
/* Search libthread_db_search_path for libthread_db which "agrees"
prev parent reply other threads:[~2011-05-18 15:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-10 19:09 Doug Evans
2011-05-12 20:12 ` Tom Tromey
2011-05-13 22:38 ` Doug Evans
2011-05-18 15:28 ` Tom Tromey [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3zkmkcav3.fsf@fleche.redhat.com \
--to=tromey@redhat.com \
--cc=dje@google.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox