Tracing.st

Download

[codesyntax lang=”smalltalk”]

Smalltalk at: #SSDefaultMessageTracer put: nil!
   
Object
	subclass: #SSMessageTracer
	instanceVariableNames: 'level'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'TT - Tracing'!

SSMessageTracer
	subclass: #SSSimpleMessageTracer
	instanceVariableNames: 'tracing'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'TT - Tracing'!
   
Object
	subclass: #SSTraceFactory
	instanceVariableNames: 'tracer'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'TT - Tracing'!

SSTraceFactory class instanceVariableNames: 'current'!
  
SSTraceFactory
	subclass: #SSDirectTraceFactory
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'TT - Tracing'!

SSTraceFactory
	subclass: #SSErrorHandlingTraceFactory
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'TT - Tracing'!

!SSDirectTraceFactory methodsFor: 'prototypes' !
 
optimizedPrototype

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original.
    ] ifFalse: [
        | result |
        SSDefaultMessageTracer traceSendBegin: self
            selector: #original
            class: #OriginalMethodClass
            sender: self sender.

        result := super original.

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original
            class: #OriginalMethodClass
            sender: self sender
            result: result.

        ^result.
    ].!
 
optimizedPrototype: a1

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1.
    ] ifFalse: [
        | result |
        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:
            class: #OriginalMethodClass
            with: a1
            sender: self sender.

        result := super original: a1.

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:
            class: #OriginalMethodClass
            with: a1
            sender: self sender
            result: result.

        ^result.
    ].!
   
optimizedPrototype: a1 w: a2

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2.
    ] ifFalse: [
        | result |
        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:
            class: #OriginalMethodClass
            with: a1 with: a2
            sender: self sender.

        result := super original: a1 w: a2.

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:
            class: #OriginalMethodClass
            with: a1 with: a2
            sender: self sender
            result: result.

        ^result.
    ].!
   
optimizedPrototype: a1 w: a2 w: a3

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3.
    ] ifFalse: [
        | result |
        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:
            class: #OriginalMethodClass
            with: a1 with: a2 with: a3
            sender: self sender.

        result := super original: a1 w: a2 w: a3.

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:
            class: #OriginalMethodClass
            with: a1 with: a2 with: a3
            sender: self sender
            result: result.

        ^result.
    ].!
   
