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