Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug: add interactive debug mode #203

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

debug: add interactive debug mode #203

wants to merge 9 commits into from

Conversation

jow-
Copy link
Owner

@jow- jow- commented May 24, 2024

Introduce a new interactive debug cli which can be started by invoking the ucode interpreter with the -x flag.

The main debugger functionality resides in the debug library while the cli frontend just gains some minimal amount of code to load and instantiate the debug library when the -x option is passed.

As a precondition for the new debug functionality, the ucode VM has been extended with low level breakpoint support.

jow- added 9 commits June 19, 2024 16:19
When an inner function invoked exit() in a ucode > native > ucode call stack
situation, the VM did end up with an empty callframe stack after the native
function returned, leading to subsequent invalid memory accesses.

Properly deal with situation similar to how we also check for an empty call
stack after processing I_RETURN and additionally translate the current
exception type to a status return value.

Signed-off-by: Jo-Philipp Wich <[email protected]>
Add missing definition for the SIGWINCH signal number in order to allow
ucode programs to subscribe to terminal size change signals.

Signed-off-by: Jo-Philipp Wich <[email protected]>
Use a two byte structure to encode { byte offset, insns count } offset
info tuples and introduce additional flags plus related api functions to
encode statement start- and end boundaries in offsetinfo.

The new encoding format more than halves the required memory footprint
in many cases, especially for whitespace- and comment heavy sources.

Signed-off-by: Jo-Philipp Wich <[email protected]>
Utilize the new chunk offset info facilities to encode the start and end
offsets of logical statements in the offset information vector of the
debug data area.

This information can be used later by debuggers to step through logical
statements instead of single instructions.

Signed-off-by: Jo-Philipp Wich <[email protected]>
Introduce low level facilities for registering breakpoints in the running
VM context. The breakpoint primitives allow invoking provided callback
functions when the VM reaches an associated instruction address.

This functionality provides the foundation for building more thorough
interactive debug functionality on top.

Signed-off-by: Jo-Philipp Wich <[email protected]>
Publicly export the instruction format table in order to make it useable
for libucode.so users, such as dynamically loaded debug libraries.

Signed-off-by: Jo-Philipp Wich <[email protected]>
When additional ucode scripts are loaded through require() or similar means,
and the required code invokes exit(), the VM will clear the stack before
returning, so we must ensure that the stack size matches our expectation
before we're trying to pop values from it after returning from require.

Signed-off-by: Jo-Philipp Wich <[email protected]>
Implement an interactive command line debugger within the debug module
which can be started by invoking the `debugger()` function.

The debugger offers common features such as the ability to set breakpoints,
stepping through commands, examining call stacks and variables as well as
byte code disassembly source code highlighting.

Signed-off-by: Jo-Philipp Wich <[email protected]>
Introduce a new command line switch `-x` which loads the debug module and
launches the given program or expression within the interactive debugger.

Signed-off-by: Jo-Philipp Wich <[email protected]>
@jow- jow- marked this pull request as ready for review June 20, 2024 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant