Hi Yoshiki,<br><br><div class="gmail_quote">On Tue, Mar 13, 2012 at 3:27 AM, Yoshiki Ohshima <span dir="ltr"><<a href="mailto:Yoshiki.Ohshima@acm.org">Yoshiki.Ohshima@acm.org</a>></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 < 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's return: call. i.e. the debugged process is in Foo>>test at pc 43:</div>
<div><br></div><div>37 <22> pushConstant: 3</div><div>38 <23> pushConstant: 4</div><div>39 <B2> send: <</div><div>40 <9B> jumpFalse: 45</div><div>41 <89> pushThisContext: </div><div>42 <21> pushConstant: 42</div>
<div>43 <E0> send: return:</div><div>44 <87> pop</div><div>45 <24> pushConstant: 666</div><div>46 <7C> returnTop</div><div><br></div><div>The stack in the debugger is </div><div>Process>>complete:</div>
<div>Process>>completeStep:</div><div>Debugger>>doStep</div><div><br></div><div><br></div><div><br></div><div>and Process>complete: is </div><div><br></div><div><div>complete: aContext </div><div><span class="Apple-tab-span" style="white-space:pre">        </span>"Run self until aContext is popped or an unhandled error is raised. Return self's new top context, unless an unhandled error was raised then return the signaler context (rather than open a debugger)."</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. "disable this process while running its stack in active process below"</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>test, and aContext is the activation of ContextPart>return: (whose receiver is also the receiver of complete:, the activation of Foo>test).</div>
<div><br></div><div>In this case runUntilErrorOrReturnFrom: aContext should return the sender of the activation of Foo>test and the result to be returned (42). But instead it answers the activation of Foo>test and nil. Hence the return in ContextPart>return: isn't simulated and control passes to the next statement, ^666.</div>
<div><br></div><div>Once again I'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>