Skip to content

Commit

Permalink
scripts/gdb: add internal helper and convenience function to retrieve…
Browse files Browse the repository at this point in the history
… 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 <[email protected]>
Cc: Tony Luck <[email protected]>
Cc: Fenghua Yu <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Jason Wessel <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Ben Widawsky <[email protected]>
Cc: Borislav Petkov <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
jan-kiszka authored and torvalds committed Feb 17, 2015
1 parent b24e2d2 commit cf7492e
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions scripts/gdb/linux/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,38 @@ def invoke(self, pid):


LxTaskByPidFunc()


thread_info_type = utils.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 utils.is_target_arch("ia64"):
global ia64_task_size
if ia64_task_size is 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.
$lx_thread_info(TASK): Given TASK, return the corresponding thread_info
variable."""

def __init__(self):
super(LxThreadInfoFunc, self).__init__("lx_thread_info")

def invoke(self, task):
return get_thread_info(task)


LxThreadInfoFunc()

0 comments on commit cf7492e

Please sign in to comment.