diff options
Diffstat (limited to 'dynamic.e')
| -rw-r--r-- | dynamic.e | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/dynamic.e b/dynamic.e index 0251e20..39ddd3f 100644 --- a/dynamic.e +++ b/dynamic.e @@ -204,6 +204,56 @@ newline ; +: symbolize-pointer + dup is-in-log { + dup containing-entry dup { + ~ Any format we're going to use here starts with the entry's name; by + ~ printing it now we don't have to keep track of it later. + dup entry-to-name emitstring + + dup entry-to-execution-token + ~ (scrutinee, entry pointer, codeword pointer) + dup 3 pick >= { + ~ The pointer is somewhere in the word's body, so we compute the + ~ offset from the codeword. + swap drop - + ~ (offset) + dup { + ." +" . + } { + ~ The pointer goes to the codeword. We don't print anything here, + ~ so the output is just the word's name. This will look "right" in + ~ a code listing styled like the ones produced by "describe". + drop + } if-else + } { + ~ The pointer is in the header, so we compute the offset from the + ~ entry address. + drop - + ~ (offset) + + ~ We always print the offset, even if it's zero; this visually + ~ emphasizes the difference between entry addresses and content + ~ addresses... or that's the hope. + ." :" . + } if-else + + ~ All of the above paths printed SOMETHING, so we're done. + exit + } { drop } if-else + } if + + ~ If we fall through, just print it as a number. + ." 0x" .hex64 ; + + +: list-callers + control@ { dup r0 @ > } + { dup @ symbolize-pointer newline 8 + } while + drop ; + + + : bye 0 sys-exit ; @@ -238,6 +288,8 @@ ~ do that. It compiles into a call to the word that's currently being ~ defined (strictly speaking, the one whose definition was most recently ~ begun). +~ +~ TODO it seems like maybe the log-load transform breaks this? hm : recurse latest @ entry-to-execution-token , ; make-immediate |