summaryrefslogtreecommitdiff
path: root/module/system/repl/error-handling.scm
AgeCommit message (Collapse)AuthorFilesLines
2023-02-24Remove unnecessary module imports.Ludovic Courtès1-1/+0
These were found with: make GUILE_WARNINGS='-W1 -Wunused-module' * module/ice-9/copy-tree.scm: * module/ice-9/eval-string.scm: * module/ice-9/getopt-long.scm: * module/ice-9/poll.scm: * module/ice-9/popen.scm: * module/ice-9/sandbox.scm: * module/ice-9/threads.scm: * module/sxml/apply-templates.scm: * module/sxml/simple.scm: * module/system/base/types.scm: * module/system/repl/command.scm: * module/system/repl/common.scm: * module/system/repl/coop-server.scm: * module/system/repl/debug.scm: * module/system/repl/error-handling.scm: * module/system/repl/repl.scm: * module/system/repl/server.scm: * module/system/vm/assembler.scm: * module/system/vm/disassembler.scm: * module/system/vm/dwarf.scm: * module/system/vm/elf.scm: * module/system/vm/frame.scm: * module/system/vm/inspect.scm: * module/system/vm/linker.scm: * module/system/vm/program.scm: * module/system/vm/trace.scm: * module/system/vm/trap-state.scm: * module/system/vm/traps.scm: * module/system/xref.scm: * module/texinfo/indexing.scm: * module/texinfo/plain-text.scm: * module/texinfo/reflection.scm: * module/texinfo/string-utils.scm: * module/web/client.scm: * module/web/http.scm: * module/web/request.scm: * module/web/response.scm: Remove imports of unused modules.
2017-02-07Avoid stacks in dynamically-bound valuesAndy Wingo1-3/+3
* libguile/dynstack.h: * libguile/dynstack.c (scm_dynstack_find_old_fluid_value): New function. * libguile/fluids.c (saved_dynamic_state_ref): New helper. (scm_fluid_ref): Fix docstring. (scm_fluid_ref_star): New function allowing access to previous values for a fluid. (scm_dynamic_state_ref): New internal function. * libguile/fluids.h: Add scm_fluid_ref_star and scm_dynamic_state_ref. * libguile/stacks.c (scm_stack_id): Adapt to %stacks not being a chain. * libguile/throw.c (catch, throw_without_pre_unwind): Adapt to %exception-handlers not being a chain. * module/ice-9/boot-9.scm (catch, dispatch-exception): Instead of having %exception-handlers be a chain, use fluid-ref* to access the chain that is in place at the time the exception is thrown. Prevents unintended undelimited capture of the current exception handler stack by a delimited "catch". (%start-stack): Similarly, don't be a chain. * module/system/repl/debug.scm (frame->stack-vector): * module/system/repl/error-handling.scm (call-with-error-handling): * module/ice-9/save-stack.scm (save-stack): Adapt to %stacks not being a chain. * test-suite/tests/exceptions.test ("delimited exception handlers"): Add tests. * doc/ref/api-control.texi (Fluids and Dynamic States): Add docs.
2014-03-22Out-of-memory situations raise exceptions instead of abortingAndy Wingo1-1/+1
* libguile/gc.c (scm_oom_fn, scm_init_gc): Install an out-of-memory handler that raises an unwind-only out-of-memory exception. (scm_gc_warn_proc, scm_init_gc): Install a warning proc that tries to print to the current warning port, if the current warning port is a file port. (scm_gc_after_nonlocal_exit): New interface. Should be called after a nonlocal return to potentially collect memory; otherwise allocations could try to expand again when they should collect. * libguile/continuations.c (scm_i_make_continuation): * libguile/eval.c (eval): * libguile/throw.c (catch): * libguile/vm.c (scm_call_n): Call scm_gc_after_nonlocal_exit after nonlocal returns. * libguile/throw.c (abort_to_prompt, throw_without_pre_unwind): Rework to avoid allocating memory. (scm_report_out_of_memory): New interface. (scm_init_throw): Pre-allocate the arguments for stack-overflow and out-of-memory errors. * module/ice-9/boot-9.scm: Add an out-of-memory exception printer. * module/system/repl/error-handling.scm (call-with-error-handling): Add out-of-memory to the report-keys set. * libguile/gc-malloc.c (scm_realloc): Call scm_report_out_of_memory if realloc fails. * libguile/error.h: * libguile/error.c: * libguile/deprecated.h: * libguile/deprecated.c (scm_memory_error): Deprecate. * test-suite/standalone/Makefile.am: * test-suite/standalone/test-out-of-memory: New test case.
2014-03-16Document stack-overflow handlers, limits, and unwind-only exceptionsAndy Wingo1-26/+22
* module/system/repl/error-handling.scm (call-with-error-handling): Add #:report-keys kwarg, so that unwind-only exceptions (stack-overflow in particular) get reported. * doc/ref/api-debug.texi (Pre-Unwind Debugging): Add documentation for #:report-keys kwarg of call-with-error-handling. (Stack Overflow): New subsubsection. (Debug Options): Remove discussion of stack overflow.
2013-11-07Program sources are always pre-retire nowAndy Wingo1-3/+3
* 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.
2012-01-26Fix a couple of warnings.Ludovic Courtès1-1/+2
* module/scripts/list.scm: Use SRFI-1. * module/system/repl/error-handling.scm: Use (ice-9 format).
2011-09-02more define-syntax-rule usageAndy Wingo1-4/+2
* module/ice-9/boot-9.scm: * module/ice-9/control.scm: * module/ice-9/futures.scm: * module/ice-9/optargs.scm: * module/ice-9/poll.scm: * module/ice-9/receive.scm: * module/ice-9/threads.scm: * module/ice-9/vlist.scm: * module/language/assembly/compile-bytecode.scm: * module/language/ecmascript/compile-tree-il.scm: * module/language/tree-il.scm: * module/oop/goops.scm: * module/oop/goops/simple.scm: * module/oop/goops/stklos.scm: * module/srfi/srfi-1.scm: * module/srfi/srfi-35.scm: * module/srfi/srfi-39.scm: * module/srfi/srfi-45.scm: * module/srfi/srfi-67/compare.scm: * module/sxml/match.scm: * module/system/repl/error-handling.scm: * module/system/repl/repl.scm: * module/system/vm/inspect.scm: * module/texinfo.scm: * module/web/server.scm: Use define-syntax-rule, where it makes sense.
2011-03-22Do not enter the debugger if the thrown key is in `pass-keys'Mark H Weaver1-21/+22
* module/system/repl/error-handling.scm (call-with-error-handling): Do _not_ enter the debugger if the thrown key is in `pass-keys'. Previously, for example, (throw 'quit) entered the debugger when run from the REPL, despite the fact that 'quit is in `pass-keys'.
2011-03-17allow ,option on-error report instead of debugAndy Wingo1-0/+28
* 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.
2011-02-11(system repl error-handling) uses print-exceptionAndy Wingo1-47/+11
* module/system/repl/error-handling.scm (error-string): Just use print-exception instead of rolling our own printer. (call-with-error-handling): Simplify.
2011-02-08hackily fix another case where display-exception would be aproposAndy Wingo1-1/+27
* module/system/repl/error-handling.scm (display-syntax-error) (error-string): Until we get the exception-printing patch merged in, copy display-syntax-error into error-handling so that we avoid display-error. Fixes bug 32365.
2010-11-12call-with-error-handling pass-keys w/ procedural handlers fixAndy Wingo1-2/+4
* module/system/repl/error-handling.scm (call-with-error-handling): Respect the pass-keys set for procedural on-error and post-error handlers.
2010-10-12debug has for-trap? fieldAndy Wingo1-2/+2
* 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-08further repl tweaksAndy Wingo1-9/+9
* 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-08Fixlets for REPL error handling.Ludovic Courtès1-1/+2
* 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-05debug-trap-handler ephemeral trap enhancementAndy Wingo1-4/+8
* 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-09-23avoid traps in repl except when evaluating the expressionAndy Wingo1-14/+24
* 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-19implement breakpoints in the replAndy Wingo1-1/+28
* 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-08-31Add new debug meta-command ,error-messageJose A. Ortega Ruiz1-10/+16
* 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-07-15don't re-print the error by default in call-with-error-handlingAndy Wingo1-1/+5
* 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-15error-handling tweakAndy Wingo1-1/+0
* module/system/repl/error-handling.scm (call-with-error-handling): Remove extra newline.
2010-07-15pass a frame to display-error in system repl error-handlingAndy Wingo1-22/+20
* module/system/repl/error-handling.scm (call-with-error-handling): Pass a frame to display-error.
2010-07-10finally, backtraces only showing frames for the computationAndy Wingo1-9/+13
* 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-09integrate the debugger into the replAndy Wingo1-0/+114
* 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.