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