DebugView.st
changeset 58 43b7d463a7e5
parent 57 36e13831b62d
child 61 cb5e3560bd82
--- a/DebugView.st	Mon Feb 06 02:01:18 1995 +0100
+++ b/DebugView.st	Wed Feb 08 04:21:08 1995 +0100
@@ -31,7 +31,7 @@
 COPYRIGHT (c) 1989 by Claus Gittinger
 	      All Rights Reserved
 
-$Header: /cvs/stx/stx/libtool/DebugView.st,v 1.21 1995-02-06 00:59:38 claus Exp $
+$Header: /cvs/stx/stx/libtool/DebugView.st,v 1.22 1995-02-08 03:20:53 claus Exp $
 '!
 
 !DebugView class methodsFor:'documentation'!
@@ -52,7 +52,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libtool/DebugView.st,v 1.21 1995-02-06 00:59:38 claus Exp $
+$Header: /cvs/stx/stx/libtool/DebugView.st,v 1.22 1995-02-08 03:20:53 claus Exp $
 "
 !
 
@@ -465,7 +465,7 @@
 
     inWrap ifTrue:[
 	wrappedMethod := nil.
-	3 timesRepeat:[
+	5 timesRepeat:[
 "/ where selector printNL.
 	    (where notNil and:[where isBlockContext not]) ifTrue:[
 		method := where method.
@@ -504,8 +504,8 @@
 	"
 	where := nil. here := nil.
 	ObjectMemory flushInlineCaches.
-	StepInterruptPending := true.
-	InterruptPending := true.
+	StepInterruptPending := 1.
+	InterruptPending := 1.
 	InStepInterrupt := nil.
 	^ nil
     ].
@@ -569,8 +569,8 @@
 			      look for pending interrupts
 			    "
 			    ObjectMemory flushInlineCaches.
-			    StepInterruptPending := true.
-			    InterruptPending := true.
+			    StepInterruptPending := 1.
+			    InterruptPending := 1.
 			    InStepInterrupt := nil.
 			    ^ nil
 			].
@@ -632,8 +632,8 @@
 	  look for pending interrupts
 	"
 	ObjectMemory flushInlineCaches.
-	StepInterruptPending := true.
-	InterruptPending := true.
+	StepInterruptPending := 1.
+	InterruptPending := 1.
 	InStepInterrupt := nil.
 	^ nil
     ].
@@ -703,7 +703,6 @@
 	abortButton turnOffWithoutRedraw.
 	stepButton turnOffWithoutRedraw.
 	sendButton turnOffWithoutRedraw.
-"/        self rerealize
     ] ifFalse:[
 	exclusive ifFalse:[
 	    windowGroup isNil ifTrue:[
@@ -711,23 +710,21 @@
 		windowGroup addTopView:self.
 	    ].
 	].
-"/        self realize.
 	self iconLabel:'Debugger'.
     ].
 
-"/    "
-"/   bring us to the top
-"/  "
-"/  self raise.
-"/  Display synchronizeOutput.
-
     "
      get the walkback list
     "
     self setContext:aContext.
 
     "
-     and find one to show
+     and find the one context to show initially
+     - if we came here by a send (single step), its the top context;
+     - if we came here by a step (i.e. bigStep), its the top context
+       (for ifs and whiles) or the sender (for regular sends).
+     - otherwise, we came here by some signal raise, and we are interrested
+       in the context where the raise actually occured.
     "
     exitAction == #step ifTrue:[
 	selection := 1.
@@ -742,6 +739,9 @@
 		    selection := 2
 		]
 	    ].
+	    "
+	     for bigStep, we could also be in a block below the actual method ...
+	    "
 	    (aContext home notNil and:[
 	    (ObjectMemory addressOf:aContext home) == steppedContextAddress]) ifTrue:[
 		selection := 1
@@ -799,6 +799,12 @@
 	]
     ].
 
