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