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

63 commits

Author SHA1 Message Date
Andy Wingo
691697de09 Rename "RTL" to "bytecode"
"RTL" didn't make any sense, and now that there's no other bytecode to
disambiguate against, just call it bytecode.

* module/Makefile.am:
* module/ice-9/eval-string.scm:
* module/language/bytecode.scm:
* module/language/bytecode/spec.scm:
* module/language/cps/arities.scm:
* module/language/cps/compile-bytecode.scm:
* module/language/cps/compile-rtl.scm:
* module/language/cps/contification.scm:
* module/language/cps/elide-values.scm:
* module/language/cps/primitives.scm:
* module/language/cps/reify-primitives.scm:
* module/language/cps/spec.scm:
* module/language/cps/specialize-primcalls.scm:
* module/language/rtl.scm:
* module/language/rtl/spec.scm:
* module/scripts/compile.scm:
* module/system/base/compile.scm:
* module/system/repl/common.scm:
* module/system/vm/assembler.scm:
* module/system/vm/debug.scm:
* module/system/vm/disassembler.scm:
* module/system/vm/dwarf.scm:
* test-suite/tests/cross-compilation.test:
* test-suite/tests/dwarf.test:
* test-suite/tests/rtl-compilation.test:
* test-suite/tests/rtl.test:
* test-suite/vm/run-vm-tests.scm: Fixups.
2013-12-02 21:31:47 +01:00
Andy Wingo
4cbc95f150 Rename objcodes?.{scm,c,h} to loader.{scm,c,h}
* libguile/loader.c:
* libguile/loader.h: Rename from objcodes.[ch].
* module/system/vm/loader.scm: Rename from objcode.scm.

* libguile/Makefile.am:
* libguile/gsubr.c:
* libguile/init.c:
* libguile/procs.c:
* libguile/vm.c:
* module/Makefile.am:
* module/ice-9/eval-string.scm:
* module/language/rtl/spec.scm:
* module/system/base/target.scm:
* module/system/repl/command.scm:
* module/system/repl/common.scm:
* module/system/vm/debug.scm:
* module/system/vm/disassembler.scm:
* module/system/vm/objcode.scm:
* test-suite/tests/compiler.test:
* test-suite/tests/dwarf.test:
* test-suite/tests/rtl-compilation.test:
* test-suite/tests/rtl.test: Adapt.
2013-11-19 21:45:07 +01:00
Andy Wingo
34cf09ccdf Rename internals of (system vm program) program-minimum-arity
* module/system/vm/debug.scm (find-program-minimum-arity): Rename from
  program-minimum-arity.

* module/system/vm/program.scm (program-minimum-arity): Rename from
  rtl-program-minimum-arity.

* libguile/programs.c (scm_i_program_arity): Adapt.
2013-11-19 19:45:56 +01:00
Andy Wingo
056110754e Binary search to find procedure properties.
* module/system/vm/debug.scm (find-program-properties): Use binary
  search.
2013-11-09 16:25:12 +01:00
Andy Wingo
d81658a7ec Binary search to find docstrings.
* module/system/vm/debug.scm (find-program-docstring): Use binary
  search.
2013-11-09 16:15:12 +01:00
Andy Wingo
d8595af555 Finding a procedure's arity uses binary search
* module/system/vm/assembler.scm (pack-arity-flags):
  (write-arity-headers): Add a flag to indicate that an arity is part of
  a case-lambda, so that we can use binary search to find arities.

* module/system/vm/debug.scm (is-in-case-lambda?)
  (arity-is-in-case-lambda?, find-first-arity): Use binary search.
2013-11-09 16:02:13 +01:00
Andy Wingo
695e6b7551 Use binary search in find-elf-symbol
* module/system/vm/debug.scm (binary-search): New helper.
  (find-elf-symbol): Use binary search.
2013-11-09 15:51:54 +01:00
Andy Wingo
e391f179e4 (system vm traps) support for rtl programs
* module/system/vm/debug.scm: Export program-debug-info-size.

* module/system/vm/traps.scm (frame-matcher): Remove stack program
  case.  Use absolute frame-instruction-procedure to match if
  match-code?.
  (program-last-ip): Use (system vm debug) interfaces.
  (program-sources-by-line): Use program-sources, as
  program-sources-pre-retire will go away soon.  Return absolute
  addresses.