prototype

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original.
    ] ifFalse: [
        | args result |
        args := Array new: 0.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        result := super original.

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
  
prototype: a1

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1.
    ] ifFalse: [
        | args result |
        args := Array new: 1.
        args at: 1 put: a1.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        result := super original: a1.

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
   
prototype: a1 w: a2

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2.
    ] ifFalse: [
        | args result |
        args := Array new: 2.
        args at: 1 put: a1.
        args at: 2 put: a2.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        result := super original: a1 w: a2.

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!

prototype: a1 w: a2 w: a3

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3.
    ] ifFalse: [
        | args result |
        args := Array new: 3.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        result := super original: a1 w: a2 w: a3.

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
 
prototype: a1 w: a2 w: a3 w: a4

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4.
    ] ifFalse: [
        | args result |
        args := Array new: 4.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        result := super original: a1 w: a2 w: a3 w: a4.

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
  
prototype: a1 w: a2 w: a3 w: a4 w: a5

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5.
    ] ifFalse: [
        | args result |
        args := Array new: 5.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        result := super original: a1 w: a2 w: a3 w: a4 w: a5.

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
   
prototype: a1 w: a2 w: a3 w: a4 w: a5 w: a6

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6.
    ] ifFalse: [
        | args result |
        args := Array new: 6.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.
        args at: 6 put: a6.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        result := super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6.

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!

prototype: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7.
    ] ifFalse: [
        | args result |
        args := Array new: 7.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.
        args at: 6 put: a6.
        args at: 7 put: a7.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        result := super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7.

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
 
prototype: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8.
    ] ifFalse: [
        | args result |
        args := Array new: 8.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.
        args at: 6 put: a6.
        args at: 7 put: a7.
        args at: 8 put: a8.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        result := super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8.

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
  
prototype: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9.
    ] ifFalse: [
        | args result |
        args := Array new: 9.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.
        args at: 6 put: a6.
        args at: 7 put: a7.
        args at: 8 put: a8.
        args at: 9 put: a9.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        result := super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9.

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
   
prototype: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10.
    ] ifFalse: [
        | args result |
        args := Array new: 10.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.
        args at: 6 put: a6.
        args at: 7 put: a7.
        args at: 8 put: a8.
        args at: 9 put: a9.
        args at: 10 put: a10.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        result := super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10.

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
  
prototype: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11.
    ] ifFalse: [
        | args result |
        args := Array new: 11.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.
        args at: 6 put: a6.
        args at: 7 put: a7.
        args at: 8 put: a8.
        args at: 9 put: a9.
        args at: 10 put: a10.
        args at: 11 put: a11.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        result := super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11.

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
  
prototype: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12.
    ] ifFalse: [
        | args result |
        args := Array new: 12.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.
        args at: 6 put: a6.
        args at: 7 put: a7.
        args at: 8 put: a8.
        args at: 9 put: a9.
        args at: 10 put: a10.
        args at: 11 put: a11.
        args at: 12 put: a12.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        result := super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12.

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
  
prototype: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13.
    ] ifFalse: [
        | args result |
        args := Array new: 13.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.
        args at: 6 put: a6.
        args at: 7 put: a7.
        args at: 8 put: a8.
        args at: 9 put: a9.
        args at: 10 put: a10.
        args at: 11 put: a11.
        args at: 12 put: a12.
        args at: 13 put: a13.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        result := super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13.

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
  
prototype: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14.
    ] ifFalse: [
        | args result |
        args := Array new: 14.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.
        args at: 6 put: a6.
        args at: 7 put: a7.
        args at: 8 put: a8.
        args at: 9 put: a9.
        args at: 10 put: a10.
        args at: 11 put: a11.
        args at: 12 put: a12.
        args at: 13 put: a13.
        args at: 14 put: a14.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        result := super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14.

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
  
prototype: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15.
    ] ifFalse: [
        | args result |
        args := Array new: 15.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.
        args at: 6 put: a6.
        args at: 7 put: a7.
        args at: 8 put: a8.
        args at: 9 put: a9.
        args at: 10 put: a10.
        args at: 11 put: a11.
        args at: 12 put: a12.
        args at: 13 put: a13.
        args at: 14 put: a14.
        args at: 15 put: a15.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        result := super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15.

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
  
prototype: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15 w: a16

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15 w: a16.
    ] ifFalse: [
        | args result |
        args := Array new: 16.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.
        args at: 6 put: a6.
        args at: 7 put: a7.
        args at: 8 put: a8.
        args at: 9 put: a9.
        args at: 10 put: a10.
        args at: 11 put: a11.
        args at: 12 put: a12.
        args at: 13 put: a13.
        args at: 14 put: a14.
        args at: 15 put: a15.
        args at: 16 put: a16.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        result := super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15 w: a16.

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
  
prototype: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15 w: a16 w: a17

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15 w: a16 w: a17.
    ] ifFalse: [
        | args result |
        args := Array new: 17.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.
        args at: 6 put: a6.
        args at: 7 put: a7.
        args at: 8 put: a8.
        args at: 9 put: a9.
        args at: 10 put: a10.
        args at: 11 put: a11.
        args at: 12 put: a12.
        args at: 13 put: a13.
        args at: 14 put: a14.
        args at: 15 put: a15.
        args at: 16 put: a16.
        args at: 17 put: a17.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        result := super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15 w: a16 w: a17.

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
  
prototype: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15 w: a16 w: a17 w: a18

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15 w: a16 w: a17 w: a18.
    ] ifFalse: [
        | args result |
        args := Array new: 18.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.
        args at: 6 put: a6.
        args at: 7 put: a7.
        args at: 8 put: a8.
        args at: 9 put: a9.
        args at: 10 put: a10.
        args at: 11 put: a11.
        args at: 12 put: a12.
        args at: 13 put: a13.
        args at: 14 put: a14.
        args at: 15 put: a15.
        args at: 16 put: a16.
        args at: 17 put: a17.
        args at: 18 put: a18.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        result := super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15 w: a16 w: a17 w: a18.

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
  
prototype: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15 w: a16 w: a17 w: a18 w: a19

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15 w: a16 w: a17 w: a18 w: a19.
    ] ifFalse: [
        | args result |
        args := Array new: 19.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.
        args at: 6 put: a6.
        args at: 7 put: a7.
        args at: 8 put: a8.
        args at: 9 put: a9.
        args at: 10 put: a10.
        args at: 11 put: a11.
        args at: 12 put: a12.
        args at: 13 put: a13.
        args at: 14 put: a14.
        args at: 15 put: a15.
        args at: 16 put: a16.
        args at: 17 put: a17.
        args at: 18 put: a18.
        args at: 19 put: a19.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        result := super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15 w: a16 w: a17 w: a18 w: a19.

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
  
prototype: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15 w: a16 w: a17 w: a18 w: a19 w: a20

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15 w: a16 w: a17 w: a18 w: a19 w: a20.
    ] ifFalse: [
        | args result |
        args := Array new: 20.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.
        args at: 6 put: a6.
        args at: 7 put: a7.
        args at: 8 put: a8.
        args at: 9 put: a9.
        args at: 10 put: a10.
        args at: 11 put: a11.
        args at: 12 put: a12.
        args at: 13 put: a13.
        args at: 14 put: a14.
        args at: 15 put: a15.
        args at: 16 put: a16.
        args at: 17 put: a17.
        args at: 18 put: a18.
        args at: 19 put: a19.
        args at: 20 put: a20.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        result := super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15 w: a16 w: a17 w: a18 w: a19 w: a20.

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].! !

!SSDirectTraceFactory methodsFor: 'private' !
   
