diff options
| -rw-r--r-- | scripts/gdb/linux/tasks.py | 27 | ||||
| -rw-r--r-- | scripts/gdb/vmlinux-gdb.py | 1 |
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 | |||
| 49 | def get_task_by_pid(pid): | ||
| 50 | for task in TaskList(): | ||
| 51 | if int(task['pid']) == pid: | ||
| 52 | return task | ||
| 53 | return None | ||
| 54 | |||
| 55 | |||
| 56 | class 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 | ||
| 60 | return 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 | |||
| 73 | LxTaskByPidFunc() | ||
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 | ||
