summaryrefslogtreecommitdiff
path: root/module/system/vm/debug.scm
Commit message (Collapse)AuthorAgeFilesLines
* Fix frame-call-representation for callees without closuresAndy Wingo2019-11-271-0/+4
| | | | | | | | | | | | * module/system/vm/assembler.scm (<arity>): Add new "has-closure?" flag. (begin-kw-arity, pack-arity-flags, write-arities): Write "elided-closure?" flag into binary. A negative flag for compat reasons. * module/system/vm/debug.scm (elided-closure?, arity-has-closure?): Add arity-has-closure? accessor. * module/system/vm/frame.scm (frame-call-representation): Count from 0 for callees with elided closures.
* Rename gc-pointer-ref to pointer-refAndy Wingo2018-01-141-1/+1
| | | | | | | | | | | | | | | | The pointer dereferencing instructions will keep the pointer alive by referencing a containing object. * module/language/cps/compile-bytecode.scm: * libguile/vm-engine.c: * module/language/cps/cse.scm: * module/language/cps/effects-analysis.scm: * module/language/cps/reify-primitives.scm: * module/language/cps/slot-allocation.scm: * module/language/cps/specialize-primcalls.scm: * module/language/cps/types.scm: * module/system/vm/assembler.scm: * module/system/vm/debug.scm: Rename instructions.
* Add support for raw gc-managed pointer localsAndy Wingo2018-01-101-3/+4
| | | | | | | | | | | | * libguile/vm-engine.c (gc-pointer-ref/immediate) (gc-pointer-set!/immediate): New instructions. (SP_REF_PTR, SP_SET_PTR): New helper definitions. * libguile/vm.c (SLOT_DESC_LIVE_GC): Rename from SLOT_DESC_LIVE_SCM, as it can indicate GC-protected raw pointers also. (scm_i_vm_mark_stack): Adapt. * module/system/vm/assembler.scm (write-arities): * module/system/vm/debug.scm (arity-definitions): Add gcptr representation. This is a binary-incompatible change!
* Add support for unboxed s64 valuesAndy Wingo2015-12-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * libguile/frames.c (enum stack_item_representation): (scm_to_stack_item_representation): (scm_frame_local_ref, scm_frame_local_set_x): Support for S64 representations. * libguile/frames.h (union scm_vm_stack_element): Add signed 64-bit integer field. * libguile/vm-engine.c (scm->s64, s64->scm, load-s64): New instructions. * module/language/cps/compile-bytecode.scm (compile-function): * module/language/cps/cse.scm (compute-equivalent-subexpressions): * module/language/cps/effects-analysis.scm: * module/language/cps/slot-allocation.scm (compute-var-representations) (compute-needs-slot, allocate-slots): * module/language/cps/utils.scm (compute-constant-values): * module/language/cps/specialize-primcalls.scm (specialize-primcalls): Add support for new primcalls. * module/language/cps/types.scm (&s64): New type. (&s64-min, &s64-max, &u64-max): New convenience definitions. (&range-min, &range-max): Use &s64-min and &u64-max names. (scm->s64, load-s64, s64->scm): Add support for new primcalls. * module/system/vm/assembler.scm (emit-scm->s64, emit-s64->scm) (emit-load-s64): New exports. * module/system/vm/assembler.scm (write-arities): Support for s64 slots. * module/system/vm/debug.scm (arity-definitions): Support for s64 slots.
* Add low-level support for unboxed 64-bit unsigned intsAndy Wingo2015-12-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | * libguile/frames.c (enum stack_item_representation) * libguile/frames.c (scm_to_stack_item_representation): (scm_frame_local_ref, scm_frame_local_set_x): Support 'u64 slots. * libguile/frames.h (union scm_vm_stack_element): Add as_u64 member. * libguile/vm-engine.c (SP_REF_U64, SP_SET_U64): New helpers. (scm->u64, u64->scm): New instructions. * module/language/cps/cse.scm (compute-equivalent-subexpressions): Scalar replacement for u64->scm and scm->u64. * module/language/cps/effects-analysis.scm (scm->u64, u64->scm): Add cases. * module/language/cps/slot-allocation.scm (compute-var-representations): (allocate-slots): Represent the result of scm->u64 as a "u64" slot. * module/language/cps/types.scm (&u64): New type. (scm->u64, u64->scm): Add support for these ops. * module/system/vm/assembler.scm (write-arities): * module/system/vm/debug.scm (arity-definitions): Support u64 representations.
* All arities serialize a "closure" bindingAndy Wingo2015-12-011-11/+13
| | | | | | | | | | * module/language/cps/compile-bytecode.scm (compile-function): Always define a 'closure binding in slot 0. * module/system/vm/frame.scm (available-bindings): No need to futz around not having a closure binding. * module/system/vm/debug.scm (arity-arguments-alist): Expect a closure binding. * test-suite/tests/rtl.test: Emit definitions for the closure.
* Reflection support for unboxed f64 slotsAndy Wingo2015-10-281-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * module/system/vm/assembler.scm (emit-definition): Add representation field. (write-arities): Emit representations into the arities section. * module/system/vm/debug.scm (arity-definitions): Read representations. * module/system/vm/frame.scm (<binding>): Add representation field and binding-representation getter. (available-bindings): Pass representation to make-binding. (frame-binding-set!, frame-binding-ref, frame-call-representation): Pass representation to frame-local-ref / frame-local-set!. * test-suite/tests/rtl.test: Update definition instructions. * module/language/cps/slot-allocation.scm ($allocation): Add representations field. (lookup-representation): New public function. (allocate-slots): Pass representations to make-$allocation. * module/language/cps/compile-bytecode.scm (compile-function): Adapt to emit-definition change. * libguile/frames.h: * libguile/frames.c (scm_frame_local_ref, scm_frame_local_set_x): Take representation argument. (scm_to_stack_item_representation): New internal helper.
* Fix source-line-for-user for unknown lineAndy Wingo2014-05-311-1/+1
| | | | | * module/system/vm/debug.scm (source-line-for-user): Fix to allow for unknown lines.
* Add arity-codeAndy Wingo2014-04-161-0/+12
| | | | * module/system/vm/debug.scm (arity-code): New interface.
* Add ability to query local definitions for a procedureAndy Wingo2014-04-151-0/+53
| | | | | | | | | | | | | * module/system/vm/debug.scm (arity-definitions): New interface. * module/system/vm/program.scm (make-binding, binding:boxed?) (binding:index, binding:start, binding:end): Remove. (binding:definition-offset, binding:slot): Add. (program-arity-bindings-for-ip): Rename from program-bindings-for-ip, as it gives all definitions in an arity. The user will have to do data-flow analysis to recover the set of variables that are actually available at any given point. (arity->arguments-alist): Remove crufty code.
* Write all local variable names into the arities sectionAndy Wingo2014-04-151-31/+78
| | | | | | | | | | | | | * module/system/vm/assembler.scm (put-uleb128, put-sleb128) (port-position): Lift out these helpers. (arity-header-len, write-arities, link-arities): Add "nlocals" to the arity headers. Write names of all locals into the arities section, not just the arguments. Write them as uleb128's instead of uint32's, to save space. * module/system/vm/debug.scm (arity-header-len, arity-nlocals*) (arity-nlocals, arity-locals, arity-arguments-alist): Adapt to new encoding for arities.
* Tweak arities debugging representationAndy Wingo2014-04-151-29/+16
| | | | | | | * module/system/vm/assembler.scm (meta-arities-size, write-arity-links): * module/system/vm/debug.scm (arity-keyword-args) (arity-arguments-alist): Rewrite to put they keyword literals link first. Unfortunately requires a recompile :/
* Better backtraces for optimized closuresAndy Wingo2014-04-151-1/+33
| | | | | | | | * module/system/vm/debug.scm (arity-keyword-args, find-program-arity): New exports. * module/system/vm/frame.scm (frame-call-representation): Prefer to use the frame IP to get the procedure.
* Rename "RTL" to "bytecode"Andy Wingo2013-12-021-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "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.
* Rename objcodes?.{scm,c,h} to loader.{scm,c,h}Andy Wingo2013-11-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* Rename internals of (system vm program) program-minimum-arityAndy Wingo2013-11-191-3/+3
| | | | | | | | | | * 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.
* Binary search to find procedure properties.Andy Wingo2013-11-091-12/+12
| | | | | * module/system/vm/debug.scm (find-program-properties): Use binary search.
* Binary search to find docstrings.Andy Wingo2013-11-091-19/+21
| | | | | * module/system/vm/debug.scm (find-program-docstring): Use binary search.
* Finding a procedure's arity uses binary searchAndy Wingo2013-11-091-14/+21
| | | | | | | | | * 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.
* Use binary search in find-elf-symbolAndy Wingo2013-11-091-18/+24
| | | | | * module/system/vm/debug.scm (binary-search): New helper. (find-elf-symbol): Use binary search.
* (system vm traps) support for rtl programsAndy Wingo2013-11-081-0/+1
| | | | | | | | | | | | * 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.
* Fix program-minimum-arity to work better with case-lambda.wip-rtl-halloweenAndy Wingo2013-11-081-1/+11
| | | | | * module/system/vm/debug.scm (program-minimum-arity): Be more precise with case-lambdas.
* Fix procedure-arguments on RTL programs, and tweak session.testAndy Wingo2013-11-081-2/+2
| | | | | | | | | | | | * 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.
* Fix reading and writing arities into DWARF.Andy Wingo2013-11-081-6/+12
| | | | | | | | | | | | | | | | | | * 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.
* frame-instruction-pointer is absolute; rewrite (system vm coverage)Andy Wingo2013-11-071-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* add fold-all-debug-contexts, fold-source-locationsAndy Wingo2013-11-071-1/+44
| | | | | | | | * 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.
* Fix first find-program-sources resultAndy Wingo2013-11-061-2/+10
| | | | | * module/system/vm/debug.scm (find-program-sources): Manually set the pc of the first result in a function.
* fix docstring assembly and fetchingAndy Wingo2013-11-051-5/+4
| | | | | | | * 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!
* (system vm debug): implement arity-low-pc, arity-high-pcAndy Wingo2013-10-181-0/+8
| | | | | * module/system/vm/debug.scm (arity-low-pc, arity-high-pc): Implement these exports.
* better RTL debuggingAndy Wingo2013-10-041-41/+52
| | | | | | | | | | | | | | | | | | | | | * 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.
* anonymous RTl functions print with source infoAndy Wingo2013-10-031-2/+4
| | | | | | | | | | | * 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.
* Add (system vm debug) interface to source location informationAndy Wingo2013-10-031-2/+91
| | | | | | | | | * 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.
* add ability to disassemble ELF imagesAndy Wingo2013-08-291-5/+24
| | | | | | | | | | | | | * 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.
* fix rtl program arity functionsAndy Wingo2013-07-211-3/+3
| | | | | | | | * 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!
* procedure-properties for RTL functionsAndy Wingo2013-06-091-1/+44
| | | | | | | | | | | | | | | | | * 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.
* procedure-documentation works on RTL proceduresAndy Wingo2013-06-091-1/+33
| | | | | | | | | | | | | | | * 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.
* Wire up ability to print RTL program aritiesAndy Wingo2013-06-091-1/+2
| | | | | | | | | | | | | | | | | | | | | | | * 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.
* (system vm debug) can read arity informationAndy Wingo2013-06-091-1/+173
| | | | | | | | | | * 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.
* Add RTL disassemblerAndy Wingo2013-06-091-0/+1
| | | | | | | * module/Makefile.am: * module/system/vm/disassembler.scm: New module. * module/system/repl/command.scm (disassemble): Work with RTL programs.
* Add runtime support for reading debug information from ELFAndy Wingo2013-06-091-0/+160
| | | | | | | | | | * 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.
* remove (system vm debug)Andy Wingo2010-07-161-522/+0
| | | | | | | | * module/system/vm/debug.scm: Remove. * module/Makefile.am: Update. * module/system/repl/debug.scm: Add some TODOs and a commented-out function here.
* `(debug)' debugs the current stack.Andy Wingo2010-06-181-4/+8
| | | | | * module/system/vm/debug.scm (debug): Change to debug the current stack instead of the last stack.
* fix error handling when reading debugger argsAndy Wingo2010-06-101-4/+9
| | | | | * module/system/vm/debug.scm (debugger-repl): Errors reading debugger args no longer drop us out of the debugger.
* repl.scm simplificationsAndy Wingo2010-06-101-1/+6
| | | | | | | | * 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.
* start cleaning up repl/debugger error handlingAndy Wingo2010-06-101-36/+73
| | | | | | | | | | | | * 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.
* brown-paper-bag commitAndy Wingo2010-06-021-8/+9
| | | | | * module/system/vm/debug.scm (frame->module): In which our author misunderstands git's index.
* flesh out recursive repl module with local varsAndy Wingo2010-06-021-0/+14
| | | | | | * 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 :)
* recursive repl supportAndy Wingo2010-06-021-0/+17
| | | | | | | | | | | | | | | | | | * 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.
* add debugging input and output portsAndy Wingo2010-04-091-11/+39
| | | | | | | | | * 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.
* (debug) at the repl invokes the vm debuggerAndy Wingo2010-03-141-8/+15
| | | | | | | | | * 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.