From: Juho S. <js...@ik...> - 2005-05-04 17:15:49
|
On Wed, May 04, 2005 at 11:06:14AM -0400, Will M. Farr wrote: > Is there a way to get ahold of the actual code vector addresses of the > function associated with a given symbol? I'm thinking of a command > like > > (code-vector-begin (symbol-function 'f)) => 0x..... > (code-vector-end (symbol-function 'f)) => 0x.... + a bit Something like the following should work: (defun function-code-bounds (fun) (let* ((info (sb-di::fun-debug-fun fun)) (cdf (sb-di::compiled-debug-fun-compiler-debug-fun info)) (start-offset (sb-c::compiled-debug-fun-start-pc cdf)) (end-offset (sb-c::compiled-debug-fun-elsewhere-pc cdf)) (component (sb-di::compiled-debug-fun-component info)) (start-pc (sb-sprof::code-start component))) (values (+ start-pc start-offset) (+ start-pc end-offset)))) (function-code-bounds #'foo) Note that the code uses unsupported internal interfaces, and might break at any time. Also note that the GC might move the functions around (SB-SPROF automatically adjusts for this), so you need to run SB-EXT:PURIFY before taking the offsets/running your tests. -- Juho Snellman |