Skip to content

Commit

Permalink
Merge pull request #90 from jgfoster/james
Browse files Browse the repository at this point in the history
Terminate non-current process from debugger
  • Loading branch information
ericwinger authored Aug 21, 2018
2 parents d24d66f + 5976fe3 commit 57be879
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 10 deletions.
2 changes: 1 addition & 1 deletion sources/GciSession.cls
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,10 @@ logout
self trigger: #'logoutPending'.
library ifNotNil: [
library logoutSession: gciSessionId.
library := nil.
].
self trigger: #'logout'.
gciSessionId := nil.
library := nil.
!

logoutRequested
Expand Down
9 changes: 6 additions & 3 deletions sources/JadeDebugger.cls
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ JadeDebugger comment: ''!

_terminateProcess

| cachedGsProcess |
cachedGsProcess := gsProcess.
self clearUI.
(processList size == 1 or: [gsProcess == processList first]) ifTrue: [self view close. ^self].
processList := processList copyWithout: gsProcess.
(processList size == 1 or: [gsProcess oopType = processList first oopType]) ifTrue: [self view close. ^self].
processList copy do: [:each | each oopType = gsProcess oopType ifTrue: [processList remove: each]].
processListPresenter list: processList.
[
self _terminateProcess: gsProcess.
self _terminateProcess: cachedGsProcess.
] on: TerminateProcess do: [:ex |
ex return: nil.
].
Expand Down
2 changes: 1 addition & 1 deletion sources/Rowan UI Tests.pax
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ JadeiteAbstractTestCase subclass: #JadeiteProjectBrowserTestCase
poolDictionaries: ''
classInstanceVariableNames: ''!
JadeiteAbstractTestCase subclass: #RowanDebuggerTestCase
instanceVariableNames: 'debugger process'
instanceVariableNames: 'debugger gsProcess process'
classVariableNames: ''
poolDictionaries: ''
classInstanceVariableNames: ''!
Expand Down
18 changes: 16 additions & 2 deletions sources/RowanDebugger.cls
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,22 @@ RowanDebugger comment: ''!
!RowanDebugger categoriesForClass!Unclassified! !
!RowanDebugger methodsFor!

_terminateProcess: aRowanProcessService
_processList

gciSession terminate: aRowanProcessService oopType.
^processList!

_terminateProcess: aGsProcess

| string |
string := '
| gsProcess |
gsProcess := Object _objectForOop: ' , aGsProcess oopType value printString , '.
gsProcess ifNotNil: [gsProcess terminate. (Delay forMilliseconds: 10) wait].
Processor allProcesses includes: gsProcess'.
5 timesRepeat: [
(gciSession executeString: string) ifFalse: [^self].
].
self error: 'terminate process failed'.
!

basicSelectedFrame
Expand Down Expand Up @@ -319,6 +332,7 @@ variableDataPresenter

variableListPresenter
^variableListPresenter! !
!RowanDebugger categoriesFor: #_processList!public! !
!RowanDebugger categoriesFor: #_terminateProcess:!public! !
!RowanDebugger categoriesFor: #basicSelectedFrame!public! !
!RowanDebugger categoriesFor: #browseFrameMethod!public! !
Expand Down
29 changes: 26 additions & 3 deletions sources/RowanDebuggerTestCase.cls
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"Filed out from Dolphin Smalltalk 7"!

JadeiteAbstractTestCase subclass: #RowanDebuggerTestCase
instanceVariableNames: 'debugger process'
instanceVariableNames: 'debugger gsProcess process'
classVariableNames: ''
poolDictionaries: ''
classInstanceVariableNames: ''!
Expand Down Expand Up @@ -94,10 +94,29 @@ systemBrowser
tearDown

process ifNotNil: [process terminate. process := nil].
self closeDebuggers.
self
terminateGsProcess;
closeDebuggers;
yourself.
RowanDebugger debuggerClass: nil.
RowanDebugger semaphore: nil.
super tearDown.
(Delay forMilliseconds: 50) wait.!

terminateGsProcess

| string |
gsProcess ifNil: [^self].
string := '
| gsProcess |
gsProcess := Object _objectForOop: ' ,gsProcess printString , '.
gsProcess ifNotNil: [gsProcess terminate. (Delay forMilliseconds: 10) wait].
Processor allProcesses includes: gsProcess'.
gsProcess := nil.
5 timesRepeat: [
(debugger gciSession executeString: string) ifFalse: [^self].
].
self assert: false.
!

test1
Expand Down Expand Up @@ -310,11 +329,13 @@ testBug82
"Terminate a process other than the primary one"

| confirmProcess |
session executeString: '[(Delay forSeconds: 9999) wait] fork'.
gsProcess := session executeString: '[(Delay forSeconds: 9999) wait] fork asOop'.
self
openDebuggerOn: 'nil halt';
assert: debugger _processList size equals: 2;
assert: debugger processListPresenter list size equals: 2;
assert: (debugger processListPresenter selectionByIndex: 2) notNil;
assert: (debugger _processList at: 2) oopType value equals: gsProcess;
yourself.
confirmProcess := [
[
Expand All @@ -330,6 +351,7 @@ testBug82
[
self
assert: debugger terminateProcess notNil;
assert: debugger _processList size equals: 1;
assert: debugger processListPresenter list size equals: 1;
debuggerDo: [debugger resumeProcess];
yourself.
Expand Down Expand Up @@ -404,6 +426,7 @@ testSaveMethod
!RowanDebuggerTestCase categoriesFor: #setUp!public!running! !
!RowanDebuggerTestCase categoriesFor: #systemBrowser!public! !
!RowanDebuggerTestCase categoriesFor: #tearDown!public!running! !
!RowanDebuggerTestCase categoriesFor: #terminateGsProcess!public!running! !
!RowanDebuggerTestCase categoriesFor: #test1!public!tests! !
!RowanDebuggerTestCase categoriesFor: #test2!public!tests! !
!RowanDebuggerTestCase categoriesFor: #test3!public!tests! !
Expand Down
12 changes: 12 additions & 0 deletions sources/RowanProcessService.cls
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,24 @@ oopType

^OopType64 fromInteger: oop!

printOn: aStream

aStream
nextPutAll: 'GsProcess(';
print: oop;
nextPutAll: ') with ';
print: frames size;
nextPutAll: ' frames';
yourself.
!

stack

^frames collect: [:each | each printString]! !
!RowanProcessService categoriesFor: #frameForLevel:!public! !
!RowanProcessService categoriesFor: #gsProcessForSession:!public! !
!RowanProcessService categoriesFor: #oop!public! !
!RowanProcessService categoriesFor: #oopType!public! !
!RowanProcessService categoriesFor: #printOn:!public! !
!RowanProcessService categoriesFor: #stack!public! !

0 comments on commit 57be879

Please sign in to comment.