Setting breakpoints?
Marcus Denker
marcus at ira.uka.de
Fri May 5 08:55:46 UTC 2000
On Wed, Apr 19, 2000 at 03:57:27PM -0700, Dan Ingalls wrote:
>Does anyone know of better code available of a prefereable way of doing
>this?
ST/X has a similar but more powerfull Breakpoint-system:
With the "MessageTracer" it is possible to wrap methods with blocks that are
evaluated on entry or exit of the wrapped method.
MassageTracer allows both class-based and object-based method-wrapping.
The normal Behaviour-hierarchy is used for building special classes, no
"lightwight" classes are used.
Method-based:
MessageTracer
wrapMethod:aMethod
onEntry:entryBlock
onExit:exitBlock
Object-based:
MessageTracer
wrap:anObject
selector:aSelector
onEntry:entryBlock
onExit:exitBlock
MessageTraver provides many predefined Entry/Exit-Blocks and shortcuts:
(breakpointing, tracing, timing, memory-usage, modifications)
BreakPoint on Selector:
MessageTracer trap:anObject selector:aSelector
A trace is installed by:
MessageTracer trace:anObject selector:aSelector
this arranges that a trace message is printed to the standard error output
(Stderr), both upon entry and exit to/from the method.
BreakPoint when an instancevariable is changed:
MessageTracer
trapModificationsIn:anObject
MethodWrapping is a very powerfull tool, e.g. it can be used for conditional
Breakpointing:
|p|
p := Point new.
MessageTracer wrap:p selector:#x:
onEntry:[:con |
(con args at:1) > 5 ifTrue:[
Debugger
enter:con
withMessage:'hit breakPoint; arg > 5'
]
]
onExit:nil.
p x:4. "nothing happens"
p x:-1. "nothing happens."
p x:10. "bummm"
Or for counting method-invocations:
Smalltalk at:#MyCount put:0 .
MessageTracer
wrapMethod:(Float compiledMethodAt:#+)
onEntry:[:con | MyCount := MyCount + 1]
onExit:[:con :ret | ].
All wrapped methods are removed with
MessageTracer unwrapAllMethods
--
Marcus Denker marcus at ira.uka.de phone at home:(0721)614235 @work:(0721)608-2749
More information about the Squeak-dev
mailing list
|