patchOptimizedTracingMethod: compiledMethod prototype: prototype

    | selectorPlaceholder |
    selectorPlaceholder := self originalSelector: compiledMethod argumentCount.

    " Replace the SSDefaultMessageTracer variable in the method. "
    self ASSERT: (prototype at: 1) == (Smalltalk associationAt: #SSDefaultMessageTracer).
    prototype at: 1 put: tracer.

    " Replace the symbol used to send to the trace messages "
    self ASSERT: (prototype at: 2) == selectorPlaceholder.
    prototype at: 2 put: compiledMethod selector.

    " Replace the name of the class where the original method is implemented "
    self ASSERT: (prototype at: 3) == #OriginalMethodClass.
    prototype at: 3 put: compiledMethod classField symbol.

    " Replace the selector of the method for the <super> send "
    self ASSERT: (prototype at: 7) ==  selectorPlaceholder.
    prototype at: 7 put: compiledMethod selector.!
  
patchTracingMethod: compiledMethod prototype: prototype

    | selectorPlaceholder |
    selectorPlaceholder := self originalSelector: compiledMethod argumentCount.

    " Replace the SSDefaultMessageTracer variable in the method. "
    self ASSERT: (prototype at: 1) == (Smalltalk associationAt: #SSDefaultMessageTracer).
    prototype at: 1 put: tracer.

    " Replace the symbol used to send to the trace messages "
    self ASSERT: (prototype at: 3) == selectorPlaceholder.
    prototype at: 3 put: compiledMethod selector.

    " Replace the name of the class where the original method is implemented "
    self ASSERT: (prototype at: 4) == #OriginalMethodClass.
    prototype at: 4 put: compiledMethod classField symbol.

    " Replace the selector of the method for the <super> send "
    self ASSERT: (prototype at: 8) ==  selectorPlaceholder.
    prototype at: 8 put: compiledMethod selector.! !

!SSDirectTraceFactory class methodsFor: 'development' !
  
writeMethodPrototype: args on: str

    self writeMethodPrototypeProlog: args on: str.

    str nextPutAll: '    SSDefaultMessageTracer isNil ifTrue: ['; cr.
    str nextPutAll: '        ^super '.
    self writeOriginalMethodSendPlaceholder: args on: str.
    str nextPutAll: '.'; cr.
    str nextPutAll: '    ] ifFalse: ['; cr.
    str nextPutAll: '        | args result |'; cr.
    str nextPutAll: '        args := Array new: ', args asString, '.'; cr.
    1 to: args do: [ :i | str nextPutAll: '        args at: ', i asString, ' put: a', i asString, '.'; cr ].
    str cr.
    str nextPutAll: '        SSDefaultMessageTracer traceSendBegin: self '; cr.
    str nextPutAll: '            selector: #'. self writeOriginalMethodSelectorPlaceholder: args on: str. str cr.
    str nextPutAll: '            class: #OriginalMethodClass'; cr.
    str nextPutAll: '            arguments: args'; cr.
    str nextPutAll: '            sender: self sender.'; cr; cr.
    str nextPutAll: '        result := super '.
    self writeOriginalMethodSendPlaceholder: args on: str.
    str nextPutAll: '.'; cr; cr.
    str nextPutAll: '        SSDefaultMessageTracer traceSendReturn: self '; cr.
    str nextPutAll: '            selector: #'. self writeOriginalMethodSelectorPlaceholder: args on: str. str cr.
    str nextPutAll: '            class: #OriginalMethodClass'; cr.
    str nextPutAll: '            arguments: args'; cr.
    str nextPutAll: '            sender: self sender'; cr.
    str nextPutAll: '            result: result.'; cr; cr.
    str nextPutAll: '        ^result.'; cr.
    str nextPutAll: '    ].'; cr.! !

!SSErrorHandlingTraceFactory methodsFor: 'prototypes' !
  
optimizedPrototype

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original.
    ] ifFalse: [
        | result |
        SSDefaultMessageTracer traceSendBegin: self
            selector: #original
            class: #OriginalMethodClass
            sender: self sender.

        [
            result := super original.
        ] on: SSDefaultMessageTracer errorClass do: [ :err |
            SSDefaultMessageTracer traceSendError: self
                selector: #original
                class: #OriginalMethodClass
                sender: self sender
                error: err.
            err pass.
        ].

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original
            class: #OriginalMethodClass
            sender: self sender
            result: result.

        ^result.
    ].!

optimizedPrototype: a1

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1.
    ] ifFalse: [
        | result |

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:
            class: #OriginalMethodClass
            with: a1
            sender: self sender.

        [
            result := super original: a1.
        ] on: SSDefaultMessageTracer errorClass do: [ :err |
            SSDefaultMessageTracer traceSendError: self
                selector: #original:
                class: #OriginalMethodClass
                with: a1
                sender: self sender
                error: err.
            err pass.
        ].

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:
            class: #OriginalMethodClass
            with: a1
            sender: self sender
            result: result.

        ^result.
    ].!
 
optimizedPrototype: a1 w: a2

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2.
    ] ifFalse: [
        | result |

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:
            class: #OriginalMethodClass
            with: a1 with: a2
            sender: self sender.

        [
            result := super original: a1 w: a2.
        ] on: SSDefaultMessageTracer errorClass do: [ :err |
            SSDefaultMessageTracer traceSendError: self
                selector: #original:w:
                class: #OriginalMethodClass
                with: a1 with: a2
                sender: self sender
                error: err.
            err pass.
        ].

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:
            class: #OriginalMethodClass
            with: a1 with: a2
            sender: self sender
            result: result.

        ^result.
    ].!
  
optimizedPrototype: a1 w: a2 w: a3

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3.
    ] ifFalse: [
        | result |

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:
            class: #OriginalMethodClass
            with: a1 with: a2 with: a3
            sender: self sender.

        [
            result := super original: a1 w: a2 w: a3.
        ] on: SSDefaultMessageTracer errorClass do: [ :err |
            SSDefaultMessageTracer traceSendError: self
                selector: #original:w:w:
                class: #OriginalMethodClass
                with: a1 with: a2 with: a3
                sender: self sender
                error: err.
            err pass.
        ].

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:
            class: #OriginalMethodClass
            with: a1 with: a2 with: a3
            sender: self sender
            result: result.

        ^result.
    ].!
   
