class: DebugView
authorClaus Gittinger <cg@exept.de>
Thu, 20 Jun 2013 17:56:42 +0200
changeset 12937 cf8330cc265e
parent 12936 3624ecb36435
child 12938 626cbab0ce93
class: DebugView added:10 methods changed:15 methods added ignoreForReceiver and ignoreInProcess
DebugView.st
--- a/DebugView.st	Thu Jun 20 13:27:17 2013 +0200
+++ b/DebugView.st	Thu Jun 20 17:56:42 2013 +0200
@@ -40,7 +40,8 @@
 !
 
 Object subclass:#IgnoredHaltOrBreakpoint
-	instanceVariableNames:'ignoreEndTime ignoreCount ignoreUntilShiftKeyPressed'
+	instanceVariableNames:'ignoreEndTime ignoreCount ignoreUntilShiftKeyPressed
+		ignoredReceiverClasses ignoredProcesses'
 	classVariableNames:''
 	poolDictionaries:''
 	privateIn:DebugView
@@ -236,7 +237,36 @@
     ^ IgnoredHalts notEmptyOrNil
 !
 
-ignoreBreakpointWithParameter:parameterOrNil forCount:countOrNil orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey
+ignoreBreakpointWithParameter:parameterOrNil forCount:countOrNil orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey orReceiverClass:receiverClassOrNil orProcess:processOrNil
+    "remember to ignore a breakpoint with a parameter (i.e. breakpoint:#cg) for some number of invocations
+     or until some time has elapsed.
+     With nil count and time arguments, such an ignored breakpoint is reactivated"
+
+    self 
+        ignoreHaltOrBreakpoint:#halt 
+        method:nil line:nil  
+        parameter:parameterOrNil 
+        forCount:countOrNil orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey
+        orReceiverClass:receiverClassOrNil orProcess:processOrNil
+!
+
+ignoreHaltIn:haltingMethod at:lineNrOfHalt forCount:countOrNil orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey orReceiverClass:receiverClassOrNil orProcess:processOrNil
+    "remember to ignore a halt in some method for some number of invocations
+     or until some time has elapsed.
+     With nil count and time arguments, such an ignored halt is reactivated"
+
+    self 
+        ignoreHaltOrBreakpoint:#halt 
+        method:haltingMethod line:lineNrOfHalt  
+        parameter:nil 
+        forCount:countOrNil orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey
+        orReceiverClass:receiverClassOrNil orProcess:processOrNil
+!
+
+ignoreHaltOrBreakpoint:type method:methodOrNil line:lineNrOfHaltOrNil parameter:parameterOrNil 
+        forCount:countOrNil orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey
+        orReceiverClass:receiverClassOrNil orProcess:processOrNil
+
     "remember to ignore a breakpoint with a parameter (i.e. breakpoint:#cg) for some number of invocations
      or until some time has elapsed.
      With nil count and time arguments, such an ignored breakpoint is reactivated"
@@ -245,19 +275,34 @@
 
     IgnoredHalts notNil ifTrue:[
         self removeInactiveIgnores.
-        oldEntry := IgnoredHalts
-                        detect:[:ign | ign isForBreakpointWithParameter:parameterOrNil]
-                        ifNone:nil.
+        type == #halt ifTrue:[
+            oldEntry := IgnoredHalts
+                            detect:[:ign | ign isForMethod:methodOrNil line:lineNrOfHaltOrNil]
+                            ifNone:nil.
+        ] ifFalse:[
+            oldEntry := IgnoredHalts
+                            detect:[:ign | ign isForBreakpointWithParameter:parameterOrNil]
+                            ifNone:nil.
+        ].
         oldEntry notNil ifTrue:[
             IgnoredHalts remove:oldEntry ifAbsent:[].
         ]
     ].
 
