* doc/ref/api-debug.texi (VM Hooks): Update documentation.
* libguile/vm.c (vm_dispatch_hook):
* libguile/vm-engine.c: Rework the hook machinery so that they can
receive an arbitrary number of arguments. The return and abort
hooks will pass the values that they return to their continuations.
(vm_engine): Adapt to ABORT_CONTINUATION_HOOK change.
* libguile/vm-i-system.c (return, return/values): Adapt to
POP_CONTINUATION_HOOK change.
* module/system/vm/frame.scm (frame-return-values): Remove. The
pop-continuation-hook will pass the values directly.
* module/system/vm/trace.scm (print-return):
(trace-calls-to-procedure):
(trace-calls-in-procedure): Update to receive return values
directly.
* module/system/vm/traps.scm (trap-in-procedure)
(trap-in-dynamic-extent): Ignore return values.
(trap-frame-finish, trap-calls-in-dynamic-extent)
(trap-calls-to-procedure): Pass return values to the handlers.
* libguile/programs.h:
* libguile/programs.c (scm_program_source): Add an optional arg, the
sources table to traverse. Defaults to the result of
scm_program_sources.
* module/system/vm/program.scm (program-sources-pre-retire): Move
definition here from (system vm traps), and export.
* module/system/vm/traps.scm: Adapt.
* module/system/vm/frame.scm (frame-next-source): New exported binding,
returns the source line corresponding to the next instruction instead
of the previous instruction.
* module/system/vm/traps.scm (trap-matching-instructions): New trap,
just installs a next hook and runs the handler when a predicate
succeeds.
* module/system/vm/trap-state.scm (add-ephemeral-stepping-trap!): New
procedure, uses trap-matching-instructions with an appropriate
predicate to handle step, stepi, next, and nexti repl metacommands.
* module/system/repl/command.scm (step, step-instruction, next)
(next-instruction): New repl debugger commands.
* module/system/vm/traps.scm: Fix a comment.
* module/system/vm/trap-state.scm (<trap-state>): Add next-ephemeral-idx
slot.
(wrapper-at-index): Use eqv? instead of = to avoid type errors in user
inputs.
(next-ephemeral-index!, ephemeral-handler-for-index): New functions,
allocate ephemeral trap ids for functions to be called only once.
(add-trap-at-frame-finish!): New export, traps when a frame finishes.
* module/system/vm/traps.scm (trap-at-procedure-ip-in-range): Rework not
to call the handler when returning to a frame that was already
entered. So now breaking at foo.scm:1234 doesn't break when returning
to that line.
* module/system/vm/traps.scm (trap-in-procedure): If we are
(re-)entering the procedure from a return, call the enter-proc with
the returnee, not the returner.
(in-range?): Tighten up a bit.
(program-sources-before-retire): New helper, like program-sources but
indexed before instructions are retired instead of after.
(program-sources-by-line): Use program-sources-before-retire so that
we can break on instructions by source line *before* those
instructions are executed.
* module/system/vm/trap-state.scm (add-trap-at-source-location!):
* module/system/vm/traps.scm (trap-at-source-location): Rename "line"
argument to "user-line", indicating that the line is one-based instead
of zero-based. Decrement the line before handing off to
source-closures-or-procedures and source->ip-range.
* module/system/vm/traps.scm (frame-matcher): New helper.
(trap-at-procedure-call, trap-in-procedure, trap-in-dynamic-extent)
(trap-calls-in-dynamic-extent, trap-instructions-in-dynamic-extent)
(trap-instructions-in-procedure, trap-at-procedure-ip-in-range): Add
ability to trap on procedures that are closures.
(trap-at-source-location): Check source-closures first, to catch
source locations that are in nested procedures.
* module/system/vm/traps.scm (trap-frame-finish): Use frame-address
instead of frame-dynamic-link.
(trap-calls-to-procedure): New proc, traps on procedure calls and
their corresponding returns.
* module/system/vm/traps.scm (trap-frame-finish)
(trap-in-dynamic-extent, trap-calls-in-dynamic-extent)
(trap-instructions-in-dynamic-extent): New traps, for implementing
tracing, and the `finish' command.
* module/system/vm/trace.scm (trace-calls-in-procedure)
(trace-instructions-in-procedure): New tracing traps.
(vm-trace): Reimplement in terms of the new traps.
* module/system/vm/trap-state.scm (add-trap!): New helper; not used in
this commit, though.
* module/system/vm/traps.scm (new-disabled-trap): Don't manipulate the
VM trace level in the enable and disable handlers. Unfortunately, this
makes traps not work unless you enable hooks, but given that
vm_dispatch_hook has to set trace-level to 0, there needs to be an
object with a broader view of what traps are enabled. That object is
the hook state.
* module/system/vm/trap-state.scm (trap-state->trace-level): New
procedure.
(with-default-trap-handler): Add an optional trap-state argument. Now
makes sure that the vm-trace-level is set appropriately during the
execution of the thunk, allowing for breakpoints from recursive
prompts.
* module/system/vm/traps.scm: New module, implements higher-level traps
based on the VM hooks. Inspired by (ice-9 debugging traps). Instead of
the ice-9's variety, these traps have a procedural interface instead
of a GOOPS interface.
* module/Makefile.am: Add the new module.