eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'MessageTracer':

Home

everywhere
www.exept.de
for:
[back]

Class: MessageTracer


Inheritance:

   Object
   |
   +--MessageTracer
      |
      +--MessageTracer::InteractionCollector
      |
      +--MessageTracer::PrintingMessageTracer

Package:
stx:libbasic3
Category:
System-Debugging-Support
Version:
rev: 1.110 date: 2010/04/19 16:47:24
user: cg
file: MessageTracer.st directory: libbasic3
module: stx stc-classLibrary: libbasic3
Author:
Claus Gittinger

Description:


This class provides a common home for the tracing
facilities (originally, they where in Object, but have been moved to
allow easier separation of development vs. runtime configurations.

tracing execution of a block:

    MessageTracer trace:[ ... ]

    MessageTracer traceFull:[ ... ]

    (for system developer only:)

    MessageTracer debugTrace:[ ... ]


trapping sends to a specific object:

    MessageTracer trap:anObject selector:aSelector
    ...
    MessageTracer untrap:anObject selector:aSelector
    or:
    MessageTracer untrap:anObject



trapping some messages sent to a specific object:

    MessageTracer trap:anObject selectors:aCollectionOfSelectors
    ...
    MessageTracer untrap:anObject



trapping any message sent to a specific object:

    MessageTracer trapAll:anObject
    ...
    MessageTracer untrap:anObject



trapping evaluation of a specific method:

    MessageTracer trapMethod:aMethod
    ...
    MessageTracer unwrapMethod:aMethod



trapping evaluation of a specific method with
receiver being an instance of some class:

    MessageTracer trapMethod:aMethod forInstancesOf:aClass
    ...
    MessageTracer unwrapMethod:aMethod



tracing sends to a specific object:

    MessageTracer trace:anObject selector:aSelector
    ...
    MessageTracer untrace:anObject selector:aSelector
    or:
    MessageTracer untrace:anObject



tracing sender only:

    MessageTracer traceSender:anObject selector:aSelector
    ...
    MessageTracer untrace:anObject selector:aSelector
    or:
    MessageTracer untrace:anObject



tracing evaluation of a specific method:

    MessageTracer traceMethod:aMethod
    ...
    MessageTracer unwrapmethod:aMethod

  see more in examples and in method comments.


Class protocol:

Signal constants
o  breakpointSignal

o  objectWrittenBreakpointSignal

class initialization
o  initialize

o  update: something with: parameter from: changedObject
sent when restarted after a snapIn

class tracing
o  untraceAllClasses
remove all traces of messages sent to any class

o  untraceClass: aClass
remove all traces of messages sent to instances of aClass

class wrapping
o  wrapClass: orgClass selector: aSelector onEntry: entryBlock onExit: exitBlock
arrange for the two blocks entryBlock and exitBlock to be evaluated whenever
aSelector is sent to instances of orgClass or subclasses.
EntryBlock will be called on entry, and get the current context passed as argument.
ExitBlock will be called, when the method is left, and get context and the methods return value as arguments.

cleanup
o  cleanup
if you forgot which classes/methods where wrapped and/or trapped,
this cleans up everything ...

execution trace
o  debugTrace: aBlock
trace execution of aBlock. This is for system debugging only;
The trace output is a low level trace generated in the VM.

o  trace: aBlock
evaluate aBlock sending trace information to stdout.
Return the value of the block.

o  traceFull: aBlock
evaluate aBlock sending trace information to stdout.
Return the value of the block.
The trace information is more detailed.

o  traceFullIndented: aBlock
evaluate aBlock sending trace information to stdout.
Return the value of the block.
The trace information is more detailed.

o  traceIndented: aBlock
evaluate aBlock sending trace information to stdout.
Return the value of the block.

method breakpointing
o  trapClass: aClass selector: aSelector
arrange for the debugger to be entered when a message with aSelector is
sent to instances of aClass (or subclass instances). Use untrapClass to remove this trap.
Be careful, to not place a trap on code needed in the debugger (i.e. on scrollBars etc.);
if there is a need to trap those, use the low-level wrap-methods, and put a check into the
entry/leave blocks.

o  trapMethod: aMethod
arrange for the debugger to be entered when aMethod is about to be executed.
The trap is enabled for any process - see #trapMethod:inProcess: for a more
selective breakPoint.
Use unwrapMethod or untrapClass to remove this trap.
Be careful, to not place a trap on code needed in the debugger (i.e. on scrollBars etc.);
if there is a need to trap those, use the low-level wrap-methods, and put a check into the
entry/leave blocks.

o  trapMethod: aMethod after: countInvocations
arrange for the debugger to be entered when aMethod has been invoked countInvocations times.
The trap is enabled for any process.
Use unwrapMethod or untrapClass to remove this trap.
Be careful, to not place a trap on code needed in the debugger (i.e. on scrollBars etc.);
if there is a need to trap those, use the low-level wrap-methods, and put a check into the
entry/leave blocks.

o  trapMethod: aMethod forInstancesOf: aClass
arrange for the debugger to be entered when aMethod is about to be executed
for an instance of aClass.
Use unwrapMethod or untrapClass to remove this trap.
Be careful, to not place a trap on code needed in the debugger (i.e. on scrollBars etc.);
if there is a need to trap those, use the low-level wrap-methods, and put a check into the
entry/leave blocks.

o  trapMethod: aMethod if: conditionBlock
arrange for the debugger to be entered when aMethod has been invoked and conditionBlock
evaluates to true.
The trap is enabled for any process.
Use unwrapMethod or untrapClass to remove this trap.
Be careful, to not place a trap on code needed in the debugger (i.e. on scrollBars etc.);
if there is a need to trap those, use the low-level wrap-methods, and put a check into the
entry/leave blocks.

o  trapMethod: aMethod inProcess: aProcess
arrange for the debugger to be entered when aMethod is about to be executed,
but only, if executed aProcess or one of aProcess's offspring.
This allows for breakpoints to be set on system-critical code.
The trap will only fire for selected processes (making browsers etc. still usable).
Use unwrapMethod or untrapClass to remove this trap.
Be careful, to not place a trap on code needed in the debugger (i.e. on scrollBars etc.);
if there is a need to trap those, use the low-level wrap-methods, and put a check into the
entry/leave blocks.

o  untrapAllClasses
remove any traps on any class

o  untrapClass: aClass
remove any traps on aClass

o  untrapClass: aClass selector: aSelector
remove trap of aSelector sent to aClass

o  untrapMethod: aMethod
remove break on aMethod

method counting
o  countMethod: aMethod
arrange for a aMethods execution to be counted.
Use unwrapMethod to remove this.

o  executionCountOfMethod: aMethod
return the current count

o  resetCountOfMethod: aMethod
return the current count

o  stopCountingMethod: aMethod
remove counting of aMethod

method memory usage
o  countMemoryUsageOfMethod: aMethod
arrange for aMethods memory usage to be counted.
Use unwrapMethod to remove this.

o  isCountingMemoryUsage: aMethod
return true if aMethod is counting memoryUsage

o  memoryUsageOfMethod: aMethod
return the current count

o  resetMemoryUsageOfMethod: aMethod
reset the current usage

o  stopCountingMemoryUsageOfMethod: aMethod
remove counting memory of aMethod

method timing
o  executionTimesOfMethod: aMethod
return the current gathered execution time statistics

o  resetExecutionTimesOfMethod: aMethod
reset the gathered execution times statistics for aMethod;
the method remains wrapped.

o  stopTimingMethod: aMethod
remove timing of aMethod

o  timeMethod: aMethod
arrange for a aMethods execution time to be measured.
Use unwrapMethod: or stopTimingMethod: to remove this.

method tracing
o  traceClass: aClass selector: aSelector
arrange for a trace message to be output on Stderr, when a message with aSelector is
sent to instances of aClass (or subclass instances). Use untraceClass to remove this.

o  traceClass: aClass selector: aSelector on: aStream
arrange for a trace message to be output on aStream, when a message with aSelector is
sent to instances of aClass (or subclass instances). Use untraceClass to remove this.

o  traceMethod: aMethod
arrange for a trace message to be output on Stderr,
when aMethod is executed. Traces both entry and exit.
Use unwrapMethod to remove this.

o  traceMethod: aMethod on: aStream
arrange for a trace message to be output on aStream,
when aMethod is executed. Traces both entry and exit.
Use unwrapMethod to remove this.

o  traceMethodAll: aMethod
arrange for a full trace message to be output on Stderr, when aMethod is executed.
Only the sender is traced on entry.
Use untraceMethod to remove this trace.
This is for system debugging only;
The trace output is a low level trace generated in the VM.

o  traceMethodEntry: aMethod
arrange for a trace message to be output on stdErr,
when aMethod is executed. Only entry is traced.
Use unwrapMethod to remove this.

o  traceMethodEntry: aMethod on: aStream
arrange for a trace message to be output on aStream,
when aMethod is executed. Only entry is traced.
Use unwrapMethod to remove this.

o  traceMethodFull: aMethod
arrange for a full trace message to be output on Stderr, when amethod is executed.
Only the sender is traced on entry.
Use untraceMethod to remove this trace.

o  traceMethodFull: aMethod on: aStream
arrange for a full trace message to be output on Stderr, when aMethod is executed.
Only the sender is traced on entry.
Use untraceMethod to remove this trace.

o  traceMethodSender: aMethod
arrange for a trace message to be output on Stderr,
when amethod is executed.
Only the sender is traced on entry.
Use untraceMethod to remove this trace.

o  traceMethodSender: aMethod on: aStream
arrange for a trace message to be output on Stderr, when amethod is executed.
Only the sender is traced on entry.
Use untraceMethod to remove this trace.

o  traceUpdateMethod: aMethod on: aStream
arrange for a trace message to be output on aStream,
when aMethod is executed.
Traces both entry and exit.
Use unwrapMethod to remove this.
This one is specialized for change-update calling i.e. it traces from the update
back to the origial change message.

o  untraceMethod: aMethod
remove tracing of aMethod

method wrapping
o  unwrapAllMethods
just in case you dont know what methods have break/trace-points
on them; this removes them all

o  unwrapMethod: aMethod
remove any wrapper on aMethod

o  wrapMethod: aMethod onEntry: entryBlock onExit: exitBlock

o  wrapMethod: aMethod onEntry: entryBlock onExit: exitBlock onUnwind: unwindBlock
arrange for the two blocks entryBlock and exitBlock to be evaluated whenever
aMethod is evaluated.
EntryBlock will be called on entry, and gets the current context passed as argument.
ExitBlock will be called, when the method is left, and gets the context and
the methods return value as arguments.
UnwindBlock will be called when the contxt of aMethod is unwound.
If there is an unwindBlock, the entry and exitBlocks will be called within the unwind block,
because allocating the unwindBlock uses memory and some users want to count allocated memory.

object breakpointing
o  objectHasWraps: anObject
return true, if anObject has any wraps

o  realClassOf: anObject
return anObjects real class

o  trap: anObject selector: aSelector
arrange for the debugger to be entered when a message with aSelector is
sent to anObject. Use untrap to remove this trap.
The current implementation does not allow integers or nil to be trapped.

o  trap: anObject selectors: aCollection

o  trapAll: anObject
trap on all messages which are understood by anObject

o  trapAll: anObject from: aClass
trap on all messages defined in aClass sent to anObject

o  untrap: anObject
remove any traps on anObject

o  untrap: anObject selector: aSelector
remove trap on aSelector from anObject

o  wrappedSelectorsOf: anObject
return the set of wrapped selectors (if any)

object modification traps
o  trapModificationsIn: anObject
trap modifications in anObject

o  trapModificationsIn: anObject filter: aFilterBlock
trap modifications in anObject

o  trapModificationsIn: anObject selector: aSelector filter: aFilterBlock
install a trap for modifications in anObject by aSelector-messages.
the filterBlock will be invoked (after a modification) with the old and
new values as arguments and should return true,
if the debugger is really wanted.

o  trapModificationsIn: anObject selectors: aCollectionOfSelectors filter: aFilterBlock
install a trap for modifications in anObject by aSelector-messages.
the filterBlock will be invoked (after a modification) with the old and
new values as arguments and should return true,
if the debugger is really wanted.

o  trapModificationsOf: anInstVarOrOffset in: anObject
trap modifications in anObject

object tracing
o  trace: anObject selector: aSelector
arrange for a trace message to be output on Stderr, when a message with
aSelector is sent to anObject. Both entry and exit are traced.
Use untrap to remove this trace.
The current implementation does not allow integers or nil to be traced.

o  trace: anObject selector: aSelector on: aStream
arrange for a trace message to be output on Stderr, when a message with
aSelector is sent to anObject. Both entry and exit are traced.
Use untrap to remove this trace.
The current implementation does not allow integers or nil to be traced.

o  trace: anObject selectors: aCollectionOfSelectors
arrange for a trace message to be output on Stderr, when any message
from aCollectionOfSelectors is sent to anObject.
Both entry and exit are traced.
Use untrap:/untrace: to remove this trace.
The current implementation does not allow integers or nil to be traced.

o  trace: anObject selectors: aCollectionOfSelectors on: aStream
arrange for a trace message to be output on Stderr, when any message
from aCollectionOfSelectors is sent to anObject.
Both entry and exit are traced.
Use untrap:/untrace: to remove this trace.
The current implementation does not allow integers or nil to be traced.

o  traceAll: anObject
trace all messages which are understood by anObject

o  traceAll: anObject from: aClass
trace all messages defined in aClass sent to anObject

o  traceAll: anObject from: aClass on: aStream
trace all messages defined in aClass sent to anObject

o  traceAll: anObject on: aStream
trace all messages which are understood by anObject

o  traceEntry: anObject selectors: aCollectionOfSelectors on: aStream
arrange for a trace message to be output on Stderr, when any message
from aCollectionOfSelectors is sent to anObject.
Only entry is traced.
Use untrap:/untrace: to remove this trace.
The current implementation does not allow integers or nil to be traced.

o  traceSender: anObject selector: aSelector
arrange for a trace message to be output on Stderr, when a message with
aSelector is sent to anObject. Only the sender is traced on entry.
Use untrap to remove this trace.
The current implementation does not allow integers or nil to be traced.

o  traceSender: anObject selector: aSelector on: aStream
arrange for a trace message to be output on Stderr, when a message with
aSelector is sent to anObject. Only the sender is traced on entry.
Use untrap to remove this trace.
The current implementation does not allow integers or nil to be traced.

o  untrace: anObject
remove any traces on anObject

o  untrace: anObject selector: aSelector
remove traces of aSelector sent to anObject

object wrapping
o  wrap: anObject selector: aSelector onEntry: entryBlock onExit: exitBlock
arrange for the two blocks entryBlock and exitBlock to be evaluated whenever
a message with aSelector is sent to anObject. EntryBlock will be called on
entry, and get the current context passed as argument. ExitBlock will be called,
when the method is left, and get the context and the methods return value as arguments.
The current implementation does not allow integers or nil to be wrapped.

o  wrap: anObject selector: aSelector onEntry: entryBlock onExit: exitBlock additionalEntryCode: additionalEntryCode additionalExitCode: additionalExitCode additionalVariables: additionalVariables withOriginalClass: withOriginalClass flushCaches: flushCaches
arrange for the two blocks entryBlock and exitBlock to be evaluated whenever
a message with aSelector is sent to anObject. EntryBlock will be called on
entry, and get the current context passed as argument. ExitBlock will be called,
when the method is left, and get the current context and the methods return value as argument.
If withOriginalClass is true, the class of anObject will be set to its original class
before the wrapped method will be called.
NOTICE: The current implementation does not allow integers or nil to be wrapped.

o  wrap: anObject selector: aSelector onEntry: entryBlock onExit: exitBlock withOriginalClass: withOriginalClass flushCaches: flushCaches
arrange for the two blocks entryBlock and exitBlock to be evaluated whenever
a message with aSelector is sent to anObject. EntryBlock will be called on
entry, and get the current context passed as argument. ExitBlock will be called,
when the method is left, and get the current context and the methods return value as argument.
If withOriginalClass is true, the class of anObject will be set to its original class
before the wrapped method will be called.
NOTICE: The current implementation does not allow integers or nil to be wrapped.

o  wrap: anObject selectors: aCollection onEntry: entryBlock onExit: exitBlock
install wrappers for anObject on all selectors from aCollection

o  wrapAll: anObject onEntry: entryBlock onExit: exitBlock
install wrappers for anObject on all implemented selectors

queries
o  allWrappedMethods

o  areAnyMethodsWrapped

o  isCounting: aMethod
return true if aMethod is counted

o  isTiming: aMethod
return true if aMethod is timed

o  isTrapped: aMethod
return true, if a breakpoint is set on aMethod.
This only returns true for standard breakpoints (i.e. for user-wraps,
this returns false)

trace helpers
o  dummyEmptyMethod
helper - to get the time it takes to evaluate the wrappers for
a dummy method.

o  getTimeForWrappers
helper - get the overhead (in ms) spent in the wrapper code of
a timed method.

o  printEntryFull: aContext

o  printEntryFull: aContext level: lvl

o  printEntryFull: aContext level: lvl on: aStream

o  printEntryFull: aContext on: aStream

o  printEntrySender: aContext on: aStream

o  printExit: aContext with: retVal

o  printExit: aContext with: retVal level: lvl

o  printExit: aContext with: retVal level: lvl on: aStream

o  printExit: aContext with: retVal on: aStream

o  printFull: aContext on: aStream withSender: withSender

o  printFull: aContext on: aStream withSenderContext: aSenderContextOrNil

o  printObject: anObject on: aStream

o  printSender: aSenderContext on: aStream

o  printUpdateEntryFull: aContext level: lvl on: aStream

o  traceEntryFull: aContext on: aStream

o  traceFullBlockFor: aStream
avoid generation of fullBlocks

o  traceSenderBlockFor: aStream
avoid generation of fullBlocks


Instance protocol:

trace helpers
o  trace: aBlock detail: fullDetail
trace execution of aBlock.


Private classes:

    InteractionCollector
    MethodTimingInfo
    PrintingMessageTracer

Examples:


For the common cases, you will find a menu entry in the SystemBrowser. Howeever, more special cases (especially with condition checks) can be set up by evaluating the lower level entries. trapping specific methods: (by class/selector):


   MessageTracer trapClass:Collection selector:#select:.
   Dictionary new select:[:e | ].       'not caught - Dictionary has its own select'.
   (Array new:10) select:[:e | ].       'not caught - SeqColl has its own select'.
   Set new select:[:e | ].              'caught - Set inherits this from Collection'.
   MessageTracer untrapClass:Collection 
(by method):


   MessageTracer trapMethod:(Collection compiledMethodAt:#select:).
   Dictionary new select:[:e | ].       'not caught - Dictionary has its own select'.
   (Array new:10) select:[:e | ].       'not caught - SeqColl has its own select'.
   Set new select:[:e | ].              'caught - Set inherits this from Collection'.
   MessageTracer unwrapMethod:(Collection compiledMethodAt:#select:).
(by method & instance class):


   MessageTracer trapMethod:(SequenceableCollection compiledMethodAt:#select:)
                 forInstancesOf:SortedCollection.
   Dictionary new select:[:e | ].       'not caught - Dictionary has its own select'.
   (Array new:10) select:[:e | ].       'not caught - not a SortedCollection'.
   OrderedCollection new select:[:e | ]. 'not caught - not a SortedCollection'.
   SortedCollection new select:[:e | ].  'caught - Set inherits this from Collection'.
   MessageTracer unwrapMethod:(SequenceableCollection compiledMethodAt:#select:).
tracing specific methods: (by class/selector):


   MessageTracer traceClass:SequenceableCollection selector:#quickSortFrom:to:.
   #(6 1 9 66 2 17) copy sort.
   MessageTracer untraceClass:SequenceableCollection 
(by method):


   MessageTracer traceMethod:(SequenceableCollection compiledMethodAt:#quickSortFrom:to:).
   #(6 1 9 66 2 17) copy sort.
   MessageTracer unwrapMethod:(SequenceableCollection compiledMethodAt:#quickSortFrom:to:). 
object trapping:


   |o|

   o := OrderedCollection new.
   MessageTracer trapAll:o.
   o collect:[:el | el].
trapping modifications to an objects instVars:


   |o|

   o := Point new.
   MessageTracer trapModificationsIn:o.
   o x:1.
   o y:2.
   o x:1.
   o y:2.
   MessageTracer untrap:o
trapping modifications of a particular instVar:


   |o|

   o := Point new.
   MessageTracer trapModificationsIn:o filter:[:old :new | old x ~~ new x].
   o x:1.
   o y:2.
   o x:1.
   o y:2.
   MessageTracer untrap:o


ST/X 6.1.1; WebServer 1.620 at exept:8081; Tue, 22 May 2012 21:14:04 GMT