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