-    (countOrNil notNil or:[dTOrNil notNil or:[untilShiftKey == true]]) ifTrue:[
+    (countOrNil notNil 
+      or:[dTOrNil notNil 
+      or:[untilShiftKey == true
+      or:[receiverClassOrNil notNil
+      or:[processOrNil notNil]]]]
+    ) ifTrue:[
         IgnoredHalts isNil ifTrue:[
             IgnoredHalts := OrderedCollection new.
         ].
-        ign := IgnoredHalt new breakpointWithParameter:parameterOrNil.
+        type == #halt ifTrue:[
+            ign := IgnoredHalt new method:methodOrNil lineNumber:lineNrOfHaltOrNil.
+        ] ifFalse:[
+            ign := IgnoredHalt new breakpointWithParameter:parameterOrNil.
+        ].
 
         (countOrNil notNil and:[countOrNil > 0]) ifTrue:[
             ign ignoreCount:countOrNil.
@@ -268,6 +313,12 @@
         untilShiftKey == true ifTrue:[
             ign ignoreUntilShiftKeyPressed:true.
         ].
+        receiverClassOrNil notNil ifTrue:[
+            ign ignoreForReceiverClass:receiverClassOrNil.
+        ].
+        processOrNil notNil ifTrue:[
+            ign ignoreForProcess:processOrNil.
+        ].
         IgnoredHalts add:ign.
     ].
     Smalltalk changed:#ignoredHalts.
@@ -275,46 +326,7 @@
     "Created: / 06-03-2012 / 12:37:58 / cg"
 !
 
-ignoreHaltIn:haltingMethod at:lineNrOfHalt forCount:countOrNil orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey
-    "remember to ignore a halt in some method for some number of invocations
-     or until some time has elapsed.
-     With nil count and time arguments, such an ignored halt is reactivated"
-
-    |oldEntry ign|
-
-    IgnoredHalts notNil ifTrue:[
-        self removeInactiveIgnores.
-        oldEntry := IgnoredHalts
-                        detect:[:ign | ign isForMethod:haltingMethod line:lineNrOfHalt]
-                        ifNone:nil.
-        oldEntry notNil ifTrue:[
-            IgnoredHalts remove:oldEntry ifAbsent:[].
-        ]
-    ].
-
-    (countOrNil notNil or:[dTOrNil notNil or:[untilShiftKey == true]]) ifTrue:[
-        IgnoredHalts isNil ifTrue:[
-            IgnoredHalts := OrderedCollection new.
-        ].
-        ign := IgnoredHalt new method:haltingMethod lineNumber:lineNrOfHalt.
-
-        (countOrNil notNil and:[countOrNil > 0]) ifTrue:[
-            ign ignoreCount:countOrNil.
-        ].
-        (dTOrNil notNil) ifTrue:[
-            ign ignoreEndTime:(Timestamp now + dTOrNil).
-        ].
-        untilShiftKey == true ifTrue:[
-            ign ignoreUntilShiftKeyPressed:true.
-        ].
-        IgnoredHalts add:ign.
-    ].
-    Smalltalk changed:#ignoredHalts.
-
-    "Created: / 27-01-2012 / 11:33:38 / cg"
-!
-
-isBreakpointToBeIgnoredForParameter:parameter modifyEntryCount:modifyCount
+isBreakpointToBeIgnoredForParameter:parameter context:aContext modifyEntryCount:modifyCount
     "/ should a breakpoint be ignored ?
 
     IgnoredHalts isNil ifTrue:[^ false].
@@ -343,14 +355,14 @@
     "Created: / 06-03-2012 / 12:50:30 / cg"
 !
 
-isHaltToBeIgnoredIn:haltingMethod atLineNr:lineNrInHaltingMethod modifyEntryCount:modifyCount
+isHaltToBeIgnoredIn:haltingMethod atLineNr:lineNrInHaltingMethod context:aContext modifyEntryCount:modifyCount
     "should a halt be ignored ?"
 
     IgnoredHalts isNil ifTrue:[^ false].
 
     "/ Transcript showCR:'halt/break in ',haltingMethod printString,' at ',lineNrInHaltingMethod printString.
     IgnoredHalts do:[:ign |
-        (ign isHaltIgnoredInMethod:haltingMethod line:lineNrInHaltingMethod) ifTrue:[
+        (ign isHaltIgnoredInMethod:haltingMethod line:lineNrInHaltingMethod context:aContext) ifTrue:[
             Transcript show:'Debugger [info]: halt/break ignored in ', haltingMethod whoString.
             Transcript show:' ('; show:ign; showCR:')'.
 
@@ -706,6 +718,16 @@
                 )
                (MenuItem
                   enabled: isStoppedAtHaltOrBreakPointOrSelectedContextIsWrapped
+                  label: 'For this Receiver Class'
+                  itemValue: ignoreHaltForThisReceiverClass
+                )
+               (MenuItem
+                  enabled: isStoppedAtHaltOrBreakPointOrSelectedContextIsWrapped
+                  label: 'In Current Process'
+                  itemValue: ignoreHaltForCurrentProcess
+                )
+               (MenuItem
+                  enabled: isStoppedAtHaltOrBreakPointOrSelectedContextIsWrapped
                   label: 'Until Shift-Key is Pressed'
                   itemValue: ignoreHaltUntilShiftKeyIsPressed
                 )
@@ -5286,13 +5308,19 @@
 !
 
 ignoreAllHaltsForever
-    self addIgnoredHaltForCount:-1 orTimeDuration:nil orUntilShiftKey:false forAll:true.
+    self 
+        addIgnoredHaltForCount:-1 orTimeDuration:nil orUntilShiftKey:false 
+        orThisReceiverClass:false orCurrentProcess:false 
+        forAll:true.
 
     "Created: / 08-05-2011 / 10:19:56 / cg"
 !
 
 ignoreAllHaltsUntilShiftKeyIsPressed
-    self addIgnoredHaltForCount:nil orTimeDuration:nil orUntilShiftKey:true forAll:true.
+    self 
+        addIgnoredHaltForCount:nil orTimeDuration:nil orUntilShiftKey:true 
+        orThisReceiverClass:false orCurrentProcess:false 
+        forAll:true.
 
     "Created: / 27-01-2012 / 11:32:14 / cg"
 !
@@ -5305,19 +5333,46 @@
 !
 
 ignoreBreakpointsWithThisParameterUntilShiftKeyIsPressed
-    self addIgnoredHaltForCount:nil orTimeDuration:nil orUntilShiftKey:true forAll:false.
+    self 
+        addIgnoredHaltForCount:nil orTimeDuration:nil orUntilShiftKey:true 
+        orThisReceiverClass:false orCurrentProcess:false 
+        forAll:false.
 
     "Created: / 06-03-2012 / 12:35:22 / cg"
 !
 
+ignoreHaltForCurrentProcess
+    self 
+        addIgnoredHaltForCount:nil orTimeDuration:nil orUntilShiftKey:false 
+        orThisReceiverClass:false orCurrentProcess:true 
+        forAll:true.
+
+    "Created: / 27-01-2012 / 11:32:14 / cg"
+!
+
+ignoreHaltForThisReceiverClass
+    self 
+        addIgnoredHaltForCount:nil orTimeDuration:nil orUntilShiftKey:false 
+        orThisReceiverClass:true orCurrentProcess:false 
+        forAll:true.
+
+    "Created: / 27-01-2012 / 11:32:14 / cg"
+!
+
 ignoreHaltForever
-    self addIgnoredHaltForCount:-1 orTimeDuration:nil orUntilShiftKey:false forAll:false.
+    self 
+        addIgnoredHaltForCount:-1 orTimeDuration:nil orUntilShiftKey:false 
+        orThisReceiverClass:false orCurrentProcess:false 
+        forAll:false.
 
     "Modified: / 27-01-2012 / 11:31:37 / cg"
 !
 
 ignoreHaltUntilShiftKeyIsPressed
-    self addIgnoredHaltForCount:nil orTimeDuration:nil orUntilShiftKey:true forAll:false.
+    self 
+        addIgnoredHaltForCount:nil orTimeDuration:nil orUntilShiftKey:true 
+        orThisReceiverClass:false orCurrentProcess:false 
+        forAll:false.
 
     "Created: / 27-01-2012 / 11:36:54 / cg"
 !
@@ -5340,7 +5395,10 @@
         dT := TimeDuration readFrom:answer onError:[ nil ].
         dT notNil ifTrue:[
             LastIgnoreHaltDuration := dT.
-            self addIgnoredHaltForCount:nil orTimeDuration:dT orUntilShiftKey:false forAll:true.
+            self 
+                addIgnoredHaltForCount:nil orTimeDuration:dT orUntilShiftKey:false 
+                orThisReceiverClass:false orCurrentProcess:false 
+                forAll:true.
             ^ self.
         ].
     ] loop
@@ -5362,7 +5420,10 @@
         n := Integer readFrom:answer onError:nil.
         n notNil ifTrue:[
             LastIgnoreHaltNTimes := n.
-            self addIgnoredHaltForCount:n orTimeDuration:nil orUntilShiftKey:false forAll:false.
+            self 
+                addIgnoredHaltForCount:n orTimeDuration:nil orUntilShiftKey:false 
+                orThisReceiverClass:false orCurrentProcess:false 
+                forAll:false.
             ^ self.
         ].
     ] loop.
@@ -5385,7 +5446,10 @@
         dT := TimeDuration readFrom:answer onError:[ nil ].
         dT notNil ifTrue:[
             LastIgnoreHaltDuration := dT.
-            self addIgnoredHaltForCount:nil orTimeDuration:dT orUntilShiftKey:false forAll:false.
+            self 
+                addIgnoredHaltForCount:nil orTimeDuration:dT orUntilShiftKey:false 
+                orThisReceiverClass:false orCurrentProcess:false 
+                forAll:false.
             ^ self.
         ].
     ] loop
