X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=contrib%2Fsb-sprof%2Fsb-sprof.lisp;h=7d2374edb912b1f4cf5ce7cf040c5ba8ddce2542;hb=4d0b87793a047baecf2403455ddca1a82f44a41b;hp=3b6aad6990a7237b6a1411c486524c6b866971ec;hpb=2db410feb35e7e30c95af8f20f67e6177fa92488;p=sbcl.git diff --git a/contrib/sb-sprof/sb-sprof.lisp b/contrib/sb-sprof/sb-sprof.lisp index 3b6aad6..7d2374e 100644 --- a/contrib/sb-sprof/sb-sprof.lisp +++ b/contrib/sb-sprof/sb-sprof.lisp @@ -483,7 +483,7 @@ profiling") 'trace-start)) (incf (samples-index samples) 2)) -;;; List of thread currently profiled, or T for all threads. +;;; List of thread currently profiled, or :ALL for all threads. (defvar *profiled-threads* nil) (declaim (type (or list (member :all)) *profiled-threads*)) @@ -492,9 +492,10 @@ profiling") (defun profiled-threads () (let ((profiled-threads *profiled-threads*)) - (if (eq :all profiled-threads) - (remove *timer-thread* (sb-thread:list-all-threads)) - profiled-threads))) + (remove *timer-thread* + (if (eq :all profiled-threads) + (sb-thread:list-all-threads) + profiled-threads)))) (defun profiled-thread-p (thread) (let ((profiled-threads *profiled-threads*)) @@ -508,7 +509,8 @@ profiling") (defvar *profiler-lock* (sb-thread:make-mutex :name "Statistical Profiler")) (defvar *distribution-lock* (sb-thread:make-mutex :name "Wallclock profiling lock")) - (define-alien-routine pthread-kill int (signal int) (os-thread unsigned-long)) + (declaim (inline pthread-kill)) + (define-alien-routine pthread-kill int (os-thread unsigned-long) (signal int)) ;;; A random thread will call this in response to either a timer firing, ;;; This in turn will distribute the notice to those threads we are @@ -562,14 +564,11 @@ profiling") (with-alien ((scp (* os-context-t) :local scp)) (let* ((pc-ptr (sb-vm:context-pc scp)) (fp (sb-vm::context-register scp #.sb-vm::ebp-offset))) - ;; For some reason completely bogus small values for the - ;; frame pointer are returned every now and then, leading - ;; to segfaults. Try to avoid these cases. - ;; - ;; FIXME: Do a more thorough sanity check on ebp, or figure - ;; out why this is happening. - ;; -- JES, 2005-01-11 - (when (< fp 4096) + ;; foreign code might not have a useful frame + ;; pointer in ebp/rbp, so make sure it looks + ;; reasonable before walking the stack + (unless (sb-di::control-stack-pointer-valid-p (sb-sys:int-sap fp)) + (record samples pc-ptr) (return-from sigprof-handler nil)) (incf (samples-trace-count samples)) (pushnew self (samples-sampled-threads samples)) @@ -801,7 +800,7 @@ The following keyword args are recognized: (let ((alloc-signal (1- alloc-interval))) #+sb-thread (progn - (when (eq t threads) + (when (eq :all threads) ;; Set the value new threads inherit. (sb-thread::with-all-threads-lock (setf sb-thread::*default-alloc-signal* alloc-signal))) @@ -1262,7 +1261,9 @@ The following keyword args are recognized: Value of this function is a CALL-GRAPH object representing the resulting call-graph, or NIL if there are no samples (eg. right after -calling RESET.)" +calling RESET.) + +Profiling is stopped before the call graph is generated." (cond (*samples* (let ((graph (or call-graph (make-call-graph most-positive-fixnum)))) (ecase type