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. :-)<br>
<br>
Best,<br>
Christoph<br>
<br>
<b>=============== Summary ===============</b><br>
<br>
Change Set:        recursive-profaide<br>
Date:            4 November 2022<br>
Author:            Christoph Thiede<br>
<br>
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.<br>
<br>
This is kind of a delayed follow-up on Kernel-mt.1381. Thanks to Marcel for discussing this issue!<br>
<br>
<b>=============== Diff ===============</b><br>
<br>
<b>DebuggerTests>>test25ProcessFaithfulDebugging {tests} · ct 11/4/2022 15:46</b><br>
<font color="#FF0000">+ test25ProcessFaithfulDebugging<br>
+     "Debugging a process which sends Processor activeProcess should have the same effect as running the process directly. End-to-end equivalent for ProcessTest>>#testProcessFaithfulSimulation."<br>
+ <br>
+     | userProcess |<br>
+     process := Process forBlock: [<br>
+         Processor activeProcess environmentAt: #plonk put: 42.<br>
+         Processor activeProcess suspend.<br>
+         Processor activeProcess environmentAt: #plonk].<br>
+     process resume.<br>
+     Processor yield.<br>
+     self assert: (process environmentAt: #plonk) = 42.<br>
+     <br>
+     debugger := process debug.<br>
+     <br>
+     [userProcess := [debugger stepOver "suspend"; stepOver "activeProcess"; stepOver "environmentAt:"] fork.<br>
+     Processor yield.<br>
+     <br>
+     self deny: [process isTerminated].<br>
+     self assert: [userProcess isTerminated].<br>
+     self assert: [process suspendedContext willReturn and: [process suspendedContext top = 42]].<br>
+     self assert: (userProcess environmentAt: #plonk ifAbsent: []) = nil]<br>
+         <br>
+         ensure: [<br>
+             process terminateAggressively.<br>
+             debugger close.<br>
+             process := userProcess.<br>
+             self findDebugger "for correct tearDown"].</font><br>
<br>
<b>DebuggerTests>>test26RecursiveProcessFaithfulDebugging {tests} · ct 11/4/2022 15:46</b><br>
<font color="#FF0000">+ test26RecursiveProcessFaithfulDebugging<br>
+     "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."<br>
+ <br>
+     | userProcess metaDebugger metaProcess |<br>
+     process := Process forBlock: [<br>
+         Processor activeProcess environmentAt: #plonk put: 42.<br>
+         Processor activeProcess suspend.<br>
+         Processor activeProcess environmentAt: #plonk].<br>
+     process resume.<br>
+     Processor yield.<br>
+     self assert: (process environmentAt: #plonk) = 42.<br>
+     <br>
+     debugger := process debug.<br>
+     metaProcess := Process forBlock: [<br>
+         [debugger stepOver "suspend"; stepOver "activeProcess"; stepOver "environmentAt:"] value].<br>
+     metaDebugger := metaProcess debug.<br>
+     <br>
+     [userProcess := [metaDebugger stepOver "value"] fork.<br>
+     Processor yield.<br>
+     <br>
+     self deny: [process isTerminated].<br>
+     self assert: [userProcess isTerminated].<br>
+     self assert: [process suspendedContext willReturn and: [process suspendedContext top = 42]].<br>
+     self assert: (userProcess environmentAt: #plonk ifAbsent: []) = nil]<br>
+         <br>
+         ensure: [<br>
+             process terminateAggressively.<br>
+             debugger close.<br>
+             metaProcess terminateAggressively.<br>
+             metaDebugger close.<br>
+             process := userProcess.<br>
+             self findDebugger "for correct tearDown"].</font><br>
<br>
<b>Process>>effectiveProcess {accessing} · ct 11/4/2022 15:38 (changed)</b><br>
effectiveProcess<br>
<s><font color="#0000FF">-     "effectiveProcess is a mechanism to allow process-faithful debugging.  The debugger executes code<br>
-      on behalf of processes, so unless some effort is made the identity of Processor activeProcess is not<br>
-      correctly maintained when debugging code.  The debugger uses evaluate:onBehalfOf: to assign the<br>
-      debugged process as the effectiveProcess of the process executing the code, preserving process<br>
-      identity."<br>
-     ^effectiveProcess ifNil: [self]<br>
</font></s><font color="#FF0000">+     "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."<br>
+     ^effectiveProcess<br>
+          ifNil: [self]<br>
+         ifNotNil: [:p |<br>
+             "Recursive process-faithful debugging. See DebuggerTests>>#test25RecursiveProcessFaithfulDebugging for a practical example."<br>
+             p effectiveProcess]</font><br>
<br>
<b>ProcessTest>>testProcessFaithfulSimulationMeta {tests} · ct 12/7/2020 17:22</b><br>
<font color="#FF0000">+ testProcessFaithfulSimulationMeta<br>
+     "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:."<br>
+ <br>
+     | process result metaProcess |<br>
+     process := Process forBlock: [<br>
+         result := Processor activeProcess environmentAt: #foo].<br>
+     process environmentAt: #foo put: 42.<br>
+     <br>
+     metaProcess := Process forBlock: [<br>
+         process runUntil: [:context | context isDead]].<br>
+     metaProcess runUntil: [:context | context isDead].<br>
+     <br>
+     self assert: 42 equals: result.</font><br>
<br>
<font color="#808080">---<br>
</font><font color="#808080"><i>Sent from </i></font><font color="#808080"><i><a href="https://github.com/hpi-swa-lab/squeak-inbox-talk"><u><font color="#808080">Squeak Inbox Talk</font></u></a></i></font><br>
["recursive-profaide.2.cs"]