@@ -5405,7 +5469,10 @@
         n := Integer readFrom:answer onError:nil.
         n notNil ifTrue:[
             LastIgnoreHaltNTimes := n.
-            self addIgnoredHaltForCount:n orTimeDuration:nil orUntilShiftKey:false forAll:false.
+            self 
+                addIgnoredHaltForCount:n orTimeDuration:nil orUntilShiftKey:false 
+                orThisReceiverClass:false orCurrentProcess:false 
+                forAll:false.
             ^ self.
         ].
     ] loop.
@@ -5425,7 +5492,10 @@
         dT := TimeDuration readFrom:answer onError:[ nil ].
         dT notNil ifTrue:[
             LastIgnoreHaltDuration := dT.
-            self addIgnoredHaltForCount:nil orTimeDuration:dT orUntilShiftKey:false forAll:false.
+            self 
+                addIgnoredHaltForCount:nil orTimeDuration:dT orUntilShiftKey:false 
+                orThisReceiverClass:false orCurrentProcess:false 
+                forAll:false.
             ^ self.
         ].
     ] loop
@@ -6059,8 +6129,10 @@
 
 !DebugView methodsFor:'private-breakpoints'!
 
-addIgnoredHaltForCount:countOrNil orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey forAll:aBoolean
-    |haltingContext haltingMethod lineNrOfHalt|
+addIgnoredHaltForCount:countOrNil orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey 
+                                  orThisReceiverClass:forThisReceiverClass orCurrentProcess:forCurrentProcess 
+                                  forAll:aBoolean
+    |haltingContext haltingMethod lineNrOfHalt receiverClassOrNil processOrNil|
 
     aBoolean ifTrue:[
         haltingMethod := #all
@@ -6077,11 +6149,18 @@
             Transcript showCR:'no halt lineNr found'. 
             ^ self 
         ].
