summaryrefslogtreecommitdiff
path: root/module/system/vm/program.scm
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2014-05-01 14:26:20 +0200
committerAndy Wingo <wingo@pobox.com>2014-05-01 14:26:20 +0200
commitde0233af177806ac96d535bb58f27875fb8c5375 (patch)
tree2df38f60a3a772f10d8b351dde2054892ebf5ca0 /module/system/vm/program.scm
parentd7a67c3e918acd8ca46dc7792a8ca98b33cb94e8 (diff)
downloadguile-de0233af177806ac96d535bb58f27875fb8c5375.tar.gz
Fix inner and outer stack cuts to match on procedure code
* doc/ref/api-debug.texi (Stack Capture): Update make-stack docs. * libguile/programs.h: * libguile/programs.c (scm_program_address_range): New internal procedure. * libguile/stacks.c (narrow_stack): Interpret a pair of integers as an address range. If a cut is a procedure, attempt to resolve it to an address range. (scm_make_stack): Update docstring. * module/system/vm/program.scm (program-address-range): New exported procedure. * module/statprof.scm (statprof, gcprof): Use program-address-range to get the outer-cut, for efficiency.
Diffstat (limited to 'module/system/vm/program.scm')
-rw-r--r--module/system/vm/program.scm11
1 files changed, 11 insertions, 0 deletions
diff --git a/module/system/vm/program.scm b/module/system/vm/program.scm
index 5344d3882..8f19c5468 100644
--- a/module/system/vm/program.scm
+++ b/module/system/vm/program.scm
@@ -28,6 +28,8 @@
source:line-for-user
program-sources program-sources-pre-retire program-source
+ program-address-range
+
program-arities program-arity arity:start arity:end
arity:nreq arity:nopt arity:rest? arity:kw arity:allow-other-keys?
@@ -97,6 +99,15 @@
(lp s sources)
source)))))
+(define (program-address-range program)
+ "Return the start and end addresses of @var{program}'s code, as a pair
+of integers."
+ (let ((pdi (find-program-debug-info (program-code program))))
+ (and pdi
+ (cons (program-debug-info-addr pdi)
+ (+ (program-debug-info-addr pdi)
+ (program-debug-info-size pdi))))))
+
;; Source information could in theory be correlated with the ip of the
;; instruction, or the ip just after the instruction is retired. Guile
;; does the latter, to make backtraces easy -- an error produced while