Hi Yoshiki,<br><br><div class="gmail_quote">On Tue, Mar 13, 2012 at 3:27 AM, Yoshiki Ohshima <span dir="ltr">&lt;<a href="mailto:Yoshiki.Ohshima@acm.org">Yoshiki.Ohshima@acm.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  Hello,<br>
<br>
I noticed that step executing the following code in debugger yields<br>
different results:<br>
<br>
-------------------<br>
test<br>
<br>
        3 &lt; 4 ifTrue: [<br>
                thisContext return: 42].<br>
        ^ 666.<br>
-------------------<br>
<br>
In the normal execution, you get 42 as expected, but if you debug it<br>
and step execute, #return: does not actuall return and you get 666.<br>
<br>
It appears that the primitive for #terminateTo: is the culprit...<br></blockquote><div><br></div><div>From what I can see so far it is the return value from runUntilErrorOrReturnFrom: in complete: when the debugger executes test&#39;s return: call.  i.e. the debugged process is in Foo&gt;&gt;test at pc 43:</div>
<div><br></div><div>37 &lt;22&gt; pushConstant: 3</div><div>38 &lt;23&gt; pushConstant: 4</div><div>39 &lt;B2&gt; send: &lt;</div><div>40 &lt;9B&gt; jumpFalse: 45</div><div>41 &lt;89&gt; pushThisContext: </div><div>42 &lt;21&gt; pushConstant: 42</div>
<div>43 &lt;E0&gt; send: return:</div><div>44 &lt;87&gt; pop</div><div>45 &lt;24&gt; pushConstant: 666</div><div>46 &lt;7C&gt; returnTop</div><div><br></div><div>The stack in the debugger is </div><div>Process&gt;&gt;complete:</div>
<div>Process&gt;&gt;completeStep:</div><div>Debugger&gt;&gt;doStep</div><div><br></div><div><br></div><div><br></div><div>and Process&gt;complete: is </div><div><br></div><div><div>complete: aContext </div><div><span class="Apple-tab-span" style="white-space:pre">        </span>&quot;Run self until aContext is popped or an unhandled error is raised.  Return self&#39;s new top context, unless an unhandled error was raised then return the signaler context (rather than open a debugger).&quot;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>| ctxt pair error |</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>ctxt := suspendedContext.</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>suspendedContext := nil.  &quot;disable this process while running its stack in active process below&quot;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>pair := ctxt runUntilErrorOrReturnFrom: aContext.</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>suspendedContext := pair first.</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>error := pair second.</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>error ifNotNil: [^ error signalerContext].</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>^ suspendedContext</div></div><div><br></div><div>where the receiver is the activation of Foo&gt;test, and aContext is the activation of ContextPart&gt;return: (whose receiver is also the receiver of complete:, the activation of Foo&gt;test).</div>
<div><br></div><div>In this case runUntilErrorOrReturnFrom: aContext should return the sender of the activation of Foo&gt;test and the result to be returned (42).  But instead it answers the activation of Foo&gt;test and nil.  Hence the return in ContextPart&gt;return: isn&#39;t simulated and control passes to the next statement, ^666.</div>
<div><br></div><div>Once again I&#39;m drawn into the bowels of runUntilErrorOrReturnFrom: :) It is my nemesis.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<font color="#888888"><br>
-- Yoshiki<br>
<br>
</font></blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div><br>