1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-10 14:00:21 +02:00

fix bug in variable-set instruction; ,x prints out program metadata

* module/system/vm/disasm.scm (disassemble-program, disassemble-meta):
  Disassemble program meta information too, if it's there.

* src/vm_system.c (variable-set): Don't try to proxy name information;
  maybe we can do this later, but the code as it was was calling SCM_CAR
  on a variable, which is for the lose.
This commit is contained in:
Andy Wingo 2008-08-08 00:26:17 +02:00
parent 17d1b4bffd
commit 81aae20202
3 changed files with 27 additions and 9 deletions

View file

@ -47,6 +47,7 @@
(nexts (arity:nexts arity))
(bytes (program-bytecode prog))
(objs (program-objects prog))
(meta (program-meta prog))
(exts (program-external prog)))
;; Disassemble this bytecode
(format #t "Disassembly of ~A:\n\n" prog)
@ -58,6 +59,8 @@
(disassemble-objects objs))
(if (pair? exts)
(disassemble-externals exts))
(if meta
(disassemble-meta meta))
;; Disassemble other bytecode in it
(for-each
(lambda (x)
@ -103,13 +106,29 @@
(let ((info (object->string (car l))))
(print-info n info #f)))))
;; FIXME: update for recent meta changes
(define-macro (unless test . body)
`(if (not ,test) (begin ,@body)))
(define (disassemble-meta meta)
(display "Meta info:\n\n")
(for-each (lambda (data)
(print-info (car data) (list->info (cdr data)) #f))
meta)
(newline))
(let ((bindings (car meta))
(sources (cadr meta))
(props (cddr meta)))
(unless (null? bindings)
(display "Bindings:\n\n")
(for-each (lambda (b)
(print-info (car b) (list->info (cadr b)) #f))
bindings)
(newline))
(unless (null? sources)
(display "Sources:\n\n")
(for-each (lambda (x)
(print-info (car x) (list->info (cdr x)) #f))
sources)
(newline))
(unless (null? props)
(display "Properties:\n\n")
(for-each (lambda (x) (print-info #f x #f)) props)
(newline))))
(define (original-value addr code objs)
(define (branch-code? code)

View file

@ -74,13 +74,13 @@
(else (vector (abbrev (vector-ref x 0)) '...))))
(else x)))
(write (abbrev (cons (program-name frame)
(frame-arguments frame)))))
(frame-arguments frame)))))
(define (program-name frame)
(let ((prog (frame-program frame))
(link (frame-dynamic-link frame)))
(or (object-property prog 'name)
(frame-object-name link (1- (frame-address link)) prog)
(frame-object-name link (1- (frame-address link)) prog)
(hash-fold (lambda (s v d) (if (eq? prog (variable-ref v)) s d))
prog (module-obarray (current-module))))))

View file

@ -310,7 +310,6 @@ VM_DEFINE_INSTRUCTION (external_set, "external-set", 1, 1, 0)
VM_DEFINE_INSTRUCTION (variable_set, "variable-set", 0, 1, 0)
{
VARIABLE_SET (sp[0], sp[-1]);
scm_set_object_property_x (sp[-1], scm_sym_name, SCM_CAR (sp[0]));
sp -= 2;
NEXT;
}