[squeak-dev] The Trunk: Tools-ct.1092.mcz

mail at jaromir.net mail at jaromir.net
Sun Dec 19 19:12:34 UTC 2021


Hi Christoph,

If you execute a code with multiple invocations of the debugger - like e.g.

[[[] ensure: [^2]] ensure: [^42]] fork

and try to terminate it via menu-->terminate (instead og Abandon), two debugger windows open. The problem is you forward #abandon to #close which in turn takes care of closing the debugger and teminating the process. However, in case of #terminateProcess you terminate it first and only then forward to #close - with the unwanted effect that when the termination runs unwinds, it encounters another error and opens a new debugger before the old one is closed...

My naive suggestion is (I'm no debugger expert though):

add a boolean argument to #close and #windowIsClosing indicating the type of termination - aggresive or not and defer the termination in both cases to #windowIsClosing - does it sound reasonable and clean from the debugger's perspective (I don't know)?

Thanks,
Jaromir


~~~
^[^    Jaromir

Sent from Squeak Inbox Talk

On 2021-12-16T01:38:48+00:00, commits at source.squeak.org wrote:

> Christoph Thiede uploaded a new version of Tools to project The Trunk:
> http://source.squeak.org/trunk/Tools-ct.1092.mcz
> 
> ==================== Summary ====================
> 
> Name: Tools-ct.1092
> Author: ct
> Time: 16 December 2021, 2:27:47.069664 am
> UUID: 7a02fd08-61c8-a34c-a5f1-f7b62b68b12b
> Ancestors: Tools-ct.1091
> 
> Complements Kernel-ct.1434 (revised termination modi on Process). Connects the debugger's Abandon button to new #terminateAggressively to restore the old semantics known from 2020/Squeak 5.3 and older). Provides menu items for alternative termination modi in the debugger (window menu) and in the process browser (press shift to #destroy a process).
> 
> Details: Improves robustness of clean-ups in Debugger during closing. Improves multilingual support in ProcessBrowser.
> 
> =============== Diff against Tools-ct.1091 ===============
> 
> Item was added:
> + ----- Method: Debugger>>addModelItemsToWindowMenu: (in category 'misc') -----
> + addModelItemsToWindowMenu: aMenu
> + 
> + 	super addModelItemsToWindowMenu: aMenu.
> + 	
> + 	aMenu addLine.
> + 	aMenu
> + 		add: 'inspect process' translated target: self interruptedProcess action: #inspect;
> + 		add: 'explore process' translated target: self interruptedProcess action: #explore;
> + 		add: 'terminate process' translated target: self action: #terminateProcess;
> + 		balloonTextForLastItem: 'other than Abandon, this will allow the active context to unwind first.' translated.!
> 
> Item was added:
> + ----- Method: Debugger>>terminateProcess (in category 'context stack menu') -----
> + terminateProcess
> + 
> + 	interruptedProcess terminate.
> + 	interruptedProcess := nil.
> + 	self close.!
> 
> Item was changed:
>   ----- Method: Debugger>>windowIsClosing (in category 'initialize') -----
>   windowIsClosing
>   	"My window is being closed; clean up. Restart the low space watcher."
>   
> - 	interruptedProcess == nil ifTrue: [^ self].
> - 	interruptedProcess terminate.
> - 	interruptedProcess := nil.
> - 	
>   	contextStack := nil.
>   	receiverInspector := nil.
>   	contextVariablesInspector := nil.
> + 	
> + 	interruptedProcess == nil ifTrue: [^ self].
> + 	interruptedProcess terminateAggressively.
> + 	interruptedProcess := nil.
> + 	
> + 	Smalltalk installLowSpaceWatcher.  "restart low space handler"!
> - 	Smalltalk installLowSpaceWatcher.  "restart low space handler"
> - !
> 
> Item was added:
> + ----- Method: ProcessBrowser class>>destroyProcess: (in category 'process control') -----
> + destroyProcess: aProcess
> + 
> + 	aProcess ifNil: [^ self].
> + 	
> + 	self suspendedProcesses
> + 		removeKey: aProcess
> + 		ifAbsent: [].
> + 	aProcess destroy.!
> 
> Item was changed:
>   ----- Method: ProcessBrowser class>>terminateProcess: (in category 'process control') -----
>   terminateProcess: aProcess
> + 
> + 	^ self terminateProcess: aProcess aggressively: false!
> - 	aProcess ifNotNil: [
> - 		self suspendedProcesses
> - 			removeKey: aProcess
> - 			ifAbsent: [].
> - 		aProcess terminate
> - 	].
> - !
> 
> Item was added:
> + ----- Method: ProcessBrowser class>>terminateProcess:aggressively: (in category 'process control') -----
> + terminateProcess: aProcess aggressively: aggressive
> + 
> + 	aProcess ifNil: [^ self].
> + 	
> + 	self suspendedProcesses
> + 		removeKey: aProcess
> + 		ifAbsent: [].
> + 	aggressive
> + 		ifFalse: [aProcess terminate]
> + 		ifTrue: [aProcess terminateAggressively].!
> 
> Item was changed:
>   ----- Method: ProcessBrowser>>buildWith: (in category 'toolbuilder') -----
>   buildWith: builder
>   	"Create a pluggable version of me, answer a window"
>   	| windowSpec listSpec textSpec |
>   	windowSpec := builder pluggableWindowSpec new.
>   	windowSpec model: self.
>   	windowSpec label: 'Process Browser'.
>   	windowSpec children: OrderedCollection new.
>   
>   	listSpec := builder pluggableListSpec new.
>   	listSpec 
>   		model: self;
>   		list: #processNameList; 
>   		getIndex: #processListIndex; 
>   		setIndex: #processListIndex:; 
> + 		menu: #processListMenu:shifted:;
> - 		menu: #processListMenu:; 
>   		keyPress: #processListKey:from:;
>   		frame: (0 @ 0 extent: 0.5 @ 0.5).
>   	windowSpec children add: listSpec.
>   
>   	listSpec := builder pluggableListSpec new.
>   	listSpec 
>   		model: self;
>   		list: #stackNameList; 
>   		getIndex: #stackListIndex; 
>   		setIndex: #stackListIndex:; 
>   		menu: #stackListMenu:; 
>   		keyPress: #stackListKey:from:;
>   		frame: (0.5 @ 0.0 extent: 0.5 @ 0.5).
>   	windowSpec children add: listSpec.
>   
>   	textSpec := builder pluggableTextSpec new.
>   	textSpec 
>   		model: self;
>   		getText: #selectedMethod; 
>   		setText: nil; 
>   		selection: nil; 
>   		menu: nil;
>   		frame: (0 @ 0.5 corner: 1 @ 1).
>   	windowSpec children add: textSpec.
>   
>   	^builder build: windowSpec!
> 
> Item was added:
> + ----- Method: ProcessBrowser>>destroyProcess (in category 'process actions') -----
> + destroyProcess
> + 
> + 	| nameAndRules |
> + 	nameAndRules := self nameAndRulesForSelectedProcess.
> + 	nameAndRules second ifFalse: [
> + 		^ self inform: ('Nope, won''t destroy {1}' translated format: {nameAndRules first})].
> + 	self class destroyProcess: selectedProcess.
> + 	self updateProcessList.!
> 
> Item was changed:
>   ----- Method: ProcessBrowser>>processListKey:from: (in category 'process list') -----
>   processListKey: aKey from: aView
>   
>   	aKey
>   		caseOf: {
>   			[$f] ->		[^ self findContext].
>   			[$g] ->	[^ self nextContext].
>   			[$a] ->	[^ self toggleAutoUpdate].
>   			[$u] ->	[^ self updateProcessList] }
>   		otherwise: [].
>   	selectedProcess ifNil: [^ self changed: #flash].
>   	^ aKey
>   		caseOf: {
>   			[$i] ->		[self inspectProcess].
>   			[$I] ->		[self exploreProcess].
>   			[$c] ->	[self chasePointers].
>   			[$P] ->	[self inspectPointers].
>   			[$t] ->		[self terminateProcess].
> + 			[$T] ->		[self terminateProcessAggressively].
>   			[$r] ->		[self resumeProcess].
>   			[$s] ->		[self suspendProcess].
>   			[$d] ->	[self debugProcess].
>   			[$p] ->	[self changePriority].
>   			[$m] ->	[self messageTally].
>   			[$S] ->	[self signalSemaphore].
>   			[$k] ->	[self fullStack]}
>   		otherwise: [self arrowKey: aKey from: aView]!
> 
> Item was removed:
> - ----- Method: ProcessBrowser>>processListMenu: (in category 'process list') -----
> - processListMenu: menu
> - 
> - 	selectedProcess ifNotNil:
> - 		[:process|
> - 		 [:name :allowStop :allowDebug|
> - 		 menu addList: #(('inspect (i)' inspectProcess) ('explore (I)' exploreProcess) ('inspect Pointers (P)' inspectPointers)).
> - 		 (Smalltalk includesKey: #PointerFinder) ifTrue:
> - 			[menu add: 'chase pointers (c)' action: #chasePointers].
> - 		 allowStop ifTrue:
> - 			[menu add: 'terminate (t)' action: #terminateProcess.
> - 			 process isSuspended
> - 				ifTrue: [menu add: 'resume (r)' action: #resumeProcess]
> - 				ifFalse: [menu add: 'suspend (s)' action: #suspendProcess]].
> - 		allowDebug ifTrue:
> - 			[menu addList: #(('change priority (p)' changePriority) ('debug (d)' debugProcess))].
> - 		menu add: 'profile messages (m)' action: #messageTally.
> - 		(process suspendingList isKindOf: Semaphore) ifTrue:
> - 			[menu add: 'signal Semaphore (S)' action: #signalSemaphore].
> - 		menu addList: #(('full stack (k)' fullStack) ('copy stack to clipboard' copyProcessStackToClipboard)).
> - 		menu addLine] valueWithArguments: (self nameAndRulesFor: process)].
> - 
> - 	menu
> - 		addList: #(#('find context... (f)' findContext) #('find again (g)' nextContext));
> - 		addLine;
> - 		add: (self isAutoUpdating
> - 				ifTrue: ['turn off auto-update (a)']
> - 				ifFalse: ['turn on auto-update (a)'])
> - 			action: #toggleAutoUpdate;
> - 		add: 'update list (u)' action: #updateProcessList.
> - 
> - 	(Smalltalk at: #CPUWatcher ifAbsent: []) ifNotNil:
> - 		[:pw|
> - 		menu addLine.
> - 		pw isMonitoring
> - 			ifTrue: [menu add: 'stop CPUWatcher' action: #stopCPUWatcher]
> - 			ifFalse: [menu add: 'start CPUWatcher' action: #startCPUWatcher]].
> - 
> - 	^menu!
> 
> Item was added:
> + ----- Method: ProcessBrowser>>processListMenu:shifted: (in category 'process list') -----
> + processListMenu: menu shifted: shifted
> + 
> + 	selectedProcess ifNotNil:
> + 		[:process|
> + 		 [:name :allowStop :allowDebug|
> + 		 menu addList: #(('inspect (i)' inspectProcess) ('explore (I)' exploreProcess) ('inspect Pointers (P)' inspectPointers)).
> + 		 (Smalltalk includesKey: #PointerFinder) ifTrue:
> + 			[menu add: 'chase pointers (c)' translated action: #chasePointers].
> + 		menu addLine.
> + 		allowStop ifTrue:
> + 			[menu add: 'terminate (t)' translated action: #terminateProcess.
> + 			menu add: 'terminate aggressively (T)' translated action: #terminateProcessAggressively.
> + 			shifted ifTrue:
> + 				[menu
> + 					add: 'destroy' translated action: #destroyProcess;
> + 					balloonTextForLastItem: (Process firstCommentAt: #destroy)].
> + 			process isSuspended
> + 				ifTrue: [menu add: 'resume (r)' translated action: #resumeProcess]
> + 				ifFalse: [menu add: 'suspend (s)' translated action: #suspendProcess]].
> + 		allowDebug ifTrue:
> + 			[menu addList: #(('change priority (p)' changePriority) ('debug (d)' debugProcess))].
> + 		menu add: 'profile messages (m)' action: #messageTally.
> + 		(process suspendingList isKindOf: Semaphore) ifTrue:
> + 			[menu add: 'signal Semaphore (S)' translated action: #signalSemaphore].
> + 		menu addList: #(('full stack (k)' fullStack) ('copy stack to clipboard' copyProcessStackToClipboard)).
> + 		menu addLine] valueWithArguments: (self nameAndRulesFor: process)].
> + 
> + 	menu
> + 		addList: #(#('find context... (f)' findContext) #('find again (g)' nextContext));
> + 		addLine;
> + 		add: (self isAutoUpdating
> + 				ifTrue: ['turn off auto-update (a)' translated]
> + 				ifFalse: ['turn on auto-update (a)' translated])
> + 			action: #toggleAutoUpdate;
> + 		add: 'update list (u)' translated action: #updateProcessList.
> + 
> + 	(Smalltalk at: #CPUWatcher ifAbsent: []) ifNotNil:
> + 		[:pw|
> + 		menu addLine.
> + 		pw isMonitoring
> + 			ifTrue: [menu add: 'stop CPUWatcher' translated action: #stopCPUWatcher]
> + 			ifFalse: [menu add: 'start CPUWatcher' translated action: #startCPUWatcher]].
> + 
> + 	^menu!
> 
> Item was changed:
>   ----- Method: ProcessBrowser>>terminateProcess (in category 'process actions') -----
>   terminateProcess
> + 
> + 	^ self terminateProcess: false!
> - 	| nameAndRules |
> - 	nameAndRules := self nameAndRulesForSelectedProcess.
> - 	nameAndRules second
> - 		ifFalse: [self inform: 'Nope, won''t kill ' , nameAndRules first.
> - 			^ self].
> - 	self class terminateProcess: selectedProcess.	
> - 	self updateProcessList!
> 
> Item was added:
> + ----- Method: ProcessBrowser>>terminateProcess: (in category 'process actions') -----
> + terminateProcess: aggressive
> + 
> + 	| nameAndRules |
> + 	nameAndRules := self nameAndRulesForSelectedProcess.
> + 	nameAndRules second ifFalse: [
> + 		^ self inform: ('Nope, won''t terminate {1}' translated format: {nameAndRules first})].
> + 	self class terminateProcess: selectedProcess aggressively: aggressive.
> + 	self updateProcessList.!
> 
> Item was added:
> + ----- Method: ProcessBrowser>>terminateProcessAggressively (in category 'process actions') -----
> + terminateProcessAggressively
> + 
> + 	^ self terminateProcess: true!
> 
> 


More information about the Squeak-dev mailing list