diff options
| author | Irene Knapp <ireneista@irenes.space> | 2026-05-26 19:41:59 -0700 |
|---|---|---|
| committer | Irene Knapp <ireneista@irenes.space> | 2026-05-28 03:22:11 -0700 |
| commit | d9a82e9f3c87aa318fb05819249656b43fde15e3 (patch) | |
| tree | 136ac947f2cac5fb6ba2599ce4e0540f46cb5dcf /dynamic.e | |
| parent | 33fb92edc2a9958234b1bc2431a17fa4edbd83ea (diff) | |
add the ability to bind signal handlers
and a useful example one ;) this also involved fixing the failure cases in input.e to handle EINTR correctly. it required a lot of tracing, but now the expected state of the stack is much better commented for next time. many thanks to @cks@mastodon.social who found code in the Go compiler which had the details of what's required in regard to the restorer, which made the whole thing work, and to @snowfox@tech.lgbt who did some experimental testing around the exact requirements. both those contributions are reflected in the documentation added with this CL. additional thanks to everyone who chimed in on the fedi thread, your comments kept us going! Force-Push: yes Change-Id: I97fd89426bf807df5565e011d3665f7e904fa138
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 |