diff options
Diffstat (limited to 'scripts/gdb/linux/tasks.py')
-rw-r--r-- | scripts/gdb/linux/tasks.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/scripts/gdb/linux/tasks.py b/scripts/gdb/linux/tasks.py index e2037d9bb7eb..862a4ae24d49 100644 --- a/scripts/gdb/linux/tasks.py +++ b/scripts/gdb/linux/tasks.py | |||
@@ -18,8 +18,8 @@ from linux import utils | |||
18 | 18 | ||
19 | task_type = utils.CachedType("struct task_struct") | 19 | task_type = utils.CachedType("struct task_struct") |
20 | 20 | ||
21 | |||
21 | def task_lists(): | 22 | def task_lists(): |
22 | global task_type | ||
23 | task_ptr_type = task_type.get_type().pointer() | 23 | task_ptr_type = task_type.get_type().pointer() |
24 | init_task = gdb.parse_and_eval("init_task").address | 24 | init_task = gdb.parse_and_eval("init_task").address |
25 | t = g = init_task | 25 | t = g = init_task |
@@ -38,6 +38,7 @@ def task_lists(): | |||
38 | if t == init_task: | 38 | if t == init_task: |
39 | return | 39 | return |
40 | 40 | ||
41 | |||
41 | def get_task_by_pid(pid): | 42 | def get_task_by_pid(pid): |
42 | for task in task_lists(): | 43 | for task in task_lists(): |
43 | if int(task['pid']) == pid: | 44 | if int(task['pid']) == pid: |
@@ -65,13 +66,28 @@ return that task_struct variable which PID matches.""" | |||
65 | LxTaskByPidFunc() | 66 | LxTaskByPidFunc() |
66 | 67 | ||
67 | 68 | ||
69 | class LxPs(gdb.Command): | ||
70 | """Dump Linux tasks.""" | ||
71 | |||
72 | def __init__(self): | ||
73 | super(LxPs, self).__init__("lx-ps", gdb.COMMAND_DATA) | ||
74 | |||
75 | def invoke(self, arg, from_tty): | ||
76 | for task in task_lists(): | ||
77 | gdb.write("{address} {pid} {comm}\n".format( | ||
78 | address=task, | ||
79 | pid=task["pid"], | ||
80 | comm=task["comm"].string())) | ||
81 | |||
82 | LxPs() | ||
83 | |||
84 | |||
68 | thread_info_type = utils.CachedType("struct thread_info") | 85 | thread_info_type = utils.CachedType("struct thread_info") |
69 | 86 | ||
70 | ia64_task_size = None | 87 | ia64_task_size = None |
71 | 88 | ||
72 | 89 | ||
73 | def get_thread_info(task): | 90 | def get_thread_info(task): |
74 | global thread_info_type | ||
75 | thread_info_ptr_type = thread_info_type.get_type().pointer() | 91 | thread_info_ptr_type = thread_info_type.get_type().pointer() |
76 | if utils.is_target_arch("ia64"): | 92 | if utils.is_target_arch("ia64"): |
77 | global ia64_task_size | 93 | global ia64_task_size |