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