#REFACTORING by stefan
authorStefan Vogel <sv@exept.de>
Tue, 13 Sep 2016 14:46:09 +0200
changeset 20383 f20466f6b0a4
parent 20382 870f6e63c6aa
child 20384 78b74ac7c891
#REFACTORING by stefan class: Object changed: #signalInterrupt:
Object.st
--- a/Object.st	Tue Sep 13 14:45:33 2016 +0200
+++ b/Object.st	Tue Sep 13 14:46:09 2016 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1988 by Claus Gittinger
 	      All Rights Reserved
@@ -684,6 +686,7 @@
 ! !
 
 
+
 !Object methodsFor:'accessing'!
 
 _at:index
@@ -1780,8 +1783,6 @@
     "
 ! !
 
-
-
 !Object methodsFor:'attributes access'!
 
 objectAttributeAt:attributeKey
@@ -1909,8 +1910,6 @@
 ! !
 
 
-
-
 !Object methodsFor:'change & update'!
 
 broadcast:aSelectorSymbol
@@ -5358,43 +5357,43 @@
      action title screen|
 
     thisContext isRecursive ifTrue:[
-	'Severe error: signalInterrupt while processing a signalInterrupt.' errorPrintCR.
-	'Terminating process ' errorPrint. Processor activeProcess errorPrintCR.
+        'Severe error: signalInterrupt while processing a signalInterrupt.' errorPrintCR.
+        'Terminating process ' errorPrint. Processor activeProcess errorPrintCR.
 "/        GenericException handle:[:ex |
 "/            "/ ignore any error during termination
 "/        ] do:[
 "/           Processor activeProcess terminate.
 "/        ].
-	MiniDebugger enter.
-	Processor activeProcess terminateNoSignal.
+        MiniDebugger enter.
+        Processor activeProcess terminateNoSignal.
     ].
 
     "if there has been an ST-signal installed, use it ..."
     sig := OperatingSystem operatingSystemSignal:signalNumber.
     sig notNil ifTrue:[
-	sig raiseSignalWith:signalNumber.
-	^ self.
+        sig raiseSignalWith:signalNumber.
+        ^ self.
     ].
 
     "/ if handled, raise OSSignalInterruptSignal
     OSSignalInterrupt isHandled ifTrue:[
-	OSSignalInterrupt raiseRequestWith:signalNumber.
-	^ self.
+        OSSignalInterrupt raiseRequestWith:signalNumber.
+        ^ self.
     ].
 
     "
      special cases
-	- SIGPWR: power failure - write a crash image and continue
-	- SIGHUP: hang up - write a crash image and exit
+        - SIGPWR: power failure - write a crash image and continue
+        - SIGHUP: hang up - write a crash image and exit
     "
     (signalNumber == OperatingSystem sigPWR) ifTrue:[
-	SnapshotError ignoreIn:[ObjectMemory writeCrashImage].
-	^ self.
+        SnapshotError ignoreIn:[ObjectMemory writeCrashImage].
+        ^ self.
     ].
     (signalNumber == OperatingSystem sigHUP) ifTrue:[
-	SnapshotError ignoreIn:[ObjectMemory writeCrashImage].
-	'Object [info]: exit due to hangup signal.' errorPrintCR.
-	Smalltalk exit:1.
+        SnapshotError ignoreIn:[ObjectMemory writeCrashImage].
+        'Object [info]: exit due to hangup signal.' errorPrintCR.
+        Smalltalk exit:1.
     ].
 
     name := OperatingSystem nameForSignal:signalNumber.
@@ -5404,7 +5403,7 @@
      or:[(screen := Screen current) isNil
      or:[(screen := Screen default) isNil
      or:[screen isOpen not]]]) ifTrue:[
-	^ self startMiniDebuggerOrExit:'OS-Signal (' , name, ')'.
+        ^ self startMiniDebuggerOrExit:'OS-Signal (' , name, ')'.
     ].
 
     "ungrab - in case it happened in a box/popupview
