DebugView.st
branchjv
changeset 16066 471853fc1521
parent 15961 28a2666c445a
parent 16065 9993910b75c5
child 16074 c2698f7a8a6d
--- a/DebugView.st	Fri Jan 22 07:02:58 2016 +0100
+++ b/DebugView.st	Sat Jan 23 06:59:30 2016 +0100
@@ -1855,49 +1855,50 @@
 
     <context: #return>
 
-    |con m enteredByInterrupt sel iAmNew foundNoByteCodeContext foundExitContext c|
+    |con m enteredByInterrupt sel iAmNew foundNoByteCodeContext foundExitContext c 
+     userprefs logFile|
 
     DebuggingDebugger == true ifTrue:[
-	'==> enter2: (' print. aContext print.
-	') select: ' print. initialSelectionOrNil printCR.
+        '==> enter2: (' print. aContext print.
+        ') select: ' print. initialSelectionOrNil printCR.
     ].
     thisContext isRecursive ifTrue:[
-	"/ care for the special case, were the Debugger was autoloaded.
-	"/ in this case, thisContext IS recursive, but thats no error
-	"/ condition.
-	foundNoByteCodeContext := false.
-	foundExitContext := false.
-
-	c := thisContext findNextContextWithSelector:#enter:withMessage:mayProceed: or:#noByteCode or:#exit_unwindThenDo:.
-	[
-	 foundNoByteCodeContext not
-	 and:[ foundExitContext not
-	 and:[c notNil
-	 and:[c selector ~~ #enter:withMessage:mayProceed:
-	]]]]
-	whileTrue:[
-	    c selector == #exit_unwindThenDo: ifTrue:[
-		foundExitContext := true
-	    ].
-	    c selector == #noByteCode ifTrue:[
-		foundNoByteCodeContext := true
-	    ].
-	    c := c findNextContextWithSelector:#enter:withMessage:mayProceed: or:#noByteCode or:#exit_unwindThenDo:.
-	].
-
-	(foundNoByteCodeContext not
-	and:[ foundExitContext not]) ifFalse:[
-	    ('DebugView [warning]: reentered') errorPrintCR.
-
-	    ^ MiniDebugger
-		enter:aContext
-		withMessage:'DebugView [error]: recursive error (in debugger)'
-		mayProceed:mayProceed.
-	].
-	foundExitContext ifTrue:[
-	    'DebugView [error]: recursive error (in debugger) ignored' printCR.
-	    ^ self.
-	].
+        "/ care for the special case, were the Debugger was autoloaded.
+        "/ in this case, thisContext IS recursive, but thats no error
+        "/ condition.
+        foundNoByteCodeContext := false.
+        foundExitContext := false.
+
+        c := thisContext findNextContextWithSelector:#enter:withMessage:mayProceed: or:#noByteCode or:#exit_unwindThenDo:.
+        [
+         foundNoByteCodeContext not
+         and:[ foundExitContext not
+         and:[c notNil
+         and:[c selector ~~ #enter:withMessage:mayProceed:
+        ]]]]
+        whileTrue:[
+            c selector == #exit_unwindThenDo: ifTrue:[
+                foundExitContext := true
+            ].
+            c selector == #noByteCode ifTrue:[
+                foundNoByteCodeContext := true
+            ].
+            c := c findNextContextWithSelector:#enter:withMessage:mayProceed: or:#noByteCode or:#exit_unwindThenDo:.
+        ].
+
+        (foundNoByteCodeContext not
+        and:[ foundExitContext not]) ifFalse:[
+            ('DebugView [warning]: reentered') errorPrintCR.
+
+            ^ MiniDebugger
+                enter:aContext
+                withMessage:'DebugView [error]: recursive error (in debugger)'
+                mayProceed:mayProceed.
+        ].
+        foundExitContext ifTrue:[
+            'DebugView [error]: recursive error (in debugger) ignored' printCR.
+            ^ self.
+        ].
     ].
 
     "/'entering: ' print. aContext printCR.
@@ -1905,7 +1906,7 @@
     thisContext sender fixAllLineNumbers. "/ _CONTEXTLINENOS(s)
 
     (self isHaltToBeIgnored) ifTrue:[
-	^ self.
+        ^ self.
     ].
 "/    "/ does not work yet - but we should ignore any breakpoints while stepping
 "/    (stepping and:[steppedContext notNil]) ifTrue:[
