| @@ -29,12 +29,12 @@ · 28 unmodified lines |
| 29 | 29 | :doc-see symbol |
| 30 | 30 | text data) |
| 31 | 31 | (defstruct frame |
| 32 | | − "A stack frame. Loc is the enclosing function symbol and instruction |
| 32 | + "A stack frame. Sym is the enclosing function symbol and instruction |
| 33 | 33 | address of the frame. Retpc is the return instruction address. Sp is |
| 34 | 34 | the stack pointer value. Locals are all the local symbols." |
| 35 | 35 | :doc-group lsd |
| 36 | 36 | :doc-see symbol |
| 37 | | − loc retpc sp locals) |
| 37 | + sym retpc sp locals) |
| 38 | 38 | |
| 39 | 39 | (def coref NIL) |
| 40 | 40 | (def textf NIL) |
| @@ -222,33 +222,41 @@ · 181 unmodified lines |
| 222 | 222 | :doc-see frame |
| 223 | 223 | (reverse! (ctrace))) |
| 224 | 224 | |
| 225 | | −(def (stk) |
| 226 | | − "Print the stack trace without showing local auto values. |
| 225 | +(def (stk (:locals NIL)) |
| 226 | + "Print the stack trace optionally showing local auto values. |
| 227 | 227 | |
| 228 | 228 | Bugs: |
| 229 | 229 | |
| 230 | | − Prints the values of parameters as unsigned 64 bit |
| 231 | | − integers, not as their actual types." |
| 230 | + Prints the values of parameters and autos as unsigned |
| 231 | + 64 bit integers, not as their actual types." |
| 232 | 232 | :doc-group lsd |
| 233 | 233 | :doc-see _stk |
| 234 | + :doc-see lstk |
| 234 | 235 | (def (go pc fs) |
| 235 | 236 | (if (not fs) pc |
| 236 | 237 | (let* {[f (car fs)] |
| 237 | | − [floc (frame-loc f)]} |
| 238 | + [fsym (frame-sym f)]} |
| 238 | 239 | (receive (params autos) |
| 239 | 240 | (partition (λ (x) (equal? #\p (symbol-type x))) |
| 240 | 241 | (frame-locals f)) |
| 241 | 242 | (set! params (sort params #.< :key symbol-addr)) |
| 242 | 243 | (set! autos (sort autos #.> :key symbol-addr)) |
| 243 | | − (princ (symbol-name floc) "(") |
| 244 | + (princ (symbol-name fsym) "(") |
| 244 | 245 | (princ |
| 245 | 246 | (str-join |
| 246 | 247 | (map (λ (p) |
| 247 | 248 | (str (symbol-name p) "=" (hex (symbol-read p 'u64)))) |
| 248 | 249 | params) |
| 249 | 250 | ", ")) |
| 250 | | − (princ ")+" (hex (- pc (symbol-addr floc))) " ") |
| 251 | + (princ ")+" (hex (- pc (symbol-addr fsym))) " ") |
| 251 | 252 | (princ (src pc) "\n") |
| 253 | + (when locals |
| 254 | + (for-each (λ (l) (princ " " |
| 255 | + (symbol-name l) |
| 256 | + "=" |
| 257 | + (hex (symbol-read l 'u64)) |
| 258 | + "\n")) |
| 259 | + autos)) |
| 252 | 260 | (go (frame-retpc f) (cdr fs)))))) |
| 253 | 261 | (let* {[tos (go (curPC) (_stk))] |
| 254 | 262 | [topsym (lsd-findsym tos)]} |
| @@ -259,6 +267,13 @@ · 4 unmodified lines |
| 259 | 267 | (src tos) |
| 260 | 268 | "\n"))) |
| 261 | 269 | |
| 270 | +(def (lstk) |
| 271 | + "Print the stack trace showing local auto values." |
| 272 | + :doc-group lsd |
| 273 | + :doc-see _stk |
| 274 | + :doc-see stk |
| 275 | + (stk :locals T)) |
| 276 | + |
| 262 | 277 | (def (curPC) (and (>= pid 0) (readreg PC))) |
| 263 | 278 | |
| 264 | 279 | (def (step (n 1)) |
| @@ -371,7 +386,8 @@ · 106 unmodified lines |
| 371 | 386 | (path-cwd) |
| 372 | 387 | "\ntext\n\n" |
| 373 | 388 | (length s) |
| 374 | | − "\n" s)) |
| 389 | + "\n" |
| 390 | + s)) |
| 375 | 391 | (io-close plumbf))) |
| 376 | 392 | |
| 377 | 393 | (def (B stepper) |