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

531 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
783eeee657 system xref maintains source mapping for nested procedures too
* module/system/xref.scm (*closure-sources-db*): New global, like
  *sources-db* but for nested procedures. It's a separate map because
  these procs need to be treated differently in trap handlers -- you
  match on the bytecode, not on the program object.
  (add-source, forget-source): Take the db as an argument (the normal db
  or the closures db).
  (add-sources, forget-sources): Record sources for nested procedures to
  in *closures-db*.
  (untaint-sources, ensure-sources-db): Adapt for new closures db.
  (lookup-source-procedures): Factored out.
  (source-closures): New exported procedure, returns closures at the
  given source location.
2010-09-24 13:24:48 +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
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
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
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
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
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
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
Andy Wingo
664a8b0d66 new procedure: source-procedures
* module/system/xref.scm (source-procedures): New public procedure,
  gives the procedures defined at a given source location.
2010-09-10 13:29:56 +02:00
Andy Wingo
348fb7040f (system xref) uses module-submodules
* module/system/xref.scm (ensure-callers-db): Fix up to use
  module-submodules.
2010-09-10 12:55:09 +02:00
Ludovic Courtès
2ee073587a Rename make-foreign-function' to pointer->procedure'.
* libguile/foreign.c (scm_make_foreign_function): Rename to...
  (scm_pointer_to_procedure): ... this.
* libguile/foreign.h: Adjust accordingly.
* module/system/foreign.scm: Likewise.
* test-suite/standalone/test-ffi: Likewise.
* test-suite/tests/foreign.test: Likewise.
* doc/ref/api-foreign.texi: Likewise.
2010-09-06 22:24:44 +02:00
Ludovic Courtès
3318635666 Add `procedure->pointer' to the FFI.
* libguile/foreign.c (make_cif): New procedure, with code formerly in
  `scm_make_foreign_function'.
  (scm_make_foreign_function): Use it.
  (invoke_closure, scm_procedure_to_pointer)[FFI_CLOSURES]: New
  functions.

* libguile/foreign.h (scm_procedure_to_pointer): New declaration.

* module/system/foreign.scm: Export `procedure->pointer' when available.

* test-suite/standalone/test-ffi (f-callback-1, f-callback-2): New
  procedures and related tests.

* test-suite/standalone/test-ffi-lib.c (test_ffi_callback_1,
  test_ffi_callback_2): New functions.

* test-suite/tests/foreign.test ("procedure->pointer"): New test prefix.

* doc/ref/api-foreign.texi (Dynamic FFI): Document `procedure->pointer'.
2010-09-03 15:26:37 +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
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
Ludovic Courtès
fa2a89a6d1 Add string->pointer' and pointer->string' to the FFI.
* libguile/foreign.c (scm_string_to_pointer, scm_pointer_to_string): New
  functions.

* libguile/foreign.h (scm_string_to_pointer, scm_pointer_to_string): New
  declarations.

* module/system/foreign.scm: Export `string->pointer' and
  `pointer->string'.

* test-suite/tests/foreign.test ("pointer<->string"): New test prefix.

* doc/ref/api-foreign.texi (Void Pointers and Byte Access): Add
  `string->pointer' and `pointer->string'.
2010-08-15 16:43:39 +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