#FEATURE by cg
class: MessageTracer class
added: #trapMethod:onReturnIf:
comment/format in: #trapMethod:if:
--- a/MessageTracer.st Fri Dec 29 15:42:47 2017 +0100
+++ b/MessageTracer.st Tue Jan 16 17:16:32 2018 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 1994 by Claus Gittinger
All Rights Reserved
@@ -727,6 +729,7 @@
trapMethod:aMethod if:conditionBlock
"arrange for the debugger to be entered when aMethod has been invoked and conditionBlock
evaluates to true.
+ conditionBlock gets context and method as (optional) arguments.
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.);
@@ -734,25 +737,25 @@
entry/leave blocks."
^ self
- wrapMethod:aMethod
- onEntry:[:con |
- |conditionFires|
-
- Error handle:[:ex |
- 'MessageTrace: error in breakpoint condition caught: ' errorPrint.
- ex description errorPrintCR.
- ] do:[
- conditionBlock numArgs == 1 ifTrue:[
- conditionFires := conditionBlock value:con
- ] ifFalse:[
- conditionFires := conditionBlock value:con value:aMethod
- ].
- ].
- conditionFires == true ifTrue:[
- BreakpointSignal raiseRequestWith:nil errorString:nil in:con
- ]
- ]
- onExit:LeaveBreakBlock.
+ wrapMethod:aMethod
+ onEntry:[:con |
+ |conditionFires|
+
+ Error handle:[:ex |
+ 'MessageTrace: error in breakpoint condition caught: ' errorPrint.
+ ex description errorPrintCR.
+ ] do:[
+ conditionBlock numArgs == 1 ifTrue:[
+ conditionFires := conditionBlock value:con
+ ] ifFalse:[
+ conditionFires := conditionBlock value:con value:aMethod
+ ].
+ ].
+ conditionFires == true ifTrue:[
+ BreakpointSignal raiseRequestWith:nil errorString:nil in:con
+ ]
+ ]
+ onExit:LeaveBreakBlock.
"Created: / 18-08-2000 / 22:09:10 / cg"
"Modified: / 20-10-2010 / 09:38:57 / cg"
@@ -780,6 +783,42 @@
"Modified: 22.10.1996 / 17:40:06 / cg"
!
+trapMethod:aMethod onReturnIf:conditionBlock
+ "arrange for the debugger to be entered when aMethod returns
+ and conditionBlock evaluates to true.
+ conditionBlock gets retVal, context and method as (optional) arguments.
+ 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."
+
+ ^ self
+ wrapMethod:aMethod
+ onEntry:[:con | ]
+ onExit:[:con :retVal |
+ |conditionFires|
+
+ Error handle:[:ex |
+ 'MessageTrace: error in breakpoint condition caught: ' errorPrint.
+ ex description errorPrintCR.
+ ] do:[
+ conditionBlock numArgs == 1 ifTrue:[
+ conditionFires := conditionBlock value:retVal
+ ] ifFalse:[
+ conditionFires := conditionBlock valueWithOptionalArgument:retVal and:con and:aMethod
+ ].
+ ].
+ conditionFires == true ifTrue:[
+ BreakpointSignal raiseRequestWith:nil errorString:nil in:con
+ ].
+ retVal
+ ]
+
+ "Created: / 18-08-2000 / 22:09:10 / cg"
+ "Modified: / 20-10-2010 / 09:38:57 / cg"
+!
+
untrapAllClasses
"remove any traps on any class"