Skip to content

Commit

Permalink
Added stack dump and inspection.
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenCostiou committed Jul 18, 2020
1 parent 42aa7e2 commit 69d9f8c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/EmergencyDebugger-Tests/EDDebuggingAPITest.class.st
Expand Up @@ -81,6 +81,16 @@ EDDebuggingAPITest >> testDisplayStackSize [
equals: debugAPI class displayStackSize
]

{ #category : #'tests - stack' }
EDDebuggingAPITest >> testDumpStack [
| dump splittedDump |
dump := debugAPI dumpStack.
splittedDump := dump splitOn: Character cr.
self
assertCollection: splittedDump
equals: (session shortStack collect: [ :ctx | ctx printString ])
]

{ #category : #'tests - processes' }
EDDebuggingAPITest >> testForbiddenProcesses [
EDDebuggingAPI forbiddenProcesses
Expand Down
8 changes: 8 additions & 0 deletions src/EmergencyDebugger/EDDebuggingAPI.class.st
Expand Up @@ -99,6 +99,14 @@ EDDebuggingAPI >> displayStackSize [
^self class displayStackSize
]

{ #category : #'API - Stack' }
EDDebuggingAPI >> dumpStack [
| str |
str := String new writeStream.
self stack printOn: str delimiter: Character cr asString.
^ str contents
]

{ #category : #initialization }
EDDebuggingAPI >> initialize [
changesForMethods := Dictionary new
Expand Down
20 changes: 20 additions & 0 deletions src/EmergencyDebugger/EDEmergencyDebugger.class.st
Expand Up @@ -135,6 +135,8 @@ EDEmergencyDebugger >> buildDefaultActions [
dic at: 'terminateAll' put: [ debugAPI terminateAllProcesses ].
dic at: 'proceed' put: [ debugAPI resume ].
dic at: 'debug' put:[self debugDebuggerError].
dic at: 'dump' put:[self dumpStackAndQuit].
dic at: 'inspect' put:[self inspectStackAndQuit].
^dic
]

Expand All @@ -153,6 +155,8 @@ EDEmergencyDebugger >> buildDefaultActionsDescriptions [
dic at: 'proceed' put: 'Proceeds the execution'.
dic at: 'showDebuggerError' put: 'Display debugger error stack, i.e., why you are here.'.
dic at: 'debug' put: 'Debug the debugger error.'.
dic at: 'dump' put: 'Dump a printed representation of the stack, quits the debugger and inspects the dump.'.
dic at: 'inspect' put: 'Quits the debugger and inspects the stack.'.
^dic
]

Expand All @@ -174,6 +178,8 @@ EDEmergencyDebugger >> buildDefaultActionsDescriptionsMap [
dic at: 'proceed' put: 'proceed'.
dic at: 'showDebuggerError' put: 'showDebuggerError'.
dic at: 'debug' put: 'debug'.
dic at: 'dump' put: 'dump'.
dic at: 'inspect' put: 'inspect'.
^dic
]

Expand Down Expand Up @@ -327,6 +333,14 @@ EDEmergencyDebugger >> displayInterface: aDisplayInterface [
rawDisplay := aDisplayInterface
]

{ #category : #private }
EDEmergencyDebugger >> dumpStackAndQuit [
| stackStrace |
stackStrace := debugAPI dumpStack.
debugAPI terminateSession.
stackStrace inspect
]

{ #category : #initialization }
EDEmergencyDebugger >> emergencyDebug: aDebugSession [
[ self debug: aDebugSession ]
Expand Down Expand Up @@ -409,6 +423,12 @@ EDEmergencyDebugger >> input [
^input
]

{ #category : #private }
EDEmergencyDebugger >> inspectStackAndQuit [
debugAPI terminateSession.
debugAPI longStack inspect
]

{ #category : #testing }
EDEmergencyDebugger >> isRunning [
^isRunning
Expand Down

0 comments on commit 69d9f8c

Please sign in to comment.