aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2015-02-17 16:47:10 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-02-17 17:34:54 -0500
commit4752871081ba4fbb3c539488a95e77d8011bfe49 (patch)
treede170ba5e2b63cecfd29a1b53353a096bb6691c2 /scripts
parent7704d58a8509c65e3f7e4407ca2e5fa6360349c1 (diff)
scripts/gdb: add helper and convenience function to look up tasks
Add the helper task_by_pid that can look up a task by its PID. Also export it as a convenience function. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.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.py27
-rw-r--r--scripts/gdb/vmlinux-gdb.py1
2 files changed, 28 insertions, 0 deletions
diff --git a/scripts/gdb/linux/tasks.py b/scripts/gdb/linux/tasks.py
index cd259846ab4b..13bb97cd3312 100644
--- a/scripts/gdb/linux/tasks.py
+++ b/scripts/gdb/linux/tasks.py
@@ -44,3 +44,30 @@ class TaskList:
44 utils.container_of(t['thread_group']['next'], 44 utils.container_of(t['thread_group']['next'],
45 self.task_ptr_type, "thread_group") 45 self.task_ptr_type, "thread_group")
46 return t 46 return t
47
48
49def get_task_by_pid(pid):
50 for task in TaskList():
51 if int(task['pid']) == pid:
52 return task
53 return None
54
55
56class LxTaskByPidFunc(gdb.Function):
57 """Find Linux task by PID and return the task_struct variable.
58
59$lx_task_by_pid(PID): Given PID, iterate over all tasks of the target and
60return that task_struct variable which PID matches."""
61
62 def __init__(self):
63 super(LxTaskByPidFunc, self).__init__("lx_task_by_pid")
64
65 def invoke(self, pid):
66 task = get_task_by_pid(pid)
67 if task:
68 return task.dereference()
69 else:
70 raise gdb.GdbError("No task of PID " + str(pid))
71
72
73LxTaskByPidFunc()
diff --git a/scripts/gdb/vmlinux-gdb.py b/scripts/gdb/vmlinux-gdb.py
index fa66d23ea563..4d7eb2c409aa 100644
--- a/scripts/gdb/vmlinux-gdb.py
+++ b/scripts/gdb/vmlinux-gdb.py
@@ -26,3 +26,4 @@ else:
26 import linux.symbols 26 import linux.symbols
27 import linux.modules 27 import linux.modules
28 import linux.dmesg 28 import linux.dmesg
29 import linux.tasks