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

225 commits

Author SHA1 Message Date
Andy Wingo
0c65f52c6d more define-syntax-rule usage
* 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-09-02 11:36:14 +02:00
Andy Wingo
423fca76e6 frame-source available in default environment
* libguile/frames.c (scm_frame_source): Don't call out to (system vm
  frames), as this routine is used when printing exceptions.  Make
  available in the default environment (ugh).

* module/system/vm/frame.scm: Remove frame-source definition and
  export.
2011-02-11 12:43:05 +01:00
Andy Wingo
9b78275eb0 stepping traps use frame-next-source, not frame-source
* module/system/vm/trap-state.scm (add-ephemeral-stepping-trap!): Use
  frame-next-source in stepping traps.
2010-10-08 12:31:56 +02:00
Andy Wingo
b262b74b51 add program-sources-pre-retire to core and define frame-next-source
* libguile/programs.h:
* libguile/programs.c (scm_program_source): Add an optional arg, the
  sources table to traverse. Defaults to the result of
  scm_program_sources.

* module/system/vm/program.scm (program-sources-pre-retire): Move
  definition here from (system vm traps), and export.

* module/system/vm/traps.scm: Adapt.

* module/system/vm/frame.scm (frame-next-source): New exported binding,
  returns the source line corresponding to the next instruction instead
  of the previous instruction.
2010-10-08 12:31:56 +02:00
Andy Wingo
d608db1d59 fix error in frame-return-values
* module/system/vm/frame.scm (frame-return-values): Fix off-by-one
  error.
2010-10-08 12:31:56 +02:00
Andy Wingo
4388818adb fix tracing of mv returns
* module/system/vm/trace.scm (print-return): Fix multiple-value-return
  printing.
2010-10-08 12:31:56 +02:00
Andy Wingo
de03880abe document trap states
* module/system/vm/trap-state.scm: Export add-trap!.

* doc/ref/api-debug.texi (Trap States): Document.
2010-10-07 22:50:33 +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
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
df067433a5 (system vm trap-state): add-trap-at-frame-finish!
* 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.
2010-10-05 21:53:29 +02:00
Andy Wingo
6a4a1ef0f4 (system vm frame): frame-return-values
* module/system/vm/frame.scm (frame-return-values): New exported
  function, gives the return values for a frame.
* module/system/vm/trace.scm: Remove frame-return-values from here.
2010-10-05 21:51:44 +02:00
Andy Wingo
2c04cf390b fix embarrassing error preventing ,del from working
* module/system/vm/trap-state.scm (remove-trap-wrapper!): Oops, fix
  newbie error regarding delq and mutation.
2010-10-05 21:48:27 +02:00
Andy Wingo
6e197f3d1a avoid some double-breaks in trap-at-procedure-ip-in-range
* module/system/vm/traps.scm (trap-at-procedure-ip-in-range): Rework not
  to call the handler when returning to a frame that was already
  entered. So now breaking at foo.scm:1234 doesn't break when returning
  to that line.
2010-10-03 23:09:32 +02:00
Andy Wingo
262ce91157 bugfixen in source breakpoints and in-procedure traps
* module/system/vm/traps.scm (trap-in-procedure): If we are
  (re-)entering the procedure from a return, call the enter-proc with
  the returnee, not the returner.
  (in-range?): Tighten up a bit.
  (program-sources-before-retire): New helper, like program-sources but
  indexed before instructions are retired instead of after.
  (program-sources-by-line): Use program-sources-before-retire so that
  we can break on instructions by source line *before* those
  instructions are executed.
2010-10-03 11:12:36 +02:00
Andy Wingo
2c5fc8d034 source breakpoints accept user line numbers
* 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.
2010-10-01 18:25:44 +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
ea9f4f4b15 add call-with-vm; remove thread-vm bits; remove vm-apply; engines settable.
* libguile/vm.h (scm_c_vm_run): Make internal.
* libguile/vm.c (vm_default_engine): New static global variable.
  (make_vm): Set vp->engine based on
  (scm_vm_apply): Remove in favor of call-with-vm.
  (scm_thread_vm, scm_set_thread_vm_x): Remove these, as they did not
  have a well-defined meaning, and were dangerous to call on other
  threads.
  (scm_the_vm): Reinstate previous definition.
  (symbol_to_vm_engine, vm_engine_to_symbol)
  (vm_has_pending_computation): New helpers.
  (scm_vm_engine, scm_set_vm_engine_x, scm_c_set_vm_engine_x): New
  accessors for VM engines.
  (scm_c_set_default_vm_engine_x, scm_set_default_vm_engine_x): New
  setters for the default VM engine.
  (scm_call_with_vm): New function, applies a procedure to arguments in
  a context in which a given VM is current.

* libguile/eval.c (eval, scm_apply): VM dispatch goes through
  scm_call_with_vm.

