From 66a2c50c295e46f99fd9626c53f3e7914071f113 Mon Sep 17 00:00:00 2001
From: Nadav Har'El <nyh@cloudius-systems.com>
Date: Wed, 13 Mar 2013 18:56:18 +0200
Subject: [PATCH] Added to gdb's "osv info threads" each thread's id before its
 address, and also to the "osv thread ..." command, you can now use in
 addition to the thread's address, also its id - e.g., "osv thread 44" will go
 to the thread with id()==44.

---
 scripts/loader.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/scripts/loader.py b/scripts/loader.py
index 29fca313f..5cf816439 100644
--- a/scripts/loader.py
+++ b/scripts/loader.py
@@ -248,6 +248,7 @@ class osv_info_threads(gdb.Command):
         for t in state.thread_list:
             with thread_context(t, state):
                 cpu = t['_cpu']
+		tid = t['_id']
                 fr = gdb.selected_frame()
                 sal = fr.find_sal()
                 status = str(t['_status']['_M_i']).replace('sched::thread::', '')
@@ -257,8 +258,8 @@ class osv_info_threads(gdb.Command):
                 fname = '??'
                 if sal.symtab:
                     fname = sal.symtab.filename
-                gdb.write('0x%x cpu%s %-10s %s at %s:%s\n' %
-                          (ulong(t.address),
+                gdb.write('%d (0x%x) cpu%s %-10s %s at %s:%s\n' %
+                          (tid, ulong(t.address),
                            cpu['arch']['acpi_id'],
                            status,
                            function,
@@ -279,6 +280,9 @@ class osv_thread(gdb.Command):
         for t in state.thread_list:
             if t.address.cast(ulong_type) == long(arg, 0):
                 thread = t
+            with thread_context(t, state):
+	        if t['_id'] == long(arg, 0):
+                    thread = t
         if not thread:
             print 'Not found'
             return
-- 
GitLab