MiniDebugger.st
changeset 16249 e341857b7c41
parent 16096 7e675dfeb012
child 16557 f66c1022d93b
--- a/MiniDebugger.st	Tue Mar 11 10:27:34 2014 +0100
+++ b/MiniDebugger.st	Tue Mar 11 10:27:52 2014 +0100
@@ -76,21 +76,21 @@
             ^ self
         ].
 
-        aString printCR.
+        aString errorPrintCR.
         Processor notNil ifTrue:[
             active := Processor activeProcess.
-            'process: id=' print. active id print.
-            ' name=' print. active name printCR.
+            'process: id=' errorPrint. active id errorPrint.
+            ' name=' errorPrint. active name errorPrintCR.
 
-            'context: ' print. aContext printString printCR.
+            'context: ' errorPrint. aContext printString errorPrintCR.
             (con := aContext) notNil ifTrue:[
                 con := con sender.
-                ' ......: ' print. con printString printCR.
+                ' ......: ' errorPrint. con printString errorPrintCR.
                 [con notNil] whileTrue:[
                     sender := con sender.
                     (sender notNil and:[sender selector == con selector]) ifTrue:[
-                        ' ......: ' print. sender printString printCR.
-                        ' ......:  [** intermediate recursive contexts skipped **]' printCR.
+                        ' ......: ' errorPrint. sender printString errorPrintCR.
+                        ' ......:  [** intermediate recursive contexts skipped **]' errorPrintCR.
                         [sender notNil
                          and:[sender selector == con selector
                          and:[sender method == con method]]] whileTrue:[
@@ -99,13 +99,13 @@
                         ].
                     ].
                     con := sender.
-                    ' ......: ' print. con printString printCR.
+                    ' ......: ' errorPrint. con printString errorPrintCR.
                 ]
             ]
         ].
         NotFirstTimeEntered ~~ true ifTrue:[
             NotFirstTimeEntered := true.
-            'Type "c" to proceed, "?" for help' printCR.
+            'Type "c" to proceed, "?" for help' errorPrintCR.
         ].
     ].
 
@@ -118,7 +118,7 @@
 
         Error handle:[:ex |
             'cannot raise Abort - exiting ...' errorPrintCR.
-            Smalltalk exit.
+            OperatingSystem exit:10.
         ] do:[
             AbortOperationRequest raise.
         ]
@@ -199,7 +199,7 @@
 !
 
 trace:aBlock
-    self trace:aBlock with:[:where | where printCR]
+    self trace:aBlock with:[:where | where errorPrintCR]
 
     "Modified: 20.5.1996 / 10:27:37 / cg"
 !
