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

76 commits

Author SHA1 Message Date
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
Andy Wingo
1ad7fef524 implement a silly debugger
* module/system/vm/debug.scm: Implement the skeleton of a debugger. Not
  very useful yet.

* module/system/repl/repl.scm (call-with-backtrace): Have the pre-unwind
  hook drop the user into the debugger. Hopefully we can have something
  better within a couple weeks.
2009-12-22 23:38:06 +01:00
Ludovic Courtès
587cd3bfc9 Fix copyright headers.
* module/system/vm/debug.scm, module/system/vm/frame.scm,
  module/system/vm/vm.scm: Switch to LGPLv3+.
2009-11-17 23:42:38 +01:00
Andy Wingo
8239263f86 fix erroneous #:use-syntax clausen
* module/system/repl/command.scm:
* module/system/repl/common.scm:
* module/system/repl/repl.scm:
* module/system/vm/debug.scm:
* module/system/vm/trace.scm: Change #:use-syntax to #:use-module, as
  that's really what we want to do.
2009-04-22 22:27:50 +02:00
Andy Wingo
d9d671f76e no keyword arguments in GHIL / GLIL, just optional args -- faster compiles
* module/system/base/syntax.scm (define-record): So, in the generated
  constructors, allow optional arguments, but not keyword arguments.
  Conses much less in the constructors.
  (define-record/keywords): And the old define-record is here.

* module/language/ghil.scm (parse-ghil):
* module/language/ghil/compile-glil.scm (codegen):
* module/language/scheme/compile-ghil.scm (translate-1, quote)
  (quasiquote): Don't use keywords in this compiler hotpath.

* module/system/base/language.scm (<language>):
* module/system/repl/common.scm (<repl>):
* module/system/vm/debug.scm (<debugger>): Use define-record/keywords.
2009-02-13 00:01:47 +01:00
Andy Wingo
b0b180d522 nifty generic compiler infrastructure -- no more hardcoded passes
* module/system/base/language.scm (<language>): Rework so that instead of
  hardcoding passes in the language, we define compilers that translate
  from one language to another. Add `parser' to the language fields, a
  bit of a hack but useful for languages with s-expression external
  representations but with record internal representations.
  (define-language, *compilation-cache*, invalidate-compilation-cache!)
  (compute-compilation-order, lookup-compilation-order): Add an algorithm
  that does a depth-first search for a translation path from a source
  language to a target language, caching the result in a lookup table.

* module/language/scheme/spec.scm:
* module/language/ghil/spec.scm: Update to the new language format.

* module/language/glil/spec.scm: Add a language specification for GLIL,
  with a compiler to objcode. Also there are parsers and printers, for
  repl usage, but for some reason this doesn't work yet.

* module/language/objcode/spec.scm: Define a language specification for
  object code. There is some sleight of hand here, in the "compiler" to
  values; but there is method behind the madness, because this way we
  higher levels can pass environments (a module + externals pair) to
  objcode->program.

* module/language/value/spec.scm: Define a language specification for
  values. There is something intellectually dishonest about this, but it
  does serve its purpose as a foundation for the language hierarchy.

* configure.in:
* module/language/Makefile.am
* module/language/ghil/Makefile.am
* module/language/glil/Makefile.am
* module/language/objcode/Makefile.am
* module/language/value/Makefile.am:
  Autotomfoolery for the ghil, glil, objcode, and value languages.

* module/language/scheme/translate.scm (translate): Import the bits that
  understand `compile-time-environment' here, and pass on the relevant
  portions of the environment to the next compiler pass.

* module/system/base/compile.scm (current-language): New procedure, refs
  the current language fluid, or lazily sets it to scheme.
  (call-once, call-with-output-file/atomic): Refactor these bits to use
  with-throw-handler. No functional change.
  (compile-file, compile-and-load, compile-passes, compile-fold)
  (compile): Refactor the public interface of the compiler to be generic
  and simple. Uses `lookup-compilation-order' to find a path from the
  source language to the target language.

* module/system/base/syntax.scm (define-type): Adapt to changes in
  define-record.
  (define-record): Instead of expecting all slots in the first form,
  expect them in the body, and let the first form hold the options.

* module/system/il/compile.scm (compile): Adapt to the compilation pass
  API (three in and two out).

* module/system/il/ghil.scm (<ghil-var>, <ghil-env>)
  (<ghil-toplevel-env>): Adapt to define-record changes.

* module/system/il/glil.scm (<glil-vars>): Adapt to define-record
  changes.
  (<glil>, print-glil): Add a GLIL record printer that uses unparse.
  (parse-glil, unparse-glil): Update unparse (formerly known as pprint),
  and write a parse function.

* module/system/repl/common.scm (<repl>): Adapt to define-record changes.
  (repl-parse): New function, parses the read form using the current
  language. Something of a hack.
  (repl-compile): Adapt to changes in `compile'.
  (repl-eval): Fix up the does-the-language-have-a-compiler check for
  changes in <language>.

