34 |
|
|
35 |
;; Introduction: |
;; Introduction: |
36 |
;; ============= |
;; ============= |
37 |
;; A simple trace package that utilizes advice.el. It generates trace |
;; A simple trace package that utilizes advice.el. It generates trace |
38 |
;; information in a Lisp-style fashion and inserts it into a trace output |
;; information in a Lisp-style fashion and inserts it into a trace output |
39 |
;; buffer. Tracing can be done in the background (or silently) so that |
;; buffer. Tracing can be done in the background (or silently) so that |
40 |
;; generation of trace output won't interfere with what you are currently |
;; generation of trace output won't interfere with what you are currently |
87 |
;; (if (= n 0) 1 |
;; (if (= n 0) 1 |
88 |
;; (* n (fact (1- n))))) |
;; (* n (fact (1- n))))) |
89 |
;; fact |
;; fact |
90 |
;; |
;; |
91 |
;; (trace-function 'fact) |
;; (trace-function 'fact) |
92 |
;; fact |
;; fact |
93 |
;; |
;; |
111 |
;; |
;; |
112 |
;; |
;; |
113 |
;; (defun ack (x y z) |
;; (defun ack (x y z) |
114 |
;; (if (= x 0) |
;; (if (= x 0) |
115 |
;; (+ y z) |
;; (+ y z) |
116 |
;; (if (and (<= x 2) (= z 0)) |
;; (if (and (<= x 2) (= z 0)) |
117 |
;; (1- x) |
;; (1- x) |
118 |
;; (if (and (> x 2) (= z 0)) |
;; (if (and (> x 2) (= z 0)) |
119 |
;; y |
;; y |
120 |
;; (ack (1- x) y (ack x y (1- z))))))) |
;; (ack (1- x) y (ack x y (1- z))))))) |
121 |
;; ack |
;; ack |
128 |
;; (ack 3 3 1) |
;; (ack 3 3 1) |
129 |
;; 27 |
;; 27 |
130 |
;; |
;; |
131 |
;; |
;; |
132 |
;; The following does something similar to the functionality of the package |
;; The following does something similar to the functionality of the package |
133 |
;; log-message.el by Robert Potter, which is giving you a chance to look at |
;; log-message.el by Robert Potter, which is giving you a chance to look at |
134 |
;; messages that might have whizzed by too quickly (you won't see subr |
;; messages that might have whizzed by too quickly (you won't see subr |
264 |
(defun trace-function (function &optional buffer) |
(defun trace-function (function &optional buffer) |
265 |
"Traces FUNCTION with trace output going to BUFFER. |
"Traces FUNCTION with trace output going to BUFFER. |
266 |
For every call of FUNCTION Lisp-style trace messages that display argument |
For every call of FUNCTION Lisp-style trace messages that display argument |
267 |
and return values will be inserted into BUFFER. This function generates the |
and return values will be inserted into BUFFER. This function generates the |
268 |
trace advice for FUNCTION and activates it together with any other advice |
trace advice for FUNCTION and activates it together with any other advice |
269 |
there might be!! The trace BUFFER will popup whenever FUNCTION is called. |
there might be!! The trace BUFFER will popup whenever FUNCTION is called. |
270 |
Do not use this to trace functions that switch buffers or do any other |
Do not use this to trace functions that switch buffers or do any other |
279 |
(defun trace-function-background (function &optional buffer) |
(defun trace-function-background (function &optional buffer) |
280 |
"Traces FUNCTION with trace output going quietly to BUFFER. |
"Traces FUNCTION with trace output going quietly to BUFFER. |
281 |
For every call of FUNCTION Lisp-style trace messages that display argument |
For every call of FUNCTION Lisp-style trace messages that display argument |
282 |
and return values will be inserted into BUFFER. This function generates the |
and return values will be inserted into BUFFER. This function generates the |
283 |
trace advice for FUNCTION and activates it together with any other advice |
trace advice for FUNCTION and activates it together with any other advice |
284 |
there might be!! Trace output will quietly go to BUFFER without changing |
there might be!! Trace output will quietly go to BUFFER without changing |
285 |
the window or buffer configuration at all." |
the window or buffer configuration at all." |
293 |
(defun untrace-function (function) |
(defun untrace-function (function) |
294 |
"Untraces FUNCTION and possibly activates all remaining advice. |
"Untraces FUNCTION and possibly activates all remaining advice. |
295 |
Activation is performed with `ad-update', hence remaining advice will get |
Activation is performed with `ad-update', hence remaining advice will get |
296 |
activated only if the advice of FUNCTION is currently active. If FUNCTION |
activated only if the advice of FUNCTION is currently active. If FUNCTION |
297 |
was not traced this is a noop." |
was not traced this is a noop." |
298 |
(interactive |
(interactive |
299 |
(list (ad-read-advised-function "Untrace function: " 'trace-is-traced))) |
(list (ad-read-advised-function "Untrace function: " 'trace-is-traced))) |