* test-suite/tests/control.test ("the-vm"):
* module/system/vm/coverage.scm (with-code-coverage): Use call-with-vm.

* module/system/vm/vm.scm: Update exports.

* test-suite/vm/run-vm-tests.scm (run-vm-program):
* test-suite/tests/compiler.test ("current-reader"): Just rely on the
  result of make-program being an applicable.

* test-suite/tests/eval.test ("stack overflow"): Add a note that this
  test does not test what it should.
2010-09-27 21:12:29 +02:00
Andy Wingo
038cb3428f remove vm-version, vm options
* libguile/vm.h (struct scm_vm): Remove "options" member.
* libguile/vm.c (scm_vm_version, scm_vm_option, scm_set_vm_option_x):
  Remove.

* module/system/vm/vm.scm (vm-version, vm-option, set-vm-option!):
  Remove.
  (vms:time, vms:clock): Remove these unused definitions.
  (vm-load): Remove. "Load" should be reserved for things that exist on
  disk, methinks.
2010-09-25 12:16:05 +02:00
Ludovic Courtès
6edf58538f Make `procedure-execution-count' fail gracefully when no source info is available.
* module/system/vm/coverage.scm (procedure-execution-count): Handle the
  case where (null? (program-sources PROC)).
2010-09-24 15:39:47 +02:00
Ludovic Courtès
639b2eb710 Fix coverage analysis of procedures called from C.
* module/system/vm/coverage.scm (with-code-coverage): Switch current
  thread to VM, using `set-thread-vm!'.