@@ -243,22 +243,29 @@
     stillHere := true.
     [stillHere] whileTrue:[
         AbortOperationRequest handle:[:ex |
-            '** Abort cought - back in previous debugLevel' printCR.
+            '** Abort cought - back in previous debugLevel' errorPrintCR.
         ] do:[
             Error handle:[:ex |
-                'Error while executing MiniDebugger command: ' print.
-                ex description printCR.
-                yesNo := self getCommand:'- (i)gnore / (p)roceed / (d)ebug / b(acktrace) ? '.
-                yesNo == $d ifTrue:[
-                    MiniDebugger enterWithMessage:'Debugging debugger' mayProceed:true.
-                    ex proceed
-                ].
-                yesNo == $p ifTrue:[
-                    ex proceed
-                ].
-                yesNo == $b ifTrue:[
-                    ex suspendedContext fullPrintAll.
-                    ex proceed
+                StreamError handle:[:ex|
+                    "You won't see this probably - but you will see it when doing a syscall trace"
+                    'Error while processing error in MiniDebugger (Stdout closed?):' errorPrintCR.
+                    ex description errorPrintCR.
+                    OperatingSystem exit:10.
+                ] do:[
+                    'Error while executing MiniDebugger command: ' errorPrint.
+                    ex description errorPrintCR.
+                    yesNo := self getCommand:'- (i)gnore / (p)roceed / (d)ebug / b(acktrace) ? '.
+                    yesNo == $d ifTrue:[
+                        MiniDebugger enterWithMessage:'Debugging debugger' mayProceed:true.
+                        ex proceed
+                    ].
+                    yesNo == $p ifTrue:[
+                        ex proceed
+                    ].
+                    yesNo == $b ifTrue:[
+                        ex suspendedContext fullPrintAll.
+                        ex proceed
+                    ].
                 ].
             ] do:[
                 [
@@ -413,7 +420,7 @@
         dot := c.
         "/ dot fullPrint.
     ] ifFalse:[
-        '** dot is the bottom of the calling chain' printCR.
+        '** dot is the bottom of the calling chain' errorPrintCR.
     ].
 !
 
@@ -422,7 +429,7 @@
         dot := dot sender.
         "/ dot fullPrint.
     ] ifFalse:[
-        '** dot is the top of the calling chain' printCR.
+        '** dot is the top of the calling chain' errorPrintCR.
     ].
 !
 
@@ -450,15 +457,15 @@
 
 printDot
     dot fullPrint.
-    '  receiver: ' print. dot receiver printCR.
-    '  selector: ' print. dot selector printCR.
-    '  args: ' printCR.
+    '  receiver: ' errorPrint. dot receiver errorPrintCR.
+    '  selector: ' errorPrint. dot selector errorPrintCR.
+    '  args: ' errorPrintCR.
     dot args keysAndValuesDo:[:idx :eachArg |
-        '    ' print. idx print. ': ' print. eachArg printCR.
+        '    ' errorPrint. idx errorPrint. ': ' errorPrint. eachArg errorPrintCR.
     ].
-    '  vars: ' printCR.
+    '  vars: ' errorPrintCR.
     dot vars keysAndValuesDo:[:idx :eachVar |
-        '    ' print. idx print. ': ' print. eachVar printCR.
+        '    ' errorPrint. idx errorPrint. ': ' errorPrint. eachVar errorPrintCR.
     ].
 !
 
@@ -472,12 +479,12 @@
     home := dot methodHome.
     mthd := home method.
     mthd isNil ifTrue:[
-        '** no source **' printCR.
+        '** no source **' errorPrintCR.
         ^ self.
     ].
     src := mthd source.
     src isNil ifTrue:[
-        '** no source **' printCR.
+        '** no source **' errorPrintCR.
         ^ self.
     ].
     pcLineNr := dot lineNumber.
@@ -492,12 +499,12 @@
     ].
     startLnr to:stopLnr do:[:lNr |
         lNr == pcLineNr ifTrue:[
-            '>> ' print.
+            '>> ' errorPrint.
         ] ifFalse:[
-            '   ' print.
+            '   ' errorPrint.
         ].
-        (lNr printStringLeftPaddedTo:3) print. ' ' print.
-        (src at:lNr) printCR.
+        (lNr printStringLeftPaddedTo:3) errorPrint. ' ' errorPrint.
+        (src at:lNr) errorPrintCR.
     ]
 !
 
@@ -586,13 +593,13 @@
 
     (cmd == $w) ifTrue:[
         proc notNil ifTrue:[
-            '-------- walkback of process ' print. id print. ' -------' printCR.
+            '-------- walkback of process ' errorPrint. id errorPrint. ' -------' errorPrintCR.
             self printBacktraceFrom:(proc suspendedContext)
         ] ifFalse:[
             id notNil ifTrue:[
-                'no process with id: ' print. id printCR.
+                'no process with id: ' errorPrint. id errorPrintCR.
             ] ifFalse:[
-                '-------- walkback of current process -------' printCR.
+                '-------- walkback of current process -------' errorPrintCR.
                 self printBacktraceFrom:(self getContext)
             ]
         ].
@@ -601,13 +608,13 @@
 
     (cmd == $b) ifTrue:[
         proc notNil ifTrue:[
-            '-------- VM walkback of process ' print. id print. ' -------' printCR.
+            '-------- VM walkback of process ' errorPrint. id errorPrint. ' -------' errorPrintCR.
             ObjectMemory printStackBacktraceFrom:(proc suspendedContext)
         ] ifFalse:[
             id notNil ifTrue:[
-                'no process with id: ' print. id printCR.
+                'no process with id: ' errorPrint. id errorPrintCR.
             ] ifFalse:[
-                '-------- VM walkback of current process -------' printCR.
+                '-------- VM walkback of current process -------' errorPrintCR.
                 ObjectMemory printStackBacktrace
             ]
         ].
@@ -615,9 +622,9 @@
     ].
 
     (cmd == $S) ifTrue:[
-        'saving "crash.img"...' print.
+        'saving "crash.img"...' errorPrint.
         ObjectMemory writeCrashImage.
-        'done.' printCR.
+        'done.' errorPrintCR.
         ^ false
     ].
     (cmd == $C) ifTrue:[
@@ -628,7 +635,7 @@
         OperatingSystem isMSWINDOWSlike ifTrue:[ changesFilename replaceAll:$: with:$_ ].
 
         ChangeSet current fileOutAs: changesFilename.
-        ('saved session changes to "',changesFilename,'".') printCR.
+        ('saved session changes to "',changesFilename,'".') errorPrintCR.
         ^ false
     ].
 
@@ -647,7 +654,7 @@
     ].
 
     (cmd == $r) ifTrue:[
-        dot receiver printCR.
+        dot receiver errorPrintCR.
         ^ false
     ].
 
@@ -669,7 +676,7 @@
         ^ false
     ].
     (cmd == $e) ifTrue:[
-        (Parser evaluate:commandArg) printCR.
+        (Parser evaluate:commandArg) errorPrintCR.
         ^ false
     ].
 
@@ -689,7 +696,7 @@
         (bool notNil) ifTrue:[
             Smalltalk ignoreHalt:bool not.
         ].
-        'halts are ' print. (Smalltalk ignoreHalt ifTrue:['disabled'] ifFalse:['enabled']) printCR.
+        'halts are ' errorPrint. (Smalltalk ignoreHalt ifTrue:['disabled'] ifFalse:['enabled']) errorPrintCR.
         ^ false
     ].
 
