[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20230102101911.12765-1-linma@zju.edu.cn>
Date: Mon, 2 Jan 2023 18:19:11 +0800
From: Lin Ma <linma@....edu.cn>
To: jan.kiszka@...mens.com, kbingham@...nel.org,
linux-kernel@...r.kernel.org
Cc: Lin Ma <linma@....edu.cn>
Subject: [PATCH v3] scripts/gdb: fix 'lx-timerlist' on newer kernel
After commit 511885d7061e ("lib/timerqueue: Rely on rbtree semantics for
next timer"), the struct timerqueue_head changes the internal field hence
causes the old lx-timerlist command keeps reporting errors.
This fix adds a simple version comparison and necessary code for
traversing timerqueue on a newer kernel. Moreover, it fixes some
python 3.X compatibility bugs.
Test with python 2.7 and python 3.6
Test with gdb 10.2
Signed-off-by: Lin Ma <linma@....edu.cn>
---
V1->V2: remove the support of old versions, fix typo and adjust the
commit message
V2->V3: remove redundant re package
scripts/gdb/linux/timerlist.py | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/scripts/gdb/linux/timerlist.py b/scripts/gdb/linux/timerlist.py
index 071d0dd5a634..85072be2a196 100644
--- a/scripts/gdb/linux/timerlist.py
+++ b/scripts/gdb/linux/timerlist.py
@@ -43,8 +43,10 @@ def print_timer(rb_node, idx):
def print_active_timers(base):
- curr = base['active']['next']['node']
- curr = curr.address.cast(rbtree.rb_node_type.get_type().pointer())
+ # 511885d7061e ("lib/timerqueue: Rely on rbtree semantics for next timer")
+ leftmost = base['active']['rb_root']['rb_leftmost']
+ curr = leftmost.cast(rbtree.rb_node_type.get_type().pointer())
+
idx = 0
while curr:
yield print_timer(curr, idx)
@@ -73,10 +75,9 @@ def print_cpu(hrtimer_bases, cpu, max_clock_bases):
ts = cpus.per_cpu(tick_sched_ptr, cpu)
text = "cpu: {}\n".format(cpu)
- for i in xrange(max_clock_bases):
+ for i in range(max_clock_bases):
text += " clock {}:\n".format(i)
text += print_base(cpu_base['clock_base'][i])
-
if constants.LX_CONFIG_HIGH_RES_TIMERS:
fmts = [(" .{} : {} nsecs", 'expires_next'),
(" .{} : {}", 'hres_active'),
@@ -165,7 +166,7 @@ def pr_cpumask(mask):
i -= 1
start = i * 2
end = start + 2
- chunks.append(buf[start:end])
+ chunks.append(str(buf[start:end]))
if i != 0 and i % 4 == 0:
chunks.append(',')
@@ -184,7 +185,7 @@ class LxTimerList(gdb.Command):
def invoke(self, arg, from_tty):
hrtimer_bases = gdb.parse_and_eval("&hrtimer_bases")
- max_clock_bases = gdb.parse_and_eval("HRTIMER_MAX_CLOCK_BASES")
+ max_clock_bases = gdb.parse_and_eval("(int)HRTIMER_MAX_CLOCK_BASES")
text = "Timer List Version: gdb scripts\n"
text += "HRTIMER_MAX_CLOCK_BASES: {}\n".format(max_clock_bases)
--
2.17.1
Powered by blists - more mailing lists