author | Claus Gittinger <cg@exept.de> |
Sun, 03 Sep 2000 16:45:21 +0200 | |
changeset 970 | 116aa95d7b97 |
parent 957 | 54dade11e57f |
child 972 | 45ca50da1bfa |
permissions | -rw-r--r-- |
8 | 1 |
" |
2 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
11 | 3 |
All Rights Reserved |
8 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
950 | 13 |
"{ Package: 'stx:libbasic3' }" |
14 |
||
120 | 15 |
Object subclass:#MessageTracer |
735 | 16 |
instanceVariableNames:'traceDetail tracedBlock' |
150
54b6185e9aa7
compile without updating changes-file (also disables historyManager for the wrap)
Claus Gittinger <cg@exept.de>
parents:
120
diff
changeset
|
17 |
classVariableNames:'BreakpointSignal CallingLevel BreakBlock TraceSenderBlock |
664 | 18 |
TraceSenderBlock2 LeaveBreakBlock LeaveTraceBlock MethodCounts |
19 |
MethodMemoryUsage MethodTiming TraceFullBlock TraceFullBlock2 |
|
694
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
20 |
ObjectWrittenBreakpointSignal ObjectCopyHolders TimeForWrappers' |
150
54b6185e9aa7
compile without updating changes-file (also disables historyManager for the wrap)
Claus Gittinger <cg@exept.de>
parents:
120
diff
changeset
|
21 |
poolDictionaries:'' |
54b6185e9aa7
compile without updating changes-file (also disables historyManager for the wrap)
Claus Gittinger <cg@exept.de>
parents:
120
diff
changeset
|
22 |
category:'System-Debugging-Support' |
8 | 23 |
! |
24 |
||
970 | 25 |
MessageTracer subclass:#InteractionCollector |
735 | 26 |
instanceVariableNames:'' |
27 |
classVariableNames:'' |
|
28 |
poolDictionaries:'' |
|
29 |
privateIn:MessageTracer |
|
30 |
! |
|
31 |
||
970 | 32 |
MessageTracer subclass:#PrintingMessageTracer |
735 | 33 |
instanceVariableNames:'' |
734 | 34 |
classVariableNames:'' |
35 |
poolDictionaries:'' |
|
36 |
privateIn:MessageTracer |
|
37 |
! |
|
38 |
||
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
39 |
!MessageTracer class methodsFor:'documentation'! |
8 | 40 |
|
9 | 41 |
copyright |
42 |
" |
|
43 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
11 | 44 |
All Rights Reserved |
9 | 45 |
|
46 |
This software is furnished under a license and may be used |
|
47 |
only in accordance with the terms of that license and with the |
|
48 |
inclusion of the above copyright notice. This software may not |
|
49 |
be provided or otherwise made available to, or used by, any |
|
50 |
other person. No title to or ownership of the software is |
|
51 |
hereby transferred. |
|
52 |
" |
|
53 |
! |
|
54 |
||
8 | 55 |
documentation |
56 |
" |
|
11 | 57 |
This class provides a common home for the tracing |
58 |
facilities (originally, they where in Object, but have been moved to |
|
8 | 59 |
allow easier separation of development vs. runtime configurations. |
60 |
||
11 | 61 |
tracing execution of a block: |
62 |
||
236 | 63 |
MessageTracer trace:[ ... ] |
11 | 64 |
|
236 | 65 |
MessageTracer traceFull:[ ... ] |
11 | 66 |
|
825 | 67 |
(for system developer only:) |
11 | 68 |
|
236 | 69 |
MessageTracer debugTrace:[ ... ] |
11 | 70 |
|
71 |
||
8 | 72 |
trapping sends to a specific object: |
73 |
||
236 | 74 |
MessageTracer trap:anObject selector:aSelector |
75 |
... |
|
76 |
MessageTracer untrap:anObject selector:aSelector |
|
77 |
or: |
|
78 |
MessageTracer untrap:anObject |
|
11 | 79 |
|
8 | 80 |
|
81 |
||
27 | 82 |
trapping some messages sent to a specific object: |
83 |
||
236 | 84 |
MessageTracer trap:anObject selectors:aCollectionOfSelectors |
85 |
... |
|
86 |
MessageTracer untrap:anObject |
|
27 | 87 |
|
88 |
||
89 |
||
90 |
trapping any message sent to a specific object: |
|
91 |
||
236 | 92 |
MessageTracer trapAll:anObject |
93 |
... |
|
94 |
MessageTracer untrap:anObject |
|
27 | 95 |
|
96 |
||
97 |
||
8 | 98 |
trapping evaluation of a specific method: |
99 |
||
236 | 100 |
MessageTracer trapMethod:aMethod |
101 |
... |
|
102 |
MessageTracer unwrapMethod:aMethod |
|
8 | 103 |
|
104 |
||
105 |
||
12 | 106 |
trapping evaluation of a specific method with |
107 |
receiver being an instance of some class: |
|
108 |
||
236 | 109 |
MessageTracer trapMethod:aMethod forInstancesOf:aClass |
110 |
... |
|
111 |
MessageTracer unwrapMethod:aMethod |
|
12 | 112 |
|
113 |
||
114 |
||
8 | 115 |
tracing sends to a specific object: |
116 |
||
236 | 117 |
MessageTracer trace:anObject selector:aSelector |
118 |
... |
|
119 |
MessageTracer untrace:anObject selector:aSelector |
|
120 |
or: |
|
121 |
MessageTracer untrace:anObject |
|
11 | 122 |
|
8 | 123 |
|
124 |
||
125 |
tracing sender only: |
|
126 |
||
236 | 127 |
MessageTracer traceSender:anObject selector:aSelector |
128 |
... |
|
129 |
MessageTracer untrace:anObject selector:aSelector |
|
130 |
or: |
|
131 |
MessageTracer untrace:anObject |
|
11 | 132 |
|
8 | 133 |
|
134 |
||
135 |
tracing evaluation of a specific method: |
|
136 |
||
236 | 137 |
MessageTracer traceMethod:aMethod |
138 |
... |
|
139 |
MessageTracer unwrapmethod:aMethod |
|
18 | 140 |
|
141 |
see more in examples and in method comments. |
|
236 | 142 |
|
143 |
[author:] |
|
144 |
Claus Gittinger |
|
8 | 145 |
" |
12 | 146 |
! |
147 |
||
148 |
examples |
|
149 |
" |
|
150 |
For the common cases, you will find a menu entry in the SystemBrowser. |
|
151 |
Howeever, more special cases (especially with condition checks) can be |
|
152 |
set up by evaluating the lower level entries. |
|
153 |
||
154 |
||
155 |
trapping specific methods: |
|
156 |
(by class/selector): |
|
244 | 157 |
[exBegin] |
12 | 158 |
MessageTracer trapClass:Collection selector:#select:. |
591 | 159 |
Dictionary new select:[:e | ]. 'not caught - Dictionary has its own select'. |
160 |
(Array new:10) select:[:e | ]. 'not caught - SeqColl has its own select'. |
|
161 |
Set new select:[:e | ]. 'caught - Set inherits this from Collection'. |
|
12 | 162 |
MessageTracer untrapClass:Collection |
244 | 163 |
[exEnd] |
12 | 164 |
|
165 |
(by method): |
|
244 | 166 |
[exBegin] |
12 | 167 |
MessageTracer trapMethod:(Collection compiledMethodAt:#select:). |
591 | 168 |
Dictionary new select:[:e | ]. 'not caught - Dictionary has its own select'. |
169 |
(Array new:10) select:[:e | ]. 'not caught - SeqColl has its own select'. |
|
170 |
Set new select:[:e | ]. 'caught - Set inherits this from Collection'. |
|
12 | 171 |
MessageTracer unwrapMethod:(Collection compiledMethodAt:#select:). |
244 | 172 |
[exEnd] |
12 | 173 |
|
27 | 174 |
(by method & instance class): |
244 | 175 |
[exBegin] |
27 | 176 |
MessageTracer trapMethod:(SequenceableCollection compiledMethodAt:#select:) |
244 | 177 |
forInstancesOf:SortedCollection. |
591 | 178 |
Dictionary new select:[:e | ]. 'not caught - Dictionary has its own select'. |
179 |
(Array new:10) select:[:e | ]. 'not caught - not a SortedCollection'. |
|
180 |
OrderedCollection new select:[:e | ]. 'not caught - not a SortedCollection'. |
|
181 |
SortedCollection new select:[:e | ]. 'caught - Set inherits this from Collection'. |
|
27 | 182 |
MessageTracer unwrapMethod:(SequenceableCollection compiledMethodAt:#select:). |
244 | 183 |
[exEnd] |
27 | 184 |
|
12 | 185 |
tracing specific methods: |
186 |
(by class/selector): |
|
244 | 187 |
[exBegin] |
12 | 188 |
MessageTracer traceClass:SequenceableCollection selector:#quickSortFrom:to:. |
189 |
#(6 1 9 66 2 17) copy sort. |
|
190 |
MessageTracer untraceClass:SequenceableCollection |
|
244 | 191 |
[exEnd] |
12 | 192 |
|
193 |
(by method): |
|
244 | 194 |
[exBegin] |
12 | 195 |
MessageTracer traceMethod:(SequenceableCollection compiledMethodAt:#quickSortFrom:to:). |
196 |
#(6 1 9 66 2 17) copy sort. |
|
197 |
MessageTracer unwrapMethod:(SequenceableCollection compiledMethodAt:#quickSortFrom:to:). |
|
244 | 198 |
[exEnd] |
27 | 199 |
|
200 |
object trapping: |
|
244 | 201 |
[exBegin] |
27 | 202 |
|o| |
203 |
||
204 |
o := OrderedCollection new. |
|
205 |
MessageTracer trapAll:o. |
|
206 |
o collect:[:el | el]. |
|
244 | 207 |
[exEnd] |
661 | 208 |
|
209 |
trapping modifications to an objects instVars: |
|
210 |
[exBegin] |
|
211 |
|o| |
|
212 |
||
213 |
o := Point new. |
|
214 |
MessageTracer trapModificationsIn:o. |
|
215 |
o x:1. |
|
216 |
o y:2. |
|
217 |
o x:1. |
|
218 |
o y:2. |
|
219 |
MessageTracer untrap:o |
|
220 |
[exEnd] |
|
221 |
||
222 |
trapping modifications of a particular instVar: |
|
223 |
[exBegin] |
|
224 |
|o| |
|
225 |
||
226 |
o := Point new. |
|
227 |
MessageTracer trapModificationsIn:o filter:[:old :new | old x ~~ new x]. |
|
228 |
o x:1. |
|
229 |
o y:2. |
|
230 |
o x:1. |
|
231 |
o y:2. |
|
232 |
MessageTracer untrap:o |
|
233 |
[exEnd] |
|
12 | 234 |
" |
8 | 235 |
! ! |
236 |
||
664 | 237 |
!MessageTracer class methodsFor:'Signal constants'! |
238 |
||
239 |
breakpointSignal |
|
240 |
^ BreakpointSignal |
|
241 |
! |
|
242 |
||
243 |
objectWrittenBreakpointSignal |
|
244 |
^ ObjectWrittenBreakpointSignal |
|
245 |
||
246 |
"Created: / 21.4.1998 / 14:38:49 / cg" |
|
247 |
! ! |
|
248 |
||
249 |
!MessageTracer class methodsFor:'class initialization'! |
|
11 | 250 |
|
251 |
initialize |
|
252 |
BreakpointSignal isNil ifTrue:[ |
|
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
253 |
BreakpointSignal := HaltSignal newSignalMayProceed:true. |
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
254 |
BreakpointSignal nameClass:self message:#breakpointSignal. |
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
255 |
BreakpointSignal notifierString:'breakpoint encountered'. |
27 | 256 |
|
660 | 257 |
ObjectWrittenBreakpointSignal := BreakpointSignal newSignalMayProceed:true. |
258 |
ObjectWrittenBreakpointSignal nameClass:self message:#objectWrittenBreakpointSignal. |
|
259 |
ObjectWrittenBreakpointSignal notifierString:'object modified'. |
|
260 |
||
695 | 261 |
"/ the following have been written as cheapBlocks (by purpose) |
809 | 262 |
BreakBlock := [:con | BreakpointSignal raiseRequestWith:nil errorString:nil in:con]. |
664 | 263 |
TraceSenderBlock := [:con | MessageTracer printEntrySender:con on:(Smalltalk at:#Stderr) ]. |
264 |
TraceSenderBlock2 := [:con | MessageTracer printEntrySender:con on:(Smalltalk at:#Transcript) ]. |
|
695 | 265 |
TraceFullBlock := [:con | MessageTracer traceEntryFull:con on:(Smalltalk at:#Stderr) ]. |
266 |
TraceFullBlock2 := [:con | MessageTracer traceEntryFull:con on:(Smalltalk at:#Transcript) ]. |
|
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
267 |
LeaveBreakBlock := [:con :retVal | ]. |
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
268 |
LeaveTraceBlock := [:con :retVal | ]. |
694
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
269 |
]. |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
270 |
|
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
271 |
ObjectMemory addDependent:self. |
156 | 272 |
|
273 |
" |
|
274 |
BreakpointSignal := nil. |
|
275 |
MessageTracer initialize |
|
276 |
" |
|
277 |
||
695 | 278 |
"Modified: / 30.7.1998 / 20:41:29 / cg" |
694
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
279 |
! |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
280 |
|
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
281 |
update:something with:parameter from:changedObject |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
282 |
"sent when restarted after a snapIn" |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
283 |
|
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
284 |
(something == #restarted) ifTrue:[ |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
285 |
TimeForWrappers := nil |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
286 |
] |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
287 |
|
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
288 |
"Created: / 30.7.1998 / 17:00:09 / cg" |
11 | 289 |
! ! |
290 |
||
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
291 |
!MessageTracer class methodsFor:'class tracing'! |
88 | 292 |
|
293 |
untraceAllClasses |
|
294 |
"remove all traces of messages sent to any class" |
|
295 |
||
296 |
"just a rename for your convenience - the same basic mechanism is used for all of these |
|
297 |
trace facilities ..." |
|
298 |
||
299 |
^ self untrapAllClasses |
|
300 |
! |
|
301 |
||
302 |
untraceClass:aClass |
|
303 |
"remove all traces of messages sent to instances of aClass" |
|
304 |
||
305 |
"just a rename for your convenience - the same basic mechanism is used for all of these |
|
306 |
trace facilities ..." |
|
307 |
||
308 |
^ self untrapClass:aClass |
|
309 |
! ! |
|
310 |
||
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
311 |
!MessageTracer class methodsFor:'class wrapping'! |
88 | 312 |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
313 |
wrapClass:orgClass selector:aSelector onEntry:entryBlock onExit:exitBlock |
88 | 314 |
"arrange for the two blocks entryBlock and exitBlock to be evaluated whenever |
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
315 |
aSelector is sent to instances of orgClass or subclasses. |
88 | 316 |
EntryBlock will be called on entry, and get the current context passed as argument. |
317 |
ExitBlock will be called, when the method is left, and get context and the methods return value as arguments. |
|
318 |
" |
|
319 |
||
352
ac12b5bc2754
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
327
diff
changeset
|
320 |
|myMetaclass trapMethod s spec implClass newClass save dict| |
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
321 |
|
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
322 |
WrappedMethod autoload. "/ just to make sure ... |
88 | 323 |
|
324 |
" |
|
325 |
create a new method, which calls the original one, |
|
326 |
but only if not already being trapped. |
|
327 |
" |
|
328 |
spec := Parser methodSpecificationForSelector:aSelector. |
|
329 |
||
330 |
s := WriteStream on:String new. |
|
331 |
s nextPutAll:spec. |
|
332 |
s cr. |
|
333 |
s nextPutAll:'|retVal stubClass|'; cr. |
|
334 |
entryBlock notNil ifTrue:[ |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
335 |
s nextPutAll:'#literal1 yourself value:thisContext.'; cr. |
88 | 336 |
]. |
352
ac12b5bc2754
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
327
diff
changeset
|
337 |
s nextPutAll:('retVal := #originalMethod. '). "/ just to get a literal to be replaced by theoriginal method |
88 | 338 |
s nextPutAll:('retVal := super ' , spec , '.'); cr. |
339 |
exitBlock notNil ifTrue:[ |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
340 |
s nextPutAll:'#literal2 yourself value:thisContext value:retVal.'; cr. |
88 | 341 |
]. |
342 |
s nextPutAll:'^ retVal'; cr. |
|
343 |
||
344 |
save := Compiler stcCompilation. |
|
345 |
Compiler stcCompilation:#never. |
|
346 |
[ |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
347 |
Class withoutUpdatingChangesDo:[ |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
348 |
trapMethod := Compiler compile:s contents |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
349 |
forClass:orgClass |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
350 |
inCategory:'trapping' |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
351 |
notifying:nil |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
352 |
install:false |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
353 |
skipIfSame:false |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
354 |
silent:true. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
355 |
] |
88 | 356 |
] valueNowOrOnUnwindDo:[ |
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
357 |
Compiler stcCompilation:save |
88 | 358 |
]. |
359 |
||
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
360 |
implClass := orgClass whichClassIncludesSelector:aSelector. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
361 |
implClass isNil ifTrue:[ |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
362 |
Transcript showCR:aSelector , ' is not understood by ' , orgClass name. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
363 |
] ifFalse:[ |
352
ac12b5bc2754
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
327
diff
changeset
|
364 |
trapMethod changeLiteral:#originalMethod to:(implClass compiledMethodAt:aSelector). |
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
365 |
]. |
88 | 366 |
entryBlock notNil ifTrue:[ |
352
ac12b5bc2754
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
327
diff
changeset
|
367 |
trapMethod changeLiteral:#literal1 to:entryBlock. |
88 | 368 |
]. |
369 |
exitBlock notNil ifTrue:[ |
|
352
ac12b5bc2754
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
327
diff
changeset
|
370 |
trapMethod changeLiteral:#literal2 to:exitBlock. |
88 | 371 |
]. |
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
372 |
|
88 | 373 |
" |
374 |
change the source of this new method |
|
375 |
(to avoid confusion in the debugger ...) |
|
376 |
" |
|
377 |
trapMethod source:'this is a wrapper method - not the real one'. |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
378 |
trapMethod changeClassTo:WrappedMethod. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
379 |
|
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
380 |
dict := orgClass methodDictionary. |
88 | 381 |
|
382 |
" |
|
383 |
if not already trapping, create a new class |
|
384 |
" |
|
457
8ba8e7ac735d
use #'* trapping *' instead of #trapping as category mark
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
385 |
orgClass category == #'* trapping *' ifTrue:[ |
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
386 |
dict at:aSelector put:trapMethod. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
387 |
orgClass methodDictionary:dict. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
388 |
newClass := orgClass superclass. |
88 | 389 |
] ifFalse:[ |
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
390 |
myMetaclass := orgClass class. |
88 | 391 |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
392 |
newClass := myMetaclass copy new. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
393 |
newClass setSuperclass:orgClass superclass. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
394 |
newClass instSize:orgClass instSize. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
395 |
newClass flags:orgClass flags. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
396 |
newClass setClassVariableString:orgClass classVariableString. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
397 |
newClass setInstanceVariableString:orgClass instanceVariableString. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
398 |
newClass setName:orgClass name. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
399 |
newClass category:orgClass category. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
400 |
newClass methodDictionary:dict. |
88 | 401 |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
402 |
orgClass setSuperclass:newClass. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
403 |
orgClass setClassVariableString:''. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
404 |
orgClass setInstanceVariableString:''. |
457
8ba8e7ac735d
use #'* trapping *' instead of #trapping as category mark
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
405 |
orgClass category:#'* trapping *'. |
88 | 406 |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
407 |
dict := MethodDictionary new:1. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
408 |
dict at:aSelector put:trapMethod. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
409 |
orgClass methodDictionary:dict. |
88 | 410 |
]. |
352
ac12b5bc2754
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
327
diff
changeset
|
411 |
trapMethod changeLiteral:(newClass superclass) to:newClass. |
88 | 412 |
|
413 |
ObjectMemory flushCaches. |
|
414 |
||
415 |
" |
|
416 |
MessageTracer |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
417 |
wrapClass:Point |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
418 |
selector:#scaleBy: |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
419 |
onEntry:nil |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
420 |
onExit:[:con :retVal | |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
421 |
Transcript show:'leave Point>>scaleBy:; returning:'. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
422 |
Transcript showCR:retVal printString. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
423 |
Transcript endEntry |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
424 |
]. |
88 | 425 |
(1@2) scaleBy:5. |
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
426 |
MessageTracer untrapClass:Point selector:#scaleBy:. |
88 | 427 |
(1@2) scaleBy:5. |
428 |
" |
|
429 |
" |
|
430 |
MessageTracer |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
431 |
wrapClass:Integer |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
432 |
selector:#factorial |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
433 |
onEntry:[:con | |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
434 |
Transcript showCR:('entering ' , con receiver printString , '>>factorial'). |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
435 |
] |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
436 |
onExit:[:con :retVal | |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
437 |
Transcript show:'leave Integer>>factorial; returning:'. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
438 |
Transcript showCR:retVal printString. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
439 |
Transcript endEntry |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
440 |
]. |
258 | 441 |
Transcript showCR:'5 factorial traced'. |
88 | 442 |
5 factorial. |
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
443 |
MessageTracer untrapClass:Integer selector:#factorial. |
258 | 444 |
Transcript showCR:'5 factorial normal'. |
88 | 445 |
5 factorial. |
446 |
" |
|
447 |
" |
|
448 |
|lvl| |
|
449 |
||
450 |
lvl := 0. |
|
451 |
MessageTracer |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
452 |
wrapClass:Integer |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
453 |
selector:#factorial |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
454 |
onEntry:[:con | |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
455 |
Transcript spaces:lvl. lvl := lvl + 2. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
456 |
Transcript showCR:('entering ' , con receiver printString , '>>factorial'). |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
457 |
] |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
458 |
onExit:[:con :retVal | |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
459 |
lvl := lvl - 2. Transcript spaces:lvl. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
460 |
Transcript show:('leave ' , con receiver printString , '>>factorial; returning:'). |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
461 |
Transcript showCR:retVal printString. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
462 |
Transcript endEntry |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
463 |
]. |
258 | 464 |
Transcript showCR:'5 factorial traced'. |
88 | 465 |
5 factorial. |
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
466 |
MessageTracer untrapClass:Integer selector:#factorial. |
258 | 467 |
Transcript showCR:'5 factorial normal'. |
88 | 468 |
5 factorial. |
469 |
" |
|
150
54b6185e9aa7
compile without updating changes-file (also disables historyManager for the wrap)
Claus Gittinger <cg@exept.de>
parents:
120
diff
changeset
|
470 |
|
352
ac12b5bc2754
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
327
diff
changeset
|
471 |
"Modified: 25.6.1996 / 22:01:05 / stefan" |
457
8ba8e7ac735d
use #'* trapping *' instead of #trapping as category mark
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
472 |
"Modified: 10.9.1996 / 20:07:01 / cg" |
88 | 473 |
! ! |
474 |
||
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
475 |
!MessageTracer class methodsFor:'cleanup'! |
27 | 476 |
|
477 |
cleanup |
|
478 |
"if you forgot which classes/methods where wrapped and/or trapped, |
|
479 |
this cleans up everything ..." |
|
480 |
||
481 |
self untrapAllClasses. |
|
482 |
self unwrapAllMethods |
|
483 |
||
484 |
" |
|
485 |
MessageTracer cleanup |
|
486 |
" |
|
487 |
! ! |
|
488 |
||
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
489 |
!MessageTracer class methodsFor:'execution trace '! |
88 | 490 |
|
491 |
debugTrace:aBlock |
|
699
52a632386cef
some debugging methods moved from Smalltalk to ObjectMemory
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
492 |
"trace execution of aBlock. This is for system debugging only; |
52a632386cef
some debugging methods moved from Smalltalk to ObjectMemory
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
493 |
The trace output is a low level trace generated in the VM." |
52a632386cef
some debugging methods moved from Smalltalk to ObjectMemory
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
494 |
|
52a632386cef
some debugging methods moved from Smalltalk to ObjectMemory
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
495 |
ObjectMemory sendTraceOn. |
88 | 496 |
^ aBlock valueNowOrOnUnwindDo:[ |
699
52a632386cef
some debugging methods moved from Smalltalk to ObjectMemory
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
497 |
ObjectMemory sendTraceOff. |
88 | 498 |
] |
11 | 499 |
|
88 | 500 |
" |
501 |
MessageTracer debugTrace:[#(6 5 4 3 2 1) sort] |
|
502 |
" |
|
196
330cc5c849de
debugOn/Off is now called sendTraceOn/Off
Claus Gittinger <cg@exept.de>
parents:
172
diff
changeset
|
503 |
|
699
52a632386cef
some debugging methods moved from Smalltalk to ObjectMemory
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
504 |
"Modified: / 31.7.1998 / 16:39:43 / cg" |
88 | 505 |
! |
11 | 506 |
|
507 |
trace:aBlock |
|
508 |
"evaluate aBlock sending trace information to stdout. |
|
27 | 509 |
Return the value of the block." |
11 | 510 |
|
734 | 511 |
^ PrintingMessageTracer new trace:aBlock detail:false. |
11 | 512 |
|
513 |
" |
|
514 |
MessageTracer trace:[#(6 5 4 3 2 1) sort] |
|
515 |
" |
|
516 |
! |
|
517 |
||
518 |
traceFull:aBlock |
|
519 |
"evaluate aBlock sending trace information to stdout. |
|
520 |
Return the value of the block. |
|
27 | 521 |
The trace information is more detailed." |
11 | 522 |
|
734 | 523 |
^ PrintingMessageTracer new trace:aBlock detail:true. |
11 | 524 |
|
525 |
" |
|
526 |
MessageTracer traceFull:[#(6 5 4 3 2 1) sort] |
|
527 |
" |
|
734 | 528 |
! |
529 |
||
530 |
traceFullIndented:aBlock |
|
531 |
"evaluate aBlock sending trace information to stdout. |
|
532 |
Return the value of the block. |
|
533 |
The trace information is more detailed." |
|
534 |
||
535 |
^ PrintingMessageTracer new trace:aBlock detail:#fullIndent. |
|
536 |
||
537 |
" |
|
538 |
MessageTracer traceFullIndented:[ #(6 5 4 3 2 1) sort ] |
|
539 |
" |
|
540 |
! |
|
541 |
||
542 |
traceIndented:aBlock |
|
543 |
"evaluate aBlock sending trace information to stdout. |
|
544 |
Return the value of the block." |
|
545 |
||
546 |
^ PrintingMessageTracer new trace:aBlock detail:#indent. |
|
547 |
||
548 |
" |
|
549 |
MessageTracer traceIndented:[ #(6 5 4 3 2 1) sort ] |
|
550 |
" |
|
88 | 551 |
! ! |
552 |
||
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
553 |
!MessageTracer class methodsFor:'method breakpointing'! |
88 | 554 |
|
555 |
trapClass:aClass selector:aSelector |
|
556 |
"arrange for the debugger to be entered when a message with aSelector is |
|
557 |
sent to instances of aClass (or subclass instances). Use untrapClass to remove this trap. |
|
558 |
Be careful, to not place a trap on code needed in the debugger (i.e. on scrollBars etc.); |
|
559 |
if there is a need to trap those, use the low-level wrap-methods, and put a check into the |
|
560 |
entry/leave blocks." |
|
561 |
||
562 |
self trapMethod:(aClass compiledMethodAt:aSelector) |
|
563 |
||
564 |
" |
|
565 |
MessageTracer trapClass:Collection selector:#select:. |
|
591 | 566 |
Dictionary new select:[:e | ]. 'not caught - Dictionary has its own select'. |
567 |
(Array new:10) select:[:e | ]. 'not caught - SeqColl has its own select'. |
|
568 |
Set new select:[:e | ]. 'caught - Set inherits this from Collection'. |
|
88 | 569 |
MessageTracer untrapClass:Collection |
570 |
" |
|
11 | 571 |
! |
572 |
||
88 | 573 |
trapMethod:aMethod |
574 |
"arrange for the debugger to be entered when aMethod is about to be executed. |
|
495 | 575 |
The trap is enabled for any process - see #trapMethodInCurrentProcess: for a more |
576 |
selective breakPoint. |
|
88 | 577 |
Use unwrapMethod or untrapClass to remove this trap. |
578 |
Be careful, to not place a trap on code needed in the debugger (i.e. on scrollBars etc.); |
|
579 |
if there is a need to trap those, use the low-level wrap-methods, and put a check into the |
|
580 |
entry/leave blocks." |
|
581 |
||
582 |
^ self wrapMethod:aMethod |
|
495 | 583 |
onEntry:BreakBlock |
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
584 |
onExit:LeaveBreakBlock. |
88 | 585 |
|
586 |
" |
|
587 |
MessageTracer trapMethod:(Collection compiledMethodAt:#select:). |
|
591 | 588 |
Dictionary new select:[:e | ]. 'not caught - Dictionary has its own select'. |
589 |
(Array new:10) select:[:e | ]. 'not caught - SeqColl has its own select'. |
|
590 |
Set new select:[:e | ]. 'caught - Set inherits this from Collection'. |
|
88 | 591 |
MessageTracer unwrapMethod:(Collection compiledMethodAt:#select:). |
592 |
" |
|
495 | 593 |
|
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
594 |
"Modified: 22.10.1996 / 17:39:58 / cg" |
88 | 595 |
! |
11 | 596 |
|
908 | 597 |
trapMethod:aMethod after:countInvocations |
598 |
"arrange for the debugger to be entered when aMethod has been invoked countInvocations times. |
|
599 |
The trap is enabled for any process. |
|
600 |
Use unwrapMethod or untrapClass to remove this trap. |
|
601 |
Be careful, to not place a trap on code needed in the debugger (i.e. on scrollBars etc.); |
|
602 |
if there is a need to trap those, use the low-level wrap-methods, and put a check into the |
|
603 |
entry/leave blocks." |
|
604 |
||
605 |
|n| |
|
606 |
||
607 |
n := 0. |
|
608 |
^ self wrapMethod:aMethod |
|
609 |
onEntry:[:con | n := n + 1. |
|
610 |
n > countInvocations |
|
611 |
ifTrue:[ |
|
612 |
BreakpointSignal raiseRequestWith:nil errorString:nil in:con |
|
613 |
] |
|
614 |
] |
|
615 |
onExit:LeaveBreakBlock. |
|
616 |
||
617 |
! |
|
618 |
||
88 | 619 |
trapMethod:aMethod forInstancesOf:aClass |
620 |
"arrange for the debugger to be entered when aMethod is about to be executed |
|
621 |
for an instance of aClass. |
|
622 |
Use unwrapMethod or untrapClass to remove this trap. |
|
623 |
Be careful, to not place a trap on code needed in the debugger (i.e. on scrollBars etc.); |
|
624 |
if there is a need to trap those, use the low-level wrap-methods, and put a check into the |
|
625 |
entry/leave blocks." |
|
626 |
||
627 |
^ self wrapMethod:aMethod |
|
809 | 628 |
onEntry:[:con | |
629 |
(con receiver isMemberOf:aClass) ifTrue:[ |
|
630 |
BreakpointSignal raiseRequestWith:nil errorString:nil in:con |
|
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
631 |
] |
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
632 |
] |
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
633 |
onExit:LeaveBreakBlock. |
88 | 634 |
|
635 |
" |
|
636 |
MessageTracer trapMethod:(View compiledMethodAt:#redraw) forInstancesOf:myView. |
|
637 |
" |
|
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
638 |
|
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
639 |
"Modified: 22.10.1996 / 17:40:03 / cg" |
88 | 640 |
! |
641 |
||
950 | 642 |
trapMethod:aMethod if:conditionBlock |
643 |
"arrange for the debugger to be entered when aMethod has been invoked and conditionBlock |
|
644 |
evaluates to true. |
|
645 |
The trap is enabled for any process. |
|
646 |
Use unwrapMethod or untrapClass to remove this trap. |
|
647 |
Be careful, to not place a trap on code needed in the debugger (i.e. on scrollBars etc.); |
|
648 |
if there is a need to trap those, use the low-level wrap-methods, and put a check into the |
|
649 |
entry/leave blocks." |
|
650 |
||
651 |
^ self wrapMethod:aMethod |
|
652 |
onEntry:[:con | |conditionFires| |
|
653 |
||
654 |
conditionBlock numArgs == 1 ifTrue:[ |
|
655 |
conditionFires := conditionBlock value:con |
|
656 |
] ifFalse:[ |
|
657 |
conditionFires := conditionBlock value:con value:aMethod |
|
658 |
]. |
|
659 |
conditionFires ifTrue:[ |
|
660 |
BreakpointSignal raiseRequestWith:nil errorString:nil in:con |
|
661 |
] |
|
662 |
] |
|
663 |
onExit:LeaveBreakBlock. |
|
664 |
||
665 |
"Created: / 18.8.2000 / 22:09:10 / cg" |
|
666 |
! |
|
667 |
||
496 | 668 |
trapMethod:aMethod inProcess:aProcess |
495 | 669 |
"arrange for the debugger to be entered when aMethod is about to be executed, |
670 |
but only, if executed in the current process. |
|
671 |
This allows for breakpoints to be set on system-critical code. |
|
672 |
The trap is enabled for any process. |
|
673 |
Use unwrapMethod or untrapClass to remove this trap. |
|
674 |
Be careful, to not place a trap on code needed in the debugger (i.e. on scrollBars etc.); |
|
675 |
if there is a need to trap those, use the low-level wrap-methods, and put a check into the |
|
676 |
entry/leave blocks." |
|
677 |
||
678 |
^ self wrapMethod:aMethod |
|
496 | 679 |
onEntry:[:con | (Processor activeProcess == aProcess) |
495 | 680 |
ifTrue:[ |
809 | 681 |
BreakpointSignal raiseRequestWith:nil errorString:nil in:con |
495 | 682 |
] |
683 |
] |
|
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
684 |
onExit:LeaveBreakBlock. |
495 | 685 |
|
496 | 686 |
"Created: 14.10.1996 / 15:38:46 / cg" |
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
687 |
"Modified: 22.10.1996 / 17:40:06 / cg" |
495 | 688 |
! |
689 |
||
88 | 690 |
untrapAllClasses |
691 |
"remove any traps on any class" |
|
692 |
||
970 | 693 |
Smalltalk allClassesDo:[:aClass | |
694 |
self untrapClass:aClass |
|
11 | 695 |
] |
696 |
||
697 |
" |
|
88 | 698 |
MessageTracer untrapAllClasses |
699 |
" |
|
700 |
! |
|
701 |
||
702 |
untrapClass:aClass |
|
703 |
"remove any traps on aClass" |
|
704 |
||
705 |
"this is done by just patching the class back to the original" |
|
706 |
||
707 |
|orgClass| |
|
708 |
||
457
8ba8e7ac735d
use #'* trapping *' instead of #trapping as category mark
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
709 |
aClass category == #'* trapping *' ifFalse:[ |
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
710 |
^ self |
88 | 711 |
]. |
712 |
orgClass := aClass superclass. |
|
713 |
||
714 |
aClass setSuperclass:orgClass superclass. |
|
715 |
aClass setClassVariableString:orgClass classVariableString. |
|
716 |
aClass setInstanceVariableString:orgClass instanceVariableString. |
|
717 |
aClass category:orgClass category. |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
718 |
aClass methodDictionary:orgClass methodDictionary. |
88 | 719 |
|
720 |
ObjectMemory flushCaches. |
|
721 |
||
722 |
" |
|
723 |
MessageTracer untrapClass:Point |
|
11 | 724 |
" |
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
725 |
|
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
726 |
"Modified: 5.6.1996 / 13:57:39 / stefan" |
457
8ba8e7ac735d
use #'* trapping *' instead of #trapping as category mark
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
727 |
"Modified: 10.9.1996 / 20:06:23 / cg" |
88 | 728 |
! |
729 |
||
730 |
untrapClass:aClass selector:aSelector |
|
731 |
"remove trap of aSelector sent to aClass" |
|
732 |
||
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
733 |
|dict| |
88 | 734 |
|
457
8ba8e7ac735d
use #'* trapping *' instead of #trapping as category mark
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
735 |
aClass category == #'* trapping *' ifFalse:[ |
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
736 |
^ self |
88 | 737 |
]. |
738 |
||
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
739 |
dict := aClass methodDictionary. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
740 |
dict at:aSelector ifAbsent:[^ self]. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
741 |
|
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
742 |
ObjectMemory flushCaches. "avoid calling the old trap method" |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
743 |
|
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
744 |
dict size == 1 ifTrue:[ |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
745 |
"the last trapped method" |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
746 |
^ self untrapClass:aClass |
88 | 747 |
]. |
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
748 |
dict removeKey:aSelector. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
749 |
aClass methodDictionary:dict. |
88 | 750 |
|
751 |
" |
|
752 |
MessageTracer trapClass:Point selector:#copy. |
|
753 |
(1@2) copy. |
|
754 |
(1@2) deepCopy. |
|
755 |
MessageTracer trapClass:Point selector:#deepCopy. |
|
756 |
(1@2) copy. |
|
757 |
(1@2) deepCopy. |
|
758 |
MessageTracer untrapClass:Point selector:#copy. |
|
759 |
(1@2) copy. |
|
760 |
(1@2) deepCopy. |
|
761 |
MessageTracer untrapClass:Point selector:#deepCopy. |
|
762 |
(1@2) copy. |
|
763 |
(1@2) deepCopy. |
|
764 |
" |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
765 |
|
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
766 |
"Modified: 5.6.1996 / 14:00:55 / stefan" |
457
8ba8e7ac735d
use #'* trapping *' instead of #trapping as category mark
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
767 |
"Modified: 10.9.1996 / 20:06:29 / cg" |
88 | 768 |
! |
769 |
||
770 |
untrapMethod:aMethod |
|
771 |
"remove break on aMethod" |
|
772 |
||
773 |
"just a rename for your convenience - the same basic mechanism is used for all of these |
|
774 |
trace facilities ..." |
|
775 |
||
776 |
^ self unwrapMethod:aMethod |
|
11 | 777 |
! ! |
778 |
||
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
779 |
!MessageTracer class methodsFor:'method counting'! |
155 | 780 |
|
781 |
countMethod:aMethod |
|
782 |
"arrange for a aMethods execution to be counted. |
|
783 |
Use unwrapMethod to remove this." |
|
784 |
||
785 |
MethodCounts isNil ifTrue:[ |
|
691
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
786 |
MethodCounts := IdentityDictionary new. |
155 | 787 |
]. |
788 |
MethodCounts at:aMethod put:0. |
|
789 |
||
790 |
^ self wrapMethod:aMethod |
|
691
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
791 |
onEntry:[:con | |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
792 |
|cnt| |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
793 |
|
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
794 |
cnt := MethodCounts at:aMethod ifAbsent:0. |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
795 |
MethodCounts at:aMethod put:(cnt + 1). |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
796 |
aMethod changed:#statistics |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
797 |
] |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
798 |
onExit:[:con :retVal | |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
799 |
] |
155 | 800 |
|
801 |
" |
|
802 |
MessageTracer countMethod:(Integer compiledMethodAt:#factorial). |
|
803 |
5 factorial. |
|
804 |
MessageTracer executionCountOf:(Integer compiledMethodAt:#factorial) printNL. |
|
805 |
MessageTracer stopCountingMethod:(Integer compiledMethodAt:#factorial) |
|
806 |
" |
|
807 |
||
691
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
808 |
"Created: / 15.12.1995 / 10:57:49 / cg" |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
809 |
"Modified: / 27.7.1998 / 10:47:46 / cg" |
155 | 810 |
! |
811 |
||
812 |
executionCountOfMethod:aMethod |
|
813 |
"return the current count" |
|
814 |
||
815 |
|count| |
|
816 |
||
817 |
MethodCounts isNil ifTrue:[^ 0]. |
|
818 |
aMethod isWrapped ifTrue:[ |
|
172
cf44aece60d4
clear memoryUsage when unwrapping
Claus Gittinger <cg@exept.de>
parents:
164
diff
changeset
|
819 |
count := MethodCounts at:aMethod originalMethod ifAbsent:nil. |
cf44aece60d4
clear memoryUsage when unwrapping
Claus Gittinger <cg@exept.de>
parents:
164
diff
changeset
|
820 |
count notNil ifTrue:[^ count]. |
155 | 821 |
]. |
822 |
^ MethodCounts at:aMethod ifAbsent:0 |
|
823 |
||
824 |
"Created: 15.12.1995 / 11:01:56 / cg" |
|
825 |
"Modified: 15.12.1995 / 15:45:15 / cg" |
|
826 |
! |
|
827 |
||
694
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
828 |
resetCountOfMethod:aMethod |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
829 |
"return the current count" |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
830 |
|
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
831 |
MethodCounts notNil ifTrue:[ |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
832 |
aMethod isWrapped ifTrue:[ |
764
883a5f35113c
fixed reset count & reset memCount
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
833 |
MethodCounts at:aMethod originalMethod put:0. |
694
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
834 |
]. |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
835 |
]. |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
836 |
|
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
837 |
"Created: / 30.7.1998 / 17:42:08 / cg" |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
838 |
! |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
839 |
|
155 | 840 |
stopCountingMethod:aMethod |
841 |
"remove counting of aMethod" |
|
842 |
||
764
883a5f35113c
fixed reset count & reset memCount
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
843 |
MethodCounts notNil ifTrue:[ |
883a5f35113c
fixed reset count & reset memCount
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
844 |
aMethod isWrapped ifTrue:[ |
883a5f35113c
fixed reset count & reset memCount
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
845 |
MethodCounts removeKey:aMethod originalMethod ifAbsent:nil. |
883a5f35113c
fixed reset count & reset memCount
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
846 |
]. |
883a5f35113c
fixed reset count & reset memCount
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
847 |
]. |
155 | 848 |
^ self unwrapMethod:aMethod |
849 |
||
850 |
"Modified: 15.12.1995 / 15:43:53 / cg" |
|
851 |
! ! |
|
852 |
||
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
853 |
!MessageTracer class methodsFor:'method memory usage'! |
164
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
854 |
|
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
855 |
countMemoryUsageOfMethod:aMethod |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
856 |
"arrange for aMethods memory usage to be counted. |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
857 |
Use unwrapMethod to remove this." |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
858 |
|
501 | 859 |
|oldPriority oldScavengeCount oldNewUsed| |
164
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
860 |
|
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
861 |
MethodCounts isNil ifTrue:[ |
691
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
862 |
MethodCounts := IdentityDictionary new. |
164
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
863 |
]. |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
864 |
MethodMemoryUsage isNil ifTrue:[ |
691
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
865 |
MethodMemoryUsage := IdentityDictionary new. |
164
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
866 |
]. |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
867 |
|
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
868 |
MethodCounts at:aMethod put:0. |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
869 |
MethodMemoryUsage at:aMethod put:0. |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
870 |
|
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
871 |
^ self wrapMethod:aMethod |
691
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
872 |
onEntry:[:con | |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
873 |
oldPriority := Processor activeProcess changePriority:(Processor userInterruptPriority). |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
874 |
oldNewUsed := ObjectMemory newSpaceUsed. |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
875 |
oldScavengeCount := ObjectMemory scavengeCount. |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
876 |
] |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
877 |
onExit:[:con :retVal | |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
878 |
|cnt memUse scavenges| |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
879 |
|
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
880 |
memUse := ObjectMemory newSpaceUsed - oldNewUsed. |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
881 |
scavenges := ObjectMemory scavengeCount - oldScavengeCount. |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
882 |
scavenges ~= 0 ifTrue:[ |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
883 |
memUse := memUse + (ObjectMemory newSpaceSize * scavenges) |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
884 |
]. |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
885 |
|
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
886 |
MethodCounts notNil ifTrue:[ |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
887 |
cnt := MethodCounts at:aMethod ifAbsent:0. |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
888 |
MethodCounts at:aMethod put:(cnt + 1). |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
889 |
]. |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
890 |
MethodMemoryUsage notNil ifTrue:[ |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
891 |
cnt := MethodMemoryUsage at:aMethod ifAbsent:0. |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
892 |
MethodMemoryUsage at:aMethod put:(cnt + memUse). |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
893 |
]. |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
894 |
Processor activeProcess priority:oldPriority. |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
895 |
aMethod changed:#statistics |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
896 |
] |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
897 |
onUnwind:[ |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
898 |
oldPriority notNil ifTrue:[ |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
899 |
Processor activeProcess priority:oldPriority |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
900 |
] |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
901 |
] |
164
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
902 |
|
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
903 |
" |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
904 |
MessageTracer countMemoryUsageOfMethod:(Integer compiledMethodAt:#factorial). |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
905 |
3 factorial. |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
906 |
(MessageTracer memoryUsageOfMethod:(Integer compiledMethodAt:#factorial)) printNL. |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
907 |
MessageTracer stopCountingMemoryUsageOfMethod:(Integer compiledMethodAt:#factorial) |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
908 |
" |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
909 |
|
691
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
910 |
"Created: / 18.12.1995 / 15:41:27 / stefan" |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
911 |
"Modified: / 18.12.1995 / 21:46:48 / stefan" |
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
912 |
"Modified: / 27.7.1998 / 10:47:38 / cg" |
164
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
913 |
! |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
914 |
|
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
915 |
isCountingMemoryUsage:aMethod |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
916 |
"return true if aMethod is counting memoryUsage" |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
917 |
|
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
918 |
MethodMemoryUsage isNil ifTrue:[^ false]. |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
919 |
(MethodMemoryUsage includesKey:aMethod) ifTrue:[^ true]. |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
920 |
aMethod isWrapped ifTrue:[ |
172
cf44aece60d4
clear memoryUsage when unwrapping
Claus Gittinger <cg@exept.de>
parents:
164
diff
changeset
|
921 |
^ MethodMemoryUsage includesKey:aMethod originalMethod |
164
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
922 |
]. |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
923 |
^ false |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
924 |
|
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
925 |
"Created: 18.12.1995 / 15:51:49 / stefan" |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
926 |
! |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
927 |
|
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
928 |
memoryUsageOfMethod:aMethod |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
929 |
"return the current count" |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
930 |
|
764
883a5f35113c
fixed reset count & reset memCount
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
931 |
|count memUse orgMethod| |
164
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
932 |
|
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
933 |
(MethodCounts isNil or:[MethodMemoryUsage isNil]) ifTrue:[^ 0]. |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
934 |
aMethod isWrapped ifTrue:[ |
764
883a5f35113c
fixed reset count & reset memCount
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
935 |
orgMethod := aMethod originalMethod. |
883a5f35113c
fixed reset count & reset memCount
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
936 |
count := MethodCounts at:orgMethod ifAbsent:nil. |
883a5f35113c
fixed reset count & reset memCount
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
937 |
memUse := MethodMemoryUsage at:orgMethod ifAbsent:nil. |
164
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
938 |
]. |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
939 |
memUse isNil ifTrue:[ |
764
883a5f35113c
fixed reset count & reset memCount
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
940 |
count := MethodCounts at:aMethod ifAbsent:0. |
883a5f35113c
fixed reset count & reset memCount
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
941 |
memUse := MethodMemoryUsage at:aMethod ifAbsent:0. |
164
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
942 |
]. |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
943 |
count = 0 ifTrue:[^ 0]. |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
944 |
^ memUse//count |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
945 |
|
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
946 |
"Modified: 18.12.1995 / 16:25:51 / stefan" |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
947 |
! |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
948 |
|
694
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
949 |
resetMemoryUsageOfMethod:aMethod |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
950 |
"reset the current usage" |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
951 |
|
764
883a5f35113c
fixed reset count & reset memCount
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
952 |
|orgMethod| |
883a5f35113c
fixed reset count & reset memCount
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
953 |
|
694
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
954 |
MethodCounts notNil ifTrue:[ |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
955 |
MethodMemoryUsage notNil ifTrue:[ |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
956 |
aMethod isWrapped ifTrue:[ |
764
883a5f35113c
fixed reset count & reset memCount
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
957 |
orgMethod := aMethod originalMethod. |
883a5f35113c
fixed reset count & reset memCount
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
958 |
MethodCounts at:orgMethod put:0. |
883a5f35113c
fixed reset count & reset memCount
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
959 |
MethodMemoryUsage at:orgMethod put:nil. |
694
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
960 |
] |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
961 |
]. |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
962 |
]. |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
963 |
|
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
964 |
"Created: / 30.7.1998 / 17:43:07 / cg" |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
965 |
! |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
966 |
|
164
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
967 |
stopCountingMemoryUsageOfMethod:aMethod |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
968 |
"remove counting memory of aMethod" |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
969 |
|
764
883a5f35113c
fixed reset count & reset memCount
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
970 |
|orgMethod| |
883a5f35113c
fixed reset count & reset memCount
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
971 |
|
883a5f35113c
fixed reset count & reset memCount
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
972 |
MethodCounts notNil ifTrue:[ |
883a5f35113c
fixed reset count & reset memCount
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
973 |
MethodMemoryUsage notNil ifTrue:[ |
883a5f35113c
fixed reset count & reset memCount
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
974 |
aMethod isWrapped ifTrue:[ |
883a5f35113c
fixed reset count & reset memCount
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
975 |
orgMethod := aMethod originalMethod. |
883a5f35113c
fixed reset count & reset memCount
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
976 |
MethodCounts removeKey:orgMethod ifAbsent:nil. |
883a5f35113c
fixed reset count & reset memCount
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
977 |
MethodMemoryUsage removeKey:orgMethod ifAbsent:nil. |
883a5f35113c
fixed reset count & reset memCount
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
978 |
] |
883a5f35113c
fixed reset count & reset memCount
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
979 |
]. |
883a5f35113c
fixed reset count & reset memCount
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
980 |
]. |
164
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
981 |
^ self unwrapMethod:aMethod |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
982 |
|
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
983 |
"Modified: 18.12.1995 / 21:54:36 / stefan" |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
984 |
! ! |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
985 |
|
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
986 |
!MessageTracer class methodsFor:'method timing'! |
327 | 987 |
|
988 |
executionTimesOfMethod:aMethod |
|
694
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
989 |
"return the current gathered execution time statistics" |
327 | 990 |
|
668
7cd41a86e7b2
renamed min/max - bad names on NeXT
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
991 |
|count info minT maxT avg ret| |
7cd41a86e7b2
renamed min/max - bad names on NeXT
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
992 |
|
693
cd020921a251
use microsecond resolution in method timing
Claus Gittinger <cg@exept.de>
parents:
691
diff
changeset
|
993 |
count := 0. |
cd020921a251
use microsecond resolution in method timing
Claus Gittinger <cg@exept.de>
parents:
691
diff
changeset
|
994 |
minT := maxT := avg := nil. |
327 | 995 |
MethodTiming notNil ifTrue:[ |
996 |
aMethod isWrapped ifTrue:[ |
|
997 |
info := MethodTiming at:aMethod originalMethod ifAbsent:nil. |
|
998 |
info notNil ifTrue:[ |
|
999 |
count := info at:1. |
|
579 | 1000 |
count ~~ 0 ifTrue:[ |
668
7cd41a86e7b2
renamed min/max - bad names on NeXT
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1001 |
minT := info at:2. |
7cd41a86e7b2
renamed min/max - bad names on NeXT
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1002 |
maxT := info at:3. |
694
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
1003 |
avg := (info at:4) / count |
579 | 1004 |
] |
327 | 1005 |
]. |
1006 |
]. |
|
1007 |
]. |
|
1008 |
||
696 | 1009 |
minT notNil ifTrue:[ |
1010 |
minT > 10 ifTrue:[ |
|
1011 |
minT := minT roundTo:0.1 |
|
1012 |
] ifFalse:[ |
|
1013 |
minT := minT roundTo:0.01 |
|
1014 |
] |
|
693
cd020921a251
use microsecond resolution in method timing
Claus Gittinger <cg@exept.de>
parents:
691
diff
changeset
|
1015 |
]. |
696 | 1016 |
maxT notNil ifTrue:[ |
1017 |
maxT > 10 ifTrue:[ |
|
1018 |
maxT := maxT roundTo:0.1 |
|
1019 |
] ifFalse:[ |
|
1020 |
maxT := maxT roundTo:0.01 |
|
1021 |
]. |
|
693
cd020921a251
use microsecond resolution in method timing
Claus Gittinger <cg@exept.de>
parents:
691
diff
changeset
|
1022 |
]. |
696 | 1023 |
avg notNil ifTrue:[ |
1024 |
avg > 10 ifTrue:[ |
|
1025 |
avg := avg roundTo:0.1 |
|
1026 |
] ifFalse:[ |
|
1027 |
avg := avg roundTo:0.01 |
|
1028 |
]. |
|
693
cd020921a251
use microsecond resolution in method timing
Claus Gittinger <cg@exept.de>
parents:
691
diff
changeset
|
1029 |
]. |
327 | 1030 |
ret := IdentityDictionary new. |
1031 |
ret at:#count put:count. |
|
668
7cd41a86e7b2
renamed min/max - bad names on NeXT
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1032 |
ret at:#minTime put:minT. |
7cd41a86e7b2
renamed min/max - bad names on NeXT
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1033 |
ret at:#maxTime put:maxT. |
327 | 1034 |
ret at:#avgTime put:avg. |
1035 |
^ ret |
|
1036 |
||
693
cd020921a251
use microsecond resolution in method timing
Claus Gittinger <cg@exept.de>
parents:
691
diff
changeset
|
1037 |
"Created: / 17.6.1996 / 17:07:30 / cg" |
696 | 1038 |
"Modified: / 30.7.1998 / 18:20:45 / cg" |
694
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
1039 |
! |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
1040 |
|
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
1041 |
resetExecutionTimesOfMethod:aMethod |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
1042 |
"reset the gathered execution times statistics for aMethod; |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
1043 |
the method remains wrapped." |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
1044 |
|
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
1045 |
MethodTiming notNil ifTrue:[ |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
1046 |
aMethod isWrapped ifTrue:[ |
698 | 1047 |
MethodTiming at:aMethod put:(Array with:0 |
1048 |
with:0 |
|
1049 |
with:0 |
|
1050 |
with:0). |
|
694
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
1051 |
]. |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
1052 |
]. |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
1053 |
|
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
1054 |
"Created: / 30.7.1998 / 17:12:35 / cg" |
698 | 1055 |
"Modified: / 31.7.1998 / 00:42:50 / cg" |
327 | 1056 |
! |
1057 |
||
1058 |
stopTimingMethod:aMethod |
|
1059 |
"remove timing of aMethod" |
|
1060 |
||
1061 |
^ self unwrapMethod:aMethod |
|
1062 |
||
1063 |
"Modified: 15.12.1995 / 15:43:53 / cg" |
|
1064 |
"Created: 17.6.1996 / 17:04:03 / cg" |
|
1065 |
! |
|
1066 |
||
1067 |
timeMethod:aMethod |
|
1068 |
"arrange for a aMethods execution time to be measured. |
|
694
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
1069 |
Use unwrapMethod: or stopTimingMethod: to remove this." |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
1070 |
|
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
1071 |
|t0| |
327 | 1072 |
|
1073 |
MethodTiming isNil ifTrue:[ |
|
1074 |
MethodTiming := IdentityDictionary new. |
|
1075 |
]. |
|
1076 |
MethodTiming removeKey:aMethod ifAbsent:nil. |
|
579 | 1077 |
MethodTiming at:aMethod put:(Array with:0 |
1078 |
with:0 |
|
1079 |
with:0 |
|
1080 |
with:0). |
|
327 | 1081 |
|
694
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
1082 |
TimeForWrappers isNil ifTrue:[ |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
1083 |
self getTimeForWrappers |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
1084 |
]. |
693
cd020921a251
use microsecond resolution in method timing
Claus Gittinger <cg@exept.de>
parents:
691
diff
changeset
|
1085 |
|
327 | 1086 |
^ self wrapMethod:aMethod |
1087 |
onEntry:[:con | |
|
693
cd020921a251
use microsecond resolution in method timing
Claus Gittinger <cg@exept.de>
parents:
691
diff
changeset
|
1088 |
t0 := OperatingSystem getMicrosecondTime. |
327 | 1089 |
] |
1090 |
onExit:[:con :retVal | |
|
668
7cd41a86e7b2
renamed min/max - bad names on NeXT
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1091 |
|info t cnt minT maxT sumTimes| |
327 | 1092 |
|
693
cd020921a251
use microsecond resolution in method timing
Claus Gittinger <cg@exept.de>
parents:
691
diff
changeset
|
1093 |
t := OperatingSystem getMicrosecondTime - t0. |
694
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
1094 |
t := t - TimeForWrappers. |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
1095 |
t < 0 ifTrue:[t := 0]. |
693
cd020921a251
use microsecond resolution in method timing
Claus Gittinger <cg@exept.de>
parents:
691
diff
changeset
|
1096 |
t := t / 1000.0. |
cd020921a251
use microsecond resolution in method timing
Claus Gittinger <cg@exept.de>
parents:
691
diff
changeset
|
1097 |
|
327 | 1098 |
info := MethodTiming at:aMethod ifAbsent:nil. |
1099 |
info isNil ifTrue:[ |
|
1100 |
MethodTiming at:aMethod put:(Array with:1 |
|
1101 |
with:t |
|
1102 |
with:t |
|
1103 |
with:t) |
|
1104 |
] ifFalse:[ |
|
1105 |
cnt := info at:1. |
|
1106 |
sumTimes := info at:4. |
|
693
cd020921a251
use microsecond resolution in method timing
Claus Gittinger <cg@exept.de>
parents:
691
diff
changeset
|
1107 |
|
cd020921a251
use microsecond resolution in method timing
Claus Gittinger <cg@exept.de>
parents:
691
diff
changeset
|
1108 |
cnt == 0 ifTrue:[ |
cd020921a251
use microsecond resolution in method timing
Claus Gittinger <cg@exept.de>
parents:
691
diff
changeset
|
1109 |
info at:2 put:t. |
cd020921a251
use microsecond resolution in method timing
Claus Gittinger <cg@exept.de>
parents:
691
diff
changeset
|
1110 |
info at:3 put:t. |
327 | 1111 |
] ifFalse:[ |
693
cd020921a251
use microsecond resolution in method timing
Claus Gittinger <cg@exept.de>
parents:
691
diff
changeset
|
1112 |
minT := info at:2. |
cd020921a251
use microsecond resolution in method timing
Claus Gittinger <cg@exept.de>
parents:
691
diff
changeset
|
1113 |
maxT := info at:3. |
cd020921a251
use microsecond resolution in method timing
Claus Gittinger <cg@exept.de>
parents:
691
diff
changeset
|
1114 |
t < minT ifTrue:[ |
cd020921a251
use microsecond resolution in method timing
Claus Gittinger <cg@exept.de>
parents:
691
diff
changeset
|
1115 |
info at:2 put:t. |
cd020921a251
use microsecond resolution in method timing
Claus Gittinger <cg@exept.de>
parents:
691
diff
changeset
|
1116 |
] ifFalse:[ |
cd020921a251
use microsecond resolution in method timing
Claus Gittinger <cg@exept.de>
parents:
691
diff
changeset
|
1117 |
t > maxT ifTrue:[ |
cd020921a251
use microsecond resolution in method timing
Claus Gittinger <cg@exept.de>
parents:
691
diff
changeset
|
1118 |
info at:3 put:t. |
cd020921a251
use microsecond resolution in method timing
Claus Gittinger <cg@exept.de>
parents:
691
diff
changeset
|
1119 |
] |
cd020921a251
use microsecond resolution in method timing
Claus Gittinger <cg@exept.de>
parents:
691
diff
changeset
|
1120 |
]. |
327 | 1121 |
]. |
1122 |
info at:4 put:(sumTimes + t). |
|
1123 |
info at:1 put:cnt + 1 |
|
1124 |
]. |
|
691
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
1125 |
aMethod changed:#statistics |
327 | 1126 |
] |
1127 |
||
1128 |
" |
|
1129 |
MessageTracer timeMethod:(Integer compiledMethodAt:#factorial). |
|
1130 |
5 factorial. |
|
1131 |
5 factorial. |
|
1132 |
5 factorial. |
|
1133 |
(MessageTracer executionTimesOfMethod:(Integer compiledMethodAt:#factorial)) printCR. |
|
1134 |
MessageTracer stopTimingMethod:(Integer compiledMethodAt:#factorial) |
|
1135 |
" |
|
1136 |
||
691
17c3c522f1dc
send change notifications when a counted methods count
Claus Gittinger <cg@exept.de>
parents:
668
diff
changeset
|
1137 |
"Created: / 17.6.1996 / 17:03:50 / cg" |
694
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
1138 |
"Modified: / 30.7.1998 / 17:13:11 / cg" |
327 | 1139 |
! ! |
1140 |
||
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
1141 |
!MessageTracer class methodsFor:'method tracing'! |
11 | 1142 |
|
664 | 1143 |
traceClass:aClass selector:aSelector |
1144 |
"arrange for a trace message to be output on Stderr, when a message with aSelector is |
|
1145 |
sent to instances of aClass (or subclass instances). Use untraceClass to remove this." |
|
1146 |
||
1147 |
self traceClass:aClass selector:aSelector on:Stderr |
|
1148 |
||
1149 |
" |
|
1150 |
MessageTracer traceClass:Integer selector:#factorial. |
|
1151 |
5 factorial. |
|
1152 |
MessageTracer untraceClass:Integer |
|
1153 |
" |
|
1154 |
" |
|
1155 |
MessageTracer traceClass:SequenceableCollection selector:#quickSortFrom:to:. |
|
1156 |
#(6 1 9 66 2 17) copy sort. |
|
1157 |
MessageTracer untraceClass:SequenceableCollection |
|
1158 |
" |
|
1159 |
" |
|
1160 |
MessageTracer traceClass:Array selector:#at:. |
|
1161 |
MessageTracer traceClass:Array selector:#at:put:. |
|
1162 |
#(6 1 9 66 2 17) copy sort. |
|
1163 |
MessageTracer untraceClass:Array |
|
1164 |
" |
|
1165 |
! |
|
1166 |
||
1167 |
traceClass:aClass selector:aSelector on:aStream |
|
1168 |
"arrange for a trace message to be output on aStream, when a message with aSelector is |
|
1169 |
sent to instances of aClass (or subclass instances). Use untraceClass to remove this." |
|
1170 |
||
1171 |
self traceMethod:(aClass compiledMethodAt:aSelector) on:aStream |
|
1172 |
||
1173 |
" |
|
1174 |
MessageTracer traceClass:Integer selector:#factorial on:Transcript. |
|
1175 |
5 factorial. |
|
1176 |
MessageTracer untraceClass:Integer |
|
1177 |
" |
|
1178 |
" |
|
1179 |
MessageTracer traceClass:Integer selector:#factorialR on:Transcript. |
|
1180 |
5 factorialR. |
|
1181 |
MessageTracer untraceClass:Integer |
|
1182 |
" |
|
1183 |
||
1184 |
! |
|
1185 |
||
88 | 1186 |
traceMethod:aMethod |
664 | 1187 |
"arrange for a trace message to be output on Stderr, |
1188 |
when aMethod is executed. Traces both entry and exit. |
|
88 | 1189 |
Use unwrapMethod to remove this." |
1190 |
||
664 | 1191 |
^ self traceMethod:aMethod on:Stderr |
11 | 1192 |
|
1193 |
" |
|
88 | 1194 |
MessageTracer traceMethod:(Integer compiledMethodAt:#factorial). |
1195 |
5 factorial. |
|
1196 |
MessageTracer untraceMethod:(Integer compiledMethodAt:#factorial) |
|
1197 |
" |
|
1198 |
" |
|
664 | 1199 |
MessageTracer traceMethod:(Integer compiledMethodAt:#factorialR). |
1200 |
5 factorialR. |
|
1201 |
MessageTracer untraceMethod:(Integer compiledMethodAt:#factorialR) |
|
1202 |
" |
|
1203 |
" |
|
88 | 1204 |
MessageTracer traceMethod:(SequenceableCollection compiledMethodAt:#quickSortFrom:to:). |
1205 |
#(6 1 9 66 2 17) copy sort. |
|
1206 |
MessageTracer untraceMethod:(SequenceableCollection compiledMethodAt:#quickSortFrom:to:). |
|
1207 |
" |
|
1208 |
" |
|
1209 |
dont do this: |
|
1210 |
" |
|
1211 |
" |
|
1212 |
MessageTracer traceMethod:(Object compiledMethodAt:#at:). |
|
1213 |
MessageTracer traceMethod:(Object compiledMethodAt:#at:put:). |
|
1214 |
#(6 1 9 66 2 17) copy sort. |
|
1215 |
MessageTracer untraceMethod:(Object compiledMethodAt:#at:). |
|
1216 |
MessageTracer untraceMethod:(Object compiledMethodAt:#at:put:). |
|
11 | 1217 |
" |
1218 |
! |
|
1219 |
||
664 | 1220 |
traceMethod:aMethod on:aStream |
1221 |
"arrange for a trace message to be output on aStream, |
|
1222 |
when aMethod is executed. Traces both entry and exit. |
|
1223 |
Use unwrapMethod to remove this." |
|
1224 |
||
1225 |
|lvl inside| |
|
1226 |
||
1227 |
^ self wrapMethod:aMethod |
|
1228 |
onEntry:[:con | |
|
1229 |
inside isNil ifTrue:[ |
|
1230 |
inside := true. |
|
1231 |
CallingLevel isNil ifTrue:[ |
|
1232 |
CallingLevel := 0. |
|
1233 |
]. |
|
1234 |
lvl notNil ifTrue:[ |
|
1235 |
lvl := lvl + 1 |
|
1236 |
] ifFalse:[ |
|
1237 |
CallingLevel := lvl := CallingLevel + 1. |
|
1238 |
]. |
|
1239 |
MessageTracer printEntryFull:con level:lvl on:aStream. |
|
1240 |
inside := nil |
|
1241 |
] |
|
1242 |
] |
|
1243 |
onExit:[:con :retVal | |
|
1244 |
inside isNil ifTrue:[ |
|
1245 |
inside := true. |
|
1246 |
MessageTracer printExit:con with:retVal level:lvl on:aStream. |
|
1247 |
CallingLevel := lvl := lvl - 1. |
|
1248 |
inside := nil |
|
1249 |
] |
|
1250 |
] |
|
1251 |
||
1252 |
" |
|
1253 |
MessageTracer traceMethod:(Integer compiledMethodAt:#factorial) on:Transcript. |
|
1254 |
5 factorial. |
|
1255 |
MessageTracer untraceMethod:(Integer compiledMethodAt:#factorial) |
|
1256 |
" |
|
1257 |
" |
|
1258 |
MessageTracer traceMethod:(Integer compiledMethodAt:#factorialR) on:Transcript. |
|
1259 |
5 factorialR. |
|
1260 |
MessageTracer untraceMethod:(Integer compiledMethodAt:#factorialR) |
|
1261 |
" |
|
1262 |
" |
|
1263 |
MessageTracer traceMethod:(SequenceableCollection compiledMethodAt:#quickSortFrom:to:) on:Transcript. |
|
1264 |
#(6 1 9 66 2 17) copy sort. |
|
1265 |
MessageTracer untraceMethod:(SequenceableCollection compiledMethodAt:#quickSortFrom:to:). |
|
1266 |
" |
|
1267 |
! |
|
1268 |
||
162
ed6f37d2cc33
added traceAll (full trace - longish output)
Claus Gittinger <cg@exept.de>
parents:
161
diff
changeset
|
1269 |
traceMethodAll:aMethod |
699
52a632386cef
some debugging methods moved from Smalltalk to ObjectMemory
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
1270 |
"arrange for a full trace message to be output on Stderr, when aMethod is executed. |
162
ed6f37d2cc33
added traceAll (full trace - longish output)
Claus Gittinger <cg@exept.de>
parents:
161
diff
changeset
|
1271 |
Only the sender is traced on entry. |
699
52a632386cef
some debugging methods moved from Smalltalk to ObjectMemory
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
1272 |
Use untraceMethod to remove this trace. |
52a632386cef
some debugging methods moved from Smalltalk to ObjectMemory
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
1273 |
This is for system debugging only; |
52a632386cef
some debugging methods moved from Smalltalk to ObjectMemory
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
1274 |
The trace output is a low level trace generated in the VM." |
162
ed6f37d2cc33
added traceAll (full trace - longish output)
Claus Gittinger <cg@exept.de>
parents:
161
diff
changeset
|
1275 |
|
ed6f37d2cc33
added traceAll (full trace - longish output)
Claus Gittinger <cg@exept.de>
parents:
161
diff
changeset
|
1276 |
^ self wrapMethod:aMethod |
699
52a632386cef
some debugging methods moved from Smalltalk to ObjectMemory
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
1277 |
onEntry:[:con | ObjectMemory flushCaches. ObjectMemory sendTraceOn.] |
52a632386cef
some debugging methods moved from Smalltalk to ObjectMemory
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
1278 |
onExit:[:con :val | ObjectMemory sendTraceOff.] |
52a632386cef
some debugging methods moved from Smalltalk to ObjectMemory
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
1279 |
|
52a632386cef
some debugging methods moved from Smalltalk to ObjectMemory
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
1280 |
"Modified: / 31.7.1998 / 16:40:07 / cg" |
162
ed6f37d2cc33
added traceAll (full trace - longish output)
Claus Gittinger <cg@exept.de>
parents:
161
diff
changeset
|
1281 |
! |
ed6f37d2cc33
added traceAll (full trace - longish output)
Claus Gittinger <cg@exept.de>
parents:
161
diff
changeset
|
1282 |
|
664 | 1283 |
traceMethodEntry:aMethod |
1284 |
"arrange for a trace message to be output on stdErr, |
|
1285 |
when aMethod is executed. Only entry is traced. |
|
1286 |
Use unwrapMethod to remove this." |
|
1287 |
||
1288 |
^ self traceMethodEntry:aMethod on:Stderr |
|
1289 |
||
1290 |
" |
|
1291 |
MessageTracer traceMethodEntry:(Integer compiledMethodAt:#factorial). |
|
1292 |
5 factorial. |
|
1293 |
MessageTracer untraceMethod:(Integer compiledMethodAt:#factorial) |
|
1294 |
" |
|
1295 |
" |
|
1296 |
MessageTracer traceMethodEntry:(Integer compiledMethodAt:#factorialR). |
|
1297 |
5 factorialR. |
|
1298 |
MessageTracer untraceMethod:(Integer compiledMethodAt:#factorialR) |
|
1299 |
" |
|
1300 |
" |
|
1301 |
MessageTracer traceMethodEntry:(SequenceableCollection compiledMethodAt:#quickSortFrom:to:). |
|
1302 |
#(6 1 9 66 2 17) copy sort. |
|
1303 |
MessageTracer untraceMethod:(SequenceableCollection compiledMethodAt:#quickSortFrom:to:). |
|
1304 |
" |
|
1305 |
! |
|
1306 |
||
1307 |
traceMethodEntry:aMethod on:aStream |
|
1308 |
"arrange for a trace message to be output on aStream, |
|
1309 |
when aMethod is executed. Only entry is traced. |
|
1310 |
Use unwrapMethod to remove this." |
|
1311 |
||
1312 |
|lvl inside| |
|
1313 |
||
1314 |
^ self wrapMethod:aMethod |
|
1315 |
onEntry:[:con | |
|
1316 |
inside isNil ifTrue:[ |
|
1317 |
inside := true. |
|
1318 |
CallingLevel isNil ifTrue:[ |
|
1319 |
CallingLevel := 0. |
|
1320 |
]. |
|
1321 |
lvl notNil ifTrue:[ |
|
1322 |
lvl := lvl + 1 |
|
1323 |
] ifFalse:[ |
|
1324 |
CallingLevel := lvl := CallingLevel + 1. |
|
1325 |
]. |
|
1326 |
MessageTracer printEntryFull:con level:lvl on:aStream. |
|
1327 |
inside := nil |
|
1328 |
] |
|
1329 |
] |
|
1330 |
onExit:[:con :retVal |] |
|
1331 |
||
1332 |
" |
|
1333 |
MessageTracer traceMethodEntry:(Integer compiledMethodAt:#factorial) on:Transcript. |
|
1334 |
5 factorial. |
|
1335 |
MessageTracer untraceMethod:(Integer compiledMethodAt:#factorial) |
|
1336 |
" |
|
1337 |
" |
|
1338 |
MessageTracer traceMethodEntry:(Integer compiledMethodAt:#factorialR) on:Transcript. |
|
1339 |
5 factorialR. |
|
1340 |
MessageTracer untraceMethod:(Integer compiledMethodAt:#factorialR) |
|
1341 |
" |
|
1342 |
" |
|
1343 |
MessageTracer traceMethodEntry:(SequenceableCollection compiledMethodAt:#quickSortFrom:to:) on:Transcript. |
|
1344 |
#(6 1 9 66 2 17) copy sort. |
|
1345 |
MessageTracer untraceMethod:(SequenceableCollection compiledMethodAt:#quickSortFrom:to:). |
|
1346 |
" |
|
1347 |
! |
|
1348 |
||
156 | 1349 |
traceMethodFull:aMethod |
1350 |
"arrange for a full trace message to be output on Stderr, when amethod is executed. |
|
1351 |
Only the sender is traced on entry. |
|
1352 |
Use untraceMethod to remove this trace." |
|
1353 |
||
664 | 1354 |
^ self traceMethodFull:aMethod on:Stderr |
1355 |
||
1356 |
"Created: 15.12.1995 / 18:19:31 / cg" |
|
1357 |
"Modified: 22.10.1996 / 17:39:28 / cg" |
|
1358 |
! |
|
1359 |
||
1360 |
traceMethodFull:aMethod on:aStream |
|
1361 |
"arrange for a full trace message to be output on Stderr, when aMethod is executed. |
|
1362 |
Only the sender is traced on entry. |
|
1363 |
Use untraceMethod to remove this trace." |
|
1364 |
||
1365 |
^ self |
|
1366 |
wrapMethod:aMethod |
|
1367 |
onEntry:(self traceFullBlockFor:aStream) |
|
1368 |
onExit:LeaveTraceBlock. |
|
156 | 1369 |
|
1370 |
"Created: 15.12.1995 / 18:19:31 / cg" |
|
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
1371 |
"Modified: 22.10.1996 / 17:39:28 / cg" |
156 | 1372 |
! |
1373 |
||
88 | 1374 |
traceMethodSender:aMethod |
664 | 1375 |
"arrange for a trace message to be output on Stderr, |
1376 |
when amethod is executed. |
|
1377 |
Only the sender is traced on entry. |
|
1378 |
Use untraceMethod to remove this trace." |
|
1379 |
||
1380 |
^ self traceMethodSender:aMethod on:Stderr |
|
1381 |
! |
|
1382 |
||
1383 |
traceMethodSender:aMethod on:aStream |
|
88 | 1384 |
"arrange for a trace message to be output on Stderr, when amethod is executed. |
1385 |
Only the sender is traced on entry. |
|
1386 |
Use untraceMethod to remove this trace." |
|
35 | 1387 |
|
664 | 1388 |
^ self |
1389 |
wrapMethod:aMethod |
|
1390 |
onEntry:(self traceSenderBlockFor:aStream) |
|
1391 |
onExit:LeaveTraceBlock. |
|
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
1392 |
|
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
1393 |
"Modified: 22.10.1996 / 17:39:33 / cg" |
88 | 1394 |
! |
1395 |
||
1396 |
untraceMethod:aMethod |
|
1397 |
"remove tracing of aMethod" |
|
1398 |
||
1399 |
"just a rename for your convenience - the same basic mechanism is used for all of these |
|
1400 |
trace facilities ..." |
|
1401 |
||
1402 |
^ self unwrapMethod:aMethod |
|
11 | 1403 |
! ! |
1404 |
||
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
1405 |
!MessageTracer class methodsFor:'method wrapping'! |
11 | 1406 |
|
88 | 1407 |
unwrapAllMethods |
1408 |
"just in case you dont know what methods have break/trace-points |
|
1409 |
on them; this removes them all" |
|
1410 |
||
1411 |
WrappedMethod allInstancesDo:[:aMethod | |
|
1412 |
self unwrapMethod:aMethod |
|
1413 |
] |
|
11 | 1414 |
! |
1415 |
||
88 | 1416 |
unwrapMethod:aMethod |
1417 |
"remove any wrapper on aMethod" |
|
1418 |
||
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1419 |
|selector class originalMethod dict mthd| |
88 | 1420 |
|
155 | 1421 |
MethodCounts notNil ifTrue:[ |
265 | 1422 |
aMethod isWrapped ifTrue:[ |
1423 |
MethodCounts removeKey:aMethod originalMethod ifAbsent:nil. |
|
1424 |
]. |
|
1425 |
MethodCounts removeKey:aMethod ifAbsent:nil. |
|
1426 |
MethodCounts isEmpty ifTrue:[MethodCounts := nil]. |
|
172
cf44aece60d4
clear memoryUsage when unwrapping
Claus Gittinger <cg@exept.de>
parents:
164
diff
changeset
|
1427 |
]. |
cf44aece60d4
clear memoryUsage when unwrapping
Claus Gittinger <cg@exept.de>
parents:
164
diff
changeset
|
1428 |
MethodMemoryUsage notNil ifTrue:[ |
265 | 1429 |
aMethod isWrapped ifTrue:[ |
1430 |
MethodMemoryUsage removeKey:aMethod originalMethod ifAbsent:nil. |
|
1431 |
]. |
|
1432 |
MethodMemoryUsage removeKey:aMethod ifAbsent:nil. |
|
1433 |
MethodMemoryUsage isEmpty ifTrue:[MethodMemoryUsage := nil]. |
|
155 | 1434 |
]. |
327 | 1435 |
MethodTiming notNil ifTrue:[ |
1436 |
aMethod isWrapped ifTrue:[ |
|
1437 |
MethodTiming removeKey:aMethod originalMethod ifAbsent:nil. |
|
1438 |
]. |
|
1439 |
MethodTiming removeKey:aMethod ifAbsent:nil. |
|
1440 |
MethodTiming isEmpty ifTrue:[MethodTiming := nil]. |
|
1441 |
]. |
|
155 | 1442 |
|
88 | 1443 |
CallingLevel := 0. |
1444 |
||
1445 |
(aMethod isNil or:[aMethod isWrapped not]) ifTrue:[ |
|
265 | 1446 |
^ aMethod |
88 | 1447 |
]. |
1448 |
||
1449 |
" |
|
1450 |
get class/selector |
|
1451 |
" |
|
1452 |
class := aMethod containingClass. |
|
1453 |
class isNil ifTrue:[ |
|
536 | 1454 |
'MessageTracer [info]: no containing class for method found' infoPrintCR. |
265 | 1455 |
^ aMethod |
88 | 1456 |
]. |
1457 |
selector := class selectorAtMethod:aMethod. |
|
1458 |
||
1459 |
originalMethod := aMethod originalMethod. |
|
1460 |
originalMethod isNil ifTrue:[ |
|
808 | 1461 |
self error:'oops, could not find original method' mayProceed:true. |
265 | 1462 |
^ aMethod |
88 | 1463 |
]. |
1464 |
||
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1465 |
dict := class methodDictionary. |
506 | 1466 |
mthd := dict at:selector ifAbsent:nil. |
1467 |
mthd notNil ifTrue:[ |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1468 |
dict at:selector put:originalMethod. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1469 |
class methodDictionary:dict. |
88 | 1470 |
] ifFalse:[ |
667 | 1471 |
'MessageTracer [info]: no containing class for method found' infoPrintCR. |
1472 |
"/ self halt:'oops, unexpected error - cannot remove wrap'. |
|
1473 |
aMethod becomeSameAs:originalMethod. |
|
265 | 1474 |
^ aMethod |
88 | 1475 |
]. |
1476 |
||
1477 |
ObjectMemory flushCaches. |
|
584
2da6bb2c8017
send out change notifications when a trap is removed
Claus Gittinger <cg@exept.de>
parents:
579
diff
changeset
|
1478 |
class changed:#methodTrap with:selector. "/ tell browsers |
88 | 1479 |
^ originalMethod |
265 | 1480 |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1481 |
"Modified: 5.6.1996 / 14:08:08 / stefan" |
584
2da6bb2c8017
send out change notifications when a trap is removed
Claus Gittinger <cg@exept.de>
parents:
579
diff
changeset
|
1482 |
"Modified: 24.4.1997 / 18:20:49 / cg" |
13 | 1483 |
! |
1484 |
||
164
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
1485 |
wrapMethod:aMethod onEntry:entryBlock onExit:exitBlock |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
1486 |
^ self wrapMethod:aMethod onEntry:entryBlock onExit:exitBlock onUnwind:nil |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
1487 |
|
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
1488 |
"Modified: 18.12.1995 / 15:58:12 / stefan" |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
1489 |
! |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
1490 |
|
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
1491 |
wrapMethod:aMethod onEntry:entryBlock onExit:exitBlock onUnwind:unwindBlock |
88 | 1492 |
"arrange for the two blocks entryBlock and exitBlock to be evaluated whenever |
1493 |
aMethod is evaluated. |
|
1494 |
EntryBlock will be called on entry, and gets the current context passed as argument. |
|
1495 |
ExitBlock will be called, when the method is left, and gets the context and |
|
164
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
1496 |
the methods return value as arguments. |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
1497 |
UnwindBlock will be called when the contxt of aMethod is unwound. |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
1498 |
If there is an unwindBlock, the entry and exitBlocks will be called within the unwind block, |
572 | 1499 |
because allocating the unwindBlock uses memory and some users want to count allocated memory. |
164
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
1500 |
" |
88 | 1501 |
|
729 | 1502 |
|selector class trapMethod s spec src dict sel save xselector| |
88 | 1503 |
|
1504 |
CallingLevel := 0. |
|
1505 |
||
1506 |
" |
|
1507 |
create a new method, which calls the original one, |
|
1508 |
but only if not already being trapped. |
|
1509 |
" |
|
1510 |
(aMethod isNil or:[aMethod isWrapped]) ifTrue:[ |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1511 |
^ aMethod |
88 | 1512 |
]. |
1513 |
aMethod isLazyMethod ifTrue:[ |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1514 |
aMethod makeRealMethod |
88 | 1515 |
]. |
1516 |
||
1517 |
" |
|
1518 |
get class/selector |
|
1519 |
" |
|
1520 |
class := aMethod containingClass. |
|
1521 |
class isNil ifTrue:[ |
|
808 | 1522 |
self error:'cannot place trap (no containing class found)' mayProceed:true. |
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1523 |
^ aMethod |
88 | 1524 |
]. |
1525 |
selector := class selectorAtMethod:aMethod. |
|
1526 |
||
1527 |
||
1528 |
WrappedMethod autoload. "/ for small systems |
|
1529 |
||
1530 |
" |
|
1531 |
get a new method-spec |
|
1532 |
" |
|
730 | 1533 |
xselector := '_x'. |
729 | 1534 |
aMethod numArgs timesRepeat:[ |
1535 |
xselector := xselector , '_:' |
|
1536 |
]. |
|
1537 |
spec := Parser methodSpecificationForSelector:xselector. |
|
88 | 1538 |
|
1539 |
" |
|
1540 |
create a method, executing the trap-blocks and the original method via a direct call |
|
1541 |
" |
|
1542 |
s := WriteStream on:String new. |
|
1543 |
s nextPutAll:spec. |
|
164
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
1544 |
s nextPutAll:' |retVal context| '. |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
1545 |
s nextPutAll:' context := thisContext.'. |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
1546 |
unwindBlock notNil ifTrue:[ |
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1547 |
s nextPutAll:'['. |
164
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
1548 |
]. |
88 | 1549 |
entryBlock notNil ifTrue:[ |
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1550 |
s nextPutAll:'#entryBlock yourself value:context. '. |
88 | 1551 |
]. |
1552 |
s nextPutAll:'retVal := #originalMethod yourself'; |
|
164
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
1553 |
nextPutAll: ' valueWithReceiver:(context receiver)'; |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
1554 |
nextPutAll: ' arguments:(context args)'; |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
1555 |
nextPutAll: ' selector:(context selector)'; |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
1556 |
nextPutAll: ' search:(context searchClass)'; |
88 | 1557 |
nextPutAll: ' sender:nil. '. |
1558 |
||
1559 |
exitBlock notNil ifTrue:[ |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1560 |
s nextPutAll:'#exitBlock yourself value:context value:retVal.'. |
164
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
1561 |
]. |
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
1562 |
unwindBlock notNil ifTrue:[ |
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1563 |
s nextPutAll:'] valueOnUnwindDo:#unwindBlock yourself.'. |
88 | 1564 |
]. |
1565 |
s nextPutAll:'^ retVal'; cr. |
|
1566 |
||
1567 |
src := s contents. |
|
1568 |
save := Compiler stcCompilation. |
|
1569 |
Compiler stcCompilation:#never. |
|
1570 |
[ |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1571 |
Class withoutUpdatingChangesDo:[ |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1572 |
trapMethod := Compiler compile:src |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1573 |
forClass:UndefinedObject |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1574 |
inCategory:aMethod category |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1575 |
notifying:nil |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1576 |
install:false |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1577 |
skipIfSame:false |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1578 |
silent:true. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1579 |
] |
88 | 1580 |
] valueNowOrOnUnwindDo:[ |
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1581 |
Compiler stcCompilation:save |
88 | 1582 |
]. |
1583 |
||
955
0516771efa2a
preserve a methods packageID when wrapping
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
1584 |
trapMethod setPackage:aMethod package. |
88 | 1585 |
trapMethod changeClassTo:WrappedMethod. |
1586 |
" |
|
1587 |
raising our eyebrows here ... |
|
1588 |
" |
|
1589 |
entryBlock notNil ifTrue:[ |
|
352
ac12b5bc2754
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
327
diff
changeset
|
1590 |
trapMethod changeLiteral:#entryBlock to:entryBlock. |
88 | 1591 |
]. |
352
ac12b5bc2754
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
327
diff
changeset
|
1592 |
trapMethod changeLiteral:#originalMethod to:aMethod. |
88 | 1593 |
exitBlock notNil ifTrue:[ |
352
ac12b5bc2754
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
327
diff
changeset
|
1594 |
trapMethod changeLiteral:#exitBlock to:exitBlock. |
88 | 1595 |
]. |
164
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
1596 |
unwindBlock notNil ifTrue:[ |
352
ac12b5bc2754
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
327
diff
changeset
|
1597 |
trapMethod changeLiteral:#unwindBlock to:unwindBlock. |
164
ea53c919343f
New method to wrap with unwind-actions.
Stefan Vogel <sv@exept.de>
parents:
162
diff
changeset
|
1598 |
]. |
88 | 1599 |
" |
1600 |
change the source of this new method |
|
1601 |
(to avoid confusion in the debugger ...) |
|
1602 |
" |
|
840
5ec82d6c2e55
care for the wrappers source info (to allow source access in browser)
Claus Gittinger <cg@exept.de>
parents:
825
diff
changeset
|
1603 |
"/ trapMethod source:'this is a wrapper method - not the real one'. |
5ec82d6c2e55
care for the wrappers source info (to allow source access in browser)
Claus Gittinger <cg@exept.de>
parents:
825
diff
changeset
|
1604 |
trapMethod sourceFilename:(aMethod getSource) position:(aMethod getSourcePosition). |
88 | 1605 |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1606 |
dict := class methodDictionary. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1607 |
sel := dict at:selector ifAbsent:[0]. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1608 |
sel == 0 ifTrue:[ |
808 | 1609 |
self error:'oops, unexpected error' mayProceed:true. |
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1610 |
^ aMethod |
88 | 1611 |
]. |
1612 |
||
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1613 |
dict at:selector put:trapMethod. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1614 |
class methodDictionary:dict. |
88 | 1615 |
ObjectMemory flushCaches. |
1616 |
^ trapMethod |
|
1617 |
||
1618 |
" |
|
1619 |
MessageTracer |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1620 |
wrapMethod:(Point compiledMethodAt:#scaleBy:) |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1621 |
onEntry:nil |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1622 |
onExit:[:con :retVal | |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1623 |
Transcript show:'leave Point>>scaleBy:; returning:'. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1624 |
Transcript showCR:retVal printString. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1625 |
Transcript endEntry |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1626 |
]. |
88 | 1627 |
(1@2) scaleBy:5. |
1628 |
MessageTracer unwrapMethod:(Point compiledMethodAt:#scaleBy:). |
|
1629 |
(1@2) scaleBy:5. |
|
1630 |
" |
|
1631 |
" |
|
1632 |
MessageTracer |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1633 |
wrapMethod:(Integer compiledMethodAt:#factorial) |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1634 |
onEntry:[:con | |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1635 |
Transcript showCR:('entering ' , con receiver printString , '>>factorial'). |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1636 |
] |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1637 |
onExit:[:con :retVal | |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1638 |
Transcript show:'leave Integer>>factorial; returning:'. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1639 |
Transcript showCR:retVal printString. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1640 |
Transcript endEntry |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1641 |
]. |
258 | 1642 |
Transcript showCR:'5 factorial traced'. |
88 | 1643 |
5 factorial. |
1644 |
MessageTracer unwrapMethod:(Integer compiledMethodAt:#factorial). |
|
258 | 1645 |
Transcript showCR:'5 factorial normal'. |
88 | 1646 |
5 factorial. |
1647 |
" |
|
1648 |
" |
|
1649 |
|lvl| |
|
1650 |
||
1651 |
lvl := 0. |
|
1652 |
MessageTracer |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1653 |
wrapMethod:(Integer compiledMethodAt:#factorial) |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1654 |
onEntry:[:con | |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1655 |
Transcript spaces:lvl. lvl := lvl + 2. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1656 |
Transcript showCR:('entering ' , con receiver printString , '>>factorial'). |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1657 |
] |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1658 |
onExit:[:con :retVal | |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1659 |
lvl := lvl - 2. Transcript spaces:lvl. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1660 |
Transcript show:('leave ' , con receiver printString , '>>factorial; returning:'). |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1661 |
Transcript showCR:retVal printString. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1662 |
Transcript endEntry |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1663 |
]. |
258 | 1664 |
Transcript showCR:'5 factorial traced'. |
88 | 1665 |
5 factorial. |
1666 |
MessageTracer unwrapMethod:(Integer compiledMethodAt:#factorial). |
|
258 | 1667 |
Transcript showCR:'5 factorial normal'. |
88 | 1668 |
5 factorial. |
1669 |
" |
|
150
54b6185e9aa7
compile without updating changes-file (also disables historyManager for the wrap)
Claus Gittinger <cg@exept.de>
parents:
120
diff
changeset
|
1670 |
|
729 | 1671 |
"Modified: / 25.6.1996 / 22:04:51 / stefan" |
730 | 1672 |
"Modified: / 16.11.1998 / 16:45:30 / cg" |
88 | 1673 |
! ! |
1674 |
||
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
1675 |
!MessageTracer class methodsFor:'object breakpointing'! |
88 | 1676 |
|
525 | 1677 |
objectHasWraps:anObject |
1678 |
"return true, if anObject has any wraps" |
|
1679 |
||
1680 |
^ anObject class category == #'* trapping *' |
|
1681 |
! |
|
1682 |
||
1683 |
realClassOf:anObject |
|
1684 |
"return anObjects real class" |
|
1685 |
||
1686 |
(anObject class category == #'* trapping *') ifFalse:[ |
|
1687 |
^ anObject class |
|
1688 |
]. |
|
1689 |
^ anObject class superclass |
|
1690 |
! |
|
1691 |
||
88 | 1692 |
trap:anObject selector:aSelector |
1693 |
"arrange for the debugger to be entered when a message with aSelector is |
|
1694 |
sent to anObject. Use untrap to remove this trap. |
|
1695 |
The current implementation does not allow integers or nil to be trapped." |
|
1696 |
||
1697 |
self wrap:anObject |
|
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
1698 |
selector:aSelector |
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
1699 |
onEntry:BreakBlock |
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
1700 |
onExit:LeaveBreakBlock. |
88 | 1701 |
|
1702 |
" |
|
1703 |
|p| |
|
1704 |
||
1705 |
p := Point new. |
|
1706 |
MessageTracer trap:p selector:#x:. |
|
1707 |
p x:5 |
|
1708 |
" |
|
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
1709 |
|
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
1710 |
"Modified: 22.10.1996 / 17:39:41 / cg" |
11 | 1711 |
! |
1712 |
||
88 | 1713 |
trap:anObject selectors:aCollection |
1714 |
self wrap:anObject |
|
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
1715 |
selectors:aCollection |
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
1716 |
onEntry:BreakBlock |
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
1717 |
onExit:LeaveBreakBlock. |
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
1718 |
|
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
1719 |
"Modified: 22.10.1996 / 17:39:50 / cg" |
88 | 1720 |
! |
1721 |
||
1722 |
trapAll:anObject |
|
1723 |
"trap on all messages which are understood by anObject" |
|
1724 |
||
1725 |
self wrapAll:anObject |
|
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
1726 |
onEntry:BreakBlock |
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
1727 |
onExit:LeaveBreakBlock. |
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
1728 |
|
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
1729 |
"Modified: 22.10.1996 / 17:39:54 / cg" |
88 | 1730 |
! |
1731 |
||
1732 |
trapAll:anObject from:aClass |
|
1733 |
"trap on all messages defined in aClass sent to anObject" |
|
1734 |
||
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1735 |
self trap:anObject selectors:aClass selectors |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1736 |
|
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1737 |
"Modified: 5.6.1996 / 13:46:06 / stefan" |
88 | 1738 |
! |
1739 |
||
1740 |
untrap:anObject |
|
1741 |
"remove any traps on anObject" |
|
1742 |
||
1743 |
"this is done by just patching the objects class back to the original" |
|
1744 |
||
1745 |
|orgClass| |
|
1746 |
||
1747 |
orgClass := anObject class. |
|
457
8ba8e7ac735d
use #'* trapping *' instead of #trapping as category mark
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
1748 |
orgClass category == #'* trapping *' ifFalse:[ |
8ba8e7ac735d
use #'* trapping *' instead of #trapping as category mark
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
1749 |
^ self |
88 | 1750 |
]. |
1751 |
||
660 | 1752 |
anObject changeClassTo:orgClass superclass. |
662 | 1753 |
ObjectCopyHolders notNil ifTrue:[ |
1754 |
ObjectCopyHolders removeKey:anObject ifAbsent:nil. |
|
1755 |
]. |
|
88 | 1756 |
|
1757 |
" |
|
1758 |
|p| |
|
1759 |
||
1760 |
p := Point new copy. |
|
1761 |
MessageTracer trace:p selector:#x:. |
|
1762 |
MessageTracer trace:p selector:#y:. |
|
1763 |
p y:1. |
|
1764 |
p x:2. |
|
1765 |
MessageTracer untrap:p |
|
1766 |
p y:2. |
|
1767 |
p x:1. |
|
1768 |
" |
|
457
8ba8e7ac735d
use #'* trapping *' instead of #trapping as category mark
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
1769 |
|
660 | 1770 |
"Modified: / 21.4.1998 / 15:43:33 / cg" |
13 | 1771 |
! |
1772 |
||
88 | 1773 |
untrap:anObject selector:aSelector |
1774 |
"remove trap on aSelector from anObject" |
|
1775 |
||
501 | 1776 |
|orgClass dict| |
88 | 1777 |
|
1778 |
orgClass := anObject class. |
|
457
8ba8e7ac735d
use #'* trapping *' instead of #trapping as category mark
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
1779 |
orgClass category == #'* trapping *' ifFalse:[^ self]. |
88 | 1780 |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1781 |
dict := orgClass methodDictionary. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1782 |
dict at:aSelector ifAbsent:[^ self]. |
88 | 1783 |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1784 |
dict size == 1 ifTrue:[ |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1785 |
"the last trap got removed" |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1786 |
anObject changeClassTo:orgClass superclass. |
662 | 1787 |
ObjectCopyHolders notNil ifTrue:[ |
1788 |
ObjectCopyHolders removeKey:anObject ifAbsent:nil. |
|
1789 |
]. |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1790 |
^ self |
88 | 1791 |
]. |
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1792 |
dict removeKey:aSelector. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1793 |
orgClass methodDictionary:dict. |
88 | 1794 |
ObjectMemory flushCaches. "avoid calling the old trap method" |
1795 |
||
1796 |
" |
|
1797 |
|p| |
|
1798 |
||
1799 |
p := Point new copy. |
|
1800 |
MessageTracer trace:p selector:#x:. |
|
1801 |
MessageTracer trace:p selector:#y:. |
|
1802 |
'trace both ...' errorPrintNL. |
|
1803 |
p x:2. |
|
1804 |
p y:1. |
|
1805 |
'trace only y ...' errorPrintNL. |
|
1806 |
MessageTracer untrap:p selector:#x:. |
|
1807 |
p x:2. |
|
1808 |
p y:1. |
|
1809 |
'trace none ...' errorPrintNL. |
|
1810 |
MessageTracer untrap:p selector:#y:. |
|
1811 |
p x:2. |
|
1812 |
p y:1. |
|
1813 |
" |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
1814 |
|
660 | 1815 |
"Modified: / 5.6.1996 / 13:56:08 / stefan" |
1816 |
"Modified: / 21.4.1998 / 15:43:55 / cg" |
|
525 | 1817 |
! |
1818 |
||
1819 |
wrappedSelectorsOf:anObject |
|
1820 |
"return the set of wrapped selectors (if any)" |
|
1821 |
||
1822 |
(anObject class category == #'* trapping *') ifFalse:[ |
|
1823 |
^ #() |
|
1824 |
]. |
|
1825 |
^ anObject class selectors |
|
11 | 1826 |
! ! |
1827 |
||
660 | 1828 |
!MessageTracer class methodsFor:'object modification traps'! |
1829 |
||
1830 |
trapModificationsIn:anObject |
|
1831 |
"trap modifications in anObject" |
|
1832 |
||
667 | 1833 |
anObject isNil ifTrue:[^ self]. |
1834 |
anObject isSymbol ifTrue:[^ self]. |
|
1835 |
anObject class == SmallInteger ifTrue:[^ self]. |
|
1836 |
anObject == true ifTrue:[^ self]. |
|
1837 |
anObject == false ifTrue:[^ self]. |
|
1838 |
||
660 | 1839 |
self |
663 | 1840 |
trapModificationsIn:anObject filter:[:old :new | true] |
660 | 1841 |
|
1842 |
" |
|
1843 |
|a| |
|
1844 |
||
1845 |
a := Array new:10. |
|
1846 |
MessageTracer trapModificationsIn:a. |
|
1847 |
||
1848 |
a size. |
|
1849 |
a at:1. |
|
1850 |
a at:2 put:nil. |
|
1851 |
a at:2 put:2. |
|
1852 |
a at:2. |
|
1853 |
a at:3. |
|
1854 |
a at:2 put:2. |
|
1855 |
a at:2 put:3. |
|
1856 |
MessageTracer untrace:a. |
|
1857 |
a at:3 put:5. |
|
1858 |
" |
|
1859 |
||
1860 |
"Created: / 21.4.1998 / 14:32:34 / cg" |
|
1861 |
"Modified: / 21.4.1998 / 14:58:24 / cg" |
|
1862 |
! |
|
1863 |
||
1864 |
trapModificationsIn:anObject filter:aFilterBlock |
|
1865 |
"trap modifications in anObject" |
|
1866 |
||
1867 |
|allSelectors| |
|
1868 |
||
1869 |
allSelectors := IdentitySet new. |
|
1870 |
anObject class withAllSuperclasses do:[:aClass | |
|
1871 |
aClass methodDictionary keys addAllTo:allSelectors |
|
1872 |
]. |
|
1873 |
allSelectors remove:#class. |
|
1874 |
||
1875 |
self trapModificationsIn:anObject selectors:allSelectors filter:aFilterBlock |
|
1876 |
||
1877 |
"trap if arrays 5th slot is modified: |
|
1878 |
||
1879 |
|a| |
|
1880 |
||
1881 |
a := Array new:10. |
|
1882 |
MessageTracer trapModificationsIn:a filter:[:old :new | (old at:5) ~~ (new at:5)]. |
|
1883 |
||
1884 |
a size. |
|
1885 |
a at:1. |
|
1886 |
a at:2 put:nil. |
|
1887 |
a at:2 put:2. |
|
1888 |
a at:2. |
|
1889 |
a at:3. |
|
1890 |
a at:2 put:2. |
|
1891 |
a at:2 put:3. |
|
1892 |
a at:5 put:3. |
|
1893 |
a at:5 put:3. |
|
1894 |
MessageTracer untrace:a. |
|
1895 |
a at:3 put:5. |
|
1896 |
" |
|
1897 |
||
1898 |
"Modified: / 21.4.1998 / 15:53:38 / cg" |
|
1899 |
! |
|
1900 |
||
1901 |
trapModificationsIn:anObject selector:aSelector filter:aFilterBlock |
|
1902 |
"install a trap for modifications in anObject by aSelector-messages. |
|
1903 |
the filterBlock will be invoked (after a modification) with the old and |
|
1904 |
new values as arguments and should return true, |
|
1905 |
if the debugger is really wanted." |
|
1906 |
||
1907 |
self |
|
1908 |
trapModificationsIn:anObject |
|
1909 |
selectors:(Array with:aSelector) |
|
1910 |
filter:aFilterBlock |
|
1911 |
||
1912 |
"Modified: / 21.4.1998 / 15:34:44 / cg" |
|
1913 |
! |
|
1914 |
||
1915 |
trapModificationsIn:anObject selectors:aCollectionOfSelectors filter:aFilterBlock |
|
1916 |
"install a trap for modifications in anObject by aSelector-messages. |
|
1917 |
the filterBlock will be invoked (after a modification) with the old and |
|
1918 |
new values as arguments and should return true, |
|
1919 |
if the debugger is really wanted." |
|
1920 |
||
1921 |
|copyHolder| |
|
1922 |
||
1923 |
ObjectCopyHolders isNil ifTrue:[ |
|
1924 |
ObjectCopyHolders := IdentityDictionary new. |
|
1925 |
]. |
|
1926 |
copyHolder := ObjectCopyHolders at:anObject ifAbsent:nil. |
|
1927 |
copyHolder isNil ifTrue:[ |
|
1928 |
ObjectCopyHolders at:anObject put:(copyHolder := ValueHolder new). |
|
1929 |
]. |
|
1930 |
||
1931 |
copyHolder value:(anObject shallowCopy). |
|
1932 |
||
1933 |
aCollectionOfSelectors do:[:aSelector | |
|
1934 |
|methodName| |
|
1935 |
||
1936 |
methodName := anObject class name , '>>' , aSelector. |
|
1937 |
self |
|
1938 |
wrap:anObject |
|
1939 |
selector:aSelector |
|
1940 |
onEntry:[:con | ] |
|
1941 |
onExit:[:con :retVal | |
|
1942 |
|oldValue| |
|
1943 |
||
1944 |
oldValue := copyHolder value. |
|
1945 |
||
1946 |
"/ compare with copy ... |
|
1947 |
(anObject sameContentsAs:oldValue) ifFalse:[ |
|
1948 |
"/ see oldValue vs. anObject |
|
1949 |
(aFilterBlock value:oldValue value:anObject) ifTrue:[ |
|
1950 |
copyHolder value:(anObject shallowCopy). |
|
1951 |
ObjectWrittenBreakpointSignal |
|
1952 |
raiseRequestWith:(oldValue -> anObject) |
|
809 | 1953 |
errorString:('object was modififed in ' , methodName) |
660 | 1954 |
in:con sender |
1955 |
] |
|
1956 |
] |
|
1957 |
] |
|
1958 |
withOriginalClass:true |
|
1959 |
flushCaches:false. |
|
1960 |
]. |
|
1961 |
ObjectMemory flushCaches |
|
1962 |
||
1963 |
"Created: / 21.4.1998 / 15:34:05 / cg" |
|
1964 |
"Modified: / 21.4.1998 / 16:00:39 / cg" |
|
1965 |
! ! |
|
1966 |
||
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
1967 |
!MessageTracer class methodsFor:'object tracing'! |
88 | 1968 |
|
1969 |
trace:anObject selector:aSelector |
|
1970 |
"arrange for a trace message to be output on Stderr, when a message with |
|
1971 |
aSelector is sent to anObject. Both entry and exit are traced. |
|
1972 |
Use untrap to remove this trace. |
|
1973 |
The current implementation does not allow integers or nil to be traced." |
|
1974 |
||
664 | 1975 |
self trace:anObject selector:aSelector on:Stderr |
88 | 1976 |
|
1977 |
" |
|
1978 |
|p| |
|
8 | 1979 |
|
88 | 1980 |
p := Point new. |
1981 |
MessageTracer trace:p selector:#x:. |
|
1982 |
p x:5. |
|
1983 |
p y:1. |
|
1984 |
p x:10. |
|
1985 |
MessageTracer untrap:p. |
|
1986 |
p x:7 |
|
1987 |
" |
|
1988 |
" |
|
1989 |
|a| |
|
1990 |
||
1991 |
a := #(6 1 9 66 2 17) copy. |
|
1992 |
MessageTracer trace:a selector:#at:put:. |
|
1993 |
MessageTracer trace:a selector:#at:. |
|
1994 |
a sort. |
|
1995 |
" |
|
538
5961061365d9
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
536
diff
changeset
|
1996 |
|
660 | 1997 |
"Modified: / 21.4.1998 / 15:37:05 / cg" |
88 | 1998 |
! |
1999 |
||
664 | 2000 |
trace:anObject selector:aSelector on:aStream |
2001 |
"arrange for a trace message to be output on Stderr, when a message with |
|
2002 |
aSelector is sent to anObject. Both entry and exit are traced. |
|
2003 |
Use untrap to remove this trace. |
|
2004 |
The current implementation does not allow integers or nil to be traced." |
|
2005 |
||
2006 |
self |
|
2007 |
trace:anObject |
|
2008 |
selectors:(Array with:aSelector) |
|
2009 |
on:aStream |
|
2010 |
||
2011 |
" |
|
2012 |
|p| |
|
2013 |
||
2014 |
p := Point new. |
|
2015 |
MessageTracer trace:p selector:#x: on:Stderr. |
|
2016 |
p x:5. |
|
2017 |
p y:1. |
|
2018 |
p x:10. |
|
2019 |
MessageTracer untrap:p. |
|
2020 |
p x:7 |
|
2021 |
" |
|
2022 |
" |
|
2023 |
|a| |
|
2024 |
||
2025 |
a := #(6 1 9 66 2 17) copy. |
|
2026 |
MessageTracer trace:a selector:#at:put: on:Stderr. |
|
2027 |
MessageTracer trace:a selector:#at:. on:Stderr |
|
2028 |
a sort. |
|
2029 |
" |
|
2030 |
||
2031 |
"Modified: / 21.4.1998 / 15:37:05 / cg" |
|
2032 |
! |
|
2033 |
||
660 | 2034 |
trace:anObject selectors:aCollectionOfSelectors |
2035 |
"arrange for a trace message to be output on Stderr, when any message |
|
2036 |
from aCollectionOfSelectors is sent to anObject. |
|
2037 |
Both entry and exit are traced. |
|
2038 |
Use untrap:/untrace: to remove this trace. |
|
2039 |
The current implementation does not allow integers or nil to be traced." |
|
2040 |
||
664 | 2041 |
self trace:anObject selectors:aCollectionOfSelectors on:Stderr |
88 | 2042 |
|
2043 |
" |
|
660 | 2044 |
|p| |
2045 |
||
2046 |
p := Point new. |
|
2047 |
MessageTracer trace:p selector:#x:. |
|
2048 |
p x:5. |
|
2049 |
p y:1. |
|
2050 |
p x:10. |
|
2051 |
MessageTracer untrap:p. |
|
2052 |
p x:7 |
|
2053 |
" |
|
2054 |
" |
|
2055 |
|a| |
|
2056 |
||
2057 |
a := #(6 1 9 66 2 17) copy. |
|
2058 |
MessageTracer trace:a selector:#at:put:. |
|
2059 |
MessageTracer trace:a selector:#at:. |
|
2060 |
a sort. |
|
88 | 2061 |
" |
2062 |
||
660 | 2063 |
"Modified: / 21.4.1998 / 15:41:57 / cg" |
88 | 2064 |
! |
2065 |
||
664 | 2066 |
trace:anObject selectors:aCollectionOfSelectors on:aStream |
2067 |
"arrange for a trace message to be output on Stderr, when any message |
|
2068 |
from aCollectionOfSelectors is sent to anObject. |
|
2069 |
Both entry and exit are traced. |
|
2070 |
Use untrap:/untrace: to remove this trace. |
|
2071 |
The current implementation does not allow integers or nil to be traced." |
|
2072 |
||
2073 |
|methodName| |
|
2074 |
||
2075 |
aCollectionOfSelectors do:[:aSelector | |
|
2076 |
methodName := anObject class name , '>>' , aSelector. |
|
2077 |
self |
|
2078 |
wrap:anObject |
|
2079 |
selector:aSelector |
|
2080 |
onEntry:[:con | |
|
2081 |
aStream nextPutAll:'enter '; nextPutAll:methodName. |
|
2082 |
aStream nextPutAll:' receiver='. |
|
2083 |
con receiver printOn:aStream. |
|
2084 |
aStream nextPutAll:' args='. (con args) printOn:aStream. |
|
2085 |
aStream nextPutAll:' from:'. con sender printOn:aStream. |
|
2086 |
aStream cr; flush |
|
2087 |
] |
|
2088 |
onExit:[:con :retVal | |
|
2089 |
aStream nextPutAll:'leave '; nextPutAll:methodName. |
|
2090 |
aStream nextPutAll:' receiver='. con receiver printOn:aStream. |
|
2091 |
aStream nextPutAll:' returning:'. retVal printOn:aStream. |
|
2092 |
aStream cr; flush |
|
2093 |
] |
|
2094 |
withOriginalClass:true |
|
2095 |
flushCaches:false |
|
2096 |
]. |
|
2097 |
ObjectMemory flushCaches |
|
2098 |
||
2099 |
" |
|
2100 |
|p| |
|
2101 |
||
2102 |
p := Point new. |
|
2103 |
MessageTracer trace:p selectors:#(x:) on:Transcript. |
|
2104 |
p x:5. |
|
2105 |
p y:1. |
|
2106 |
p x:10. |
|
2107 |
MessageTracer untrap:p. |
|
2108 |
p x:7 |
|
2109 |
" |
|
2110 |
" |
|
2111 |
|a| |
|
2112 |
||
2113 |
a := #(6 1 9 66 2 17) copy. |
|
2114 |
MessageTracer trace:a selectors:#( at:put: at:) on:Transcript. |
|
2115 |
a sort. |
|
2116 |
" |
|
2117 |
||
2118 |
"Modified: / 21.4.1998 / 15:41:57 / cg" |
|
2119 |
! |
|
2120 |
||
88 | 2121 |
traceAll:anObject |
2122 |
"trace all messages which are understood by anObject" |
|
27 | 2123 |
|
664 | 2124 |
self traceAll:anObject on:Stderr |
88 | 2125 |
|
2126 |
" |
|
2127 |
trace all (implemented) messages sent to Display |
|
2128 |
(other messages lead to an error, anyway) |
|
2129 |
" |
|
2130 |
||
2131 |
" |
|
2132 |
MessageTracer traceAll:Display |
|
2133 |
MessageTracer untrace:Display |
|
2134 |
" |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
2135 |
|
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
2136 |
"Modified: 5.6.1996 / 13:43:51 / stefan" |
88 | 2137 |
! |
2138 |
||
2139 |
traceAll:anObject from:aClass |
|
2140 |
"trace all messages defined in aClass sent to anObject" |
|
2141 |
||
664 | 2142 |
self traceAll:anObject from:aClass on:Stderr |
88 | 2143 |
|
2144 |
" |
|
2145 |
trace all methods in Display, which are implemented |
|
2146 |
in the DisplayWorkstation class. |
|
2147 |
" |
|
2148 |
||
2149 |
" |
|
2150 |
MessageTracer traceAll:Display from:XWorkstation |
|
2151 |
MessageTracer untrace:Display |
|
2152 |
" |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
2153 |
|
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
2154 |
"Modified: 5.6.1996 / 13:45:37 / stefan" |
27 | 2155 |
! |
2156 |
||
664 | 2157 |
traceAll:anObject from:aClass on:aStream |
2158 |
"trace all messages defined in aClass sent to anObject" |
|
2159 |
||
2160 |
self trace:anObject selectors:aClass selectors on:aStream |
|
2161 |
||
2162 |
" |
|
2163 |
trace all methods in Display, which are implemented |
|
2164 |
in the DisplayWorkstation class. |
|
2165 |
" |
|
2166 |
||
2167 |
" |
|
2168 |
MessageTracer traceAll:Display from:XWorkstation on:Transcript |
|
2169 |
MessageTracer untrace:Display |
|
2170 |
" |
|
2171 |
||
2172 |
"Modified: 5.6.1996 / 13:45:37 / stefan" |
|
2173 |
! |
|
2174 |
||
2175 |
traceAll:anObject on:aStream |
|
2176 |
"trace all messages which are understood by anObject" |
|
2177 |
||
2178 |
|allSelectors| |
|
2179 |
||
2180 |
allSelectors := IdentitySet new. |
|
2181 |
anObject class withAllSuperclasses do:[:aClass | |
|
2182 |
aClass methodDictionary keys addAllTo:allSelectors |
|
2183 |
]. |
|
2184 |
self trace:anObject selectors:allSelectors on:aStream |
|
2185 |
||
2186 |
" |
|
2187 |
trace all (implemented) messages sent to Display |
|
2188 |
(other messages lead to an error, anyway) |
|
2189 |
" |
|
2190 |
||
2191 |
" |
|
2192 |
MessageTracer traceAll:Display on:Transcript |
|
2193 |
MessageTracer untrace:Display |
|
2194 |
" |
|
2195 |
||
2196 |
"Modified: 5.6.1996 / 13:43:51 / stefan" |
|
2197 |
! |
|
2198 |
||
2199 |
traceEntry:anObject selectors:aCollectionOfSelectors on:aStream |
|
2200 |
"arrange for a trace message to be output on Stderr, when any message |
|
2201 |
from aCollectionOfSelectors is sent to anObject. |
|
2202 |
Only entry is traced. |
|
2203 |
Use untrap:/untrace: to remove this trace. |
|
2204 |
The current implementation does not allow integers or nil to be traced." |
|
2205 |
||
2206 |
self |
|
2207 |
traceEntry:anObject selectors:aCollectionOfSelectors on:Stderr |
|
2208 |
||
2209 |
" |
|
2210 |
|p| |
|
2211 |
||
2212 |
p := Point new. |
|
2213 |
MessageTracer traceEntry:p selectors:#(x:). |
|
2214 |
p x:5. |
|
2215 |
p y:1. |
|
2216 |
p x:10. |
|
2217 |
MessageTracer untrap:p. |
|
2218 |
p x:7 |
|
2219 |
" |
|
2220 |
" |
|
2221 |
|a| |
|
2222 |
||
2223 |
a := #(6 1 9 66 2 17) copy. |
|
2224 |
MessageTracer traceEntry:a selectors:#( at:put: at:). |
|
2225 |
a sort. |
|
2226 |
" |
|
2227 |
||
2228 |
"Modified: / 21.4.1998 / 15:41:57 / cg" |
|
2229 |
! |
|
2230 |
||
88 | 2231 |
traceSender:anObject selector:aSelector |
2232 |
"arrange for a trace message to be output on Stderr, when a message with |
|
2233 |
aSelector is sent to anObject. Only the sender is traced on entry. |
|
2234 |
Use untrap to remove this trace. |
|
2235 |
The current implementation does not allow integers or nil to be traced." |
|
2236 |
||
664 | 2237 |
^ self traceSender:anObject selector:aSelector on:Stderr |
88 | 2238 |
|
2239 |
" |
|
2240 |
|p| |
|
27 | 2241 |
|
88 | 2242 |
p := Point new. |
2243 |
MessageTracer traceSender:p selector:#x:. |
|
2244 |
p x:5. |
|
2245 |
p y:1. |
|
2246 |
p x:10. |
|
2247 |
MessageTracer untrap:p. |
|
2248 |
p x:7 |
|
2249 |
" |
|
2250 |
" |
|
2251 |
|a| |
|
2252 |
||
2253 |
a := #(6 1 9 66 2 17) copy. |
|
2254 |
MessageTracer traceSender:a selector:#at:put:. |
|
2255 |
MessageTracer traceSender:a selector:#at:. |
|
2256 |
a sort. |
|
2257 |
" |
|
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
2258 |
|
538
5961061365d9
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
536
diff
changeset
|
2259 |
"Modified: 10.1.1997 / 17:54:53 / cg" |
11 | 2260 |
! |
2261 |
||
664 | 2262 |
traceSender:anObject selector:aSelector on:aStream |
2263 |
"arrange for a trace message to be output on Stderr, when a message with |
|
2264 |
aSelector is sent to anObject. Only the sender is traced on entry. |
|
2265 |
Use untrap to remove this trace. |
|
2266 |
The current implementation does not allow integers or nil to be traced." |
|
2267 |
||
2268 |
|methodName| |
|
2269 |
||
2270 |
methodName := anObject class name , '>>' , aSelector. |
|
2271 |
self wrap:anObject |
|
2272 |
selector:aSelector |
|
2273 |
onEntry:[:con | |
|
2274 |
aStream nextPutAll:methodName. |
|
2275 |
aStream nextPutAll:' from '. |
|
2276 |
con sender printOn:aStream. |
|
2277 |
aStream cr; flush. |
|
2278 |
] |
|
2279 |
onExit:LeaveTraceBlock. |
|
2280 |
||
2281 |
" |
|
2282 |
|p| |
|
2283 |
||
2284 |
p := Point new. |
|
2285 |
MessageTracer traceSender:p selector:#x: on:Transcript. |
|
2286 |
p x:5. |
|
2287 |
p y:1. |
|
2288 |
p x:10. |
|
2289 |
MessageTracer untrap:p. |
|
2290 |
p x:7 |
|
2291 |
" |
|
2292 |
" |
|
2293 |
|a| |
|
2294 |
||
2295 |
a := #(6 1 9 66 2 17) copy. |
|
2296 |
MessageTracer traceSender:a selector:#at:put: on:Transcript. |
|
2297 |
MessageTracer traceSender:a selector:#at:. on:Transcript |
|
2298 |
a sort. |
|
2299 |
" |
|
2300 |
||
2301 |
"Modified: 10.1.1997 / 17:54:53 / cg" |
|
2302 |
! |
|
2303 |
||
88 | 2304 |
untrace:anObject |
2305 |
"remove any traces on anObject" |
|
2306 |
||
2307 |
"just a rename for your convenience - the same basic mechanism is used for all of these |
|
2308 |
trace facilities ..." |
|
2309 |
||
2310 |
^ self untrap:anObject |
|
2311 |
! |
|
2312 |
||
2313 |
untrace:anObject selector:aSelector |
|
2314 |
"remove traces of aSelector sent to anObject" |
|
2315 |
||
2316 |
"just a rename for your convenience - the same basic mechanism is used for all of these |
|
2317 |
trace facilities ..." |
|
2318 |
||
2319 |
^ self untrap:anObject selector:aSelector |
|
2320 |
! ! |
|
2321 |
||
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
2322 |
!MessageTracer class methodsFor:'object wrapping'! |
88 | 2323 |
|
8 | 2324 |
wrap:anObject selector:aSelector onEntry:entryBlock onExit:exitBlock |
2325 |
"arrange for the two blocks entryBlock and exitBlock to be evaluated whenever |
|
2326 |
a message with aSelector is sent to anObject. EntryBlock will be called on |
|
2327 |
entry, and get the current context passed as argument. ExitBlock will be called, |
|
2328 |
when the method is left, and get the context and the methods return value as arguments. |
|
2329 |
The current implementation does not allow integers or nil to be wrapped." |
|
2330 |
||
2331 |
"I have not yet enough experience, if the wrapped original method should |
|
2332 |
run as an instance of the original, or of the catching class; |
|
2333 |
The latter has the advantage of catching recursive and other sends, while |
|
2334 |
it might lead into trouble when the message is sent from a debugger or a long |
|
2335 |
return is done out of the original method ... |
|
2336 |
Time will show, you can experiment by setting the withOriginalClass: flag to false |
|
2337 |
" |
|
660 | 2338 |
^ self |
2339 |
wrap:anObject |
|
2340 |
selector:aSelector |
|
2341 |
onEntry:entryBlock |
|
2342 |
onExit:exitBlock |
|
2343 |
withOriginalClass:true |
|
2344 |
flushCaches:true |
|
2345 |
||
2346 |
"Modified: / 21.4.1998 / 15:29:50 / cg" |
|
8 | 2347 |
! |
2348 |
||
660 | 2349 |
wrap:anObject selector:aSelector onEntry:entryBlock onExit:exitBlock withOriginalClass:withOriginalClass flushCaches:flushCaches |
8 | 2350 |
"arrange for the two blocks entryBlock and exitBlock to be evaluated whenever |
2351 |
a message with aSelector is sent to anObject. EntryBlock will be called on |
|
2352 |
entry, and get the current context passed as argument. ExitBlock will be called, |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
2353 |
when the method is left, and get the current context and the methods return value as argument. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
2354 |
If withOriginalClass is true, the class of anObject will be set to its original class |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
2355 |
before the wrapped method will be called. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
2356 |
NOTICE: The current implementation does not allow integers or nil to be wrapped." |
8 | 2357 |
|
955
0516771efa2a
preserve a methods packageID when wrapping
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
2358 |
|newClass orgClass myMetaclass trapMethod s spec implClass save dict |
0516771efa2a
preserve a methods packageID when wrapping
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
2359 |
originalMethod| |
8 | 2360 |
|
2361 |
" |
|
27 | 2362 |
some are not allowed (otherwise we get into trouble ...) |
2363 |
" |
|
660 | 2364 |
(aSelector == #class |
2365 |
or:[aSelector == #changeClassTo:]) ifTrue:[ |
|
256 | 2366 |
Transcript showCR:'sorry, cannot place trap on: ' , aSelector. |
2367 |
^ self |
|
27 | 2368 |
]. |
2369 |
||
2370 |
WrappedMethod autoload. "/ just to make sure ... |
|
2371 |
||
2372 |
" |
|
8 | 2373 |
create a new (anonymous) subclass of the receivers class |
2374 |
but only if not already being trapped. |
|
2375 |
" |
|
2376 |
orgClass := anObject class. |
|
457
8ba8e7ac735d
use #'* trapping *' instead of #trapping as category mark
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
2377 |
orgClass category == #'* trapping *' ifTrue:[ |
256 | 2378 |
newClass := orgClass |
8 | 2379 |
] ifFalse:[ |
256 | 2380 |
myMetaclass := orgClass class. |
8 | 2381 |
|
256 | 2382 |
newClass := myMetaclass copy new. |
2383 |
newClass setSuperclass:orgClass. |
|
2384 |
newClass instSize:orgClass instSize. |
|
2385 |
newClass flags:orgClass flags. |
|
667 | 2386 |
newClass isMeta ifFalse:[newClass setClassVariableString:'']. |
256 | 2387 |
newClass setInstanceVariableString:''. |
2388 |
newClass setName:orgClass name. |
|
457
8ba8e7ac735d
use #'* trapping *' instead of #trapping as category mark
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
2389 |
newClass category:#'* trapping *'. |
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
2390 |
newClass methodDictionary:MethodDictionary new. |
8 | 2391 |
]. |
2392 |
||
2393 |
" |
|
2394 |
create a method, executing the trap-blocks and the original method via a super-send |
|
2395 |
" |
|
2396 |
spec := Parser methodSpecificationForSelector:aSelector. |
|
2397 |
s := WriteStream on:String new. |
|
2398 |
s nextPutAll:spec. |
|
27 | 2399 |
s nextPutAll:' |retVal stubClass| '. |
8 | 2400 |
withOriginalClass ifTrue:[ |
256 | 2401 |
s nextPutAll:'stubClass := self class. '. |
2402 |
s nextPutAll:'self changeClassTo:(stubClass superclass). '. |
|
8 | 2403 |
]. |
2404 |
entryBlock notNil ifTrue:[ |
|
256 | 2405 |
s nextPutAll:'#literal1 yourself value:thisContext. '. |
8 | 2406 |
]. |
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
2407 |
s nextPutAll:('retVal := #originalMethod. '). "/ just to get a place for the originalMethod |
27 | 2408 |
s nextPutAll:('retVal := super ' , spec , '. '). |
8 | 2409 |
exitBlock notNil ifTrue:[ |
256 | 2410 |
s nextPutAll:'#literal2 yourself value:thisContext value:retVal. '. |
8 | 2411 |
]. |
2412 |
withOriginalClass ifTrue:[ |
|
256 | 2413 |
s nextPutAll:'self changeClassTo:stubClass. '. |
8 | 2414 |
]. |
2415 |
s nextPutAll:'^ retVal'; cr. |
|
2416 |
||
37 | 2417 |
save := Compiler stcCompilation. |
2418 |
Compiler stcCompilation:#never. |
|
2419 |
[ |
|
256 | 2420 |
Class withoutUpdatingChangesDo:[ |
2421 |
trapMethod := Compiler compile:s contents |
|
2422 |
forClass:newClass |
|
2423 |
inCategory:'breakpointed' |
|
2424 |
notifying:nil |
|
2425 |
install:false |
|
2426 |
skipIfSame:false |
|
2427 |
silent:true. |
|
2428 |
] |
|
37 | 2429 |
] valueNowOrOnUnwindDo:[ |
256 | 2430 |
Compiler stcCompilation:save |
37 | 2431 |
]. |
8 | 2432 |
|
646 | 2433 |
trapMethod == #Error ifTrue:[ |
2434 |
Transcript showCR:('cannot place trap on method: ' , aSelector). |
|
2435 |
^ self |
|
2436 |
]. |
|
2437 |
||
29 | 2438 |
implClass := orgClass whichClassIncludesSelector:aSelector. |
2439 |
implClass isNil ifTrue:[ |
|
256 | 2440 |
Transcript showCR:aSelector , ' is not understood by ' , orgClass name. |
29 | 2441 |
] ifFalse:[ |
955
0516771efa2a
preserve a methods packageID when wrapping
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
2442 |
originalMethod := (implClass compiledMethodAt:aSelector). |
0516771efa2a
preserve a methods packageID when wrapping
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
2443 |
originalMethod notNil ifTrue:[ |
0516771efa2a
preserve a methods packageID when wrapping
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
2444 |
trapMethod setPackage:originalMethod package. |
0516771efa2a
preserve a methods packageID when wrapping
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
2445 |
]. |
0516771efa2a
preserve a methods packageID when wrapping
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
2446 |
|
0516771efa2a
preserve a methods packageID when wrapping
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
2447 |
trapMethod changeLiteral:#originalMethod to:originalMethod. |
29 | 2448 |
]. |
8 | 2449 |
entryBlock notNil ifTrue:[ |
352
ac12b5bc2754
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
327
diff
changeset
|
2450 |
trapMethod changeLiteral:#literal1 to:entryBlock. |
8 | 2451 |
]. |
2452 |
exitBlock notNil ifTrue:[ |
|
352
ac12b5bc2754
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
327
diff
changeset
|
2453 |
trapMethod changeLiteral:#literal2 to:exitBlock. |
8 | 2454 |
]. |
2455 |
" |
|
2456 |
change the source of this new method |
|
2457 |
(to avoid confusion in the debugger ...) |
|
2458 |
" |
|
2459 |
trapMethod source:'this is a wrapper method - not the real one'. |
|
27 | 2460 |
trapMethod changeClassTo:WrappedMethod. |
8 | 2461 |
|
2462 |
" |
|
2463 |
install this new method |
|
2464 |
" |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
2465 |
dict := newClass methodDictionary. |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
2466 |
dict := dict at:aSelector putOrAppend:trapMethod. |
660 | 2467 |
flushCaches ifTrue:[ |
2468 |
newClass methodDictionary:dict. |
|
2469 |
] ifFalse:[ |
|
2470 |
newClass setMethodDictionary:dict. |
|
2471 |
]. |
|
8 | 2472 |
|
2473 |
" |
|
2474 |
and finally, the big trick: |
|
2475 |
" |
|
660 | 2476 |
newClass ~~ orgClass ifTrue:[ |
2477 |
anObject changeClassTo:newClass |
|
2478 |
]. |
|
8 | 2479 |
|
2480 |
" |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
2481 |
[exBegin] |
8 | 2482 |
|p| |
2483 |
||
2484 |
p := Point new copy. |
|
2485 |
MessageTracer |
|
256 | 2486 |
wrap:p |
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
2487 |
selector:#y: |
256 | 2488 |
onEntry:nil |
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
2489 |
onExit:[:context :retVal | |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
2490 |
Transcript show:'leave Point>>y:, returning:'. |
256 | 2491 |
Transcript showCR:retVal printString. |
2492 |
Transcript endEntry |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
2493 |
] |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
2494 |
withOriginalClass:true. |
256 | 2495 |
Transcript showCR:'sending x: ...'. |
8 | 2496 |
p x:1. |
256 | 2497 |
Transcript showCR:'sending y: ...'. |
8 | 2498 |
p y:2. |
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
2499 |
MessageTracer untrap:p. |
256 | 2500 |
Transcript showCR:'sending x: ...'. |
8 | 2501 |
p x:2. |
256 | 2502 |
Transcript showCR:'sending y: ...'. |
8 | 2503 |
p y:1. |
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
2504 |
[exEnd] |
8 | 2505 |
" |
2506 |
||
2507 |
" |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
2508 |
[exBegin] |
8 | 2509 |
|p| |
2510 |
||
2511 |
p := Point new copy. |
|
2512 |
MessageTracer wrap:p |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
2513 |
selector:#y: |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
2514 |
onEntry:[:context | self halt:'y: you are trapped'] |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
2515 |
onExit:nil |
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
2516 |
withOriginalClass:false. |
256 | 2517 |
Transcript showCR:'sending x: ...'. |
8 | 2518 |
p x:1. |
256 | 2519 |
Transcript showCR:'sending y: ...'. |
8 | 2520 |
p y:2. |
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
2521 |
MessageTracer untrap:p. |
256 | 2522 |
Transcript showCR:'sending x: ...'. |
8 | 2523 |
p x:2. |
256 | 2524 |
Transcript showCR:'sending y: ...'. |
8 | 2525 |
p y:1. |
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
2526 |
[exEnd] |
8 | 2527 |
" |
150
54b6185e9aa7
compile without updating changes-file (also disables historyManager for the wrap)
Claus Gittinger <cg@exept.de>
parents:
120
diff
changeset
|
2528 |
|
646 | 2529 |
"Modified: / 25.6.1996 / 22:11:21 / stefan" |
2530 |
"Modified: / 6.2.1998 / 02:48:13 / cg" |
|
660 | 2531 |
"Created: / 21.4.1998 / 15:30:27 / cg" |
8 | 2532 |
! |
2533 |
||
88 | 2534 |
wrap:anObject selectors:aCollection onEntry:entryBlock onExit:exitBlock |
2535 |
"install wrappers for anObject on all selectors from aCollection" |
|
8 | 2536 |
|
88 | 2537 |
aCollection do:[:aSelector | |
660 | 2538 |
self |
2539 |
wrap:anObject selector:aSelector |
|
2540 |
onEntry:entryBlock onExit:exitBlock |
|
2541 |
withOriginalClass:true |
|
2542 |
flushCaches:false |
|
2543 |
]. |
|
2544 |
ObjectMemory flushCaches |
|
2545 |
||
2546 |
"Modified: / 21.4.1998 / 15:40:28 / cg" |
|
8 | 2547 |
! |
2548 |
||
88 | 2549 |
wrapAll:anObject onEntry:entryBlock onExit:exitBlock |
2550 |
"install wrappers for anObject on all implemented selectors" |
|
27 | 2551 |
|
2552 |
|allSelectors| |
|
2553 |
||
2554 |
allSelectors := IdentitySet new. |
|
2555 |
anObject class withAllSuperclasses do:[:aClass | |
|
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
2556 |
aClass methodDictionary keys addAllTo:allSelectors |
27 | 2557 |
]. |
88 | 2558 |
self wrap:anObject selectors:allSelectors onEntry:entryBlock onExit:exitBlock |
309
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
2559 |
|
d2a145453677
Use methodDictionary instyead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
265
diff
changeset
|
2560 |
"Modified: 5.6.1996 / 14:50:07 / stefan" |
88 | 2561 |
! ! |
2562 |
||
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
2563 |
!MessageTracer class methodsFor:'queries'! |
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
2564 |
|
579 | 2565 |
isCounting:aMethod |
2566 |
"return true if aMethod is counted" |
|
2567 |
||
2568 |
MethodCounts isNil ifTrue:[^ false]. |
|
2569 |
(MethodCounts includesKey:aMethod) ifTrue:[^ true]. |
|
2570 |
aMethod isWrapped ifTrue:[ |
|
2571 |
^ MethodCounts includesKey:aMethod originalMethod |
|
2572 |
]. |
|
2573 |
^ false |
|
2574 |
||
2575 |
"Created: 15.12.1995 / 11:07:58 / cg" |
|
2576 |
"Modified: 15.12.1995 / 15:42:10 / cg" |
|
2577 |
! |
|
2578 |
||
2579 |
isTiming:aMethod |
|
2580 |
"return true if aMethod is timed" |
|
2581 |
||
2582 |
MethodTiming isNil ifTrue:[^ false]. |
|
2583 |
(MethodTiming includesKey:aMethod) ifTrue:[^ true]. |
|
2584 |
aMethod isWrapped ifTrue:[ |
|
2585 |
^ MethodTiming includesKey:aMethod originalMethod |
|
2586 |
]. |
|
2587 |
^ false |
|
2588 |
||
2589 |
"Modified: 15.12.1995 / 15:42:10 / cg" |
|
2590 |
"Created: 17.6.1996 / 17:04:29 / cg" |
|
2591 |
! |
|
2592 |
||
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
2593 |
isTrapped:aMethod |
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
2594 |
"return true, if a breakpoint is set on aMethod. |
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
2595 |
This only returns true for standard breakpoints (i.e. for user-wraps, |
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
2596 |
this returns false)" |
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
2597 |
|
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
2598 |
aMethod isWrapped ifFalse:[^ false]. |
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
2599 |
^ aMethod basicLiterals includesIdentical:LeaveBreakBlock |
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
2600 |
|
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
2601 |
" |
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
2602 |
MessageTracer trapMethod:(Collection compiledMethodAt:#select:). |
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
2603 |
Transcript showCR:(Collection compiledMethodAt:#select:) isWrapped. |
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
2604 |
Transcript showCR:(MessageTracer isTrapped:(Collection compiledMethodAt:#select:)). |
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
2605 |
MessageTracer unwrapMethod:(Collection compiledMethodAt:#select:). |
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
2606 |
" |
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
2607 |
|
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
2608 |
"Modified: 22.10.1996 / 17:40:37 / cg" |
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
2609 |
! ! |
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
2610 |
|
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
2611 |
!MessageTracer class methodsFor:'trace helpers'! |
88 | 2612 |
|
694
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2613 |
dummyEmptyMethod |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2614 |
"helper - to get the time it takes to evaluate the wrappers for |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2615 |
a dummy method." |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2616 |
|
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2617 |
"Created: / 30.7.1998 / 16:58:08 / cg" |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2618 |
! |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2619 |
|
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2620 |
getTimeForWrappers |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2621 |
"helper - get the overhead (in ms) spent in the wrapper code of |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2622 |
a timed method." |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2623 |
|
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2624 |
|m times| |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2625 |
|
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2626 |
TimeForWrappers := 0. |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2627 |
|
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2628 |
"/ wrap the dummy method ... |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2629 |
|
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2630 |
m := self class compiledMethodAt:#dummyEmptyMethod. |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2631 |
m := self timeMethod:m. |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2632 |
|
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2633 |
"/ invoke it a few times ... |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2634 |
"/ (cannot take the smallest, since the work done in the wrapper |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2635 |
"/ depends on whether there is already some statistic data) |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2636 |
|
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2637 |
10 timesRepeat:[ |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2638 |
self dummyEmptyMethod. |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2639 |
]. |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2640 |
|
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2641 |
"/ fetch min time & unwrap |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2642 |
|
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2643 |
times := self executionTimesOfMethod:m. |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2644 |
self stopTimingMethod:m. |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2645 |
|
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2646 |
^ (TimeForWrappers := times at:#avgTime) |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2647 |
|
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2648 |
" |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2649 |
self getTimeForWrappers |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2650 |
" |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2651 |
|
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2652 |
"Modified: / 30.7.1998 / 17:10:07 / cg" |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2653 |
! |
7c9f654a1054
much more detailed timing info;
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
2654 |
|
88 | 2655 |
printEntryFull:aContext |
664 | 2656 |
self printEntryFull:aContext level:0 on:Stderr |
88 | 2657 |
! |
27 | 2658 |
|
88 | 2659 |
printEntryFull:aContext level:lvl |
664 | 2660 |
self printEntryFull:aContext level:lvl on:Stderr |
2661 |
! |
|
2662 |
||
2663 |
printEntryFull:aContext level:lvl on:aStream |
|
2664 |
aStream |
|
2665 |
spaces:lvl; |
|
734 | 2666 |
nextPutAll:'enter '. |
2667 |
self printFull:aContext on:aStream withSender:true. |
|
88 | 2668 |
! |
27 | 2669 |
|
664 | 2670 |
printEntryFull:aContext on:aStream |
2671 |
self printEntryFull:aContext level:0 on:aStream |
|
2672 |
! |
|
2673 |
||
2674 |
printEntrySender:aContext on:aStream |
|
2675 |
|sender mClass mClassName| |
|
2676 |
||
2677 |
mClass := aContext methodClass. |
|
2678 |
mClass isNil ifTrue:[ |
|
2679 |
mClassName := '???' |
|
2680 |
] ifFalse:[ |
|
2681 |
mClassName := mClass name |
|
2682 |
]. |
|
734 | 2683 |
|
664 | 2684 |
aStream |
2685 |
nextPutAll:mClassName; |
|
2686 |
space; |
|
665 | 2687 |
bold; |
664 | 2688 |
nextPutAll:aContext selector; |
665 | 2689 |
normal; |
664 | 2690 |
nextPutAll:' from '. |
538
5961061365d9
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
536
diff
changeset
|
2691 |
|
555
c92d12af9f1e
in trace: if sender is Object>>perform, print senders sender.
Claus Gittinger <cg@exept.de>
parents:
538
diff
changeset
|
2692 |
sender := aContext sender. |
c92d12af9f1e
in trace: if sender is Object>>perform, print senders sender.
Claus Gittinger <cg@exept.de>
parents:
538
diff
changeset
|
2693 |
sender notNil ifTrue:[ |
c92d12af9f1e
in trace: if sender is Object>>perform, print senders sender.
Claus Gittinger <cg@exept.de>
parents:
538
diff
changeset
|
2694 |
(sender selector startsWith:'perform:') ifTrue:[ |
c92d12af9f1e
in trace: if sender is Object>>perform, print senders sender.
Claus Gittinger <cg@exept.de>
parents:
538
diff
changeset
|
2695 |
sender := sender sender. |
c92d12af9f1e
in trace: if sender is Object>>perform, print senders sender.
Claus Gittinger <cg@exept.de>
parents:
538
diff
changeset
|
2696 |
]. |
c92d12af9f1e
in trace: if sender is Object>>perform, print senders sender.
Claus Gittinger <cg@exept.de>
parents:
538
diff
changeset
|
2697 |
]. |
664 | 2698 |
sender printOn:aStream. |
666 | 2699 |
aStream cr; flush. |
555
c92d12af9f1e
in trace: if sender is Object>>perform, print senders sender.
Claus Gittinger <cg@exept.de>
parents:
538
diff
changeset
|
2700 |
|
695 | 2701 |
"Modified: / 30.7.1998 / 20:40:14 / cg" |
88 | 2702 |
! |
2703 |
||
2704 |
printExit:aContext with:retVal |
|
664 | 2705 |
self printExit:aContext with:retVal level:0 on:Stderr |
27 | 2706 |
! |
2707 |
||
88 | 2708 |
printExit:aContext with:retVal level:lvl |
664 | 2709 |
self printExit:aContext with:retVal level:lvl on:Stderr |
2710 |
! |
|
2711 |
||
2712 |
printExit:aContext with:retVal level:lvl on:aStream |
|
2713 |
|mClass mClassName| |
|
2714 |
||
2715 |
mClass := aContext methodClass. |
|
2716 |
mClass isNil ifTrue:[ |
|
2717 |
mClassName := '???' |
|
2718 |
] ifFalse:[ |
|
2719 |
mClassName := mClass name |
|
2720 |
]. |
|
2721 |
aStream |
|
2722 |
spaces:lvl; |
|
2723 |
nextPutAll:'leave '; |
|
2724 |
nextPutAll:mClassName; |
|
2725 |
space; |
|
665 | 2726 |
bold; |
664 | 2727 |
nextPutAll:aContext selector; |
665 | 2728 |
normal; |
666 | 2729 |
nextPutAll:' rec=['. |
664 | 2730 |
|
2731 |
aContext receiver printOn:aStream. |
|
666 | 2732 |
aStream nextPutAll:'] return: ['. |
664 | 2733 |
retVal printOn:aStream. |
666 | 2734 |
aStream nextPutAll:']'; cr; flush. |
664 | 2735 |
! |
2736 |
||
2737 |
printExit:aContext with:retVal on:aStream |
|
2738 |
self printExit:aContext with:retVal level:0 on:aStream |
|
2739 |
! |
|
2740 |
||
734 | 2741 |
printFull:aContext on:aStream withSender:withSender |
2742 |
|sender mClass mClassName| |
|
2743 |
||
2744 |
mClass := aContext methodClass. |
|
2745 |
mClass isNil ifTrue:[ |
|
2746 |
mClassName := '???' |
|
2747 |
] ifFalse:[ |
|
2748 |
mClassName := mClass name |
|
2749 |
]. |
|
2750 |
||
2751 |
aStream |
|
2752 |
nextPutAll:mClassName; |
|
2753 |
space; |
|
2754 |
bold; |
|
2755 |
nextPutAll:aContext selector; |
|
2756 |
normal; |
|
2757 |
nextPutAll:' rec=['. |
|
2758 |
||
735 | 2759 |
self printObject:aContext receiver on:aStream. |
2760 |
||
734 | 2761 |
aStream nextPutAll:'] '. |
2762 |
(aContext args) keysAndValuesDo:[:idx :arg | |
|
2763 |
aStream nextPutAll:'arg'. idx printOn:aStream. aStream nextPutAll:'=['. |
|
735 | 2764 |
self printObject:arg on:aStream. |
734 | 2765 |
aStream nextPutAll:'] '. |
2766 |
]. |
|
2767 |
||
2768 |
withSender ifTrue:[ |
|
2769 |
sender := aContext sender. |
|
2770 |
sender notNil ifTrue:[ |
|
2771 |
(sender selector startsWith:'perform:') ifTrue:[ |
|
2772 |
sender := sender sender. |
|
2773 |
]. |
|
2774 |
]. |
|
2775 |
aStream nextPutAll:'from:'. |
|
2776 |
sender printOn:aStream. |
|
2777 |
]. |
|
2778 |
aStream cr; flush. |
|
2779 |
||
2780 |
"Modified: 5.3.1997 / 12:40:55 / cg" |
|
2781 |
! |
|
2782 |
||
735 | 2783 |
printObject:anObject on:aStream |
2784 |
|s| |
|
2785 |
||
2786 |
s := anObject printString. |
|
2787 |
s size > 20 ifTrue:[ |
|
2788 |
s := anObject classNameWithArticle |
|
2789 |
]. |
|
2790 |
aStream nextPutAll:s |
|
2791 |
! |
|
2792 |
||
697 | 2793 |
traceEntryFull:aContext on:aStream |
2794 |
aStream nextPutLine:'-----------------------------------------'. |
|
2795 |
aContext fullPrintAllOn:aStream |
|
2796 |
||
2797 |
"Created: / 30.7.1998 / 20:39:57 / cg" |
|
2798 |
"Modified: / 30.7.1998 / 20:42:23 / cg" |
|
2799 |
! |
|
2800 |
||
664 | 2801 |
traceFullBlockFor:aStream |
2802 |
"avoid generation of fullBlocks" |
|
2803 |
||
2804 |
aStream == Transcript ifTrue:[ |
|
2805 |
^ TraceFullBlock2 |
|
2806 |
]. |
|
2807 |
aStream == Stderr ifTrue:[ |
|
2808 |
^ TraceFullBlock |
|
2809 |
]. |
|
2810 |
^ [:con | con fullPrintAllOn:aStream] |
|
2811 |
||
2812 |
||
2813 |
||
2814 |
! |
|
2815 |
||
2816 |
traceSenderBlockFor:aStream |
|
2817 |
"avoid generation of fullBlocks" |
|
2818 |
||
2819 |
aStream == Transcript ifTrue:[ |
|
2820 |
^ TraceSenderBlock2 |
|
2821 |
]. |
|
2822 |
aStream == Stderr ifTrue:[ |
|
2823 |
^ TraceSenderBlock |
|
2824 |
]. |
|
2825 |
^ [:con | MessageTracer printEntrySender:con on:aStream] |
|
2826 |
||
2827 |
||
2828 |
||
88 | 2829 |
! ! |
13 | 2830 |
|
88 | 2831 |
!MessageTracer methodsFor:'trace helpers '! |
2832 |
||
2833 |
trace:aBlock detail:fullDetail |
|
2834 |
"trace execution of aBlock." |
|
2835 |
||
2836 |
traceDetail := fullDetail. |
|
735 | 2837 |
tracedBlock := aBlock. |
2838 |
||
88 | 2839 |
ObjectMemory stepInterruptHandler:self. |
2840 |
^ [ |
|
735 | 2841 |
ObjectMemory flushInlineCaches. |
2842 |
StepInterruptPending := 1. |
|
2843 |
InterruptPending := 1. |
|
2844 |
aBlock value |
|
88 | 2845 |
] valueNowOrOnUnwindDo:[ |
735 | 2846 |
tracedBlock := nil. |
2847 |
StepInterruptPending := nil. |
|
2848 |
ObjectMemory stepInterruptHandler:nil. |
|
11 | 2849 |
] |
2850 |
||
2851 |
" |
|
735 | 2852 |
PrintingMessageTracer new trace:[#(6 5 4 3 2 1) sort] detail:false |
2853 |
||
2854 |
PrintingMessageTracer new trace:[#(6 5 4 3 2 1) sort] detail:true |
|
2855 |
||
2856 |
PrintingMessageTracer new trace:[#(6 5 4 3 2 1) sort] detail:#indent |
|
2857 |
||
2858 |
PrintingMessageTracer new trace:[#(6 5 4 3 2 1) sort] detail:#fullIndent |
|
8 | 2859 |
" |
735 | 2860 |
|
8 | 2861 |
! ! |
27 | 2862 |
|
970 | 2863 |
!MessageTracer::InteractionCollector methodsFor:'trace helpers '! |
2864 |
||
2865 |
stepInterrupt |
|
2866 |
StepInterruptPending := nil. |
|
2867 |
ObjectMemory flushInlineCaches. |
|
2868 |
StepInterruptPending := 1. |
|
2869 |
InterruptPending := 1. |
|
2870 |
! ! |
|
2871 |
||
734 | 2872 |
!MessageTracer::PrintingMessageTracer methodsFor:'trace helpers '! |
2873 |
||
2874 |
stepInterrupt |
|
2875 |
"called for every send while tracing" |
|
2876 |
||
2877 |
|ignore sel con r| |
|
2878 |
||
2879 |
StepInterruptPending := nil. |
|
2880 |
con := thisContext sender. |
|
2881 |
ignore := false. |
|
2882 |
||
2883 |
con receiver == Processor ifTrue:[ |
|
2884 |
(sel := con selector) == #threadSwitch: ifTrue:[ |
|
2885 |
ignore := true. |
|
2886 |
]. |
|
2887 |
sel == #timerInterrupt ifTrue:[ |
|
2888 |
ignore := true. |
|
2889 |
] |
|
2890 |
]. |
|
2891 |
||
2892 |
con lineNumber == 1 ifFalse:[ |
|
2893 |
ignore := true |
|
2894 |
]. |
|
2895 |
||
2896 |
ignore ifFalse:[ |
|
2897 |
con markForInterruptOnUnwind. |
|
2898 |
||
2899 |
((r := con receiver) ~~ self |
|
2900 |
and:[r ~~ tracedBlock]) ifTrue:[ |
|
2901 |
traceDetail == #fullIndent ifTrue:[ |
|
2902 |
[con notNil |
|
2903 |
and:[(r := con receiver) ~~ self |
|
2904 |
and:[r ~~ tracedBlock]]] whileTrue:[ |
|
2905 |
' ' printOn:Stderr. |
|
2906 |
con := con sender. |
|
2907 |
]. |
|
2908 |
con := thisContext sender. |
|
2909 |
self class printFull:con on:Stderr withSender:false. |
|
2910 |
] ifFalse:[ |
|
2911 |
traceDetail == #indent ifTrue:[ |
|
2912 |
[con notNil |
|
2913 |
and:[(r := con receiver) ~~ self |
|
2914 |
and:[r ~~ tracedBlock]]] whileTrue:[ |
|
2915 |
' ' printOn:Stderr. |
|
2916 |
con := con sender. |
|
2917 |
]. |
|
2918 |
con := thisContext sender. |
|
2919 |
con printOn:Stderr. |
|
2920 |
Stderr cr. |
|
2921 |
] ifFalse:[ |
|
2922 |
traceDetail == true ifTrue:[ |
|
2923 |
self class printFull:con on:Stderr withSender:true. |
|
2924 |
] ifFalse:[ |
|
2925 |
con printOn:Stderr. |
|
2926 |
Stderr cr. |
|
2927 |
] |
|
2928 |
] |
|
2929 |
]. |
|
2930 |
]. |
|
2931 |
]. |
|
2932 |
||
2933 |
ObjectMemory flushInlineCaches. |
|
2934 |
StepInterruptPending := 1. |
|
2935 |
InterruptPending := 1. |
|
2936 |
||
2937 |
" |
|
2938 |
self new trace:[#(6 5 4 3 2 1) sort] detail:false |
|
2939 |
||
2940 |
self new trace:[#(6 5 4 3 2 1) sort] detail:true |
|
2941 |
||
2942 |
self new trace:[#(6 5 4 3 2 1) sort] detail:#indent |
|
2943 |
||
2944 |
self new trace:[#(6 5 4 3 2 1) sort] detail:#fullIndent |
|
2945 |
self new trace:[ View new ] detail:#fullIndent |
|
2946 |
" |
|
2947 |
! ! |
|
2948 |
||
503
67f6584e0f9f
use different leaveBlocks for break & trace
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
2949 |
!MessageTracer class methodsFor:'documentation'! |
98 | 2950 |
|
2951 |
version |
|
970 | 2952 |
^ '$Header: /cvs/stx/stx/libbasic3/MessageTracer.st,v 1.89 2000-09-03 14:45:21 cg Exp $' |
98 | 2953 |
! ! |
27 | 2954 |
MessageTracer initialize! |