From 3578206d4141a0af09d9d6cfab7bffbaa2c1c95d Mon Sep 17 00:00:00 2001 From: James Foster Date: Tue, 21 Aug 2018 11:06:04 -0700 Subject: [PATCH 1/2] Fix for https://github.com/ericwinger/Jade/issues/82. --- sources/GciSession.cls | 2 +- sources/JadeDebugger.cls | 9 ++++++--- sources/Rowan UI Tests.pax | 2 +- sources/RowanDebugger.cls | 18 ++++++++++++++++-- sources/RowanDebuggerTestCase.cls | 29 ++++++++++++++++++++++++++--- 5 files changed, 50 insertions(+), 10 deletions(-) diff --git a/sources/GciSession.cls b/sources/GciSession.cls index c32876ab..54f978da 100644 --- a/sources/GciSession.cls +++ b/sources/GciSession.cls @@ -404,10 +404,10 @@ logout self trigger: #'logoutPending'. library ifNotNil: [ library logoutSession: gciSessionId. - library := nil. ]. self trigger: #'logout'. gciSessionId := nil. + library := nil. ! logoutRequested diff --git a/sources/JadeDebugger.cls b/sources/JadeDebugger.cls index e0bd9021..65494433 100644 --- a/sources/JadeDebugger.cls +++ b/sources/JadeDebugger.cls @@ -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. ]. diff --git a/sources/Rowan UI Tests.pax b/sources/Rowan UI Tests.pax index 92c0ac3f..9399ec5b 100644 --- a/sources/Rowan UI Tests.pax +++ b/sources/Rowan UI Tests.pax @@ -46,7 +46,7 @@ JadeiteAbstractTestCase subclass: #JadeiteProjectBrowserTestCase poolDictionaries: '' classInstanceVariableNames: ''! JadeiteAbstractTestCase subclass: #RowanDebuggerTestCase - instanceVariableNames: 'debugger process' + instanceVariableNames: 'debugger gsProcess process' classVariableNames: '' poolDictionaries: '' classInstanceVariableNames: ''! diff --git a/sources/RowanDebugger.cls b/sources/RowanDebugger.cls index d668e00c..e471c9a2 100755 --- a/sources/RowanDebugger.cls +++ b/sources/RowanDebugger.cls @@ -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'. ! browseFrameMethod @@ -259,6 +272,7 @@ variableDataPresenter variableListPresenter ^variableListPresenter! ! +!RowanDebugger categoriesFor: #_processList!public! ! !RowanDebugger categoriesFor: #_terminateProcess:!public! ! !RowanDebugger categoriesFor: #browseFrameMethod!public! ! !RowanDebugger categoriesFor: #browseImplementors!public! ! diff --git a/sources/RowanDebuggerTestCase.cls b/sources/RowanDebuggerTestCase.cls index 1f1b9a5d..fcb120f1 100755 --- a/sources/RowanDebuggerTestCase.cls +++ b/sources/RowanDebuggerTestCase.cls @@ -1,7 +1,7 @@ "Filed out from Dolphin Smalltalk 7"! JadeiteAbstractTestCase subclass: #RowanDebuggerTestCase - instanceVariableNames: 'debugger process' + instanceVariableNames: 'debugger gsProcess process' classVariableNames: '' poolDictionaries: '' classInstanceVariableNames: ''! @@ -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 @@ -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 := [ [ @@ -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. @@ -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! ! From d4919f5c8afad1a885de28001f846a1835b30f8f Mon Sep 17 00:00:00 2001 From: James Foster Date: Tue, 21 Aug 2018 12:19:56 -0700 Subject: [PATCH 2/2] Add RowanProcessService>>printOn: to show more details in the debugger's process list. --- sources/RowanDebugger.cls | 2 -- sources/RowanProcessService.cls | 12 ++++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/sources/RowanDebugger.cls b/sources/RowanDebugger.cls index 2e6b4af8..66dcedc3 100755 --- a/sources/RowanDebugger.cls +++ b/sources/RowanDebugger.cls @@ -87,7 +87,6 @@ getProcessList self updateServices: (Array with: (RowanDebuggerService onProcess: gsProcess)).! - issueCommand: services | stonString stonResultString | services do:[:service | service prepareForReplication]. @@ -105,7 +104,6 @@ methodListSelection self updateServices: (Array with: methodService). ^methodService! - methodSourcePresenter ^codePane! diff --git a/sources/RowanProcessService.cls b/sources/RowanProcessService.cls index d5739635..66c930c7 100755 --- a/sources/RowanProcessService.cls +++ b/sources/RowanProcessService.cls @@ -22,11 +22,23 @@ 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: #oop!public! ! !RowanProcessService categoriesFor: #oopType!public! ! +!RowanProcessService categoriesFor: #printOn:!public! ! !RowanProcessService categoriesFor: #stack!public! !