@@ -705,7 +712,7 @@
             proc terminate.
         ] ifFalse:[
             id notNil ifTrue:[
-                'no process with id: ' print. id printCR.
+                'no process with id: ' errorPrint. id errorPrintCR.
             ] ifFalse:[
                 Processor terminateActive
             ]
@@ -715,10 +722,10 @@
 
     (cmd == $W) ifTrue:[
         proc notNil ifTrue:[
-            'stopping process id: ' print. id printCR.
+            'stopping process id: ' errorPrint. id errorPrintCR.
             proc stop.
         ] ifFalse:[
-            'invalid process id: ' print. id printCR.
+            'invalid process id: ' errorPrint. id errorPrintCR.
         ].
         ^ false
     ].
@@ -726,10 +733,10 @@
     (cmd == $a) ifTrue:[
         "without id-arg, this is handled by caller"
         proc notNil ifTrue:[
-            'aborting process id: ' print. id printCR.
+            'aborting process id: ' errorPrint. id errorPrintCR.
             proc interruptWith:[AbortOperationRequest raise]
         ] ifFalse:[
-            'aborting' printCR.
+            'aborting' errorPrintCR.
         ].
         ^ false
     ].
@@ -739,7 +746,7 @@
             proc terminateNoSignal.
         ] ifFalse:[
             id notNil ifTrue:[
-                'no process with id: ' print. id printCR.
+                'no process with id: ' errorPrint. id errorPrintCR.
             ] ifFalse:[
                 Processor terminateActiveNoSignal
             ]
@@ -810,7 +817,7 @@
             'MiniDebugger> '
           ] ifFalse:[
             'MiniDebugger' , nesting printString , '>'
-          ])) print.
+          ])) errorPrint.
 
     UserInterrupt handle:[:ex |
         ex restart
@@ -829,11 +836,11 @@
         cnt := nil.
         (cmd isDigit) ifTrue:[
             cnt := 0.
-            [cmd isDigit] whileTrue:[
+            [
                 cnt := (cnt * 10) + cmd digitValue.
                 cmd := Character fromUser
-            ].
-            [cmd == Character space] whileTrue:[
+            ] doWhile:[cmd notNil and:[cmd isDigit]].
+            [cmd notNil and:[cmd == Character space]] whileTrue:[
                 cmd := Character fromUser
             ].
         ].
@@ -860,21 +867,21 @@
     |args className sym val match showMethod|
 
     commandArg withoutSeparators isEmpty ifTrue:[
-        'usage: H className [methodPattern]' printCR.
+        'usage: H className [methodPattern]' errorPrintCR.
         ^self
     ].
     args := commandArg asCollectionOfWords.
     className := args first.
     
     (sym := className asSymbolIfInterned) isNil ifTrue:[
-        'no such class' printCR.
+        'no such class' errorPrintCR.
         ^ self.
     ].
-    val := Smalltalk at:sym ifAbsent:['no such class' printCR. ^ self.].
+    val := Smalltalk at:sym ifAbsent:['no such class' errorPrintCR. ^ self.].
     val isBehavior ifFalse:[
-        'not a class: ' print. className printCR.
+        'not a class: ' errorPrint. className errorPrintCR.
         val := val class.
-        'showing help for ' print. val name printCR.
+        'showing help for ' errorPrint. val name errorPrintCR.
     ].
     args size > 1 ifTrue:[
         match := args at:2
@@ -890,11 +897,11 @@
             or:[ sel asLowercase startsWith:match asLowercase ]) ifTrue:[
                 mthd := cls compiledMethodAt:sel.
                 mthd category ~= 'documentation' ifTrue:[
-                    sel printCR.
+                    sel errorPrintCR.
                     (mthd comment ? '') asStringCollection do:[:l |
-                        '    ' print. l withoutSeparators printCR.
+                        '    ' errorPrint. l withoutSeparators errorPrintCR.
                     ].
-                    '' printCR
+                    '' errorPrintCR
                 ].
             ].
         ].
@@ -949,13 +956,13 @@
     Process allInstancesDo:[:p |
         (p isActive not
         and:[p isDead not]) ifTrue:[
-            '---------------------------------------------------------' printCR.
-            '  proc id=' print. p id print.
-            ' name=''' print. p name print.
-            ''' createdBy: ' print. p creatorId print.
-            ' state=' print.  p state print.
-            ' prio=' print. p priority printCR.
-            '' printCR. '' printCR.
+            '---------------------------------------------------------' errorPrintCR.
+            '  proc id=' errorPrint. p id errorPrint.
+            ' name=''' errorPrint. p name errorPrint.
+            ''' createdBy: ' errorPrint. p creatorId errorPrint.
+            ' state=' errorPrint.  p state errorPrint.
+            ' prio=' errorPrint. p priority errorPrintCR.
+            '' errorPrintCR. '' errorPrintCR.
 
             self printBacktraceFrom:(p suspendedContext)
         ]
@@ -970,7 +977,7 @@
     |active|
 
     active := Processor activeProcess.
-    'current id=' print. active id print. ' name=''' print. active name print. '''' printCR.
+    'current id=' errorPrint. active id errorPrint. ' name=''' errorPrint. active name errorPrint. '''' errorPrintCR.
 
     (Process allSubInstances sort:[:a :b | (a id ? -1)<(b id ? -1)]) do:[:p |
         |doShow|
@@ -979,15 +986,15 @@
         doShow := doShow or:[ (how == #dead) and:[ p isDead ]].
         doShow := doShow or:[ (how ~~ #dead) and:[ p isDead not ]].
         doShow ifTrue:[
-            'proc id=' print. (p id printStringPaddedTo:6) print.
-            (p state printStringPaddedTo:10) print.
-            ' pri=' print. (p priority printStringPaddedTo:2) print.
-            ' creator:' print. (p creatorId printStringPaddedTo:5) print.
-            ' group:' print. (p processGroupId printStringPaddedTo:5) print.
-            ' sys:' print. (p isSystemProcess ifTrue:'y' ifFalse:'n') print.
-            ' ui:' print. (p isGUIProcess ifTrue:'y' ifFalse:'n') print.
-            ' name=''' print. p name print.
-            '''' printCR.
+            'proc id=' errorPrint. (p id printStringPaddedTo:6) errorPrint.
+            (p state printStringPaddedTo:10) errorPrint.
+            ' pri=' errorPrint. (p priority printStringPaddedTo:2) errorPrint.
+            ' creator:' errorPrint. (p creatorId printStringPaddedTo:5) errorPrint.
+            ' group:' errorPrint. (p processGroupId printStringPaddedTo:5) errorPrint.
+            ' sys:' errorPrint. (p isSystemProcess ifTrue:'y' ifFalse:'n') errorPrint.
+            ' ui:' errorPrint. (p isGUIProcess ifTrue:'y' ifFalse:'n') errorPrint.
+            ' name=''' errorPrint. p name errorPrint.
+            '''' errorPrintCR.
         ]
     ]
 
@@ -1050,10 +1057,10 @@
 !MiniDebugger class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/MiniDebugger.st,v 1.100 2014-02-20 13:14:22 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/MiniDebugger.st,v 1.101 2014-03-11 09:27:52 stefan Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/MiniDebugger.st,v 1.100 2014-02-20 13:14:22 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/MiniDebugger.st,v 1.101 2014-03-11 09:27:52 stefan Exp $'
 ! !