lkml.org 
[lkml]   [2012]   [Nov]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 07/13] scripts/gdb: Add task iteration helper
Date
The internal helper for_each_task iterates over all tasks of the target,
calling the provided function on each. For performance reasons, we cache
a reference to the gdb type object of a task.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
scripts/gdb/task.py | 40 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 40 insertions(+), 0 deletions(-)
create mode 100644 scripts/gdb/task.py

diff --git a/scripts/gdb/task.py b/scripts/gdb/task.py
new file mode 100644
index 0000000..1e4f61e
--- /dev/null
+++ b/scripts/gdb/task.py
@@ -0,0 +1,40 @@
+#
+# gdb helper commands and functions for Linux kernel debugging
+#
+# task & thread tools
+#
+# Copyright (c) 2011, 2012 Siemens AG
+#
+# Authors:
+# Jan Kiszka <jan.kiszka@siemens.com>
+#
+# This work is licensed under the terms of the GNU GPL version 2.
+#
+
+import gdb
+
+from utils import *
+
+task_ptr_type = None
+
+def get_task_ptr_type():
+ global task_ptr_type
+ if task_ptr_type == None:
+ task_ptr_type = get_type("struct task_struct").pointer()
+ return task_ptr_type
+
+def for_each_task(func, arg = None):
+ init_task = gdb.parse_and_eval("init_task")
+ g = init_task.address
+ while True:
+ g = container_of(g['tasks']['next'], get_task_ptr_type(),
+ "tasks")
+ if g == init_task.address:
+ break;
+ t = g
+ while True:
+ func(t, arg)
+ t = container_of(t['thread_group']['next'],
+ get_task_ptr_type(), "thread_group")
+ if t == g:
+ break
--
1.7.3.4


\
 
 \ /
  Last update: 2012-11-05 17:41    [W:2.620 / U:0.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site