DebugView.st
changeset 56 d0cb937cbcaa
parent 55 abfd613f95d9
child 57 36e13831b62d
--- a/DebugView.st	Wed Nov 23 00:12:17 1994 +0100
+++ b/DebugView.st	Mon Nov 28 22:11:47 1994 +0100
@@ -31,7 +31,7 @@
 COPYRIGHT (c) 1989 by Claus Gittinger
 	      All Rights Reserved
 
-$Header: /cvs/stx/stx/libtool/DebugView.st,v 1.19 1994-11-22 23:12:17 claus Exp $
+$Header: /cvs/stx/stx/libtool/DebugView.st,v 1.20 1994-11-28 21:11:09 claus Exp $
 '!
 
 !DebugView class methodsFor:'documentation'!
@@ -52,7 +52,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libtool/DebugView.st,v 1.19 1994-11-22 23:12:17 claus Exp $
+$Header: /cvs/stx/stx/libtool/DebugView.st,v 1.20 1994-11-28 21:11:09 claus Exp $
 "
 !
 
@@ -89,7 +89,7 @@
 !DebugView class methodsFor:'instance creation'!
 
 new
-    "return a DebugView - return a cached debugger if it already
+    "return a new DebugView - return a cached debugger if it already
      exists"
 
     |debugger active|
@@ -102,7 +102,8 @@
 
     (ProcessorScheduler isPureEventDriven 
     or:[(active priority >= Processor userInterruptPriority)
-    or:[active nameOrId endsWith:'dispatcher']]) ifTrue:[
+    or:[active id == 0
+    or:[active nameOrId endsWith:'dispatcher']]]) ifTrue:[
 	CachedExclusive isNil ifTrue:[
 	    debugger := self newExclusive
 	] ifFalse:[
@@ -444,29 +445,31 @@
     wrappedMethod := nil.
     5 timesRepeat:[
 "/ where selector printNL.
-	method := where method.
-	(method notNil and:[method isWrapped]) ifTrue:[
-	    "
-	     in a wrapper method
-	    "
-	    wrappedMethod ~~ method ifTrue:[
-		wrappedMethod := method.
-		lastWrappedConAddr := ObjectMemory addressOf:where.
-		where sender receiver == method originalMethod ifFalse:[
-		    isWrap := true.
-		]
-	    ] ifFalse:[
-		(ObjectMemory addressOf:where) == steppedContextAddress ifTrue:[
+	where notNil ifTrue:[
+	    method := where method.
+	    (method notNil and:[method isWrapped]) ifTrue:[
+		"
+		 in a wrapper method
+		"
+		wrappedMethod ~~ method ifTrue:[
+		    wrappedMethod := method.
+		    lastWrappedConAddr := ObjectMemory addressOf:where.
+		    where sender receiver == method originalMethod ifFalse:[
+			isWrap := true.
+		    ]
+		] ifFalse:[
+		    (ObjectMemory addressOf:where) == steppedContextAddress ifTrue:[
 "/ 'change stepCon from: ' print.
 "/  (steppedContextAddress printStringRadix:16)print.
 "/ ' to: ' print.
 "/  (lastWrappedConAddr printStringRadix:16)printNL.
 
-		    steppedContextAddress := lastWrappedConAddr
+			steppedContextAddress := lastWrappedConAddr
+		    ]
 		]
-	    ]
-	].
-	where := where sender
+	    ].
+	    where := where sender
+	]
     ].
 
     isWrap ifTrue:[
@@ -713,7 +716,16 @@
 
     self controlLoop.
 
+    "
+     release all context stuff.
+     This is required, since the debugger is reused,
+     to avoid keeping references to the debuggees objects
+     forever.
+    "
     contextArray := nil.
+    codeView contents:nil.
+    codeView acceptAction:nil.
+    contextView contents:nil.
     receiverInspector release.
     contextInspector release.
 
@@ -722,7 +734,6 @@
 	device synchronizeOutput.
 	(exitAction == #abort) ifTrue:[
 	    selectedContext := nil.
-	    InInterrupt := nil.
 	    busy := false.
 	    exclusive ifTrue:[CachedExclusive := self] ifFalse:[CachedDebugger := self].
 	    "
@@ -741,7 +752,6 @@
 	    selectedContext notNil ifTrue:[
 		con := selectedContext.
 		selectedContext := nil.
-		InInterrupt := nil.
 		busy := false.
 		exclusive ifTrue:[CachedExclusive := self] ifFalse:[CachedDebugger := self].
 		"
@@ -761,7 +771,6 @@
 		selectedContext notNil ifTrue:[
 		    con := selectedContext.
 		    selectedContext := nil.
-		    InInterrupt := nil.
 		    busy := false.
 		    exclusive ifTrue:[CachedExclusive := self] ifFalse:[CachedDebugger := self].
 		    "
@@ -779,7 +788,6 @@
 	    ] ifFalse:[
 		((exitAction == #terminate) or:[exitAction == #quickTerminate]) ifTrue:[
 		    selectedContext := nil.
-		    InInterrupt := nil.
 		    busy := false.
 		    exclusive ifTrue:[CachedExclusive := self] ifFalse:[CachedDebugger := self].
 		    exitAction == #quickTerminate ifTrue:[
@@ -916,12 +924,6 @@
 	self controlLoopCatchingErrors
     ].
     catchBlock := nil.
-
-    codeView contents:nil.
-    codeView acceptAction:nil.
-    contextView contents:nil.
-    receiverInspector release.
-    contextInspector release
 !
 
 controlLoopCatchingErrors
@@ -1186,7 +1188,7 @@
 showSelection:lineNr
     "user clicked on a header line - show selected code in textView"
 
-    |con homeContext sel method code
+    |con homeContext sel method code canAccept
      implementorClass lineNrInMethod rec m line|
 
     contextArray notNil ifTrue:[
@@ -1221,10 +1223,26 @@
 	] ifFalse:[
 	    sel := homeContext selector.
 	    sel notNil ifTrue:[
+		canAccept := true.
+
 "/                implementorClass := homeContext searchClass whichClassImplements:sel.
 		implementorClass := homeContext methodClass.
 		implementorClass isNil ifTrue:[
-		    self showError:'** no method - no source **'
+		    "
+		     special: look if this context was create by
+		     valueWithReceiver kind of method invocation;
+		     if so, grab the method from the sender and show it
+		    "
+"/                    con sender selector printNL.
+		    (con sender notNil
+		    and:[(con sender selector == #valueWithReceiver:arguments:selector:search:)
+		    and:[con sender receiver isKindOf:Method]]) ifTrue:[
+			method := con sender receiver.
+			code := method source.
+			canAccept := false.
+		    ] ifFalse:[
+			self showError:'** no method - no source **'
+		    ]
 		] ifFalse:[
 		    method := implementorClass compiledMethodAt:sel.
 		    code := method source.
@@ -1240,7 +1258,7 @@
 		    ]
 		].
 		code isNil ifTrue:[
-		    codeView acceptAction:nil.
+		    canAccept := false.
 		] ifFalse:[
 		    codeView contents:code.
 		    (lineNrInMethod notNil and:[lineNrInMethod ~~ 0]) ifTrue:[
@@ -1250,7 +1268,12 @@
 			codeView selectLine:lineNrInMethod.
 			codeView makeSelectionVisible
 		    ].
+		].
+
+		canAccept ifTrue:[
 		    codeView acceptAction:[:code | self codeAccept:code asString]
+		] ifFalse:[
+		    codeView acceptAction:nil.
 		].
 
 		"fetch rec here - so we wont need context in doItAction"