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