aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/gdb
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2015-02-17 16:47:07 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-02-17 17:34:54 -0500
commit7704d58a8509c65e3f7e4407ca2e5fa6360349c1 (patch)
treee1da4e8ecd798c511ba442c652335abd882df0f4 /scripts/gdb
parentae7dbaad23f0346dc4e2476be63a9a5a376ee472 (diff)
scripts/gdb: add task iteration class
This class allows to iterate over all tasks of the target. 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/gdb')
-rw-r--r--scripts/gdb/linux/tasks.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/scripts/gdb/linux/tasks.py b/scripts/gdb/linux/tasks.py
new file mode 100644
index 000000000000..cd259846ab4b
--- /dev/null
+++ b/scripts/gdb/linux/tasks.py
@@ -0,0 +1,46 @@
1#
2# gdb helper commands and functions for Linux kernel debugging
3#
4# task & thread tools
5#
6# Copyright (c) Siemens AG, 2011-2013
7#
8# Authors:
9# Jan Kiszka <jan.kiszka@siemens.com>
10#
11# This work is licensed under the terms of the GNU GPL version 2.
12#
13
14import gdb
15
16from linux import utils
17
18
19task_type = utils.CachedType("struct task_struct")
20
21
22class TaskList:
23 def __init__(self):
24 global task_type
25 self.task_ptr_type = task_type.get_type().pointer()
26 self.init_task = gdb.parse_and_eval("init_task")
27 self.curr_group = self.init_task.address
28 self.curr_task = None
29
30 def __iter__(self):
31 return self
32
33 def next(self):
34 t = self.curr_task
35 if not t or t == self.curr_group:
36 self.curr_group = \
37 utils.container_of(self.curr_group['tasks']['next'],
38 self.task_ptr_type, "tasks")
39 if self.curr_group == self.init_task.address:
40 raise StopIteration
41 t = self.curr_task = self.curr_group
42 else:
43 self.curr_task = \
44 utils.container_of(t['thread_group']['next'],
45 self.task_ptr_type, "thread_group")
46 return t