+    "
+     drawableId is nil, if this is a new debugger. Then do a realize.
+     Otherwise, its probably better to do a rerealize, which shows the
+     view at the previous position, without a need for the user to set the
+     position again
+    "
     drawableId notNil ifTrue:[
 	self rerealize
     ] ifFalse:[
@@ -811,19 +817,20 @@
     self raise.
     Display synchronizeOutput.
 
-    "
-     enter private event handling loop
-    "
     canContinue := true.
     exitAction := nil.
 
+    "
+     enter private event handling loop. This is left (and we come back here again)
+     when any button was pressed which requires continuation of the debuggee or
+     closedown of the debugger.
+    "
     self controlLoop.
 
     "
      release all context stuff.
-     This is required, since the debugger is reused,
-     to avoid keeping references to the debuggees objects
-     forever.
+     This is required to avoid keeping references to the debuggees objects
+     forever. (since the debugger is reused for faster startup next time)
     "
     contextArray := nil.
     codeView acceptAction:nil.
@@ -831,11 +838,11 @@
     receiverInspector release.
     contextInspector release.
 
-    (exitAction == #step) ifFalse:[
+    (exitAction ~~ #step) ifTrue:[
 	self unrealize.
 	device synchronizeOutput.
+
 	(exitAction == #abort) ifTrue:[
-	    selectedContext := actualContext := nil.
 	    self cacheMyself.
 	    "
 	     have to catch errors occuring in unwind-blocks
@@ -849,25 +856,29 @@
 	    ].
 	    'abort failed' errorPrintNL
 	].
+
 	(exitAction == #return) ifTrue:[
 	    selectedContext notNil ifTrue:[
 		"
 		 if there is a selection in the codeView,
 		 evaluate it and use the result as return value
 		"
-		codeView hasSelection ifTrue:[
-		    s := codeView selection asString.
-		    Object errorSignal handle:[:ex |
-			'DEBUGGER: error - returning nil' printNL.
-			retval := nil.
-			ex return
-		    ] do:[
-			retval := codeView doItAction value:s.
-		    ].
-		].
+"/ disabled for now, there is almost always a selection (the current line)
+"/ and that is syntactically incorrect ...
+"/ ... leading to a popup warning from the codeView
+"/
+"/                codeView hasSelection ifTrue:[
+"/                    s := codeView selection asString.
+"/                    Object errorSignal handle:[:ex |
+"/                        'DEBUGGER: error - returning nil' printNL.
+"/                        retval := nil.
+"/                        ex return
+"/                    ] do:[
+"/                        retval := codeView doItAction value:s.
+"/                    ].
+"/                ].
 
 		con := selectedContext.
-		selectedContext := actualContext := nil.
 		self cacheMyself.
 		"
 		 have to catch errors occuring in unwind-blocks
@@ -881,45 +892,44 @@
 		].
 		'cannot return from selected context' errorPrintNL
 	    ]
-	] ifFalse:[
-	    (exitAction == #restart) ifTrue:[
-		selectedContext notNil ifTrue:[
-		    con := selectedContext.
-		    selectedContext := actualContext := nil.
-		    self cacheMyself.
-		    "
-		     have to catch errors occuring in unwind-blocks
-		    "
-		    Object errorSignal handle:[:ex |
-			'ignored error while unwinding: ' errorPrint.
-			ex errorString errorPrintNL.
-			ex proceed
-		    ] do:[
-			con restart.
-		    ].
-		    'cannot restart selected context' errorPrintNL
-		]
-	    ] ifFalse:[
-		((exitAction == #terminate) or:[exitAction == #quickTerminate]) ifTrue:[
-		    selectedContext := actualContext := nil.
-		    self cacheMyself.
-		    exitAction == #quickTerminate ifTrue:[
-			Processor activeProcess terminateNoSignal
-		    ] ifFalse:[
-			"
-			 have to catch errors occuring in unwind-blocks
-			"
-			Object errorSignal handle:[:ex |
-			    'ignored error while unwinding: ' errorPrint.
-			    ex errorString errorPrintNL.
-			    ex proceed
-			] do:[
-			    Processor activeProcess terminate.
-			].
-		    ].
-		    'cannot terminate process' errorPrintNL
-		]
+	].
+
+	(exitAction == #restart) ifTrue:[
+	    selectedContext notNil ifTrue:[
+		con := selectedContext.
+		self cacheMyself.
+		"
+		 have to catch errors occuring in unwind-blocks
+		"
+		Object errorSignal handle:[:ex |
+		    'ignored error while unwinding: ' errorPrint.
+		    ex errorString errorPrintNL.
+		    ex proceed
+		] do:[
+		    con restart.
+		].
+		'cannot restart selected context' errorPrintNL
 	    ]
+	].
+
+	(exitAction == #quickTerminate) ifTrue:[
+	    self cacheMyself.
+	    Processor activeProcess terminateNoSignal
+	].
+
+	(exitAction == #terminate) ifTrue:[
+	    self cacheMyself.
+	    "
+	     have to catch errors occuring in unwind-blocks
+	    "
+	    Object errorSignal handle:[:ex |
+		'ignored error while unwinding: ' errorPrint.
+		ex errorString errorPrintNL.
+		ex proceed
+	    ] do:[
+		Processor activeProcess terminate.
+	    ].
+	    'cannot terminate process' errorPrintNL
 	]
     ].
 
@@ -931,9 +941,15 @@
     ].
 
     (exitAction == #step) ifTrue:[
-	"scedule another stepInterrupt
+	"
+	 schedule another stepInterrupt
+	 - must enter myself into the collection of open debuggers,
+	   in case the stepping process comes back again via a halt or signal
+	   before the step is finished. In this case, the stepping debugger should
+	   come up (instead of a new one)
 	 - must flush caches since optimized methods not always
-	 look for pending interrupts"
+	   look for pending interrupts
+	"
 	OpenDebuggers isNil ifTrue:[
 	    OpenDebuggers := WeakArray with:self
 	] ifFalse:[
@@ -948,11 +964,11 @@
 	].
 	self label:'single stepping - please wait ...'.
 	stepping := true.
-	ObjectMemory flushInlineCaches.
 
 	ObjectMemory stepInterruptHandler:self.
-	StepInterruptPending := true.
-	InterruptPending := true.
+	ObjectMemory flushInlineCaches.
+	StepInterruptPending := 1.
+	InterruptPending := 1.
 	InStepInterrupt := nil
     ] ifFalse:[
 	OpenDebuggers notNil ifTrue:[
@@ -1895,7 +1911,7 @@
 "/        b := Button label:'untrace' in:v.
 "/        b origin:(0 @ 0) extent:(1.0 @ (b height)).
 "/        b action:[
-"/            StepInterruptPending := false.
+"/            StepInterruptPending := nil.
 "/            tracing := false.
 "/            v unrealize.
 "/            traceView := nil