@@ -1914,10 +1915,22 @@
 "/            ^ self
 "/        ].
 "/    ].
-
+    userprefs := UserPreferences current.
+    "/ optionally log this debugger entry
+    (logFile := userprefs debuggerLogFile) notNil ifTrue:[
+        logFile asFilename appendingFileDo:[:s |
+            s cr.
+            s nextPutLine:'-----------------------'.
+            Timestamp now printOn:s. 
+            s nextPutAll:' ['; nextPutAll:Processor activeProcess name; nextPutAll:']'; cr.
+            s cr.
+            aContext fullPrintAllOn:s
+        ].    
+    ].
+    
     iAmNew := self drawableId isNil.
 
-    self verboseBacktraceHolder value:(UserPreferences current verboseBacktraceInDebugger).
+    self verboseBacktraceHolder value:(userprefs verboseBacktraceInDebugger).
 
     busy := cachable := true.
     inspecting := false.
@@ -1935,50 +1948,50 @@
     "/    but not for multi-user development, where the debugger is entered often.
     "/    What is a good solution to this dilemma ?
     Screen allScreens do:[:aScreen |
-	aScreen ungrabPointer.
-	aScreen ungrabKeyboard.
+        aScreen ungrabPointer.
+        aScreen ungrabKeyboard.
     ].
 
     ("inspectedProcess suspendedContext isNil
     or:["inspectedProcess isSystemProcess"]") ifTrue:[
-	terminateButton disable.
+        terminateButton disable.
     ] ifFalse:[
-	terminateButton enable.
-	abortButton enable.
+        terminateButton enable.
+        abortButton enable.
     ].
 
     iAmNew ifFalse:[
-	"/ not the first time - disable buttons & menus
-	"/ from the previous life
-	self turnOffAllButtons.
-
-	m := contextView middleButtonMenu.
-	m notNil ifTrue:[
-	    m disableAll:#(showMore "skip skipForReturn" inspectContext).
-	].
-	self showingDenseWalkback:(self verboseBacktraceHolder value not).
+        "/ not the first time - disable buttons & menus
+        "/ from the previous life
+        self turnOffAllButtons.
+
+        m := contextView middleButtonMenu.
+        m notNil ifTrue:[
+            m disableAll:#(showMore "skip skipForReturn" inspectContext).
+        ].
+        self showingDenseWalkback:(self verboseBacktraceHolder value not).
     ].
     self iconLabel:'Debugger'.
 
     windowGroup isNil ifTrue:[
-	self windowGroup: WindowGroup new.
-	windowGroup addTopView:self.
+        self windowGroup: WindowGroup new.
+        windowGroup addTopView:self.
     ].
     exclusive ifFalse:[
-	"/ create a (modal) windowGroup for myself
-
-	windowGroup setModal:true.
+        "/ create a (modal) windowGroup for myself
+
+        windowGroup setModal:true.
     ] ifTrue:[
-	"/ create a windowGroup with a synchronous sensor for me
-
-	windowGroup beSynchronous.
+        "/ create a windowGroup with a synchronous sensor for me
+
+        windowGroup beSynchronous.
     ].
     windowGroup setProcess:Processor activeProcess.
     IsDebuggingQuery answer:true do:[
 
-	"
-	 get the walkback list; clear inspectors if we did not come here by single stepping)
-	"
+        "
+         get the walkback list; clear inspectors if we did not come here by single stepping)
+        "
 "/Transcript show:'0 '; showCR:aContext.
 "/Transcript show:'0 '; showCR:thisContext sender.
 "/Transcript show:'0 '; showCR:thisContext sender sender.
@@ -1992,28 +2005,28 @@
 "/Transcript show:'0 '; showCR:thisContext sender sender sender sender sender sender sender sender sender sender.
 "/Transcript show:'0 '; showCR:thisContext sender sender sender sender sender sender sender sender sender sender sender.
 "/Transcript showCR:initialSelectionOrNil.
