[Skiboot] [PATCH] external/mambo: add a poor man's ftrace command

Nicholas Piggin npiggin at gmail.com
Thu Sep 8 01:42:18 AEST 2022


Add an ftrace command that steps instructions and prints the symbol
whenever it changes. This can be helpful for low level debugging.

Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
---
 external/mambo/mambo_utils.tcl | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/external/mambo/mambo_utils.tcl b/external/mambo/mambo_utils.tcl
index 96f8971a..6d1425a0 100644
--- a/external/mambo/mambo_utils.tcl
+++ b/external/mambo/mambo_utils.tcl
@@ -169,6 +169,32 @@ proc s { {nr 1} } {
     }
 }
 
+proc ftrace { {nr 1} } {
+    upvar #0 target_t t
+    upvar #0 target_c c
+    upvar #0 target_p p
+
+    set pc [mysim cpu $p:$c:$t display spr pc]
+    set sym [lindex [split [addr2func $pc] {+}] 0]
+    set prev_pc $pc
+
+    puts [ipc]
+    puts "$sym"
+
+    for { set i 0 } { $i < $nr } { incr i 1 } {
+        set pc [mysim cpu $p:$c:$t display spr pc]
+        set sym2 [lindex [split [addr2func $pc] {+}] 0]
+
+        if { $sym2 != $sym } {
+            puts "$sym2 \t\t(from [addr2func $prev_pc])"
+            set sym $sym2
+        }
+        set prev_pc $pc
+
+        mysim step 1
+    }
+}
+
 proc S { {nr 1} } {
     upvar #0 target_t t
     upvar #0 target_c c
-- 
2.37.2



More information about the Skiboot mailing list