prototype

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original.
    ] ifFalse: [
        | args result |
        args := Array new: 0.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        [
            result := super original.
        ] on: SSDefaultMessageTracer errorClass do: [ :err |
            SSDefaultMessageTracer traceSendError: self
                selector: #original
                class: #OriginalMethodClass
                arguments: args
                sender: self sender
                error: err.
            err pass.
        ].

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!

prototype: a1

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1.
    ] ifFalse: [
        | args result |
        args := Array new: 1.
        args at: 1 put: a1.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        [
            result := super original: a1.
        ] on: SSDefaultMessageTracer errorClass do: [ :err |
            SSDefaultMessageTracer traceSendError: self
                selector: #original:
                class: #OriginalMethodClass
                arguments: args
                sender: self sender
                error: err.
            err pass.
        ].

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!

prototype: a1 w: a2

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2.
    ] ifFalse: [
        | args result |
        args := Array new: 2.
        args at: 1 put: a1.
        args at: 2 put: a2.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        [
            result := super original: a1 w: a2.
        ] on: SSDefaultMessageTracer errorClass do: [ :err |
            SSDefaultMessageTracer traceSendError: self
                selector: #original:w:
                class: #OriginalMethodClass
                arguments: args
                sender: self sender
                error: err.
            err pass.
        ].

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
   
prototype: a1 w: a2 w: a3

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3.
    ] ifFalse: [
        | args result |
        args := Array new: 3.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        [
            result := super original: a1 w: a2 w: a3.
        ] on: SSDefaultMessageTracer errorClass do: [ :err |
            SSDefaultMessageTracer traceSendError: self
                selector: #original:w:w:
                class: #OriginalMethodClass
                arguments: args
                sender: self sender
                error: err.
            err pass.
        ].

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
  
prototype: a1 w: a2 w: a3 w: a4

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4.
    ] ifFalse: [
        | args result |
        args := Array new: 4.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        [
            result := super original: a1 w: a2 w: a3 w: a4.
        ] on: SSDefaultMessageTracer errorClass do: [ :err |
            SSDefaultMessageTracer traceSendError: self
                selector: #original:w:w:w:
                class: #OriginalMethodClass
                arguments: args
                sender: self sender
                error: err.
            err pass.
        ].

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
 
prototype: a1 w: a2 w: a3 w: a4 w: a5

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5.
    ] ifFalse: [
        | args result |
        args := Array new: 5.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        [
            result := super original: a1 w: a2 w: a3 w: a4 w: a5.
        ] on: SSDefaultMessageTracer errorClass do: [ :err |
            SSDefaultMessageTracer traceSendError: self
                selector: #original:w:w:w:w:
                class: #OriginalMethodClass
                arguments: args
                sender: self sender
                error: err.
            err pass.
        ].

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!

prototype: a1 w: a2 w: a3 w: a4 w: a5 w: a6

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6.
    ] ifFalse: [
        | args result |
        args := Array new: 6.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.
        args at: 6 put: a6.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        [
            result := super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6.
        ] on: SSDefaultMessageTracer errorClass do: [ :err |
            SSDefaultMessageTracer traceSendError: self
                selector: #original:w:w:w:w:w:
                class: #OriginalMethodClass
                arguments: args
                sender: self sender
                error: err.
            err pass.
        ].

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
   
prototype: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7.
    ] ifFalse: [
        | args result |
        args := Array new: 7.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.
        args at: 6 put: a6.
        args at: 7 put: a7.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        [
            result := super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7.
        ] on: SSDefaultMessageTracer errorClass do: [ :err |
            SSDefaultMessageTracer traceSendError: self
                selector: #original:w:w:w:w:w:w:
                class: #OriginalMethodClass
                arguments: args
                sender: self sender
                error: err.
            err pass.
        ].

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
  
prototype: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8.
    ] ifFalse: [
        | args result |
        args := Array new: 8.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.
        args at: 6 put: a6.
        args at: 7 put: a7.
        args at: 8 put: a8.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        [
            result := super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8.
        ] on: SSDefaultMessageTracer errorClass do: [ :err |
            SSDefaultMessageTracer traceSendError: self
                selector: #original:w:w:w:w:w:w:w:
                class: #OriginalMethodClass
                arguments: args
                sender: self sender
                error: err.
            err pass.
        ].

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
 
prototype: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9.
    ] ifFalse: [
        | args result |
        args := Array new: 9.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.
        args at: 6 put: a6.
        args at: 7 put: a7.
        args at: 8 put: a8.
        args at: 9 put: a9.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        [
            result := super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9.
        ] on: SSDefaultMessageTracer errorClass do: [ :err |
            SSDefaultMessageTracer traceSendError: self
                selector: #original:w:w:w:w:w:w:w:w:
                class: #OriginalMethodClass
                arguments: args
                sender: self sender
                error: err.
            err pass.
        ].

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!

prototype: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10.
    ] ifFalse: [
        | args result |
        args := Array new: 10.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.
        args at: 6 put: a6.
        args at: 7 put: a7.
        args at: 8 put: a8.
        args at: 9 put: a9.
        args at: 10 put: a10.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        [
            result := super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10.
        ] on: SSDefaultMessageTracer errorClass do: [ :err |
            SSDefaultMessageTracer traceSendError: self
                selector: #original:w:w:w:w:w:w:w:w:w:
                class: #OriginalMethodClass
                arguments: args
                sender: self sender
                error: err.
            err pass.
        ].

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
 
prototype: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11.
    ] ifFalse: [
        | args result |
        args := Array new: 11.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.
        args at: 6 put: a6.
        args at: 7 put: a7.
        args at: 8 put: a8.
        args at: 9 put: a9.
        args at: 10 put: a10.
        args at: 11 put: a11.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        [
            result := super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11.
        ] on: SSDefaultMessageTracer errorClass do: [ :err |
            SSDefaultMessageTracer traceSendError: self
                selector: #original:w:w:w:w:w:w:w:w:w:w:
                class: #OriginalMethodClass
                arguments: args
                sender: self sender
                error: err.
            err pass.
        ].

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
   
prototype: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12.
    ] ifFalse: [
        | args result |
        args := Array new: 12.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.
        args at: 6 put: a6.
        args at: 7 put: a7.
        args at: 8 put: a8.
        args at: 9 put: a9.
        args at: 10 put: a10.
        args at: 11 put: a11.
        args at: 12 put: a12.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        [
            result := super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12.
        ] on: SSDefaultMessageTracer errorClass do: [ :err |
            SSDefaultMessageTracer traceSendError: self
                selector: #original:w:w:w:w:w:w:w:w:w:w:w:
                class: #OriginalMethodClass
                arguments: args
                sender: self sender
                error: err.
            err pass.
        ].

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
 
prototype: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13.
    ] ifFalse: [
        | args result |
        args := Array new: 13.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.
        args at: 6 put: a6.
        args at: 7 put: a7.
        args at: 8 put: a8.
        args at: 9 put: a9.
        args at: 10 put: a10.
        args at: 11 put: a11.
        args at: 12 put: a12.
        args at: 13 put: a13.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        [
            result := super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13.
        ] on: SSDefaultMessageTracer errorClass do: [ :err |
            SSDefaultMessageTracer traceSendError: self
                selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:
                class: #OriginalMethodClass
                arguments: args
                sender: self sender
                error: err.
            err pass.
        ].

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
   
prototype: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14.
    ] ifFalse: [
        | args result |
        args := Array new: 14.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.
        args at: 6 put: a6.
        args at: 7 put: a7.
        args at: 8 put: a8.
        args at: 9 put: a9.
        args at: 10 put: a10.
        args at: 11 put: a11.
        args at: 12 put: a12.
        args at: 13 put: a13.
        args at: 14 put: a14.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        [
            result := super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14.
        ] on: SSDefaultMessageTracer errorClass do: [ :err |
            SSDefaultMessageTracer traceSendError: self
                selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:
                class: #OriginalMethodClass
                arguments: args
                sender: self sender
                error: err.
            err pass.
        ].

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
 
prototype: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15.
    ] ifFalse: [
        | args result |
        args := Array new: 15.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.
        args at: 6 put: a6.
        args at: 7 put: a7.
        args at: 8 put: a8.
        args at: 9 put: a9.
        args at: 10 put: a10.
        args at: 11 put: a11.
        args at: 12 put: a12.
        args at: 13 put: a13.
        args at: 14 put: a14.
        args at: 15 put: a15.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        [
            result := super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15.
        ] on: SSDefaultMessageTracer errorClass do: [ :err |
            SSDefaultMessageTracer traceSendError: self
                selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:w:
                class: #OriginalMethodClass
                arguments: args
                sender: self sender
                error: err.
            err pass.
        ].

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
   
prototype: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15 w: a16

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15 w: a16.
    ] ifFalse: [
        | args result |
        args := Array new: 16.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.
        args at: 6 put: a6.
        args at: 7 put: a7.
        args at: 8 put: a8.
        args at: 9 put: a9.
        args at: 10 put: a10.
        args at: 11 put: a11.
        args at: 12 put: a12.
        args at: 13 put: a13.
        args at: 14 put: a14.
        args at: 15 put: a15.
        args at: 16 put: a16.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        [
            result := super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15 w: a16.
        ] on: SSDefaultMessageTracer errorClass do: [ :err |
            SSDefaultMessageTracer traceSendError: self
                selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:
                class: #OriginalMethodClass
                arguments: args
                sender: self sender
                error: err.
            err pass.
        ].

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
 
prototype: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15 w: a16 w: a17

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15 w: a16 w: a17.
    ] ifFalse: [
        | args result |
        args := Array new: 17.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.
        args at: 6 put: a6.
        args at: 7 put: a7.
        args at: 8 put: a8.
        args at: 9 put: a9.
        args at: 10 put: a10.
        args at: 11 put: a11.
        args at: 12 put: a12.
        args at: 13 put: a13.
        args at: 14 put: a14.
        args at: 15 put: a15.
        args at: 16 put: a16.
        args at: 17 put: a17.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        [
            result := super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15 w: a16 w: a17.
        ] on: SSDefaultMessageTracer errorClass do: [ :err |
            SSDefaultMessageTracer traceSendError: self
                selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:
                class: #OriginalMethodClass
                arguments: args
                sender: self sender
                error: err.
            err pass.
        ].

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
   
prototype: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15 w: a16 w: a17 w: a18

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15 w: a16 w: a17 w: a18.
    ] ifFalse: [
        | args result |
        args := Array new: 18.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.
        args at: 6 put: a6.
        args at: 7 put: a7.
        args at: 8 put: a8.
        args at: 9 put: a9.
        args at: 10 put: a10.
        args at: 11 put: a11.
        args at: 12 put: a12.
        args at: 13 put: a13.
        args at: 14 put: a14.
        args at: 15 put: a15.
        args at: 16 put: a16.
        args at: 17 put: a17.
        args at: 18 put: a18.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        [
            result := super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15 w: a16 w: a17 w: a18.
        ] on: SSDefaultMessageTracer errorClass do: [ :err |
            SSDefaultMessageTracer traceSendError: self
                selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:
                class: #OriginalMethodClass
                arguments: args
                sender: self sender
                error: err.
            err pass.
        ].

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
 
prototype: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15 w: a16 w: a17 w: a18 w: a19

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15 w: a16 w: a17 w: a18 w: a19.
    ] ifFalse: [
        | args result |
        args := Array new: 19.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.
        args at: 6 put: a6.
        args at: 7 put: a7.
        args at: 8 put: a8.
        args at: 9 put: a9.
        args at: 10 put: a10.
        args at: 11 put: a11.
        args at: 12 put: a12.
        args at: 13 put: a13.
        args at: 14 put: a14.
        args at: 15 put: a15.
        args at: 16 put: a16.
        args at: 17 put: a17.
        args at: 18 put: a18.
        args at: 19 put: a19.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        [
            result := super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15 w: a16 w: a17 w: a18 w: a19.
        ] on: SSDefaultMessageTracer errorClass do: [ :err |
            SSDefaultMessageTracer traceSendError: self
                selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:
                class: #OriginalMethodClass
                arguments: args
                sender: self sender
                error: err.
            err pass.
        ].

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].!
   