-	self setContext:aContext releaseInspectors:(exitAction ~~ #step).
-	"/'after setContext; first is ' print.
-	"/(contextArray at:1 ifAbsent:nil) printCR.
-	self setInitialSelectionOnEntry:initialSelectionOrNil context:aContext.
-
-	self updateButtonsAndMenuItemsForContext:aContext.
-
-	"
-	 If this is a new debugger, do a realize.
-	 Otherwise, its probably better to do a map, which shows the
-	 view at the previous position, without a need for the user to set the
-	 position again
-	"
-	iAmNew ifTrue:[
-	    self realize.
-	] ifFalse:[
-	    self remap.
-	].
-	self setForegroundWindow.
-
-	exclusive ifTrue:[
-	    self showError:'
+        self setContext:aContext releaseInspectors:(exitAction ~~ #step).
+        "/'after setContext; first is ' print.
+        "/(contextArray at:1 ifAbsent:nil) printCR.
+        self setInitialSelectionOnEntry:initialSelectionOrNil context:aContext.
+
+        self updateButtonsAndMenuItemsForContext:aContext.
+
+        "
+         If this is a new debugger, do a realize.
+         Otherwise, its probably better to do a map, which shows the
+         view at the previous position, without a need for the user to set the
+         position again
+        "
+        iAmNew ifTrue:[
+            self realize.
+        ] ifFalse:[
+            self remap.
+        ].
+        self setForegroundWindow.
+
+        exclusive ifTrue:[
+            self showError:'
 Debugging system process `' , (inspectedProcess nameOrId) printString , '''.
 
 This is a modal debugger - all event processing is stopped..
@@ -2021,28 +2034,28 @@
 open any other tools while this debugger is active.
 
 Also, there is no event processing (redraw) for other views.'
-	].
-
-	self autoRaiseView ifTrue:[
-	    "/ self raise.
-	    self raiseDeiconified.
-	    self topView activate; setForegroundWindow; activate.
-	].
-
-	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] ifCurtailed:[
-	    windowGroup notNil ifTrue:[
-		windowGroup setProcess:nil.
-	    ].
-	    NumberOfDebuggers := (NumberOfDebuggers ? 1) - 1.
-	    self destroy
-	].
-	NumberOfDebuggers := (NumberOfDebuggers ? 1) - 1.
+        ].
+
+        self autoRaiseView ifTrue:[
+            "/ self raise.
+            self raiseDeiconified.
+            self topView activate; setForegroundWindow; activate.
+        ].
+
+        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] ifCurtailed:[
+            windowGroup notNil ifTrue:[
+                windowGroup setProcess:nil.
+            ].
+            NumberOfDebuggers := (NumberOfDebuggers ? 1) - 1.
+            self destroy
+        ].
+        NumberOfDebuggers := (NumberOfDebuggers ? 1) - 1.
     ].
     "/ here after my own control loop is finished.
 
@@ -2055,34 +2068,34 @@
     codeView doItAction:nil.
 
     ObjectMemory stepInterruptHandler == self ifTrue:[
-	ObjectMemory stepInterruptHandler:nil.
+        ObjectMemory stepInterruptHandler:nil.
     ].
 
     lastSelectionInReceiverInspector := receiverInspector selectedKeyName.
     lastSelectionInContextInspector := contextInspector selectedKeyName.
 
     (exitAction ~~ #step) ifTrue:[
-	"/ not stepping or continue - close window
-	self cacheMyself.
-	receiverInspector release.
-	contextInspector release.
-
-	self unmap.
-	self flush.
-
-	(exitAction == #abort) ifTrue:[ self exit_abort. "does not return" ].
-	(exitAction == #abortAll) ifTrue:[ self exit_abortAll. "does not return" ].
-	(exitAction == #return) ifTrue:[ self exit_return. "does not return" ].
-	(exitAction == #restart) ifTrue:[ self exit_restart. "does not return" ].
-	(exitAction == #resend) ifTrue:[ self exit_resend. "does not return" ].
-	(exitAction == #quickTerminate) ifTrue:[ self exit_quickTerminate. "does not return" ].
-	(exitAction == #terminate) ifTrue:[ self exit_terminate. "does not return" ].
-	exitAction isBlock ifTrue:[
-	    self exit_unwindThenDo:exitAction.
-	    "does not return"
-	].
-	"not reached"
-	^ self
+        "/ not stepping or continue - close window
+        self cacheMyself.
+        receiverInspector release.
+        contextInspector release.
+
+        self unmap.
+        self flush.
+
+        (exitAction == #abort) ifTrue:[ self exit_abort. "does not return" ].
+        (exitAction == #abortAll) ifTrue:[ self exit_abortAll. "does not return" ].
+        (exitAction == #return) ifTrue:[ self exit_return. "does not return" ].
+        (exitAction == #restart) ifTrue:[ self exit_restart. "does not return" ].
+        (exitAction == #resend) ifTrue:[ self exit_resend. "does not return" ].
+        (exitAction == #quickTerminate) ifTrue:[ self exit_quickTerminate. "does not return" ].
+        (exitAction == #terminate) ifTrue:[ self exit_terminate. "does not return" ].
+        exitAction isBlock ifTrue:[
+            self exit_unwindThenDo:exitAction.
+            "does not return"
+        ].
+        "not reached"
+        ^ self
     ].
 
     "/ stepping - window stays open
@@ -2090,96 +2103,96 @@
 
     "/ restore the previous pointer grab
     grabber notNil ifTrue:[
-	self graphicsDevice grabPointerInView:grabber.
-	grabber := nil.
+        self graphicsDevice grabPointerInView:grabber.
+        grabber := nil.
     ].
 
     (exitAction == #step) ifTrue:[
-	"
-	 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
-	"
-
-	"/
-	"/ also must care for stepping into a return
-	"/
-	steppedContext notNil ifTrue:[
-	    Processor activeProcess forceInterruptOnReturnOf:steppedContext.
-	].
-
-	OpenDebuggers isNil ifTrue:[
-	    OpenDebuggers := WeakIdentitySet new.
-	].
-	OpenDebuggers add:self.
-
-	self label:'single stepping - please wait ...'.
-	stepping := true.
-
-	ObjectMemory stepInterruptHandler:self.
-	Processor activeProcess stepInterruptHandler:self.
-	ObjectMemory flushCaches.
-
-	Context singleStepInterruptRequest isHandled ifTrue:[
-	    Context singleStepInterruptRequest
-		raiseWith:
-		    (("bigStep" steppedContextLineno notNil)
-			ifTrue:[#next]
-			ifFalse:[#step])
-	] ifFalse:[
-	    "/ see if we came here through an interrupt-action
-	    "/ (i.e. aProcess interruptWith:...)
-
-	    enteredByInterrupt := false.
-	    con := thisContext findNextContextWithSelector:#timerInterrupt or:#ioInterrupt or:nil.
-	    [enteredByInterrupt not
-	     and:[con notNil
-	     and:[con ~~ aContext]]] whileTrue:[
-		((sel := con selector) == #timerInterrupt
-		or:[sel == #ioInterrupt]) ifTrue:[
-		    enteredByInterrupt := true.
-		] ifFalse:[
-		    con := con findNextContextWithSelector:#timerInterrupt or:#ioInterrupt or:nil.
-		].
-	    ].
-
-	    ObjectMemory flushInlineCaches.
-
-	    DebuggingDebugger == true ifTrue:[
-		enteredByInterrupt printCR.
-	    ].
-	    enteredByInterrupt ifTrue:[
-		"/ don't want to step through all intermediate
-		"/ (scheduler-) contexts; place a return-trap on the
-		"/ one right below the interesting one
+        "
+         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
+        "
+
+        "/
+        "/ also must care for stepping into a return
+        "/
+        steppedContext notNil ifTrue:[
+            Processor activeProcess forceInterruptOnReturnOf:steppedContext.
+        ].
+
+        OpenDebuggers isNil ifTrue:[
+            OpenDebuggers := WeakIdentitySet new.
+        ].
+        OpenDebuggers add:self.
+
+        self label:'single stepping - please wait ...'.
+        stepping := true.
+
+        ObjectMemory stepInterruptHandler:self.
+        Processor activeProcess stepInterruptHandler:self.
+        ObjectMemory flushCaches.
+
+        Context singleStepInterruptRequest isHandled ifTrue:[
+            Context singleStepInterruptRequest
+                raiseWith:
+                    (("bigStep" steppedContextLineno notNil)
+                        ifTrue:[#next]
+                        ifFalse:[#step])
+        ] ifFalse:[
+            "/ see if we came here through an interrupt-action
+            "/ (i.e. aProcess interruptWith:...)
+
+            enteredByInterrupt := false.
+            con := thisContext findNextContextWithSelector:#timerInterrupt or:#ioInterrupt or:nil.
+            [enteredByInterrupt not
+             and:[con notNil
+             and:[con ~~ aContext]]] whileTrue:[
+                ((sel := con selector) == #timerInterrupt
+                or:[sel == #ioInterrupt]) ifTrue:[
+                    enteredByInterrupt := true.
+                ] ifFalse:[
+                    con := con findNextContextWithSelector:#timerInterrupt or:#ioInterrupt or:nil.
+                ].
+            ].
+
+            ObjectMemory flushInlineCaches.
+
+            DebuggingDebugger == true ifTrue:[
+                enteredByInterrupt printCR.
+            ].
+            enteredByInterrupt ifTrue:[
+                "/ don't want to step through all intermediate
+                "/ (scheduler-) contexts; place a return-trap on the
+                "/ one right below the interesting one
 
 "/                'special unwind return' printCR.
-		con unwindThenDo:[
-				  Processor activeProcess stepInterruptHandler:self.
-				  ObjectMemory stepInterruptHandler:self.
-				  InStepInterrupt := nil.
-				  StepInterruptPending := 1.
-				  InterruptPending := 1].
-	    ] ifFalse:[
+                con unwindThenDo:[
+                                  Processor activeProcess stepInterruptHandler:self.
+                                  ObjectMemory stepInterruptHandler:self.
+                                  InStepInterrupt := nil.
+                                  StepInterruptPending := 1.
+                                  InterruptPending := 1].
+            ] ifFalse:[
 "/                'normal step return' printCR.
-		skipLineNr ~~ #return ifTrue:[
-		    StepInterruptPending := 1.
-		    InterruptPending := 1.
-		] ifFalse:[
+                skipLineNr ~~ #return ifTrue:[
+                    StepInterruptPending := 1.
+                    InterruptPending := 1.
+                ] ifFalse:[
 "/                    'step for return' printCR.
-		]
-	    ].
-	    InStepInterrupt := nil
-	]
+                ]
+            ].
+            InStepInterrupt := nil
+        ]
     ] ifFalse:[
-	OpenDebuggers notNil ifTrue:[
-	    OpenDebuggers remove:self ifAbsent:[].
-	].
-	self cacheMyself.
+        OpenDebuggers notNil ifTrue:[
+            OpenDebuggers remove:self ifAbsent:[].
+        ].
+        self cacheMyself.
     ]
 
     "Modified: / 17-04-1997 / 13:01:32 / stefan"
@@ -6583,30 +6596,30 @@
     |oldSelection oldContext con idx|
 
     contextArray notNil ifTrue:[
-	self withExecuteCursorDo:[
-	    oldSelection := contextView selection.
-	    oldSelection notNil ifTrue:[
-		oldContext := contextArray at:oldSelection ifAbsent:nil.
-	    ].
-
-	    con := firstContext.
+        self withExecuteCursorDo:[
+            oldSelection := contextView selection.
+            oldSelection notNil ifTrue:[
+                oldContext := contextArray at:oldSelection ifAbsent:nil.
+            ].
+
+            con := firstContext.
 "/            con := contextArray at:1.
-	    "/ force redeisplay, even if same by changing the first entry
-	    contextArray size > 0 ifTrue:[
-		contextArray at:1 put:nil.
-	    ].
-	    self setContext:con.
-
-	    oldContext isNil ifTrue:[
-		idx := oldSelection
-	    ] ifFalse:[
-		idx := contextArray identityIndexOf:oldContext ifAbsent:nil.
-	    ].
-	    contextView setSelection:idx.
-	    idx notNil ifTrue:[
-		self showSelection:idx
-	    ]
-	]
+            "/ force redisplay, even if same by changing the first entry
+            contextArray size > 0 ifTrue:[
+                contextArray at:1 put:nil.
+            ].
+            self setContext:con.
+
+            oldContext isNil ifTrue:[
+                idx := oldSelection
+            ] ifFalse:[
+                idx := contextArray identityIndexOf:oldContext ifAbsent:nil.
+            ].
+            contextView setSelection:idx.
+            idx notNil ifTrue:[
+                self showSelection:idx
+            ]
+        ]
     ]
 
     "Created: / 10.1.1997 / 21:36:46 / cg"