+        forThisReceiverClass ifTrue:[
+            receiverClassOrNil := haltingContext receiver class
+        ].
+        forCurrentProcess ifTrue:[
+            processOrNil := Processor activeProcess
+        ].
     ].
 
     self class
         ignoreHaltIn:haltingMethod at:lineNrOfHalt
         forCount:countOrNil orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey
+        orReceiverClass:receiverClassOrNil orProcess:processOrNil
 
     "Created: / 27-01-2012 / 11:31:12 / cg"
 !
@@ -6317,7 +6396,11 @@
                ^ false
             ].
             breakpointParameter := c argAt:1.
-            (self class isBreakpointToBeIgnoredForParameter:breakpointParameter modifyEntryCount:true) ifTrue:[
+            (self class 
+                    isBreakpointToBeIgnoredForParameter:breakpointParameter
+                    context:(c sender)
+                    modifyEntryCount:true
+            ) ifTrue:[
                 ^ true.
             ].
         ].
@@ -6340,6 +6423,7 @@
     ^ self class
         isHaltToBeIgnoredIn:haltingMethod
         atLineNr:lineNrInHaltingMethod
+        context:c
         modifyEntryCount:true.
 
     "Created: / 22-10-2010 / 12:09:53 / cg"
@@ -8097,6 +8181,20 @@
     ignoreEndTime := something.
 !
 