2013-11-08 17:31:51 +01:00
Andy Wingo
8734229528 Fix program-minimum-arity to work better with case-lambda.
* module/system/vm/debug.scm (program-minimum-arity): Be more precise
  with case-lambdas.
2013-11-08 14:19:41 +01:00
Andy Wingo
f41accb9c2 Fix procedure-arguments on RTL programs, and tweak session.test
* module/ice-9/session.scm (procedure-arguments): Add an rtl-program?
  case.

* module/system/vm/debug.scm (arity-arguments-alist): Use the order that
  session.test expects.

* test-suite/tests/session.test ("procedure-arguments"): Adapt tests
  with keywords for the new starting-with-the-procedure numbering of
  locals.
2013-11-08 13:29:03 +01:00
Andy Wingo
0e3a59f750 Fix reading and writing arities into DWARF.
* libguile/gsubr.h:
* libguile/gsubr.c (scm_i_primitive_call_ip):
* libguile/programs.c (scm_primitive_call_ip): Adapt to return an
  absolute address.

* module/system/vm/assembler.scm (write-arity-headers): Adapt to write
  byte addresses (relative to the text base).

* module/system/vm/debug.scm (arity-low-pc, arity-high-pc): Return
  absolute addresses, instead of word offsets relative to the text
  base.
  (find-first-arity): Adapt for absolute addresses.

* module/system/vm/program.scm (program-arguments-alist): Adapt for
  arity-low-pc / arity-high-pc absolute addresses.
2013-11-08 10:11:48 +01:00
Andy Wingo
581a4eb82b frame-instruction-pointer is absolute; rewrite (system vm coverage)
* libguile/frames.c (scm_frame_source): Instead of assuming that
  scm_frame_procedure is correct, use the IP to get the source.
  (scm_frame_instruction_pointer): Return an absolute value instead of
  assuming that slot 0 is correct.  (It isn't, when preparing for a tail
  call.)

* libguile/programs.h:
* libguile/programs.c (scm_find_source_for_addr): New internal helper.

* module/system/repl/debug.scm (print-registers): Readably print
  absolute instruction pointers.

* module/system/vm/coverage.scm: Complete rewrite to use absolute IP's.
  We can't assume that frame-procedure is cheap if it is correct, or
  correct if it is cheap.  Anyway using the address is better anyway.
  (coverage-data->lcov): Disable per-function info temporarily.
  (loaded-modules, module-procedures, closest-source-line)
  (closed-over-procedures): Remove these.  Instead of going from
  procedures to source info, now we go from ELF image to source info.

* module/system/vm/debug.scm (debug-context-length): New interface.

* module/system/vm/program.scm (source-for-addr): New internal helper.
2013-11-07 23:03:45 +01:00
Andy Wingo
0128bb9c38 add fold-all-debug-contexts, fold-source-locations
* module/system/vm/objcode.scm:
* libguile/objcodes.c (scm_all_mapped_elf_images): New proc.

* module/system/vm/debug.scm (fold-all-debug-contexts):
  (fold-source-locations): New public interfaces.
2013-11-07 17:53:04 +01:00
Andy Wingo
963d95f1d9 Fix first find-program-sources result
* module/system/vm/debug.scm (find-program-sources): Manually set the pc
  of the first result in a function.
2013-11-06 17:33:43 +01:00
Andy Wingo
0a1d52ac77 fix docstring assembly and fetching
* module/system/vm/assembler.scm (link-docstrs): Write pc offsets as
  byte addresses.  Works better with native code.
* module/system/vm/debug.scm (find-program-docstring): Fix the linear
  search.  How embarassing!
2013-11-05 21:29:46 +01:00
Andy Wingo
9dff1df97f (system vm debug): implement arity-low-pc, arity-high-pc
* module/system/vm/debug.scm (arity-low-pc, arity-high-pc): Implement
  these exports.
2013-10-18 11:39:35 +02:00
Andy Wingo
f8fb13ef8c better RTL debugging
* libguile/frames.c (scm_frame_source, scm_frame_instruction_pointer):
  Fix to work with RTL programs.

* module/system/vm/debug.scm (find-debug-context): Allow for the
  possibility of there being no ELF image.
  (find-program-debug-info, find-program-arities)
  (program-minimum-arity, find-program-docstring)
  (find-program-properties, find-source-for-addr)
  (find-program-die, find-program-sources): Don't bail if we couldn't
  get the debug context.

* module/system/vm/frame.scm (frame-next-source)
  (frame-call-representation): Allow RTL programs.

