aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/gdb/linux/tasks.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/gdb/linux/tasks.py')
-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()