ref: 4dc2b808297a191122ab24b83683a0ce07f316cc
parent: f8093f8e32ba6ef75cbdcefb40834a1a3b85a1da
author: spew <spew@cbza.org>
date: Tue Mar 18 16:34:22 EDT 2025
lsd: add src and Bsrc, fix documentation
--- a/src/plan9/lsd.lsp
+++ b/src/plan9/lsd.lsp
@@ -102,7 +102,7 @@
(writecore addr (get bptbl addr))
(del! bptbl addr)))))
-(doc-for bpset
+(doc-for (bpset loc)
"Set a breakpoint.
The location can either be a symbol, in which case
@@ -112,12 +112,9 @@
Examples:
(bpset 'strcpy) ; breakpoint on strcpy function.
- (bpset (readreg PC)) ; breakpoint on current instruction.
+ (bpset (readreg PC)) ; breakpoint on current instruction.")
- Signature:
- (bpset loc)")
-
-(doc-for bpdel
+(doc-for (bpdel loc)
"Delete a breakpoint.
The location can either be a symbol, in which case
@@ -127,11 +124,8 @@
Examples:
(bpdel 'strcpy) ; remove breakpoint on strcpy function.
- (bpdel (readreg PC)) ; remove breakpoint on current instruction.
+ (bpdel (readreg PC)) ; remove breakpoint on current instruction.")
- Signature:
- (bpdel loc)")
-
(def (detach)
(if regsf (io-close regsf))
(if fpregsf (io-close fpregsf))
@@ -207,17 +201,16 @@
(startstop)
(or (curPC) (void))))
-(def (asm addr (n 5))
+(def (asm (n 5) (addr (readreg PC)))
"Print the next n disassembled instructions at addr.
- By default n is 5 and it returns the following instruction
- address so it can be called again.
+ This returns the following instruction address so it can be called again.
Examples:
- (asm (readreg PC)) ; print out 5 from current program instruction.
- (asm (readreg PC) 10) ; print out 10 from current program instruction.
- (asm (step)) ; step and then print out 5.
- (asm (asm (readreg PC)) 3) ; print 3 more."
+ (asm) ; print out 5 from current program instruction.
+ (asm 10 (readreg PC)) ; print out 10 from current program instruction.
+ (asm 5 (step)) ; step and then print out 5.
+ (asm 3 (asm)) ; print 3 more."
(if (<= n 0)
addr
(let ((on-bp (has? bptbl addr)))
@@ -227,7 +220,33 @@
(instr (cadr a)))
(princ instr "\n")
(if on-bp (writecore addr bpinst))
- (asm (+ addr next) (1- n))))))
+ (asm (1- n) (+ addr next))))))
+
+(def (src (addr (readreg PC)))
+ "Returns a string of the filename and line number corresponding
+ to the instruction address.
+
+ Examples:
+ (src)
+ (src (asm 10)) ; read 10 instructions forward first."
+ (lsd-fileline addr))
+
+(def (Bsrc (addr (readreg PC)))
+ "Sends a plumb message of the filename and line number so
+ the source code corresponnding to the instruction address
+ can be viewed in your text editor.
+
+ See the examples for (src), this works the same."
+ (let ((s (src addr))
+ (plumbf (file "/mnt/plumb/send" :write)))
+ (io-write plumbf
+ (str "plumb\n\n"
+ (path-cwd)
+ "\ntext\n\n"
+ (length s)
+ "\n" s))
+ (io-close plumbf)))
+
(def (at-exit s)
(if proc-stdin (io-close proc-stdin))