1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 20:00:19 +02:00
Commit graph

263 commits

Author SHA1 Message Date
Andreas Rottmann
8fdd85f834 Allow user-defined meta-commands
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>
2010-11-20 23:55:19 +01:00
Andy Wingo
c372cd74fd repl read/write using current ports, not captured ports
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.
2010-11-18 14:32:53 +01:00
Andy Wingo
29de6ae2e8 repl.scm displays syntax errors on read as well
* module/system/repl/repl.scm (prompting-meta-read): Use
  display-syntax-error as appropriate.
2010-11-18 12:21:36 +01:00
Andy Wingo
2090f909b4 add proper pretty-printing for syntax errors
* module/system/repl/repl.scm (display-syntax-error): New helper,
  displays a syntax error.
  (abort-on-error, run-repl): Use it.

* libguile/throw.c (handler_message): Re-code the same thing in C.
2010-11-16 02:57:27 +01:00
Andy Wingo
67d655849a call-with-error-handling pass-keys w/ procedural handlers fix
* module/system/repl/error-handling.scm (call-with-error-handling):
  Respect the pass-keys set for procedural on-error and post-error
  handlers.
2010-11-12 17:16:35 +01:00
Andy Wingo
5aa12c699c ,frame and related commands handle for-trap? appropriately
* 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?.
2010-10-12 13:24:46 +02:00
Andy Wingo
5414d33376 don't warn for (format #t fmt) -- format string actually named fmt
* 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".
2010-10-12 13:11:40 +02:00
Andy Wingo
a36c3a458e debug has for-trap? field
* 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.
2010-10-12 13:09:48 +02:00
Ludovic Courtès
08002eae4d Fix typo.
* module/system/repl/command.scm (repl-pop-continuation-resumer): Remove
  extraneous argument to `format'.
2010-10-10 19:10:11 +02:00
Andy Wingo
d30542c2b7 add (system repl server)
* module/system/repl/server.scm: New module, listens on a socket for
  connections, then serves repls to those sockets.

* module/Makefile.am: Add repl server.
2010-10-10 12:15:34 +02:00
Andy Wingo
a627100bf3 further repl tweaks
* module/system/repl/error-handling.scm (error-string): Refactor a
  little.
  (call-with-error-handling): Ensure a trailing newline when printing
  the error-msg.

* module/system/repl/repl.scm (run-repl): We don't know the name of the
  meta-command here.
2010-10-08 19:27:45 +02:00
Ludovic Courtès
7390e4bd11 Fixlets for REPL error handling.
* module/system/repl/error-handling.scm (error-string): Don't call
  `display-error' when STACK is empty.
  (call-with-error-handling): Display ERROR-MSG instead of using
  `format', since ERROR-MSG may contain `format' escapes.

* module/system/repl/repl.scm (run-repl): Add missing argument to
  `format'.
2010-10-08 15:25:56 +02:00
Andy Wingo
aee24bac50 fix a bug in `finish'
* module/system/repl/command.scm (repl-pop-continuation-resumer)
  (finish): Fix a bug printing return values.
2010-10-08 12:31:56 +02:00
Andy Wingo
1ecf39a6a7 add repl debugging command docs
* doc/ref/scheme-using.texi (Debug Commands): Add docs for new debugging
  commands (break, step, registers, etc).
2010-10-08 12:31:50 +02:00
Andy Wingo
e7544f39a4 rename vm-trace to call-with-trace
* 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.
2010-10-07 12:55:37 +02:00
Andy Wingo
90966af895 update (system repl debug) todo
* module/system/repl/debug.scm: Update todo.
2010-10-06 21:19:49 +02:00
Andy Wingo
439e032b0b add ,step ,stepi ,next and ,nexti
* 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.
2010-10-06 21:19:08 +02:00
Andy Wingo
e8e4e7310c cleanups to ,finish
* module/system/repl/command.scm (repl-pop-continuation-resumer): Factor
  out of finish.
  (finish): Adapt.