+ignoreForProcess:aProcess
+    ignoredProcesses isNil ifTrue:[
+        ignoredProcesses := WeakIdentitySet new.
+    ].
+    ignoredProcesses add:aProcess
+!
+
+ignoreForReceiverClass:aClass
+    ignoredReceiverClasses isNil ifTrue:[
+        ignoredReceiverClasses := WeakIdentitySet new.
+    ].
+    ignoredReceiverClasses add:aClass
+!
+
 ignoreUntilShiftKeyPressed:aBoolean
     ignoreUntilShiftKeyPressed := aBoolean.
 
@@ -8116,25 +8214,33 @@
 !DebugView::IgnoredHaltOrBreakpoint methodsFor:'printing'!
 
 printConditionOn:aStream
-    ignoreUntilShiftKeyPressed == true ifTrue:[
-        aStream nextPutAll:' until shiftKey pressed'.
+    ignoredProcesses notEmptyOrNil ifTrue:[
+        aStream nextPutAll:' in processes ',(ignoredProcesses collect:[:each | each name]).
     ] ifFalse:[
-        ignoreEndTime notNil ifTrue:[
-            aStream nextPutAll:' until '.
-            ignoreEndTime printOn:aStream.
+        ignoredReceiverClasses notNil ifTrue:[
+            aStream nextPutAll:' for classes ',(ignoredReceiverClasses collect:[:each | each name]).
         ] ifFalse:[
-            (ignoreCount notNil) ifTrue:[
-                (ignoreCount > 0) ifTrue:[
-                    aStream nextPutAll:' for '.
-                    ignoreCount printOn:aStream.
+            ignoreUntilShiftKeyPressed == true ifTrue:[
+                aStream nextPutAll:' until shiftKey pressed'.
+            ] ifFalse:[
+                ignoreEndTime notNil ifTrue:[
+                    aStream nextPutAll:' until '.
+                    ignoreEndTime printOn:aStream.
                 ] ifFalse:[
-                    (ignoreCount < 0) ifTrue:[
-                        aStream nextPutAll:' forEver'.
-                    ] ifFalse:[
-                        aStream nextPutAll:' no longer'.
-                    ].
+                    (ignoreCount notNil) ifTrue:[
+                        (ignoreCount > 0) ifTrue:[
+                            aStream nextPutAll:' for '.
+                            ignoreCount printOn:aStream.
+                        ] ifFalse:[
+                            (ignoreCount < 0) ifTrue:[
+                                aStream nextPutAll:' forEver'.
+                            ] ifFalse:[
+                                aStream nextPutAll:' no longer'.
+                            ].
+                        ].
+                    ]
                 ].
-            ]
+            ].
         ].
     ].
 
@@ -8295,11 +8401,24 @@
 !
 
 isHaltIgnoredInMethod:aMethod line:line
+    ^ self isHaltIgnoredInMethod:aMethod line:line context:nil
+!
+
+isHaltIgnoredInMethod:aMethod line:line context:context
     "/ Transcript show:'?same as ign '; show:(weakMethodHolder at:1); show:' at '; showCR:lineNumber.
 
     (self isForMethod:aMethod line:line) ifFalse:[^ false].
     "/ Transcript show:'is same; ignored: '; showCR:self isHaltIgnored.
 
+    context notNil ifTrue:[
+        ignoredReceiverClasses notNil ifTrue:[
+            ^ ignoredReceiverClasses includes:(context receiver class)
+        ].
+        ignoredProcesses notNil ifTrue:[
+            ^ ignoredProcesses includes:(Processor activeProcess)
+        ].
+    ].
+
     ^ self isHaltIgnored
 ! !
 
@@ -8339,15 +8458,15 @@
 !DebugView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/DebugView.st,v 1.593 2013-06-19 06:31:23 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/DebugView.st,v 1.594 2013-06-20 15:56:42 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/DebugView.st,v 1.593 2013-06-19 06:31:23 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/DebugView.st,v 1.594 2013-06-20 15:56:42 cg Exp $'
 !
 
 version_SVN
-    ^ '$Id: DebugView.st,v 1.593 2013-06-19 06:31:23 stefan Exp $'
+    ^ '$Id: DebugView.st,v 1.594 2013-06-20 15:56:42 cg Exp $'
 ! !