prototype: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15 w: a16 w: a17 w: a18 w: a19 w: a20

    " Auto generated method for tracing - method source may be mismatching "

    SSDefaultMessageTracer isNil ifTrue: [
        ^super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15 w: a16 w: a17 w: a18 w: a19 w: a20.
    ] ifFalse: [
        | args result |
        args := Array new: 20.
        args at: 1 put: a1.
        args at: 2 put: a2.
        args at: 3 put: a3.
        args at: 4 put: a4.
        args at: 5 put: a5.
        args at: 6 put: a6.
        args at: 7 put: a7.
        args at: 8 put: a8.
        args at: 9 put: a9.
        args at: 10 put: a10.
        args at: 11 put: a11.
        args at: 12 put: a12.
        args at: 13 put: a13.
        args at: 14 put: a14.
        args at: 15 put: a15.
        args at: 16 put: a16.
        args at: 17 put: a17.
        args at: 18 put: a18.
        args at: 19 put: a19.
        args at: 20 put: a20.

        SSDefaultMessageTracer traceSendBegin: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender.

        [
            result := super original: a1 w: a2 w: a3 w: a4 w: a5 w: a6 w: a7 w: a8 w: a9 w: a10 w: a11 w: a12 w: a13 w: a14 w: a15 w: a16 w: a17 w: a18 w: a19 w: a20.
        ] on: SSDefaultMessageTracer errorClass do: [ :err |
            SSDefaultMessageTracer traceSendError: self
                selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:
                class: #OriginalMethodClass
                arguments: args
                sender: self sender
                error: err.
            err pass.
        ].

        SSDefaultMessageTracer traceSendReturn: self
            selector: #original:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:w:
            class: #OriginalMethodClass
            arguments: args
            sender: self sender
            result: result.

        ^result.
    ].! !