* test-suite/tests/coverage.test ("procedure-execution-count")["called
  from C"]: New test.
2010-09-24 15:39:47 +02:00
Ludovic Courtès
271c3d3196 Add thread-vm' and set-thread-vm!'.
* libguile/vm.c (thread_vm, scm_thread_vm, scm_set_thread_vm_x): New
  functions.
  (scm_the_vm): Add docstring.  Use `thread_vm'.

* libguile/vm.h (scm_thread_vm, scm_set_thread_vm_x): New declarations.

* module/system/vm/vm.scm: Export `thread-vm' and `set-thread-vm!'.
2010-09-24 15:39:47 +02:00
Andy Wingo
f4a23f910f procedure traps can fire on nested procedures
* module/system/vm/traps.scm (frame-matcher): New helper.
  (trap-at-procedure-call, trap-in-procedure, trap-in-dynamic-extent)
  (trap-calls-in-dynamic-extent, trap-instructions-in-dynamic-extent)
  (trap-instructions-in-procedure, trap-at-procedure-ip-in-range): Add
  ability to trap on procedures that are closures.

  (trap-at-source-location): Check source-closures first, to catch
  source locations that are in nested procedures.
2010-09-24 13:25:26 +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
3db15dce00 another trap printing tweak
* module/system/vm/trap-state.scm (add-trap-at-procedure-call!):
  (add-trace-at-procedure-call!): Breakpoint / tracepoint name tweaks.
2010-09-23 17:28:15 +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
1241f6944b trace printing tweak
* module/system/vm/trap-state.scm (add-trace-at-procedure-call!): Tweak
  to the #:prefix string.
2010-09-23 17:25:30 +02:00
Andy Wingo
6263b8722e add trap-name procedure
* module/system/vm/trap-state.scm (trap-name): New proc.
2010-09-23 17:20:05 +02:00
Andy Wingo
abb4b5cbbd tracepoints print their trap number
* 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.
2010-09-23 17:17:16 +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
8dde88e0d6 add trap-calls-to-procedure
* module/system/vm/traps.scm (trap-frame-finish): Use frame-address
  instead of frame-dynamic-link.
  (trap-calls-to-procedure): New proc, traps on procedure calls and
  their corresponding returns.
2010-09-23 13:42:12 +02:00
Andy Wingo
1bc1800ffa tracing in terms of traps
* 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.
2010-09-23 11:56:21 +02:00
Andy Wingo
65bce23759 breakpoints from recursive prompts work
* 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.
2010-09-21 21:37:11 +02:00
Andy Wingo
e366757659 default-trap-handler bugfix
* module/system/vm/trap-state.scm (default-trap-handler): Fix thinko.
2010-09-19 12:20:58 +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
Andy Wingo
c939b1275b add (system vm traps)
* module/system/vm/traps.scm: New module, implements higher-level traps
  based on the VM hooks. Inspired by (ice-9 debugging traps). Instead of
  the ice-9's variety, these traps have a procedural interface instead
  of a GOOPS interface.

* module/Makefile.am: Add the new module.
2010-09-17 13:33:47 +02:00
Andy Wingo
8d033f4839 instruction tracing tweak
* module/system/vm/trace.scm (vm-trace): No need to output the opcode
  number, and display the ip as a decimal, not a hexidecimal.
2010-09-16 13:04:57 +02:00
Andy Wingo
839eb61cde only trace instructions inside the thunk
* module/system/vm/trace.scm (vm-trace): Only trace instructions when
  we're in the dynamic extent of the thunk.
2010-09-16 12:58:59 +02:00
Andy Wingo
f312025167 add vm-abort-continuation-hook, vm-restore-continuation-hook
* libguile/vm-i-system.c (call_cc, tail_call_cc): Call the new
  RESTORE_CONTINUATION_HOOK when a continuation is restored.
  (prompt): Call the new ABORT_CONTINUATION_HOOK when entering the abort
  handler's continuation.

* libguile/vm-engine.h (ABORT_CONTINUATION_HOOK)
  (RESTORE_CONTINUATION_HOOK):
* libguile/vm.h (SCM_VM_ABORT_CONTINUATION_HOOK)
  (SCM_VM_RESTORE_CONTINUATION_HOOK):
* libguile/vm.c: (scm_vm_abort_continuation_hook): New hook, called when
  entering an abort handler.
  (scm_vm_restore_continuation_hook): New hook, called after returning
  to a continuation.

* module/system/vm/vm.scm: Add hooks to export list.
2010-09-16 12:48:41 +02:00
Andy Wingo
c45d4d775d trim our set of vm hooks
* libguile/vm.h (SCM_VM_PUSH_CONTINUATION_HOOK)
  (SCM_VM_POP_CONTINUATION_HOOK): New hooks, to replace
  enter/exit/return.
  (SCM_VM_BOOT_HOOK, SCM_VM_HALT_HOOK, SCM_VM_BREAK_HOOK): Remove these
  useless hooks.

* libguile/vm.c (scm_vm_push_continuation_hook)
  (scm_vm_pop_continuation_hook): New accessors.

* libguile/vm-i-system.c: Remove boot, halt, break, enter, exit, and
  return hooks. Also remove the break instruction. Instead now when we
  push a new continuation onto the stack we call PUSH_CONTINUATION_HOOK,
  and when we pop via a return we call POP_CONTINUATION_HOOK. APPLY_HOOK
  is now decoupled from continuation pushes and pops.

* libguile/vm-engine.h:
* libguile/vm-engine.c: Adapt for hooks.

* module/system/vm/trace.scm (vm-trace): Adapt for hooks. Also revive
  the #:instructions? #t mode.

* module/system/vm/vm.scm: Adapt exports for new set of hooks.
2010-09-16 12:16:02 +02:00
Andy Wingo
7c42238610 remove unused (system vm profile)
* module/Makefile.am:
* module/system/vm/profile.scm: Remove (system vm profile). We use
  statprof.
2010-09-16 12:03:10 +02:00
Ludovic Courtès
ea975f72cf Remove unneeded #:use-module.
* module/system/vm/frame.scm: Remove use of (srfi srfi-1).
2010-08-27 18:59:42 +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
5827e220ab `(debug)' debugs the current stack.
* module/system/vm/debug.scm (debug): Change to debug the current stack
  instead of the last stack.
2010-06-18 13:10:33 +02:00
Andy Wingo
222a2b19a1 fix error handling when reading debugger args
* module/system/vm/debug.scm (debugger-repl): Errors reading debugger
  args no longer drop us out of the debugger.
2010-06-10 14:15:26 +02:00
Andy Wingo
7b69cafd0a repl.scm simplifications
* module/system/repl/repl.scm (prompting-meta-read): Use
  call-with-error-handling.

* module/system/vm/debug.scm (call-with-error-handling): Add case for
  #:on-error 'pass. Have the catch handler return the unspecified value.
2010-06-10 14:15:26 +02:00
Andy Wingo
b93c34c0ca start cleaning up repl/debugger error handling
* module/system/repl/repl.scm (prompting-meta-read): Catch and print
  read errors here, returning unspecified in that case.
  (start-repl): Don't enable the debugger while reading expressions.
  Adapt with-backtrace to with-error-handling.

* module/system/vm/debug.scm (run-debugger, debugger-repl): No need to
  take a stack, the frames vector is sufficient.
  (call-with-error-handling, with-error-handling): New public utilities.
  Notably they do not poke the-last-stack.
2010-06-10 14:15:26 +02:00
Andy Wingo
615eb45521 brown-paper-bag commit
* module/system/vm/debug.scm (frame->module): In which our author
  misunderstands git's index.
2010-06-02 22:56:10 +02:00
Andy Wingo
9a598c47f7 flesh out recursive repl module with local vars
* module/system/vm/debug.scm (frame->module): Actually bind frame-local
  variables to values in the new anonymous module. Setting settable vars
  should work too :)
2010-06-02 22:52:49 +02:00