[squeak-dev] Review Request: recursive-profaide.2.cs

christoph.thiede at student.hpi.uni-potsdam.de christoph.thiede at student.hpi.uni-potsdam.de
Fri Nov 4 15:08:02 UTC 2022


I will leave this for one more week in the inbox and then merge it into the Trunk if you don't see any other problems. :-)

Best,
Christoph

=============== Summary ===============

Change Set:        recursive-profaide
Date:            4 November 2022
Author:            Christoph Thiede

Adds support for recursive process-faithful debugging and tests. Without this patch, debugging the debugger for a process which sends Processor activeProcess will have a different effect than running the original debugger directly.

This is kind of a delayed follow-up on Kernel-mt.1381. Thanks to Marcel for discussing this issue!

=============== Diff ===============

DebuggerTests>>test25ProcessFaithfulDebugging {tests} · ct 11/4/2022 15:46
+ test25ProcessFaithfulDebugging
+     "Debugging a process which sends Processor activeProcess should have the same effect as running the process directly. End-to-end equivalent for ProcessTest>>#testProcessFaithfulSimulation."
+ 
+     | userProcess |
+     process := Process forBlock: [
+         Processor activeProcess environmentAt: #plonk put: 42.
+         Processor activeProcess suspend.
+         Processor activeProcess environmentAt: #plonk].
+     process resume.
+     Processor yield.
+     self assert: (process environmentAt: #plonk) = 42.
+     
+     debugger := process debug.
+     
+     [userProcess := [debugger stepOver "suspend"; stepOver "activeProcess"; stepOver "environmentAt:"] fork.
+     Processor yield.
+     
+     self deny: [process isTerminated].
+     self assert: [userProcess isTerminated].
+     self assert: [process suspendedContext willReturn and: [process suspendedContext top = 42]].
+     self assert: (userProcess environmentAt: #plonk ifAbsent: []) = nil]
+         
+         ensure: [
+             process terminateAggressively.
+             debugger close.
+             process := userProcess.
+             self findDebugger "for correct tearDown"].

DebuggerTests>>test26RecursiveProcessFaithfulDebugging {tests} · ct 11/4/2022 15:46
+ test26RecursiveProcessFaithfulDebugging
+     "Debugging the debugger for a process which sends Processor activeProcess should have the same effect as running the original debugger directly. End-to-end equivalent for ProcessTest>>#testProcessFaithfulSimulationMeta."
+ 
+     | userProcess metaDebugger metaProcess |
+     process := Process forBlock: [
+         Processor activeProcess environmentAt: #plonk put: 42.
+         Processor activeProcess suspend.
+         Processor activeProcess environmentAt: #plonk].
+     process resume.
+     Processor yield.
+     self assert: (process environmentAt: #plonk) = 42.
+     
+     debugger := process debug.
+     metaProcess := Process forBlock: [
+         [debugger stepOver "suspend"; stepOver "activeProcess"; stepOver "environmentAt:"] value].
+     metaDebugger := metaProcess debug.
+     
+     [userProcess := [metaDebugger stepOver "value"] fork.
+     Processor yield.
+     
+     self deny: [process isTerminated].
+     self assert: [userProcess isTerminated].
+     self assert: [process suspendedContext willReturn and: [process suspendedContext top = 42]].
+     self assert: (userProcess environmentAt: #plonk ifAbsent: []) = nil]
+         
+         ensure: [
+             process terminateAggressively.
+             debugger close.
+             metaProcess terminateAggressively.
+             metaDebugger close.
+             process := userProcess.
+             self findDebugger "for correct tearDown"].

Process>>effectiveProcess {accessing} · ct 11/4/2022 15:38 (changed)
effectiveProcess
-     "effectiveProcess is a mechanism to allow process-faithful debugging.  The debugger executes code
-      on behalf of processes, so unless some effort is made the identity of Processor activeProcess is not
-      correctly maintained when debugging code.  The debugger uses evaluate:onBehalfOf: to assign the
-      debugged process as the effectiveProcess of the process executing the code, preserving process
-      identity."
-     ^effectiveProcess ifNil: [self]
+     "effectiveProcess is a mechanism to allow process-faithful debugging.  The debugger executes code on behalf of processes, so unless some effort is made the identity of Processor activeProcess is not correctly maintained when debugging code.  The debugger uses evaluate:onBehalfOf: to assign the debugged process as the effectiveProcess of the process executing the code, preserving process identity."
+     ^effectiveProcess
+          ifNil: [self]
+         ifNotNil: [:p |
+             "Recursive process-faithful debugging. See DebuggerTests>>#test25RecursiveProcessFaithfulDebugging for a practical example."
+             p effectiveProcess]

ProcessTest>>testProcessFaithfulSimulationMeta {tests} · ct 12/7/2020 17:22
+ testProcessFaithfulSimulationMeta
+     "While stacking multiple simulation processes into each other, process variables should be looked up in the process being simulated. Acceptance test for process-faithful debugging, see #evaluate:onBehalfOf:."
+ 
+     | process result metaProcess |
+     process := Process forBlock: [
+         result := Processor activeProcess environmentAt: #foo].
+     process environmentAt: #foo put: 42.
+     
+     metaProcess := Process forBlock: [
+         process runUntil: [:context | context isDead]].
+     metaProcess runUntil: [:context | context isDead].
+     
+     self assert: 42 equals: result.

---
Sent from Squeak Inbox Talk
["recursive-profaide.2.cs"]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20221104/3666ca8c/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: recursive-profaide.2.cs
Type: application/octet-stream
Size: 4319 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20221104/3666ca8c/attachment.obj>


More information about the Squeak-dev mailing list