Skip to contentSkip to conversation

scripts/gdb: timerlist: fix rb_node access and python errors

PATCH In review Amjad Ouled-Ameur 2 participants 6 messages Jul 27, 2022 – Mar 26, 2023 GDB kernel debugging helper scripts

lore
Share & tools
lore
#0 lore raw

cover scripts/gdb: timerlist: fix rb_node access and python errors

This patchset fixes use of lx-timerlist with kgdb.

It has been tested on Amlogic libretech-cc s905X and works fine [0]

[0]: https://pastebin.com/RAhQYh6L

Amjad Ouled-Ameur (3):
scripts/gdb: timerlist: use range instead of xrange scripts/gdb: timerlist: fix rb_node access scripts/gdb: timerlist: convert int chunks to str

 scripts/gdb/linux/timerlist.py | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
Signature · 1 line
2.37.1
#1 lore raw

PATCH 1/3 scripts/gdb: timerlist: use range instead of xrange

xrange has been renamed to range in Python 3. Therefore, timerlist currently fails with NameError exception:

Python Exception <class 'NameError'> name 'xrange' is not defined.

Use range instead of xrange.

---
 scripts/gdb/linux/timerlist.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/gdb/linux/timerlist.py +1 -1
index 071d0dd5a634..fac951236dc4 100644
@@ -73,7 +73,7 @@ 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])
 
Signature · 1 line
2.37.1
#2 lore raw

PATCH 2/3 scripts/gdb: timerlist: fix rb_node access

In reply to Amjad Ouled-Ameur

"strcut timerqueue_head" no longer has "next" member since v5.4-rc1:
commit 511885d7061e ("lib/timerqueue: Rely on rbtree semantics for next timer")

Therefore, access "rb_node" through active->rb_root->rb_root->rb_node.

Moreoever, remove curr.address.cast() on rb_node as this breaks the code and is not necessary.

---
 scripts/gdb/linux/timerlist.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
scripts/gdb/linux/timerlist.py +1 -2
index fac951236dc4..d16909f8df35 100644
@@ -43,8 +43,7 @@ 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())
+    curr = base['active']['rb_root']['rb_root']['rb_node']
     idx = 0
     while curr:
         yield print_timer(curr, idx)
Signature · 1 line
2.37.1
#3 lore raw

PATCH 3/3 scripts/gdb: timerlist: convert int chunks to str

In reply to Amjad Ouled-Ameur

join() expects strings but integers are given.

Convert chunks list to strings before passing it to join()

---
 scripts/gdb/linux/timerlist.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/gdb/linux/timerlist.py +1 -1
index d16909f8df35..98bb9a239283 100644
@@ -172,7 +172,7 @@ def pr_cpumask(mask):
     if 0 < extra <= 4:
         chunks[0] = chunks[0][0]  # Cut off the first 0
 
-    return "".join(chunks)
+    return "".join(str(chunks))
 
 
 class LxTimerList(gdb.Command):
Signature · 1 line
2.37.1
Tested-by on the v1 series
#4 lore raw
In reply to Amjad Ouled-Ameur

Hi Amjad, Jan,

Quoted 5 lines · Amjad Ouled-Ameur

This patchset fixes use of lx-timerlist with kgdb.

It has been tested on Amlogic libretech-cc s905X and works fine [0]

[0]: https://pastebin.com/RAhQYh6L

Was right about to submit similar fixes. The whole series is:

Jan, it would appear there were earlier attempts at fixing timerlist.py, however as of 6.3-rc3, none of those patches have been merged, can you take them? Thanks!

Signature · 1 line
Florian
#5 lore raw

Hi Florian,

Thank you for testing the series.

Regards,

Amjad

Quoted 14 lines · Florian Fainelli

Hi Amjad, Jan,

Quoted 5 lines · Amjad Ouled-Ameur

This patchset fixes use of lx-timerlist with kgdb.

It has been tested on Amlogic libretech-cc s905X and works fine [0]

[0]: https://pastebin.com/RAhQYh6L

Was right about to submit similar fixes. The whole series is:

Jan, it would appear there were earlier attempts at fixing timerlist.py, however as of 6.3-rc3, none of those patches have been merged, can you take them? Thanks!