[Skiboot] [PATCH 1/3] mambo_utils: make p return a value

Oliver O'Halloran oohall at gmail.com
Fri Dec 2 16:38:58 AEDT 2016


Currently the "p" command uses puts to output the result to the user.
This works for interactive usage, but it makes it impossible for use
inside scripts. This patch changes the function to return the value
rather than print it. The mambo interpreter prints the result of an
expression so this should not cause any user visible changes.

With this change you can use p in expressions:

	x [p r3] 4

Which will display the word at the address in r3.

Signed-off-by: Oliver O'Halloran <oohall at gmail.com>
---
 external/mambo/mambo_utils.tcl | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/external/mambo/mambo_utils.tcl b/external/mambo/mambo_utils.tcl
index a97bdc42af64..e1243432cdaf 100644
--- a/external/mambo/mambo_utils.tcl
+++ b/external/mambo/mambo_utils.tcl
@@ -6,28 +6,25 @@ proc p { reg { t 0 } { c 0 } } {
     switch -regexp $reg {
 	^r$ {
             set val [mysim cpu $c thread $t display gprs]
-            puts "$val"
 	}
         ^r[0-9]+$ {
             regexp "r(\[0-9\]*)" $reg dummy num
             set val [mysim cpu $c thread $t display gpr $num]
-            puts "$val"
         }
         ^f[0-9]+$ {
             regexp "f(\[0-9\]*)" $reg dummy num
             set val [mysim cpu $c thread $t display fpr $num]
-            puts "$val"
         }
         ^v[0-9]+$ {
             regexp "v(\[0-9\]*)" $reg dummy num
             set val [mysim cpu $c thread $t display vmxr $num]
-            puts "$val"
         }
         default {
             set val [mysim cpu $c thread $t display spr $reg]
-            puts "$val"
         }
     }
+
+    return "$val"
 }
 
 #
-- 
2.5.5



More information about the Skiboot mailing list