annotate lisp/energize/backtrace-logging.el @ 149:538048ae2ab8 r20-3b1

Import from CVS: tag r20-3b1
author cvs
date Mon, 13 Aug 2007 09:36:16 +0200
parents 131b0175ea99
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; -*- Mode: EMACS-LISP; Syntax: E-Lisp; Base: 10 -*-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;;; backtrace-logging.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;; User code for interacting with backtrace logging.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;; ***************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;; Revision: 29-Jan-92 12:14:49
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;; Programmer: Harlan Sexton
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;; Edit-History:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; Created: 30-Aug-91 by hbs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;; End-of-Edit-History
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 (defvar *btl-index-counter* 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 (defvar *btl-data-file* nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 (defvar *btl-indices-assigned* nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 (defvar elisp-only-btl nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 (defvar cadillac-id-tag-save 'cadillac-id-tag-save)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 (defun assign-btl-indices (&optional force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 (if (or force
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 (not *btl-indices-assigned*))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 (mapatoms 'assign-btl-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 (setq *btl-indices-assigned* t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (defun btl-compiled-p (function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (or (subrp function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (compiled-function-p function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (and (consp function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (eq (car function) 'lambda)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (let ((rest (cdr (cdr function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (quit nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (while (and rest (not quit))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (let ((trial (car rest)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (if (consp trial)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (setq quit (eq (car trial) 'byte-code)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (setq rest (cdr rest))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 quit))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (defun get-btl-index (symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (if (symbolp symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (let ((val (or (get symbol cadillac-id-tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (get symbol 'cadillac-id-tag-save))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (if (and val (integerp val) (> val 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 val
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (setq val *btl-index-counter*)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (setq *btl-index-counter* (1+ *btl-index-counter*))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 val)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (defun disable-btl-index (symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (if (symbolp symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (let ((val (or (get symbol cadillac-id-tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (get symbol 'cadillac-id-tag-save))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (if (and val (integerp val) (> val 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (put symbol 'cadillac-id-tag-save val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (remprop symbol cadillac-id-tag))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (defun assign-btl-index (symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (if (and (symbolp symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (fboundp symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (let* ((function (symbol-function symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (subr-function (subrp function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (compiled-function (btl-compiled-p function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (tagged-function (get symbol cadillac-id-tag)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (cond ((and elisp-only-btl compiled-function (not tagged-function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (put symbol cadillac-id-tag (get-btl-index symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ((and (not elisp-only-btl) subr-function tagged-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (disable-btl-index symbol))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (defun file-to-btl-data-file (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (let ((base-dir (expand-file-name "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (if (string-equal base-dir file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (setq file nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (setq file (or file *btl-data-file*))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (let ((go-ahead nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (if (or (not (stringp file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (file-directory-p file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (setq go-ahead nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (if (file-exists-p file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (setq go-ahead
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (y-or-n-p (message "File exists -- overwrite %s? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (setq go-ahead t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (if (not go-ahead)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (error "Bad data file.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (defun btl-init (file &optional pc-logging)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (setq file (file-to-btl-data-file file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (let ((log-type (if pc-logging "PC logging" "btl")))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
98 (message "Initializing %s..." log-type)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (sit-for 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (assign-btl-indices t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (setq *btl-data-file* file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (if pc-logging
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (initialize-pc-logging-internal file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (initialize-backtrace-logging-internal file))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
105 (message "Initializing %s...done." log-type)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (sit-for 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (message "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (sit-for 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (defun start-btl (file &optional elisp-flag-val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (interactive "FFile in which to write data: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (terminate-logging)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (setq elisp-only-btl elisp-flag-val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (btl-init file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (start-logging))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (defun start-btl-elisp (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (interactive "FFile in which to write data: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (start-btl file t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (defun consing-btl (file &optional elisp-flag-val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (interactive "FFile in which to write data: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (terminate-logging)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (setq elisp-only-btl elisp-flag-val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (set-log-signal 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (btl-init file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (start-logging))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (defun consing-btl-elisp (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (interactive "FFile in which to write data: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (consing-btl file t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (defun set-elisp-btl (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (setq elisp-only-btl (eql arg 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (defun start-pcl (file &optional elisp-flag-val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (interactive "FFile in which to write data: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (setq elisp-only-btl elisp-flag-val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (btl-init file t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (start-logging))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (defun start-pcl-elisp (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (interactive "FFile in which to write data: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (start-pcl file t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (defun suspend-btl ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (stop-logging))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (defun suspend-pcl ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (stop-logging))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (defun resume-btl ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (start-logging))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (defun resume-pcl ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (start-logging))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (defun stop-btl ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (terminate-logging))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (defun stop-pcl ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (terminate-logging))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (defun show-btl ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (terminate-logging)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (switch-to-buffer (get-buffer-create "*BTL Log Info*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (buffer-disable-undo (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (if *btl-data-file*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (summarize-logging *btl-data-file*)))