* 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.
* 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.
* module/system/repl/error-handling.scm: use the error string to
construct the <debug> instance.
* module/system/repl/command.scm: new debug command `error-message'
that extracts the new <debug> field, available to stack commands as
`message'.
* doc/ref/scheme-using.texi: documentation for new command.
* module/system/repl/debug.scm: <debug> stores the error string in a
new field.
* module/system/repl/common.scm: Use (ice-9 history). Turns on value
history by default.
(repl-default-options): Expand the format of options to include an
optional value transformer, run when setting a value. Add prompt and
value-history options.
(repl-prepare-eval-thunk): Use repl-option-ref.
(repl-option-ref): Error if the option is unknown.
(repl-option-set!, repl-default-option-set!): Error if the option is
unknown. Pass the val through the transformer procedure.
(repl-default-prompt-set!): Just use repl-default-option-set!.
* module/system/repl/command.scm (option): Update for the new options
format.
* module/system/repl/command.scm (read-command): Remove a pk.
* module/system/repl/repl.scm (run-repl): Export. Use % and abort to
implement the prompt.
* module/system/repl/debug.scm: New file, defines a data type to hold
state for a debugger stack, and some helper procedures to print the
stack or print a frame. Most pieces are from (system vm debug).
* module/system/repl/error-handling.scm: New file, implements
call-with-error-handling and with-error-handling, and instead of going
into a debugger, we go into a recursive repl that happens to have
debugging information. Will be removing the old debugger from (system
vm debug) shortly.
* module/Makefile.am (SYSTEM_SOURCES): Add error-handling and debug scm
files.
* module/system/repl/repl.scm (prompting-meta-read): Better error
handling -- we don't want to go into a debugger when reading a
command.
(start-repl): Add #:debug keyword argument, and just dispatch to
run-repl.
(run-repl): New function, with the guts of the old start-repl. Added a
prompt, to which a throw to 'quit will abort.
* module/system/repl/common.scm (repl-prepare-eval-thunk): New
helper. In the future we will use this to not enter the debugger on
errors that happen at compile time.
(repl-eval): Use repl-prepare-eval-thunk.
(repl-print): Run the before-print-hook when printing a value.
* module/system/repl/command.scm (*command-table*): Move `option' to the
`system' group. Move `trace' to the `profile' group. Add `debug' and
`inspect' groups.
(command-abbrevs): Rename from command-abbrev, and allow multiple
abbreviations.
(display-group): Fix the case where abbrev? was #f.
(display-summary): Fix alignment of the command and
abbreviations. Allow multiple abbreviations.
(read-command): Rename from read-datum, and have better error
handling.
(meta-command): Better error handling.
(define-meta-command): Better error handling.
(help, show, import, compile, disassemble, time, profile, trace): Fix
docstrings and error messages.
(define-stack-command): New helper, for commands that operate on a
saved stack.
(backtrace, up, down, frame, procedure, locals): New debugger
commands, in the REPL now.
(inspect, pretty-print): New "inspect" commands.
* module/system/repl/common.scm (<repl>): Add inport and outport fields
and accessors.
(make-repl): Add optional "debug" argument. Bind inport and outport to
the current inport and output ports at the time of repl creation.
(repl-read): Read from the repl inport.
(repl-print): Write to the repl outport.
* module/system/repl/command.scm (read-datum, read-line, meta-command):
Respect repl-inport, and bind the outport of meta-commands to the repl
outport.
* module/system/repl/command.scm: Add support for ,show with topics
"warranty", "copying", and "version".
(language): Don't re-print the welcome; print sometime more terse.
* module/system/repl/common.scm (*version*, *warranty*, *copying*): New
public globals.
(repl-welcome): Display *version*.
* module/system/repl/common.scm (<repl>): Remove "vm" field and repl-vm
accessor. I think the correct model is to just use the-vm. This change
was prompted by the need to have the REPL itself not cause a recursive
VM invocation, so that captured prompts at the REPL are rewindable.
(make-repl): Remove treatment of #:vm.
(repl-eval): Load a compiled expression as a simple thunk, avoiding a
recursive VM call.
* module/system/repl/command.scm (profile, trace): Remove repl-vm
treatment.
(backtrace, debugger, step): Remove, as they were not implemented.
* module/statprof.scm: Use VM modules, instead of using @ hacks.
(statprof): New public export, a functional interface to the profiler.
(profile-signal-handler, count-call, statprof-start, statprof-stop):
Fix call counting with the VM.
(statprof-call-data->stats): Hack around a case in which a call could
be sampled but not counted, if you get my drift.
(procedure=?): Update for current API.
(with-statprof): Use `statprof'.
* module/system/repl/command.scm (profile): Use the `statprof'
procedural interface.
* module/system/vm/trace.scm (vm-trace): Change to just export the one
procedure, vm-trace. This way it's threadsafe and more robust. Also
refactor to not print any of Guile's internal bits. Hopefully Neil
will be happier :)
* module/system/repl/command.scm (option): Adapt to removal of
vm-trace-on! and vm-trace-off!, as those are unlikely to DTRT.
* libguile/tags.h (scm_tc7_frame, scm_tc7_objcode, scm_tc7_vm)
(scm_tc7_vm_cont): Take more tc7s for VM-related data structures.
* libguile/evalext.c (scm_self_evaluating_p):
* libguile/gc.c (scm_i_tag_name):
* libguile/goops.c (scm_class_of, create_standard_classes):
* libguile/print.c (iprin1): Add cases for the new tc7s.
* libguile/frames.c:
* libguile/frames.h:
* libguile/objcodes.c:
* libguile/objcodes.h:
* libguile/vm.c:
* libguile/vm.h: Desmobify.
* libguile/vm.c (scm_vm_apply): Export to Scheme, because VM objects are
no longer applicable.
* module/system/repl/command.scm (profile):
* module/system/vm/trace.scm (vm-trace):
* module/system/vm/vm.scm (vm-load): Call vm-apply to run a program in a
VM instead of treating the VM as applicable.
* libguile/vm.h (struct scm_vm): Remove "time" and "clock" members. The
time was bogusly measured, and the "clock" measured instructions
retired, which is not a very useful measurement, and it was causing
lots of memory accesses. Not that I have done a proper profile,
though...
(scm_vm_stats): Remove this procedure, which provided access to "time"
and "clock".
* libguile/vm.c:
* libguile/vm-engine.h:
* libguile/vm-engine.c:
* libguile/vm-i-system.c: Adapt to scm_vm changes and scm_vm_stats
removal.
* module/system/repl/command.scm:
* module/system/vm/vm.scm: Adapt to vm-stats removal by removing
vm-stats from <repl>.