* module/system/vm/program.scm (program-arguments-alist): Placeholder
  implementation for RTL programs.
  (program-arguments-alists): Don't bail if we couldn't get the
  arities.
2013-10-04 19:55:12 +02:00
Andy Wingo
b43e81dc60 anonymous RTl functions print with source info
* module/system/vm/debug.scm (find-program-sources): If there is no
  source location before the low-pc of the procedure we're grovelling
  for, we were skipping the source loc info.  Fix that.

* module/system/vm/program.scm (write-program): Get source info for
  anonymous RTL functions.
  (program-sources, program-sources-pre-retire): Provide program
  counters relative to the beginning of the procedure.
2013-10-03 22:48:17 +02:00
Andy Wingo
c0ada5a766 Add (system vm debug) interface to source location information
* module/system/vm/debug.scm (<source>, source-pre-pc)
  (source-post-pc, source-file, source-line, source-column)
  (source-line-for-user): New data type for source location
  information.
  (find-source-for-addr, find-program-sources): New procedures to get
  source location information for a particular address.
2013-10-03 16:14:29 +02:00
Andy Wingo
610295ec9d add ability to disassemble ELF images
* module/scripts/disassemble.scm (disassemble): Update to work with
  RTl (and only RTL, as that's the future).

* module/system/vm/debug.scm (for-each-elf-symbol): New public
  interface.
  (debug-context-from-image): New helper.
  (find-debug-context): Use the helper.

* module/system/vm/disassembler.scm (disassemble-image): New public
  interface.
2013-08-29 20:44:55 +02:00
Andy Wingo
081cf91029 fix rtl program arity functions
* libguile/programs.c (parse_arity): Lookup rtl-program-minimum-arity
  from (system vm debug).

* module/system/vm/debug.scm (find-first-arity): Fix the linear search.
  Whoops!
2013-07-21 17:12:21 +02:00
Andy Wingo
c4c098e355 procedure-properties for RTL functions
* module/system/vm/assembler.scm (link-procprops, link-objects): Arrange
  to write procedure property links out to a separate section.

* libguile/procprop.c (scm_procedure_properties):
* libguile/programs.h:
* libguile/programs.c (scm_i_rtl_program_properties):
* module/system/vm/debug.scm (find-program-properties): Wire up
  procedure-properties for RTL procedures.  Yeah!  Fistpumps!  :)

* module/system/vm/debug.scm (find-program-debug-info): Return #f if the
  string is "", as it is if we don't have a name.  Perhaps
  elf-symbol-name should return #f in that case...

* test-suite/tests/rtl.test: Add some tests.
2013-06-09 23:59:19 +02:00
Andy Wingo
bf8328ec16 procedure-documentation works on RTL procedures
* libguile/procprop.h:
* libguile/procprop.c (scm_procedure_documentation): Move here from
  procs.c, and to make the logic more similar to that of procedure-name,
  which allows RTL programs to dispatch to rtl-program-documentation.

* libguile/programs.c (scm_i_rtl_program_documentation):
* libguile/programs.h:
* module/system/vm/program.scm (rtl-program-documentation): New
  plumbing.

* module/system/vm/debug.scm (find-program-docstring): New interface to
  grovel ELF for a docstring.
2013-06-09 23:59:01 +02:00
Andy Wingo
eb2bc00fb3 Wire up ability to print RTL program arities
* libguile/procprop.c (scm_i_procedure_arity): Allow RTL programs to
  dispatch to scm_i_program_arity.

* libguile/programs.c (scm_i_program_print): Refactor reference to
  write-program.
  (scm_i_rtl_program_minimum_arity): New procedure, dispatches to
  Scheme.
  (scm_i_program_arity): Dispatch to scm_i_rtl_program_minimum_arity if
  appropriate.

* module/system/vm/debug.scm (program-minimum-arity): New export.

* module/system/vm/program.scm (rtl-program-minimum-arity): New internal
  function.
  (program-arguments-alists): New helper, implemented also for RTL
  procedures.
  (write-program): Refactor a bit, and call program-arguments-alists.

* test-suite/tests/rtl.test ("simply procedure arity"): Add tests that
  arities make it all the way to cold ELF and back to warm Guile.