!SSErrorHandlingTraceFactory methodsFor: 'private' !
   
patchOptimizedTracingMethod: compiledMethod prototype: prototype

    | selectorPlaceholder |
    selectorPlaceholder := self originalSelector: compiledMethod argumentCount.

    " Replace the SSDefaultMessageTracer variable in the method. "
    self ASSERT: (prototype at: 1) == (Smalltalk associationAt: #SSDefaultMessageTracer).
    prototype at: 1 put: tracer.

    " Replace the symbol used to send to the trace messages "
    self ASSERT: (prototype at: 2) == selectorPlaceholder.
    prototype at: 2 put: compiledMethod selector.

    " Replace the name of the class where the original method is implemented "
    self ASSERT: (prototype at: 3) == #OriginalMethodClass.
    prototype at: 3 put: compiledMethod classField symbol.

    " Replace the selector of the method for the <super> send "
    self ASSERT: (prototype at: 13) ==  selectorPlaceholder.
    prototype at: 13 put: compiledMethod selector.!

patchTracingMethod: compiledMethod prototype: prototype

    | selectorPlaceholder |
    selectorPlaceholder := self originalSelector: compiledMethod argumentCount.

    " Replace the SSDefaultMessageTracer variable in the method. "
    self ASSERT: (prototype at: 1) == (Smalltalk associationAt: #SSDefaultMessageTracer).
    prototype at: 1 put: tracer.

    " Replace the symbol used to send to the trace messages "
    self ASSERT: (prototype at: 3) == selectorPlaceholder.
    prototype at: 3 put: compiledMethod selector.

    " Replace the name of the class where the original method is implemented "
    self ASSERT: (prototype at: 4) == #OriginalMethodClass.
    prototype at: 4 put: compiledMethod classField symbol.

    " Replace the selector of the method for the <super> send "
    self ASSERT: (prototype at: 14) ==  selectorPlaceholder.
    prototype at: 14 put: compiledMethod selector.
! !

!SSErrorHandlingTraceFactory class methodsFor: 'development' !
   
writeMethodPrototype: args on: str

    self writeMethodPrototypeProlog: args on: str.

    str nextPutAll: '    SSDefaultMessageTracer isNil ifTrue: ['; cr.
    str nextPutAll: '        ^super '.
    self writeOriginalMethodSendPlaceholder: args on: str.
    str nextPutAll: '.'; cr.
    str nextPutAll: '    ] ifFalse: ['; cr.
    str nextPutAll: '        | args result |'; cr.
    str nextPutAll: '        args := Array new: ', args asString, '.'; cr.
    1 to: args do: [ :i | str nextPutAll: '        args at: ', i asString, ' put: a', i asString, '.'; cr ].
    str cr.
    str nextPutAll: '        SSDefaultMessageTracer traceSendBegin: self '; cr.
    str nextPutAll: '            selector: #'. self writeOriginalMethodSelectorPlaceholder: args on: str. str cr.
    str nextPutAll: '            class: #OriginalMethodClass'; cr.
    str nextPutAll: '            arguments: args'; cr.
    str nextPutAll: '            sender: self sender.'; cr; cr.
    str nextPutAll: '        ['; cr.
    str nextPutAll: '            result := super '.
    self writeOriginalMethodSendPlaceholder: args on: str.
    str nextPutAll: '.'; cr.
    str nextPutAll: '        ] on: SSDefaultMessageTracer errorClass do: [ :err |'; cr.
    str nextPutAll: '            SSDefaultMessageTracer traceSendError: self '; cr.
    str nextPutAll: '                selector: #'. self writeOriginalMethodSelectorPlaceholder: args on: str. str cr.
    str nextPutAll: '                class: #OriginalMethodClass'; cr.
    str nextPutAll: '                arguments: args'; cr.
    str nextPutAll: '                sender: self sender'; cr.
    str nextPutAll: '                error: err.'; cr.
    str nextPutAll: '            err pass.'; cr.
    str nextPutAll: '        ].'; cr; cr.
    str nextPutAll: '        SSDefaultMessageTracer traceSendReturn: self '; cr.
    str nextPutAll: '            selector: #'. self writeOriginalMethodSelectorPlaceholder: args on: str. str cr.
    str nextPutAll: '            class: #OriginalMethodClass'; cr.
    str nextPutAll: '            arguments: args'; cr.
    str nextPutAll: '            sender: self sender'; cr.
    str nextPutAll: '            result: result.'; cr; cr.
    str nextPutAll: '        ^result.'; cr.
    str nextPutAll: '    ].'; cr.! !

!SSMessageTracer methodsFor: 'tracing-begin' !
   
traceSendBegin: anObject selector: aSymbol class: aClassSymbol arguments: anArray sender: aSenderObject

    level := level + 1.
!
   
traceSendBegin: anObject selector: aSymbol class: aClassSymbol sender: aSenderObject

    level := level + 1.
!
  
traceSendBegin: anObject selector: aSymbol class: aClassSymbol with: arg1 sender: aSenderObject

    level := level + 1.
!
   
traceSendBegin: anObject selector: aSymbol class: aClassSymbol with: arg1 with: arg2 sender: aSenderObject

    level := level + 1.
!

traceSendBegin: anObject selector: aSymbol class: aClassSymbol with: arg1 with: arg2 with: arg3 sender: aSenderObject

    level := level + 1.
! !

!SSMessageTracer methodsFor: 'tracing-end' !
   
traceSendReturn: anObject selector: aSymbol class: aClassSymbol arguments: anArray sender: aSenderObject result: aResult

    level := level - 1.
!
  
traceSendReturn: anObject selector: aSymbol class: aClassSymbol sender: aSenderObject result: aResult

    level := level - 1.
!
 
traceSendReturn: anObject selector: aSymbol class: aClassSymbol with: arg1 sender: aSenderObject result: aResult

    level := level - 1.
!
  
traceSendReturn: anObject selector: aSymbol class: aClassSymbol with: arg1 with: arg2  sender: aSenderObject result: aResult

    level := level - 1.
!
  
traceSendReturn: anObject selector: aSymbol class: aClassSymbol with: arg1 with: arg2 with: arg3 sender: aSenderObject result: aResult

    level := level - 1.! !

!SSMessageTracer methodsFor: 'tracing-error' !
  
traceSendError: anObject selector: aSymbol class: aClassSymbol arguments: anArray sender: aSenderObject error: anError

    level := level - 1.
!

traceSendError: anObject selector: aSymbol class: aClassSymbol sender: aSenderObject error: anError

    level := level - 1.!
 
traceSendError: anObject selector: aSymbol class: aClassSymbol with: arg1 sender: aSenderObject error: anError

    level := level - 1.
!

traceSendError: anObject selector: aSymbol class: aClassSymbol with: arg1 with: arg2 sender: aSenderObject error: anError

    level := level - 1.
!
 
traceSendError: anObject selector: aSymbol class: aClassSymbol with: arg1 with: arg2 with: arg3 sender: aSenderObject error: anError

    level := level - 1.
! !

!SSMessageTracer methodsFor: 'private' !

errorClass

    ^Error.!
  
initialize

    level := 0.
    super initialize.! !

!SSMessageTracer class methodsFor: 'as yet unclassified' !
   
new

    ^super new initialize; yourself.! !

!SSSimpleMessageTracer methodsFor: 'tracing-begin' !
  
traceSendBegin: anObject selector: aSymbol class: aClassSymbol arguments: anArray sender: aSenderObject

    tracing == true ifTrue: [ ^self ].
    tracing := true.
    level := level + 1.
    [
        [
            | str |
            str := WriteStream on: (String new: 150).
            level - 1 timesRepeat: [ str tab ].
            aClassSymbol printOn: str.
            str nextPutAll: '>>'.
            aSymbol printOn: str.
            str space.
            anArray printOn: str.
            str cr.

            self outputTrace: str.
        ] on: Error do: [ ].
    ] ensure: [ tracing := false ].!
 
traceSendBegin: anObject selector: aSymbol class: aClassSymbol sender: aSenderObject

    tracing == true ifTrue: [ ^self ].
    tracing := true.
    level := level + 1.
    [
        [
            | str |
            str := WriteStream on: (String new: 150).
            level - 1 timesRepeat: [ str tab ].
            aClassSymbol printOn: str.
            str nextPutAll: '>>'.
            aSymbol printOn: str.
            str cr.

            self outputTrace: str.
        ] on: Error do: [ ].
    ] ensure: [ tracing := false ].!
   
traceSendBegin: anObject selector: aSymbol class: aClassSymbol with: arg1 sender: aSenderObject

    tracing == true ifTrue: [ ^self ].
    tracing := true.
    level := level + 1.
    [
        [
            | str |
            str := WriteStream on: (String new: 150).
            level - 1 timesRepeat: [ str tab ].
            aClassSymbol printOn: str.
            str nextPutAll: '>>'.
            aSymbol printOn: str.
            str nextPutAll: ' ('.
            arg1 printOn: str.
            str nextPutAll: ')'.
            str cr.

            self outputTrace: str.
        ] on: Error do: [ ].
    ] ensure: [ tracing := false ].!
   
traceSendBegin: anObject selector: aSymbol class: aClassSymbol with: arg1 with: arg2 sender: aSenderObject

    tracing == true ifTrue: [ ^self ].
    tracing := true.
    level := level + 1.
    [
        [
            | str |
            str := WriteStream on: (String new: 150).
            level - 1 timesRepeat: [ str tab ].
            aClassSymbol printOn: str.
            str nextPutAll: '>>'.
            aSymbol printOn: str.
            str nextPutAll: ' ('.
            arg1 printOn: str.
            str space.
            arg2 printOn: str.
            str nextPutAll: ')'.
            str cr.

            self outputTrace: str.
        ] on: Error do: [ ].
    ] ensure: [ tracing := false ].!

traceSendBegin: anObject selector: aSymbol class: aClassSymbol with: arg1 with: arg2 with: arg3 sender: aSenderObject

    tracing == true ifTrue: [ ^self ].
    tracing := true.
    level := level + 1.
    [
        [
            | str |
            str := WriteStream on: (String new: 150).
            level - 1 timesRepeat: [ str tab ].
            aClassSymbol printOn: str.
            str nextPutAll: '>>'.
            aSymbol printOn: str.
            str nextPutAll: ' ('.
            arg1 printOn: str.
            str space.
            arg2 printOn: str.
            str space.
            arg3 printOn: str.
            str nextPutAll: ')'.
            str cr.

            self outputTrace: str.
        ] on: Error do: [ ].
    ] ensure: [ tracing := false ].! !

!SSSimpleMessageTracer methodsFor: 'private' !
 
outputTrace: stream

    Transcript show: stream contents.! !

!SSTraceFactory methodsFor: 'private' !
  
createMethodDictionary: methodDictionaryArray for: aClass upToClass: aSuperclass

    | md tracingClass |
    md := MethodDictionary new.
    self installTracingMethods: methodDictionaryArray in: md upToClass: aSuperclass.
    " Next two lines are <the magic> that make it possible for <super> sends to work correctly. "
    tracingClass := self createTracingClass: aClass.
    md do: [ :compiledMethod | compiledMethod classField: tracingClass ].
    ^md.!
   
createTracingClass: aClass

    | cls |
    cls := aClass objectShallowCopy.
    self ASSERT: cls ~~ aClass.
    " Unfortunately, too difficult to change that info for meta classes "
    cls isMetaClass ifFalse: [ cls newNameSymbol: ('Tracing', cls name asString) asSymbol ].
    " Now, fix the superclass so method lookup for <super> works as expected. "
    " NB: They still share the same method dictionary array, but we don't care - we'll not use it. "
    cls superclass: aClass.
    ^cls.!
   
getPrototype: args

    ^(self class compiledMethodAt: (self optimizedPrototypeSelector: args))
        ifNil: [ self class compiledMethodAt: (self prototypeSelector: args) ].!
 
initialize

    tracer := #Tracer -> SSSimpleMessageTracer new.
    super initialize.!
   
installTracingMethod: compiledMethod in: methodDictionary

    | args prototype tracingMethod |
    ( #( vmInterrupt: doesNotUnderstand: sender ) includes: compiledMethod selector )
        ifTrue: [  ^self " Don't trace those - too dangerous " ].
    " Determine number of method arguments. "
    args := compiledMethod argumentCount.
    " And determine if this is a special binary selector ... currently we only support keywords "
    ( args = (Message numberOfArgumentsFor: compiledMethod selector) and: [ args = (compiledMethod selector occurrencesOf: $: ) ] )
        ifFalse: [ ^self ].

    " Get the prototype method for the requested number of arguments. "
    prototype := self getPrototype: args.
    prototype isNil
        ifTrue: [ ^self ].

    " Copy the prototype and fix the literla array "
    tracingMethod := prototype copy.
    " Fix the prototype by replacing literals in it. "
    (tracingMethod selector asString indexOfString: 'optimized') = 1
        ifTrue: [ self patchOptimizedTracingMethod: compiledMethod prototype: tracingMethod ]
        ifFalse: [ self patchTracingMethod: compiledMethod prototype: tracingMethod ].
    " Rename it, and clear the JIT cache. "
    tracingMethod selector: compiledMethod selector.
    tracingMethod primitive: nil.
    " Add it to the method dictionary array. "
    methodDictionary at: tracingMethod selector put: tracingMethod.




    !
  
installTracingMethods: mdaOrMd in: methodDictionary upToClass: aClass

    mdaOrMd isArray ifTrue: [
        mdaOrMd do: [ :md |
            (self installTracingMethods: md in: methodDictionary upToClass: aClass)
                ifFalse: [ ^false " Terminate " ].
        ].
        ^true. " Continue "
    ] ifFalse: [
        mdaOrMd do: [ :compiledMethod |
            (methodDictionary includesKey: compiledMethod selector)
                ifFalse: [ self installTracingMethod: compiledMethod in: methodDictionary ].
        ].
        ^aClass isNil | (mdaOrMd classField ~= aClass). " <true> continue, <false> terminate "
    ].!

optimizedPrototypeSelector: args

    | str |
    str := WriteStream on: String new.
    self class writePrototypeMethodSelector: args on: str.
    str := str contents.
    str at: 1 put: str first asUppercase.
    ^('optimized', str) asSymbol.!

originalSelector: args

    | str |
    str := WriteStream on: String new.
    self class writeOriginalMethodSelectorPlaceholder: args on: str.
    ^str contents asSymbol.!
   
patchOptimizedTracingMethod: compiledMethod prototype: prototype

    self implementedBySubclass.!

patchTracingMethod: compiledMethod prototype: prototype

    self implementedBySubclass.!
 
prototypeSelector: args

    | str |
    str := WriteStream on: String new.
    self class writePrototypeMethodSelector: args on: str.
    ^str contents asSymbol.! !

!SSTraceFactory methodsFor: 'public' !

activateTracingFor: anObject

    self activateTracingFor: anObject upToClass: nil.!
  
activateTracingFor: anObject upToClass: aClass

    | mda md |
    mda := anObject methodDictionaryArray.
    md := self createMethodDictionary: mda for: anObject class upToClass: aClass.
    anObject propertyAt: self put: md.
    anObject addBehavior: md.!
 
deactivateTracingFor: anObject

    | md |
    md := anObject propertyAt: self ifAbsent: [ nil ].
    md isNil ifTrue: [ ^self ].
    anObject removePropertyAt: self.
    anObject removeBehavior: md.!
  
tracer

    ^tracer value.!
   
tracer: anSSMessageTracer

    tracer value: anSSMessageTracer.! !

!SSTraceFactory class methodsFor: 'development' !
   
createMethodPrototypeSource: args

    | str |
    str := WriteStream on: String new.
    self writeMethodPrototype: args on: str.
    ^str contents.!
 
writeMethodPrototype: args on: str

    self implementedBySubclass.!
  
writeMethodPrototypeProlog: args on: str

    str nextPutAll: 'prototype'.
    (1 to: args) do: [ :argIdx |
        str nextPutAll: ': a', argIdx asString.
    ] andBetweenDo: [
        str nextPutAll: ' w'.
    ].
    str cr; cr; nextPutAll: '    " Auto generated method for tracing - method source may be mismatching " '; cr; cr.!

writeOriginalMethodSelectorPlaceholder: args on: str

    str nextPutAll: 'original'.
    (1 to: args) do: [ :na | str nextPutAll: ':' ] andBetweenDo: [ str nextPutAll: 'w' ].
!
   
writeOriginalMethodSendPlaceholder: args on: str

    str nextPutAll: 'original'.
    (1 to: args) do: [ :argIdx |
        str nextPutAll: ': a', argIdx asString.
    ] andBetweenDo: [
        str nextPutAll: ' w'.
    ].!
   
writePrototypeMethodSelector: args on: str

    str nextPutAll: 'prototype'.
    (1 to: args) do: [ :argIdx | str nextPutAll: ':' ] andBetweenDo: [ str nextPutAll: 'w' ].! !

!SSTraceFactory class methodsFor: 'public' !

current

    current isNil ifTrue: [ current := self new ].
    ^current.!
   
new

    ^super new initialize; yourself.! !

!Object methodsFor: 'tracing' !
   
ssActivateTracing

    SSDirectTraceFactory current activateTracingFor: self.
    ^self.! !

!Object methodsFor: 'tracing' !
   
ssActivateTracingUpToClass: aClass

    SSDirectTraceFactory current activateTracingFor: self upToClass: aClass.
    ^self.! !

!Object methodsFor: 'tracing' !

ssDeactivateTracing

    SSDirectTraceFactory current deactivateTracingFor: self.
    ^self.! !

[/codesyntax]

Leave a Reply

Your email address will not be published. Required fields are marked *