show args to subr calls in backtraces
authorAndy Wingo <wingo@pobox.com>
Sun, 10 Jan 2010 22:10:24 +0000 (23:10 +0100)
committerAndy Wingo <wingo@pobox.com>
Sun, 10 Jan 2010 22:10:24 +0000 (23:10 +0100)
* module/system/vm/frame.scm (frame-arguments): For subrs, we don't get
  names in the lambda-list, we get #f instead. But still, parse out the
  args in that case, assuming they are on the stack in that order.

module/system/vm/frame.scm

index c28197b2cdd4622d210ca1e03180d4a0b450a43c..ea012fa747255f56a8fe2cdf95f94a21beba8921 100644 (file)
@@ -1,6 +1,6 @@
 ;;; Guile VM frame functions
 
-;;; Copyright (C) 2001, 2005, 2009 Free Software Foundation, Inc.
+;;; Copyright (C) 2001, 2005, 2009, 2010 Free Software Foundation, Inc.
 ;;;
 ;;; This library is free software; you can redistribute it and/or
 ;;; modify it under the terms of the GNU Lesser General Public
                          (frame-instruction-pointer frame))
     ;; case 1
     => (lambda (formals)
-         (let lp ((formals formals))
+         (let lp ((formals formals) (i 0))
            (pmatch formals
              (() '())
              ((,x . ,rest) (guard (symbol? x))
-              (cons (frame-binding-ref frame x) (lp rest)))
-             ((,x . ,rest)
-              ;; could be a keyword
-              (cons x (lp rest)))
+              (cons (frame-binding-ref frame x) (lp rest (1+ i))))
+             ((,x . ,rest) (guard (keyword? x))
+              (cons x (lp rest i)))
+             ((,x . ,rest) (guard (not x) (< i (frame-num-locals frame)))
+              ;; an arg, but we don't know the name. ref by index.
+              (cons (frame-local-ref frame i) (lp rest (1+ i))))
              (,rest (guard (symbol? rest))
               (frame-binding-ref frame rest))
+             (,rest (guard (not rest) (< i (frame-num-locals frame)))
+              ;; again, no name.
+              (frame-local-ref frame i))
              ;; let's not error here, as we are called during
              ;; backtraces...
              (else '???)))))