2013-06-09 23:43:25 +02:00
Andy Wingo
f88e574d58 (system vm debug) can read arity information
* module/system/vm/debug.scm (<arity>): New object, for reading
  arities.  Unlike <arity> in the assembler, this one only holds on to a
  couple of pointers, and doesn't even load in argument names.  Unlike
  the arity lists in (system vm program), it can load in names.  Very
  early days but it does seem to work.
  (find-program-arities, arity-arguments-alist): New higher-level
  interfaces.
2013-06-09 23:43:18 +02:00
Andy Wingo
82e299f386 Add RTL disassembler
* module/Makefile.am:
* module/system/vm/disassembler.scm: New module.

* module/system/repl/command.scm (disassemble): Work with RTL programs.
2013-06-09 20:07:57 +02:00
Andy Wingo
cb86cbd71d Add runtime support for reading debug information from ELF
* module/Makefile.am:
* module/system/vm/debug.scm: New module.

* module/system/vm/elf.scm (elf-section-by-name): New helper.
  (elf-symbol-table-len): New helper.

* test-suite/tests/rtl.test: Add test for finding debug info.
2013-06-09 19:50:30 +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
Andy Wingo
3098986b1a recursive repl support
* module/system/repl/common.scm (*repl-level*): New public fluid.
  (repl-prompt): If *repl-level* is a positive integer, add it to the
  prompt.

* module/system/repl/repl.scm (start-repl): The `lang' argument is now
  optional, and defaults to (current-language). New kwargs level and
  welcome; level defaults to 0, or 1+ the existing level, and the
  welcome is a boolean, true if level is 0. Parameterize *repl-level*
  during the dynamic extent of this repl. Also, parameterize
  the-last-stack to #f for the duration of this repl.

* module/system/vm/debug.scm (frame->module, debugger-repl): Stubs of a
  recursive repl implementation. The idea is to be a repl in the lexical
  context of the error; but it would be nice to be able to operate in
  the module of the proc too, for example to export bindings. Hmm.
2010-06-02 22:19:40 +02:00
Andy Wingo
92e19ec06d add debugging input and output ports
* module/system/vm/debug.scm (*debug-input-port*):
  (*debug-output-port*): New public fluids.
  (run-debugger): Add some kwargs for input and output ports, defaulting
  to the debug input and output ports.
  (debug-pre-unwind-handler): Print to debug output port.
  (debug): Untabify.
2010-04-09 13:41:31 +02:00
Andy Wingo
42ee0d00ba (debug) at the repl invokes the vm debugger
* module/ice-9/boot-9.scm (top-repl): Map (debug) at the repl to (system
  vm debug).

* module/system/vm/debug.scm (run-debugger, debugger-repl): Don't take
  the index as an arg, for now anyway.
  (debug): New wrapper.
2010-03-14 23:06:58 +01:00
Andy Wingo
06dcb9dfb6 narrowing stacks to prompts; backtrace shows frames from start-stack
* libguile/stacks.c (scm_sys_stacks): New global variable, moved here
  from boot-9.scm.
  (scm_init_stacks): Define scm_sys_stacks to %stacks.
  (stack_depth): Remove narrowing by frame pointer.
  (find_prompt): New helper.
  (narrow_stack): Clean up a bit, and allow narrowing by prompt tag.
  (scm_make_stack): Update docs, and use scm_stack_id to get the stack
  id.
  (scm_stack_id): The current stack id may be fetched as the cdar of
  %stacks.
  (stack_id_with_fp): Remove helper.

* module/ice-9/boot-9.scm (%start-stack): Fix indentation.
  (%stacks): Remove definition, it's in stacks.c now.
  (default-pre-unwind-handler): Narrow by another frame.
  (save-stack): Remove special handling for certain stack ids, as it is
  often possible that the function isn't on the stack -- in the
  interpreter, or after a tail call. Better to narrow by prompt ids.

* module/system/vm/debug.scm (print-frames): Change to operate on a
  vector of frames.
  (run-debugger): Change to receive a vector of frames. The debugger
  also has the full stack, so it can re-narrow (or widen) to get the
  whole stack, if the user wants.
  (stack->vector): New helper.
  (debug-pre-unwind-handler): Narrow by more frames, and to the most
  recent start-stack invocation. Adapt to run-debugger change.
2010-03-13 21:03:06 +01:00
Andy Wingo
e106eca674 inspector integration in debugger
* module/system/vm/debug.scm: Integrate with the inspector. Add a
  "procedure" command.
2010-01-12 00:20:50 +01:00
Andy Wingo
913ddf0574 slight tweak to stack narrowing in the debugger
* module/system/vm/debug.scm: Really narrow two frames and not by
  function, so it works in the evaluator.
2010-01-09 21:53:04 +01:00
Andy Wingo
37e9bc8ae4 Narrow one more frame in debug.scm:debug-pre-unwind-handler
* module/system/vm/debug.scm (debug-pre-unwind-handler): Narrow two
  frames instead of stack-reffing past one. The second frame is
  necessary, now that make-stack itself is on the stack.
2010-01-09 20:40:36 +01:00
Andy Wingo
391d29029d print the error more nicely when we enter the debugger
* module/system/vm/debug.scm (debug-pre-unwind-handler): Nicer printing
  of the error.
2010-01-09 20:31:35 +01:00
Andy Wingo
8217c9251a make backtraces prettier
* module/system/vm/debug.scm (print-frames): Clean up a bit, reverting
  part of the previous change. (The problem was that in the else branch
  of the conditional, it didn't consume an arg.)

  In the future I would like to preserve the clean look of the
  backtraces. It's easier to read that way.
2010-01-09 20:21:37 +01:00
Ludovic Courtès
a589525d4e Fix frame printing in the debugger.
* module/system/vm/debug.scm (location-string): New procedure.
  (print-frames): Use it.  This fixes cases where LINE is #f and makes a
  distinction between FILE = stdin and FILE is unknown.
2010-01-08 16:12:12 +01:00
Andy Wingo
441891f376 cleanups to debugger
* module/system/vm/debug.scm (debugger-repl): Remove the `bindings'
  command, it is superseded by `locals'.
  Update the TODO.
  (debug-pre-unwind-handler): Remove scary "beta" warning. Already being
  able to bt #:width 1000 #:full? #t is quite useful...
2009-12-29 21:26:48 +01:00
Andy Wingo
0c2a05c321 debugger's backtrace implemented in scheme
* module/system/vm/debug.scm (print-locals): Factor out to a function.
  (collect-frames, print-frames): Implement the guts of `backtrace' in
  Scheme.
  (debugger-repl): Add #:width and #:full? options to `backtrace'.
  Backtrace uses the backtrace code implemented in scheme.
