ref: 409a8dab1d8ef6cbd70b7c6b80c0ab8b7e9d2826
parent: c1a95ad2f6d2211d3d562a17b44450836ba44d51
author: spew <spew@cbza.org>
date: Thu Apr 10 10:39:22 EDT 2025
lsd: some cleanups around accessors
--- a/src/plan9/lsd.sl
+++ b/src/plan9/lsd.sl
@@ -149,31 +149,32 @@
`(def (,name loc (n NIL))
,(str "Read the value at the location as a " size " value.\n\n"
" Optionally read an array of n values\n\n"
- " The input to this function is as in @")
+ " The input to this function is as in @.")
:doc-see @
:doc-group lsd
- (if n (core-read (@ loc) ,size n)
- (core-read (@ loc) ,size))))
+ (if n (core-read (@ loc) ',size n)
+ (core-read (@ loc) ',size))))
-(defcval c-byte 'utf8)
-(defcval c-short 's16)
-(defcval c-ushort 'u16)
-(defcval c-int 's32)
-(defcval c-uint 'u32)
-(defcval c-long 's32)
-(defcval c-ulong 'u32)
-(defcval c-vlong 's64)
-(defcval c-uvlong 'u64)
-(defcval c-ptr 'ptr)
+(defcval c-byte u8)
+(defcval c-char utf8)
+(defcval c-uchar u8)
+(defcval c-short s16)
+(defcval c-ushort u16)
+(defcval c-int s32)
+(defcval c-uint u32)
+(defcval c-long s32)
+(defcval c-ulong u32)
+(defcval c-vlong s64)
+(defcval c-uvlong u64)
+(defcval c-ptr ptr)
+(defcval c-float float)
+(defcval c-double double)
(def (c-str loc)
"Read the null-terminated string at the pointer location"
- (def (go a)
- (let {[v (core-read a 'utf8)]}
- (if (= v (utf8 0))
- ()
- (cons v (go (1+ a))))))
- (apply arr (cons 'utf8 (go (c-ptr (@ loc))))))
+ (unless coref (error "not attached to proc"))
+ (io-seek coref (c-ptr (@ loc)))
+ (str-trim (io-readuntil coref 0) "" "\x00"))
(def (@ loc)
«Return the address of local or global data.
@@ -191,13 +192,12 @@
(eq? type #\p)
(eq? type #\d)
(eq? type #\D)
- (error "expected a data symbol" s))
- (symbol-addr s)))
+ (error "expected a data symbol" s)))
+ (symbol-addr s))
(def (str-addr s)
- (let {[symb (or (local-symbol s)
- (global-symbol s :data T)
- (error "could not find symbol " s))]}
- (symb-addr symb)))
+ (symb-addr (or (local-symbol s)
+ (global-symbol s :data T)
+ (error "could not find symbol " s))))
(cond ((str? loc) (str-addr loc))
((num? loc) (ptr loc))
((symbol? loc) (symb-addr loc))
@@ -239,8 +239,8 @@
(def (bpset at)
"Set a breakpoint at the location.
- Location is as in instr"
- :doc-see instr
+ Location is as in pc"
+ :doc-see pc
:doc-see bpdel
:doc-group lsd
(waitstop)
@@ -253,8 +253,8 @@
(def (bpdel at)
"Delete a breakpoint at the location.
- Location is as in instr"
- :doc-see instr
+ Location is as in pc"
+ :doc-see pc
:doc-see bpdel
:doc-group lsd
(waitstop)
@@ -367,7 +367,7 @@
(when on-bp (core-write addr bpinst))
(step (1- n))))))
-(def (cont)
+(def (cont (:print T))
"Continue program execution.
Return the next instruction address to be executed or `void` if the