aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2015-02-17 16:47:15 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-02-17 17:34:54 -0500
commitcf7492e933c0df200f8fa46c3684e8bd20890ab2 (patch)
tree5cda24e7cb12be776f05adee52dae2a3debf4217 /scripts
parentb24e2d21ac6efd23a67652870fac0cfb943d2264 (diff)
scripts/gdb: add internal helper and convenience function to retrieve thread_info
Add the internal helper get_thread_info that calculates the thread_info from a given task variable. Also export this service as a convenience function. Note: ia64 version is untested. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Cc: Tony Luck <tony.luck@intel.com> Cc: Fenghua Yu <fenghua.yu@intel.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Jason Wessel <jason.wessel@windriver.com> Cc: Andi Kleen <andi@firstfloor.org> Cc: Ben Widawsky <ben@bwidawsk.net> Cc: Borislav Petkov <bp@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/gdb/linux/tasks.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/scripts/gdb/linux/tasks.py b/scripts/gdb/linux/tasks.py
index 13bb97cd3312..63cd6c517e6d 100644
--- a/scripts/gdb/linux/tasks.py
+++ b/scripts/gdb/linux/tasks.py
@@ -71,3 +71,38 @@ return that task_struct variable which PID matches."""
71 71
72 72
73LxTaskByPidFunc() 73LxTaskByPidFunc()
74
75
76thread_info_type = utils.CachedType("struct thread_info")
77
78ia64_task_size = None
79
80
81def get_thread_info(task):
82 global thread_info_type
83 thread_info_ptr_type = thread_info_type.get_type().pointer()
84 if utils.is_target_arch("ia64"):
85 global ia64_task_size
86 if ia64_task_size is None:
87 ia64_task_size = gdb.parse_and_eval("sizeof(struct task_struct)")
88 thread_info_addr = task.address + ia64_task_size
89 thread_info = thread_info_addr.cast(thread_info_ptr_type)
90 else:
91 thread_info = task['stack'].cast(thread_info_ptr_type)
92 return thread_info.dereference()
93
94
95class LxThreadInfoFunc (gdb.Function):
96 """Calculate Linux thread_info from task variable.
97
98$lx_thread_info(TASK): Given TASK, return the corresponding thread_info
99variable."""
100
101 def __init__(self):
102 super(LxThreadInfoFunc, self).__init__("lx_thread_info")
103
104 def invoke(self, task):
105 return get_thread_info(task)
106
107
108LxThreadInfoFunc()