@@ -5416,117 +5415,114 @@
 
     "there is a screen. use it to bring up a box asking for what to do ..."
     Screen currentScreenQuerySignal answer:screen do:[
-	"
-	 SIGBUS, SIGSEGV and SIGILL do not make sense to ignore (i.e. continue)
-	 since the system will retry the faulty instruction, which leads to
-	 another signal - to avoid frustration, better not offer this option.
-	"
-	fatal := OperatingSystem isFatalSignal:signalNumber.
-	fatal ifTrue:[
-	    (Debugger isNil or:[here isRecursive]) ifTrue:[
-		'Object [hard error]: signal ' errorPrint. signalNumber errorPrintCR.
-		^ self startMiniDebuggerOrExit:'OS-Signal (' , name, ')'.
-	    ].
-	    "
-	     a hard signal - go into debugger immediately
-	    "
-	    msg := 'OS-signal: ', name.
-
-	    "/ the IRQ-PC is passed as low-hi, to avoid the need
-	    "/ to allocate a LargeInteger in the VM during signal
-	    "/ time. I know, this is ugly.
-
-	    InterruptPcLow notNil ifTrue:[
-		pc := InterruptPcLow + (InterruptPcHi bitShift:((SmallInteger maxBits + 1) // 2)).
-		pc ~~ 0 ifTrue:[
-		    msg := msg , ' PC=' , (pc printStringRadix:16)
-		].
-	    ].
-	    InterruptAddrLow notNil ifTrue:[
-		addr := InterruptAddrLow + (InterruptAddrHi bitShift:((SmallInteger maxBits + 1) // 2)).
-		addr ~~ 0 ifTrue:[
-		    msg := msg , ' ADDR=' , (addr printStringRadix:16)
-		].
-	    ].
-	    Debugger enter:here withMessage:msg mayProceed:false.
-	    "unreachable"
-	    ^ nil.
-	].
-
-	"if possible, open an option box asking the user what do.
-	 Otherwise, start a debugger"
-	Dialog notNil ifTrue:[
-	    OperatingSystem isOSXlike ifTrue:[
-		titles := #('Save crash image' 'Dump core' 'GDB' 'Exit ST/X' 'Debug').
-		actions := #(save core gdb exit debug).
-	    ] ifFalse:[
-		titles := #('Save crash image' 'Dump core' 'Exit ST/X' 'Debug').
-		actions := #(save core exit debug).
-	    ].
-	    action := nil.
-	    title := 'OS Signal caught (' , name, ')'.
-	    title := (title , '\[in ST-process: ' , Processor activeProcess nameOrId ,']') withCRs.
-
-	    "/ if caught while in the scheduler or event dispatcher,
-	    "/ a modal dialog is not possible ...
-	    "/ (therefore, abort & return does not makes sense)
-
-	    Processor activeProcess isSystemProcess ifFalse:[
-		titles := #('Abort') , titles.
-		actions := #(abort), actions.
-
-		badContext canReturn ifTrue:[
-		    titles := #('Return') , titles.
-		    actions :=  #(return), actions.
-		].
-	    ].
-
-	    fatal ifFalse:[
-		titles := titles, #('Ignore').
-		actions := actions , #(ignore).
-	    ].
-	    action := Dialog choose:title
-			     labels:titles
-			     values:actions
-			     default:(fatal ifTrue:[nil] ifFalse:[#ignore]).
-
-	    "Dialog may fail (if system process), default action is debug"
-	    action isEmptyOrNil ifTrue:[action := #debug].
-	] ifFalse:[
-	    action := #debug.
-	].
-
-	action == #save ifTrue:[
-	    ObjectMemory writeCrashImage
-	].
-	action == #gdb ifTrue:[
-	    |pid|
-
-	    pid := OperatingSystem getProcessId.
-	    OperatingSystem openTerminalWithCommand:('gdb -p %1' bindWith:pid) inBackground:true.
-	    MiniDebugger enter. "/ to stop, so gdb can show where we are
-	    AbortOperationRequest raise.
-	].
-	action == #core ifTrue:[
-	    Smalltalk fatalAbort
-	].
-	action == #exit ifTrue:[
-	    Smalltalk exit:10.
-	].
-	action == #return ifTrue:[
-	    badContext return
-	].
-	action == #abort ifTrue:[
-	    AbortOperationRequest raise.
-	].
-
-	action == #debug ifTrue:[
-	    Debugger isNil ifTrue:[
-		^ self startMiniDebuggerOrExit:'OS-Signal (' , name, ')'.
-	    ].
-	    Debugger enter:here withMessage:('OS-Signal ', name) mayProceed:true.
-	].
-	"action == #ignore"
+        "
+         SIGBUS, SIGSEGV and SIGILL do not make sense to ignore (i.e. continue)
+         since the system will retry the faulty instruction, which leads to
+         another signal - to avoid frustration, better not offer this option.
+        "
+        fatal := OperatingSystem isFatalSignal:signalNumber.
+        fatal ifTrue:[
+            (Debugger isNil or:[here isRecursive]) ifTrue:[
+                'Object [hard error]: signal ' errorPrint. signalNumber errorPrintCR.
+                ^ self startMiniDebuggerOrExit:'OS-Signal (' , name, ')'.
+            ].
+            "
+             a hard signal - go into debugger immediately
+            "
+            msg := 'OS-signal: ', name.
+
+            "/ the IRQ-PC is passed as low-hi, to avoid the need
+            "/ to allocate a LargeInteger in the VM during signal
+            "/ time. I know, this is ugly.
+
+            InterruptPcLow notNil ifTrue:[
+                pc := InterruptPcLow + (InterruptPcHi bitShift:((SmallInteger maxBits + 1) // 2)).
+                pc ~~ 0 ifTrue:[
+                    msg := msg , ' PC=' , (pc printStringRadix:16)
+                ].
+            ].
+            InterruptAddrLow notNil ifTrue:[
+                addr := InterruptAddrLow + (InterruptAddrHi bitShift:((SmallInteger maxBits + 1) // 2)).
+                addr ~~ 0 ifTrue:[
+                    msg := msg , ' ADDR=' , (addr printStringRadix:16)
+                ].
+            ].
+            Debugger enter:here withMessage:msg mayProceed:false.
+            "unreachable"
+            ^ nil.
+        ].
+
+        "if possible, open an option box asking the user what do.
+         Otherwise, start a debugger"
+        Dialog notNil ifTrue:[
+            OperatingSystem isOSXlike ifTrue:[
+                titles := #('Save crash image' 'Dump core' 'GDB' 'Exit ST/X' 'Debug').
+                actions := #(save core gdb exit debug).
+            ] ifFalse:[
+                titles := #('Save crash image' 'Dump core' 'Exit ST/X' 'Debug').
+                actions := #(save core exit debug).
+            ].
+            action := nil.
+            title := 'OS Signal caught (' , name, ')'.
+            title := (title , '\[in ST-process: ' , Processor activeProcess nameOrId ,']') withCRs.
+
+            "/ if caught while in the scheduler or event dispatcher,
+            "/ a modal dialog is not possible ...
+            "/ (therefore, abort & return does not makes sense)
+
+            Processor activeProcess isSystemProcess ifFalse:[
+                titles := #('Abort') , titles.
+                actions := #(abort), actions.
+
+                badContext canReturn ifTrue:[
+                    titles := #('Return') , titles.
+                    actions :=  #(return), actions.
+                ].
+            ].
+
+            fatal ifFalse:[
+                titles := titles, #('Ignore').
+                actions := actions , #(ignore).
+            ].
+            action := Dialog choose:title
+                             labels:titles
+                             values:actions
+                             default:(fatal ifTrue:[nil] ifFalse:[#ignore]).
+
+            "Dialog may fail (if system process), default action is debug"
+            action isEmptyOrNil ifTrue:[action := #debug].
+        ] ifFalse:[
+            action := #debug.
+        ].
+
+        action == #save ifTrue:[
+            ObjectMemory writeCrashImage
+        ].
+        action == #gdb ifTrue:[
+            OperatingSystem openTerminalWithCommand:('gdb -p %1' bindWith:OperatingSystem getProcessId) inBackground:true.
+            MiniDebugger enter. "/ to stop, so gdb can show where we are
+            AbortOperationRequest raise.
+        ].
+        action == #core ifTrue:[
+            Smalltalk fatalAbort
+        ].
+        action == #exit ifTrue:[
+            Smalltalk exit:10.
+        ].
+        action == #return ifTrue:[
+            badContext return
+        ].
+        action == #abort ifTrue:[
+            AbortOperationRequest raise.
+        ].
+
+        action == #debug ifTrue:[
+            Debugger isNil ifTrue:[
+                ^ self startMiniDebuggerOrExit:'OS-Signal (' , name, ')'.
+            ].
+            Debugger enter:here withMessage:('OS-Signal ', name) mayProceed:true.
+        ].
+        "action == #ignore"
     ].
 
     "Modified: / 15-09-2011 / 16:38:14 / cg"
@@ -10443,7 +10439,6 @@
 
 
 
-
 !Object class methodsFor:'documentation'!
 
 version