summaryrefslogtreecommitdiffstats
path: root/gnu
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2010-11-22 20:52:18 +0000
committerdim <dim@FreeBSD.org>2010-11-22 20:52:18 +0000
commit71b42433f68a7680bcd07cef6c81b5a9bbe4e948 (patch)
tree09b00ba0fbac964aa5e3af51d7a50e20465b2577 /gnu
parent29458224998b52266f5d890a3d9bff4c1f5d3ccb (diff)
parent11b4830687fabb0a27817feb05bf835db82f3147 (diff)
downloadFreeBSD-src-71b42433f68a7680bcd07cef6c81b5a9bbe4e948.zip
FreeBSD-src-71b42433f68a7680bcd07cef6c81b5a9bbe4e948.tar.gz
Sync: merge r215464 through r215708 from ^/head.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/usr.bin/gdb/libgdb/fbsd-threads.c47
1 files changed, 44 insertions, 3 deletions
diff --git a/gnu/usr.bin/gdb/libgdb/fbsd-threads.c b/gnu/usr.bin/gdb/libgdb/fbsd-threads.c
index 129f4f5..605efe6 100644
--- a/gnu/usr.bin/gdb/libgdb/fbsd-threads.c
+++ b/gnu/usr.bin/gdb/libgdb/fbsd-threads.c
@@ -430,6 +430,46 @@ fbsd_thread_deactivate (void)
init_thread_list ();
}
+static char *
+fbsd_thread_get_name (lwpid_t lwpid)
+{
+ static char last_thr_name[MAXCOMLEN + 1];
+ char section_name[32];
+ struct ptrace_lwpinfo lwpinfo;
+ bfd_size_type size;
+ struct bfd_section *section;
+
+ if (target_has_execution)
+ {
+ if (ptrace (PT_LWPINFO, lwpid, (caddr_t)&lwpinfo, sizeof (lwpinfo)) == -1)
+ goto fail;
+ strncpy (last_thr_name, lwpinfo.pl_tdname, sizeof (last_thr_name) - 1);
+ }
+ else
+ {
+ snprintf (section_name, sizeof (section_name), ".tname/%u", lwpid);
+ section = bfd_get_section_by_name (core_bfd, section_name);
+ if (! section)
+ goto fail;
+
+ /* Section size fix-up. */
+ size = bfd_section_size (core_bfd, section);
+ if (size > sizeof (last_thr_name))
+ size = sizeof (last_thr_name);
+
+ if (! bfd_get_section_contents (core_bfd, section, last_thr_name,
+ (file_ptr)0, size))
+ goto fail;
+ if (last_thr_name[0] == '\0')
+ goto fail;
+ }
+ last_thr_name[sizeof (last_thr_name) - 1] = '\0';
+ return last_thr_name;
+fail:
+ strcpy (last_thr_name, "<unknown>");
+ return last_thr_name;
+}
+
static void
fbsd_thread_new_objfile (struct objfile *objfile)
{
@@ -1162,7 +1202,7 @@ fbsd_thread_find_new_threads (void)
static char *
fbsd_thread_pid_to_str (ptid_t ptid)
{
- static char buf[64];
+ static char buf[64 + MAXCOMLEN];
if (IS_THREAD (ptid))
{
@@ -1182,8 +1222,9 @@ fbsd_thread_pid_to_str (ptid_t ptid)
if (ti.ti_lid != 0)
{
- snprintf (buf, sizeof (buf), "Thread %llx (LWP %d)",
- (unsigned long long)th.th_thread, ti.ti_lid);
+ snprintf (buf, sizeof (buf), "Thread %llx (LWP %d/%s)",
+ (unsigned long long)th.th_thread, ti.ti_lid,
+ fbsd_thread_get_name (ti.ti_lid));
}
else
{
OpenPOWER on IntegriCloud