shithub: sl

Download patch

ref: c9b8a86744a09675fa6c3582d2904fac287c1611
parent: 4dc2b808297a191122ab24b83683a0ce07f316cc
author: spew <spew@cbza.org>
date: Tue Mar 18 11:09:28 EDT 2025

lsd: allow multiples steps

--- a/src/plan9/lsd.lsp
+++ b/src/plan9/lsd.lsp
@@ -179,27 +179,29 @@
 
 (def (curPC) (if (>= pid 0) (readreg PC)))
 
-(def (step)
-  "Step one assembly instruction. Returns the next instruction
-   address to be executed or void if the program has exited."
-  (let* ((addr (readreg PC))
-         (on-bp (has? bptbl addr)))
-    (if on-bp (writecore addr (get bptbl addr)))
-    (let* ((f (follow addr))
-           (o (map (λ (a) (readcore a 'byte (length bpinst))) f)))
-      (for-each (λ (a) (writecore a bpinst)) f)
-      (startstop)
-      (map writecore f o)
-      (if on-bp (writecore addr bpinst))
-      (or (curPC) (void)))))
+(def (step (n 1))
+  "Step n assembly instructions. Returns the next instruction
+   address to be executed or NIL if the program has exited."
+  (if (= n 0)
+      (curPC)
+      (let* ((addr (readreg PC))
+             (on-bp (has? bptbl addr)))
+        (if on-bp (writecore addr (get bptbl addr)))
+        (let* ((f (follow addr))
+               (o (map (λ (a) (readcore a 'byte (length bpinst))) f)))
+          (for-each (λ (a) (writecore a bpinst)) f)
+          (startstop)
+          (map writecore f o)
+          (if on-bp (writecore addr bpinst))
+          (step (1- n))))))
 
 (def (cont)
   "Continue program execution. Returns the next instruction
-   address to be executed or void if the program has exited."
+   address to be executed or NIL if the program has exited."
   (let ((addr (readreg PC)))
     (if (has? bptbl addr) (step))
     (startstop)
-    (or (curPC) (void))))
+    (curPC)))
 
 (def (asm (n 5) (addr (readreg PC)))
   "Print the next n disassembled instructions at addr.
@@ -233,7 +235,7 @@
 
 (def (Bsrc (addr (readreg PC)))
   "Sends a plumb message of the filename and line number so
-   the source code corresponnding to the instruction address
+   the source code corresponding to the instruction address
    can be viewed in your text editor.
 
    See the examples for (src), this works the same."