[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <c4fb2b8d82932f2e86956bd0bd08caf15855b652.1359463075.git.jan.kiszka@siemens.com>
Date: Tue, 29 Jan 2013 13:37:57 +0100
From: Jan Kiszka <jan.kiszka@...mens.com>
To: Andrew Morton <akpm@...ux-foundation.org>,
linux-kernel@...r.kernel.org
Cc: Jason Wessel <jason.wessel@...driver.com>,
kgdb-bugreport@...ts.sourceforge.net,
Andi Kleen <andi@...stfloor.org>,
Tom Tromey <tromey@...hat.com>,
Ben Widawsky <ben@...dawsk.net>,
Borislav Petkov <bp@...en8.de>,
Tony Luck <tony.luck@...el.com>,
Fenghua Yu <fenghua.yu@...el.com>, linux-ia64@...r.kernel.org
Subject: [PATCH v5 14/20] scripts/gdb: Add internal helper and convenience function to retrieve thread_info
Add the internal helper get_thread_info that calculated the thread_info
from a given task variable. Also export this service as a convenience
function.
Note: ia64 version is untested.
CC: Tony Luck <tony.luck@...el.com>
CC: Fenghua Yu <fenghua.yu@...el.com>
CC: linux-ia64@...r.kernel.org
Signed-off-by: Jan Kiszka <jan.kiszka@...mens.com>
---
scripts/gdb/task.py | 35 +++++++++++++++++++++++++++++++++++
1 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/scripts/gdb/task.py b/scripts/gdb/task.py
index fe42eb0..8e96238 100644
--- a/scripts/gdb/task.py
+++ b/scripts/gdb/task.py
@@ -62,3 +62,38 @@ class LxTaskByPidFunc(gdb.Function):
raise gdb.GdbError("No task of PID " + str(pid))
LxTaskByPidFunc()
+
+
+thread_info_type = CachedType("struct thread_info")
+
+ia64_task_size = None
+
+def get_thread_info(task):
+ global thread_info_type
+ thread_info_ptr_type = thread_info_type.get_type().pointer()
+ if is_target_arch("ia64"):
+ global ia64_task_size
+ if ia64_task_size == None:
+ ia64_task_size = gdb.parse_and_eval(
+ "sizeof(struct task_struct)")
+ thread_info_addr = task.address + ia64_task_size
+ thread_info = thread_info_addr.cast(thread_info_ptr_type)
+ else:
+ thread_info = task['stack'].cast(thread_info_ptr_type)
+ return thread_info.dereference()
+
+
+class LxThreadInfoFunc (gdb.Function):
+ # Calculate Linux thread_info from task variable.
+ __doc__ = "Calculate Linux thread_info from task variable.\n" \
+ "\n" \
+ "$lx_thread_info(TASK): Given TASK, return the corresponding thread_info\n" \
+ "variable."
+
+ def __init__(self):
+ super(LxThreadInfoFunc, self).__init__("lx_thread_info")
+
+ def invoke(self, task):
+ return get_thread_info(task)
+
+LxThreadInfoFunc()
--
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists