* libguile/vm.h:
* libguile/vm.c:
(scm_vm_apply_hook, scm_vm_push_continuation_hook,
scm_vm_pop_continuation_hook, scm_vm_abort_continuation_hook,
scm_vm_restore_continuation_hook, scm_vm_next_hook,
scm_vm_trace_level, scm_set_vm_trace_level_x, scm_vm_engine,
scm_set_vm_engine_x, scm_c_set_vm_engine_x): The VM argument is now
implicit: the VM for the current thread.
* doc/ref/api-debug.texi (VM Hooks): Try to adapt.
* module/ice-9/command-line.scm:
* module/statprof.scm:
* module/system/vm/coverage.scm:
* module/system/vm/trace.scm:
* module/system/vm/trap-state.scm:
* module/system/vm/traps.scm:
* test-suite/tests/control.test:
* test-suite/tests/eval.test: Adapt users that set hooks or ensure that
we have a debug engine.
* module/system/repl/debug.scm (<debug>): Remove for-trap?. Backtraces
with RTL will always happen pre-retire on the top frame, source info
is pre-retire, and continuations will always have a source-marked
receive or receive-values or whatever with the right source marking,
so we can remove this complication.
(print-frame): Use frame-source.
(print-frames): Remove for-trap? kw.
* module/system/repl/command.scm (define-stack-command, backtrace)
(up, down, frame): Remove for-trap? introduced local, and its uses.
(repl-pop-continuation-resumer): Adapt to make-debug change.
* module/system/repl/error-handling.scm (call-with-error-handling):
Adapt to make-debug change.
* module/system/vm/frame.scm (frame-next-source): Remove. RTL sources
are pre-retire.
* module/system/vm/trap-state.scm (add-ephemeral-stepping-trap!): Adapt
to use frame-source. Still some work to do here.
* 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/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/trap-state.scm (add-trap-at-source-location!): New
proc.
* module/system/repl/command.scm (break-at-source): New repl
meta-command. Doesn't work as well as it could now because it doesn't
know about nested functions, but that's coming.
* module/system/vm/trap-state.scm (list-traps): Just return the integers
identifying the traps; people can use trap-name to get the names.
* module/system/repl/command.scm (traps): Adapt.
* module/system/vm/trace.scm (print-application, print-return): Add a
prefix before the printout.
(trace-calls-to-procedure, trace-calls-in-procedure): Add prefix
keyword args.
* module/system/vm/trap-state.scm (add-trace-at-procedure-call!): Give a
useful prefix for tracepoint printouts.
* module/system/vm/trace.scm (print-return, print-application)
(frame-return-values): Factored out of other things.
(trace-calls-to-procedure): New proc, installs a trap tracing only
calls to the given proc.
(trace-calls-in-procedure): Refactor a bit.
* module/system/vm/trap-state.scm (add-trace-at-procedure-call!): New
proc.
* module/system/repl/command.scm (tracepoint): New command, installs a
tracepoint on a procedure.
* module/system/vm/trap-state.scm (with-default-trap-handler): Don't
enable traps if we are setting a handler of #f.
* module/system/repl/error-handling.scm (call-with-error-handling): Add
#:trap-handler arg.
* module/system/repl/repl.scm (run-repl): Only have traps enabled while
running the thunk. Otherwise we trace on procedures called as part of
the repl.
* 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/trap-state.scm: New file, tracks a VM-specific set of
traps.
* module/Makefile.am: Add trap-state.scm.
* module/system/repl/error-handling.scm: While in a with-error-handling
block, bind a default trap handler that invokes a recursive prompt.
* module/system/repl/command.scm: Add a `break' repl meta-command.