2009-12-29 21:19:05 +01:00
Andy Wingo
2d8c757cf1 integers at debugger select frames
* module/system/vm/debug.scm (debugger-repl): Fix implementation of
  frame-at-index. Allow integers as commands, as a shorthand for "frame
  N".
2009-12-29 14:35:10 +01:00
Andy Wingo
1c5e812258 clean up (system vm frames), add locals command to debugger
* libguile/frames.c (scm_init_frames): No need to bootstrap the VM here,
  it should be already bootstrapped by init.c.
  (scm_bootstrap_frames): No need to register an extension, as
  scm_init_frames is called by init.c.

* module/system/vm/frame.scm: Don't load the scm_init_frames extension,
  as the primitives from frames.c are loaded by Guile's init.
  (frame-bindings): Change to return bindings, as can be accessed by the
  binding: accessors from program.scm.
  (frame-lookup-binding): Revive and make this one work with current
  code.
  (frame-binding-set!):
  (frame-binding-ref): Use the new frame-lookup-binding. Perhaps these
  should handle boxing and unboxing, though.
  (frame-source): New accessor, returns a source object.
  (frame-call-representation): Change to return a full list, as
  truncated-print can truncate for us.
  (frame-environment, frame-object-binding, frame-object-name): Update
  not to take an address, as the address is part of the frame.
  (frame-variable-exists?, frame-variable-ref, frame-variable-set!)
  (frame-local-variables, frame-program-name, print-frame)
  (print-frame-chain-as-backtrace, frame-file, frame-line-number)
  (make-frame-chain, bootstrap-frame?, frame-number, frame-address):
  Remove these outdated functions.

* module/system/vm/debug.scm (debugger-repl): Use
  frame-call-representation, and ~@y.
  (locals): New command, prints local variables in a frame.
2009-12-29 14:09:50 +01:00
Andy Wingo
d7a4096d25 implement up, down, frame, and bindings in the repl
* module/system/vm/debug.scm (debugger-repl): Implement up, down, frame,
  and bindings using the new command infrastructure.
2009-12-24 14:20:41 +01:00
Andy Wingo
f6fe5fe26b rewrite debugger command loop
* module/system/vm/debug.scm: Rewrite the command loop to have better
  introspection and argument handling.
2009-12-24 08:28:59 +01:00