* doc/ref/scheme-using.texi (Debug Commands):
* module/system/repl/command.scm (procedure): Remove REPL command.
Since there is a closure binding and we have improved the ,registers
output, this is no longer necessary and by removing it we remove
another bogus use of frame-procedure.
* 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.
* 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.
* module/ice-9/boot-9.scm (current-language): New parameter.
* module/system/base/language.scm (*current-language*): Pull fluid from
parameter.
(current-language): Now a re-exported parameter.
* doc/ref/compiler.texi: Update reference from *current-language* fluid
to current-language parameter.
* module/system/base/compile.scm (compile-and-load):
* module/ice-9/top-repl.scm (top-repl): Default to the current language,
not to Scheme.
* module/ice-9/eval-string.scm:
* module/system/base/language.scm:
* module/system/repl/command.scm:
* module/system/repl/repl.scm: Update to use current-language parameter
and parameterize.
* libguile/objcodes.c: Change to expect objcode on disk to be embedded
in ELF instead of having the funky cookie.
(to_native_order): Use already existing SCM_BYTE_ORDER style byte
order instead of chars.
(bytecode_to_objcode): No need for word_size arg.
(scm_bytecode_to_objcode, scm_objcode_to_bytecode): Take optional
endianness arg instead of sometimes using target-endianness.
(scm_load_objcode, scm_write_objcode, scm_bytecode_to_native_objcode):
Remove.
* libguile/objcodes.h: Adapt.
* libguile/vm.c (scm_load_compiled_with_vm): Use
scm_load_thunk_from_file.
(make_boot_program): Adapt to use scm_bytecode_to_objcode with
endianness arg.
* module/Makefile.am (OBJCODE_LANG_SOURCES): Add (language objcode
elf).
* module/language/objcode/elf.scm: New module, embeds objcode in ELF.
* module/language/bytecode/spec.scm (compile-objcode):
(decompile-objcode): Use (target-endianness).
* module/language/objcode/spec.scm: use (language objcode elf) for
write-objcode.
* module/scripts/disassemble.scm (disassemble):
* module/system/repl/command.scm (disassemble-file): Use
load-thunk-from-file.
* module/system/vm/objcode.scm: Remove load-objcode and write-objcode.
* test-suite/tests/asm-to-bytecode.test (test-target): Adapt to the new
ELF world.
* module/system/repl/command.scm (language): Set the
*current-language*.
* module/system/repl/repl.scm (start-repl): Create a new dynamic scope
for *current-language*.
* module/system/repl/command.scm (time): Use the high-precision timers
instead of stime(2). Changes the output format of `,time' too;
perhaps there is a better way.
* module/language/objcode/spec.scm (decompile-value): Don't assume that
`error' will handle format strings appropriately.
* module/system/repl/command.scm (disassemble): A more human error when
you disassemble a non-procedure.
Bug reported by Andrew Horton.
* module/system/repl/command.scm:
* module/system/repl/debug.scm (terminal-width): Move terminal-width
here, make it thread-local, and export it.
(print-locals, print-frame, print-frames): Default width to
terminal-width.
* module/system/repl/error-handling.scm (call-with-error-handling): Add
`report' and `backtrace' on-error handlers.
* module/system/repl/common.scm (repl-default-options): Add on-error
REPL option, defaulting to `debug', but which may be changed.
* module/system/repl/repl.scm (run-repl): Pass the #:on-error REPL
option to call-with-error-handling.
* module/system/repl/command.scm (terminal-width): New parameter that
will use the true terminal width if unset.
(backtrace, locals): Default to (terminal-width).
(width): Simplify.
This meta-command allows one to set the default number of columns
that output from ,backtrace and ,locals shall occupy.
* doc/ref/scheme-using.texi (Debug Commands): document ,width
* module/system/repl/command.scm (*width*): new var
(backtrace, locals): use *width* in optarg
(width): new meta-command
* module/system/repl/command.scm (warranty, copying, version): Use
`define-meta-command' to define these procedures, so they are entered
into the *command-infos* table.
Besides allowing user-defined meta-commands, this change also refactors
the meta-command machinery to split reading a command's arguments from
the procedure actually implementing it, and hence allows nesting
meta-commands. As an example of such a command, ",in" is added as a new
meta-command.
* module/system/repl/command.scm: Export `define-meta-command'.
(*command-module*): Replaced by the hash table `*command-infos*'.
(command-info, make-command-info, command-info-procedure)
(command-info-arguments-reader): New procedures, encapsulating the
information about a meta-command.
(command-procedure): Adapted to use the `command-info' lookup
procedure.
(read-command-arguments): New auxiliary procedure invoking a command's
argument reader procedure.
(meta-command): Adapted to the split of reading arguments and
executing a command.
(add-meta-command!): New auxiliary procedure, registers a meta
command's procedure and argument reader into `*command-infos* and
`*command-table*.
(define-meta-command): Extended to allow specification of the command's
category; split the argument reader and actual command procedure.
(guile:apropos, guile:load, guile:compile-file, guile:gc): Remove these
aliases, they are unnecessary as we now use a hash table instead of the
module to store the commands.
(in): New meta-command, which evaluates an expression, or alternatively
executes another meta-command, in the context of a specific module.
* doc/ref/scheme-using.texi (Module Commands): Document the `in'
meta-command.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Fixes bug in repl meta-commands after activating readline, which changes
the current input port.
* module/system/repl/common.scm (<repl>): Remove inport and outport
fields.
(make-repl): Adapt.
(repl-read, repl-print): Just read and write to the current ports.
* module/system/repl/repl.scm (meta-reader): Meta-read from the current
input port.
* module/system/repl/command.scm (read-command, define-meta-command):
Read from the current input port.
* module/system/repl/debug.scm (print-frame): Add #:next-source? arg,
for when print-frame should use frame-next-source instead of
frame-source.
(print-frames): Add #:for-trap? arg. If true, the 0th frame should be
printed with frame-next-source.
* module/system/repl/command.scm (define-stack-command): Introduce
for-trap? into the lexical env.
(backtrace, up, down, frame): Update to do the right thing regarding
#:for-trap?.
* module/language/tree-il/analyze.scm (format-analysis): Don't warn on
non-literal format string if the format string is a lexical ref to a
variable named "fmt". A slight hack, but effective :)
* module/system/repl/command.scm (display-stat): Rename the format
string to "fmt".
* module/system/repl/debug.scm (<debug>): New field, `for-trap?'. True
if the stack is for a trap, and thus the top frame should use
frame-next-source instead of frame-source.
* module/system/repl/command.scm (repl-pop-continuation-resumer)
(repl-next-resumer):
* module/system/repl/error-handling.scm (call-with-error-handling):
Update callers.
* module/system/vm/trace.scm (print-application, print-return): Change
to add more whitespace, as (ice-9 debug) did.
(call-with-trace): Rename from vm-trace, and make the vm a keyword
argument.
* module/system/repl/command.scm: Don't autoload (system vm profile).
(trace): Update for call-with-trace name change.
* 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.
* libguile/frames.h:
* libguile/frames.c (scm_frame_stack_pointer): New function.
* module/system/repl/debug.scm (print-registers): New function, prints
out registers.
* module/system/repl/command.scm (registers): New debugging
meta-command.
(inspect): Not a stack-command, a normal meta-command.
* 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-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/repl/command.scm (profile, trace, inspect)
(pretty-print): Use repl-prepare-eval-thunk instead of the lower-level
compile and make-program.