* module/system/vm/trap-state.scm (add-ephemeral-trap-at-frame-finish!):
  Rename to add "ephemeral" to the name.

* module/system/vm/traps.scm (trap-calls-to-procedure): Remove unused
  #:width kwarg.
2010-10-06 21:17:06 +02:00
Andy Wingo
c6025e76ff add ,finish repl meta-command
* module/system/repl/command.scm (finish): New REPL meta command. Uses
  fancy prompt stuff.
2010-10-05 21:53:58 +02:00
Andy Wingo
ee02e238a3 debug-trap-handler ephemeral trap enhancement
* module/system/repl/error-handling.scm (call-with-error-handling): If
  the given index is false, assume this was an ephemeral trap, and don't
  print a welcome message or reference the trap by index.
2010-10-05 21:50:57 +02:00
Andy Wingo
586aff5a27 (system repl debug): add frame->stack-vector
* module/system/repl/debug.scm (frame->stack-vector): New public
  function.
2010-10-05 21:49:13 +02:00
Andy Wingo
35c46aad66 system repl repl comments
* module/system/repl/repl.scm (meta-reader): Add a comment about peek,
  read, and the EOF object.
2010-10-05 19:58:13 +02:00
Andy Wingo
78e836efff Revert "repl.scm next-char needed to read EOF from port"
Actually peek-char => EOF does not guarantee that read-char => EOF. I
don't know what to do about this.

This reverts commit 6e1dccc42f.
2010-10-04 22:54:41 +02:00
Andy Wingo
6e1dccc42f repl.scm next-char needed to read EOF from port
* module/system/repl/repl.scm (next-char): Actually read off the EOF if
  we got one. Interesting, this.
2010-10-03 23:08:27 +02:00
Andy Wingo
e867d563a5 add source:line-for-user, returning a 1-indexed line number
* module/system/vm/program.scm (source:line-for-user): New exported
  procedure, returns a 1-indexed line, suitable for presentation to a
  user.
  (write-program): Use source:line-for-user when making fallback names.

* module/system/vm/coverage.scm (coverage-data->lcov):
* module/language/assembly/disassemble.scm (source->string):
* module/system/repl/debug.scm (print-frame): Use source:line-for-user.
2010-10-01 18:15:23 +02:00
Andy Wingo
542f975e60 add ,registers
* 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.
2010-09-30 21:29:20 +02:00
Andy Wingo
3e2c5f1ef3 fix ,traps REPL command
* module/system/repl/command.scm (traps): Fix this REPL meta-command.
2010-09-24 17:33:17 +02:00
Andy Wingo
fb5c4dc523 add ,break-at-source
* 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.
2010-09-23 17:49:55 +02:00
Andy Wingo
665196884f list-traps just returns trap identifiers, not names
* 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.
2010-09-23 17:26:12 +02:00
Andy Wingo
957205339a more uniform break / tracepoint printing in repl
* module/system/repl/command.scm (break, tracepoint): In the message,
  use the trap-name.
2010-09-23 17:20:57 +02:00
Andy Wingo
25361a80fe add repl ,tracepoint command
* 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.
2010-09-23 13:47:03 +02:00
Andy Wingo
b0e556d4d0 avoid traps in repl except when evaluating the expression
* 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.
2010-09-23 13:45:23 +02:00
Andy Wingo
d8e2ba23fc (system repl command) cleanups
* module/system/repl/command.scm (profile, trace, inspect)
  (pretty-print): Use repl-prepare-eval-thunk instead of the lower-level
  compile and make-program.
2010-09-21 21:48:09 +02:00
Andy Wingo
589520bc59 add ,traps ,delete ,disable ,enable
* module/system/repl/command.scm (traps, delete, disable, enable): New
  meta-commands.
