made interestingContextFrom: public - its useful in
authorClaus Gittinger <cg@exept.de>
Tue, 07 Jan 1997 21:43:11 +0100
changeset 913 6460993f73a3
parent 912 dae70963b64c
child 914 10583a26baad
made interestingContextFrom: public - its useful in other places as well.
DebugView.st
--- a/DebugView.st	Tue Jan 07 20:31:35 1997 +0100
+++ b/DebugView.st	Tue Jan 07 21:43:11 1997 +0100
@@ -290,6 +290,138 @@
     "Created: 1.1.1970 / 01:00:00 / cg"
 ! !
 
+!DebugView class methodsFor:'misc'!
+
+interestingContextFrom:aContext
+    "return an interesting contexts offset, or nil.
+     This is the context initially shown in the walkback.
+     We move up the calling chain, skipping all intermediate Signal
+     and Exception contexts, to present the context in which the error
+     actually occured.
+     Just for your convenience :-)"
+
+    |delta con|
+
+    delta := self interestingContextIndexFrom:aContext.
+    con := aContext.
+    [delta > 1] whileTrue:[
+        con := con sender.
+        delta := delta - 1.
+    ].
+    ^ con
+
+    "Modified: 7.1.1997 / 21:31:05 / cg"
+!
+
+interestingContextIndexFrom:aContext
+    "return an interesting contexts offset, or nil.
+     This is the context initially shown in the walkback.
+     We move up the calling chain, skipping all intermediate Signal
+     and Exception contexts, to present the context in which the error
+     actually occured.
+     Just for your convenience :-)"
+
+    |c found offset sel prev ex|
+
+    aContext isBlockContext ifTrue:[^ 1].
+
+    "somewhere, at the bottom, there must be a raise ..."
+
+    c := aContext.
+    1 to:5 do:[:i |
+        c isNil ifTrue:[^ 1 "^ nil"].
+        sel := c selector.
+        (sel == #raise) ifTrue:[
+            (c receiver isKindOf:Exception) ifTrue:[
+                ex := c receiver.
+                offset := i.
+                found := c
+            ] ifFalse:[
+                (c receiver isSignal) ifTrue:[
+                    offset := i.
+                    found := c
+                ]
+            ]
+        ].
+        c := c sender.
+    ].
+
+    "
+     if this is a noHandler exception, skip forward
+     to the erronous context
+    "
+    ex notNil ifTrue:[
+        ex signal == Signal noHandlerSignal ifTrue:[
+            c := ex suspendedContext
+        ]
+    ].
+
+    (c := found) isNil ifTrue:[
+        "/ this is a kludge, but convenient.
+        "/ show the place where the divisionByZero happend,
+        "/ not where the signal was raised.
+
+        sel := aContext selector.
+        (sel == #//      
+        or:[sel == #/
+        or:[sel == #\\]]) ifTrue:[
+            ^ 2
+        ].
+
+        ^ 1
+    ].
+
+    "
+     got it; move up, skipping all intermediate Signal and
+     Exception contexts
+    "
+    prev := nil.
+    [   
+        ((c receiver isSignal)
+        or:[(c receiver isKindOf:Exception)])
+    ] whileTrue:[
+        prev := c.
+        (c := c sender) isNil ifTrue:[^ offset].
+        offset := offset + 1.
+    ].
+
+    "
+     now, we are one above the raising context
+    "
+
+    "
+     if the sender-method of the raise is one of objects error methods ...
+    "
+    ( #( halt halt: 
+         error error: 
+         doesNotUnderstand: 
+         subclassResponsibility 
+         primitiveFailed) includes:c selector) 
+    ifTrue:[
+        c selector == #doesNotUnderstand: ifTrue:[
+            "
+             one more up, to get to the originating context
+            "
+            (c := c sender) isNil ifTrue:[^ offset].
+            offset := offset + 1.
+        ].
+        (c := c sender) isNil ifTrue:[^ offset].
+        offset := offset + 1.
+    ] ifFalse:[
+        "
+         ok, got the raise - if its a BreakPoint, look for the sender
+        "
+        (MessageTracer notNil and:[prev receiver == MessageTracer breakpointSignal]) ifTrue:[
+            offset := offset + 1
+        ].
+    ].
+
+    ^ offset
+
+    "Modified: 26.7.1996 / 16:34:58 / cg"
+    "Created: 7.1.1997 / 21:26:05 / cg"
+! !
+
 !DebugView methodsFor:'basic'!
 
 enter