* module/system/repl/repl.scm (start-repl): Parse the form before eval.

* module/system/repl/command.scm (describe): Parse.
  (compile): Be more generic.
  (compile-file): Adapt to changes in compile-file.
  (disassemble, time, profile, trace): Parse.

* module/system/vm/debug.scm:
* module/system/vm/assemble.scm: Adapt to define-record changes.

* module/language/scheme/translate.scm (receive): Fix an important bug
  that gave `receive' letrec semantics instead of let semantics. Whoops!
2008-11-14 22:42:31 +01:00
Andy Wingo
1a1a10d3a5 use #:keywords in module/*.scm, not :keywords
* module/system/base/syntax.scm (keywords): Don't enable :keywords, it
  breaks code that may assume that ':foo is a symbol, like boot-9.

* module/*.scm: Don't use :keywords, use #:keywords. The user can decide
  if she wants #:keywords in their .guile, and :keywords might make us
  compile modules differently.
2008-09-09 06:58:25 +02:00
Andy Wingo
e15f47740b More relevant VM backtrace
* module/system/repl/repl.scm: Remove a useless print in the backtrace
  handler.

* module/system/vm/debug.scm (vm-backtrace): s/reverse!/reverse/

* module/system/vm/frame.scm (bootstrap-frame?): A heuristic to see if a
  frame is a bootstrap frame, the one allocated on the stack in
  vm_engine.c; need to have a better solution for this.
  (make-frame-chain): Don't include bootstrap frames, they add no
  information.
  (print-frame-chain-as-backtrace): Remove a pk.

* src/vm_engine.c (vm_run): Add a fixme about the bootstrap prograp.
2008-08-08 13:19:49 +02:00
Andy Wingo
d0168f3da8 improve source loc info in nonlocal exits and backtraces
* module/system/il/compile.scm (codegen): The currently-executing
  instruction is actually the one right before the instruction pointer;
  so for purposes of assv to find a source location for an ip, put the
  source after the code, as it was before.

* module/system/vm/debug.scm (vm-backtrace): Move more code to frame.scm.

* module/system/vm/frame.scm (make-frame-chain): Include all frames, even
  the bootstrap one. For a reentrant backtrace we'll have boostrap
  programs anyway. Probably should check for objcode[2] == scm_op_halt,
  to not show those frames in the trace.
  (frame-line-number, frame-file): New helpers.
  (print-frame): Print out the line number too.
  (frame-call-representation): Code from print-frame-call moved here.
  (print-frame-chain-as-backtrace): A backtrace printer, yays.
  (program-name): Check link validity before calling frame-address on it.

* module/system/vm/program.scm (source:addr, source:line, source:column)
  (source:file): New accessors for the elements of program-sources.

* module/system/vm/vm.scm (vm:last-ip): New export.
  (vm-last-frame-chain): Use vm:last-ip in making the frame chain.

* src/vm.h (struct scm_vm):
* src/vm.c (make_vm, scm_vm_last_ip, scm_vm_save_stack): Save the last
  instruction pointer when saving the stack. Really though, we should be
  saving all of the stack data on a spaghetti stack.

* src/vm_system.c (late-variable-ref): Pointless s/REGISTER/BEFORE_GC/.
2008-08-08 12:55:57 +02:00
Andy Wingo
07e56b27a1 big reorg of scheme modules -- e.g. programs.c -> (system vm program)
This reorganization kills the ugly module-export-all hacks in
bootstrap.scm and core.scm. In fact, it gets rid of core.scm entirely,
breaking out its functionality into separate files.

* module/system/vm/trace.scm:
* module/system/vm/profile.scm:
* module/system/vm/disasm.scm:
* module/system/vm/debug.scm:
* module/system/vm/conv.scm:
* module/system/vm/assemble.scm:
* module/system/repl/repl.scm:
* module/system/repl/common.scm:
* module/system/base/compile.scm:
* module/system/repl/command.scm: Update for changes, and fix a bug in
  procedure-documentation.

* module/system/vm/bootstrap.scm: Just call scm_bootstrap_vm, which
  handles setting load-compiled for us.

* module/system/vm/core.scm: Removed, functionality folded into other
  modules.

* module/system/vm/frame.scm: Export the C frame procedures here; also
  move scheme functions from core.scm here.

* module/system/vm/instruction.scm: New file, exports procedures from
  instructions.c.

* module/system/vm/objcode.scm: New file, exports procedures from
  objcodes.c.

* module/system/vm/program.scm: New file, exports procedures from
  programs.c, and some scheme functions originally from core.scm.

* module/system/vm/vm.scm: New file, from vm.c and core.scm.

* src/Makefile.am (libguile_vm_la_SOURCES): Add bootstrap.h.

* src/bootstrap.h: New file, prototypes scm_bootstrap_vm (), which the
  scm_init_* functions call.

* src/frames.h:
* src/frames.c (scm_init_frames):
* src/frames.c (scm_bootstrap_frames):

* src/vm.h:
* src/instructions.h:
* src/instructions.c (scm_init_instructions):
* src/instructions.c (scm_bootstrap_instructions):
* src/objcodes.h:
* src/objcodes.c (scm_bootstrap_objcodes):
* src/objcodes.c (scm_init_objcodes):
* src/programs.h:
* src/programs.c (scm_bootstrap_programs):
* src/programs.c (scm_init_programs):
* src/vm.c (scm_bootstrap_vm):
* src/vm.c (scm_init_vm): Call scm_bootstrap_vm() before doing anything
  in an init function. Bootstrap_vm will call bootstrap_instructions(),
  etc to initialize types, then set load-compiled to point to
  load-compiled/vm.

* src/vm.c (scm_load_compiled_with_vm): Code to load .go files, if
  they're present.
2008-08-07 13:11:27 +02:00
Andy Wingo
61dc81d993 procedures-with-setters, debitrot `optimize', dedottification
* module/system/base/syntax.scm (define-record): Define the accessors as
  procedures-with-setters, not just as getters.