2010-09-19 11:32:47 +02:00
Andy Wingo
b9badc35ab implement breakpoints in the repl
* 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.
2010-09-19 11:32:11 +02:00
Ludovic Courtès
ac37b82d5b Fix typos.
* module/system/repl/repl.scm (run-repl): Fix variable name: `k', not
  `key'.

* module/texinfo/docbook.scm: Use `(srfi srfi-1)' for `fold'.
2010-09-02 00:04:39 +02:00
Jose A. Ortega Ruiz
54d9a994b1 Add new debug meta-command ,error-message
* 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.
2010-08-31 13:47:56 +02:00
Andy Wingo
3d4f8e3c2d fix stack narrowing for tail-call to throw
* module/system/repl/debug.scm (narrow-stack->vector): Fix for the
  tail-call to `throw' case, as in `(quit)'.
2010-08-06 17:39:51 +02:00
Andy Wingo
5bc97ad5dd ,x unbound does not quit repl
* module/system/repl/repl.scm (run-repl): Catch errors executing
  metacommands. Feature on top of feature...
2010-08-06 17:28:10 +02:00
Andy Wingo
2e67eb6f2d remove (system vm debug)
* module/system/vm/debug.scm: Remove.
* module/Makefile.am: Update.

* module/system/repl/debug.scm: Add some TODOs and a commented-out
  function here.
2010-07-16 17:35:43 +02:00
Andy Wingo
019fdc97d9 updates to system repl command
* module/system/repl/command.scm (help): Update docs on how to get help
  on a particular command.
  (load): Remove #:f flag.
2010-07-16 17:35:43 +02:00
Andy Wingo
d286c8ce34 don't re-print the error by default in call-with-error-handling
* module/system/repl/error-handling.scm (call-with-error-handling):
  Previous post-error changed to "report"; now "catch", the default,
  doesn't re-print the error.
2010-07-15 12:47:58 +02:00
Andy Wingo
45f84beaf1 error-handling tweak
* module/system/repl/error-handling.scm (call-with-error-handling):
  Remove extra newline.
2010-07-15 12:46:02 +02:00
Andy Wingo
867961f979 pass a frame to display-error in system repl error-handling
* module/system/repl/error-handling.scm (call-with-error-handling): Pass
  a frame to display-error.
2010-07-15 12:13:15 +02:00
Andy Wingo
0803914395 print column numbers in backtraces
* module/system/repl/debug.scm (print-frame): Print column numbers too.
2010-07-10 12:32:24 +02:00
Andy Wingo
5273854080 finally, backtraces only showing frames for the computation
* module/system/repl/repl.scm (run-repl): Run the thunk in a stack in a
  prompt, similar to the default prompt. Gives proper backtraces.

* module/system/repl/error-handling.scm (call-with-error-handling):
  Narrow one more outer frame, for the %start-stack thunk invocation.

* module/ice-9/boot-9.scm (%start-stack): Reindent.
2010-07-10 12:21:50 +02:00
Andy Wingo
c27d140ab4 validating repl options; value-history on by default
* 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.
2010-07-10 11:19:19 +02:00
Andy Wingo
2b12193df2 heap/literal fixes for repl-default-options
* module/system/repl/common.scm (repl-default-options): Heap-allocate
  the repl-default-options, to avoid mutating a literal.
  (make-repl): Copy repl-default-options.
2010-07-10 10:49:01 +02:00
Andy Wingo
ffe911f714 avoid running the debugger during parsing or compilation at the repl
* module/system/repl/repl.scm (abort-on-error): New helper.
  (run-repl): Don't enter the debugger during parsing or compilation of
  a repl expression. If you want to debug compilation, run compilation
  from the repl, not as part of the repl.
2010-07-09 18:58:01 +02:00
Andy Wingo
0ddbd88321 fix up a repl command docstring
* module/system/repl/command.scm (procedure): Fix up docstring.
2010-07-09 18:39:15 +02:00