@@ -421,7 +553,7 @@
             "
              preselect a more interesting context, (where halt/raise was ...)
             "
-            selection := self interestingContextFrom:aContext.
+            selection := self class interestingContextIndexFrom:aContext.
         ] ifFalse:[
             "
              if we came here by a big-step, show the method where we are
@@ -713,7 +845,7 @@
 
     "Created: 24.11.1995 / 19:52:54 / cg"
     "Modified: 3.5.1996 / 23:58:16 / stefan"
-    "Modified: 7.12.1996 / 13:37:23 / cg"
+    "Modified: 7.1.1997 / 21:27:28 / cg"
 !
 
 openOn:aProcess
@@ -2172,115 +2304,6 @@
     ^ inspectedProcess 
 !
 
-interestingContextFrom:aContext
-    "return an interesting contexts offset, or nil.
-     This is the context initially shown in the walkback.
-     We move up the calling chain, skipping all intermediate Signal
-     and Exception contexts, to present the context in which the error
-     actually occured.
-     Just for your convenience :-)"
-
-    |c found offset sel prev ex|
-
-    aContext isBlockContext ifTrue:[^ 1].
-
-    "somewhere, at the bottom, there must be a raise ..."
-
-    c := aContext.
-    1 to:5 do:[:i |
-        c isNil ifTrue:[^ 1 "^ nil"].
-        sel := c selector.
-        (sel == #raise) ifTrue:[
-            (c receiver isKindOf:Exception) ifTrue:[
-                ex := c receiver.
-                offset := i.
-                found := c
-            ] ifFalse:[
-                (c receiver isSignal) ifTrue:[
-                    offset := i.
-                    found := c
-                ]
-            ]
-        ].
-        c := c sender.
-    ].
-
-    "
-     if this is a noHandler exception, skip forward
-     to the erronous context
-    "
-    ex notNil ifTrue:[
-        ex signal == Signal noHandlerSignal ifTrue:[
-            c := ex suspendedContext
-        ]
-    ].
-
-    (c := found) isNil ifTrue:[
-        "/ this is a kludge, but convenient.
-        "/ show the place where the divisionByZero happend,
-        "/ not where the signal was raised.
-
-        sel := aContext selector.
-        (sel == #//      
-        or:[sel == #/
-        or:[sel == #\\]]) ifTrue:[
-            ^ 2
-        ].
-        
-        ^ 1
-    ].
-
-    "
-     got it; move up, skipping all intermediate Signal and
-     Exception contexts
-    "
-    prev := nil.
-    [   
-        ((c receiver isSignal)
-        or:[(c receiver isKindOf:Exception)])
-    ] whileTrue:[
-        prev := c.
-        (c := c sender) isNil ifTrue:[^ offset].
-        offset := offset + 1.
-    ].
-
-    "
-     now, we are one above the raising context
-    "
-
-    "
-     if the sender-method of the raise is one of objects error methods ...
-    "
-    ( #( halt halt: 
-         error error: 
-         doesNotUnderstand: 
-         subclassResponsibility 
-         primitiveFailed) includes:c selector) 
-    ifTrue:[
-        c selector == #doesNotUnderstand: ifTrue:[
-            "
-             one more up, to get to the originating context
-            "
-            (c := c sender) isNil ifTrue:[^ offset].
-            offset := offset + 1.
-        ].
-        (c := c sender) isNil ifTrue:[^ offset].
-        offset := offset + 1.
-    ] ifFalse:[
-        "
-         ok, got the raise - if its a BreakPoint, look for the sender
-        "
-        (MessageTracer notNil and:[prev receiver == MessageTracer breakpointSignal]) ifTrue:[
-            offset := offset + 1
-        ].
-    ].
-
-    ^ offset
-
-    "Created: 10.12.1995 / 13:55:21 / cg"
-    "Modified: 26.7.1996 / 16:34:58 / cg"
-!
-
 interruptProcessWith:aBlock
     "let inspected process do something, then update the context list"
 
@@ -3019,5 +3042,5 @@
 !DebugView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/DebugView.st,v 1.118 1996-12-19 13:41:58 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/DebugView.st,v 1.119 1997-01-07 20:43:11 cg Exp $'
 ! !