* module/system/il/compile.scm (optimize): This function was bitrotten
  since the addition of source locations in
  cb4cca12e7. Untested attempts to
  de-bitrot it. Dedottify as well.

* module/system/il/ghil.scm:
* module/system/il/glil.scm (unparse):
* module/system/vm/debug.scm (debugger-repl): Ongoing dedottification.
2008-05-04 15:37:54 +02:00
Andy Wingo
849cefacf1 unify variant types and records; also make-foo instead of <foo>
* module/system/base/syntax.scm (define-record): Rework to separate the
  type and its constructor. Now (define-record (<foo> bar)) will create
  `make-foo' as the constructor, not `<foo>'. Also the constructor now
  takes either keyword or positional arguments, so that it can be used as
  the implementation of variant types as well.
  (|): Map directly to define-record instead of rolling our own thing.

* module/language/scheme/translate.scm:
* module/system/base/language.scm:
* module/system/il/compile.scm:
* module/system/il/ghil.scm:
* module/system/il/glil.scm:
* module/system/repl/common.scm:
* module/system/vm/assemble.scm:
* module/system/vm/debug.scm: Change instances of record creation to use
  the make-foo procedures instead of <foo>. Adjust module exports as
  necessary.
2008-05-03 18:32:46 +02:00
Ludovic Courtes
884d46de23 Tried compiling more code; augmented the doc.
* module/language/Makefile.am: New.

* module/language/scheme/Makefile.am: New.

* configure.in: Produce these two new Makefiles.

* doc/guile-vm.texi: Documented `compile-file', `compiled-file-name', and
  `compile-in'.

* module/system/base/compile.scm: Cosmetic changes.

* module/system/base/language.scm: Likewise.

* module/system/il/Makefile.am: Tried (and failed) to compile more
  things.

* module/system/vm/Makefile.am: All source files in here can now be
  compiled without harming further compilation.

* module/system/vm/assemble.scm: Select only specific bindings from
  `(system vm core)'.
  (dump-object!): Show a more meaningful error message.

* module/system/vm/conv.scm: Select only specific bindings from `(system
  vm core)'.

* module/system/vm/debug.scm: Likewise.

* module/system/vm/frame.scm: Changed the header.  Use a renamer for
  `(system vm core)'.

* src/guilec.in: Added options, via `getopt-long'.

git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-6
2008-04-25 19:09:30 +02:00
Keisuke Nishida
af988bbf9c *** empty log message *** 2001-04-23 04:28:13 +00:00
Renamed from module/system/vm/backtrace.scm (Browse further)