<br><br><div class="gmail_quote">On Thu, Dec 2, 2010 at 8:40 AM, Frank Shearar <span dir="ltr">&lt;<a href="mailto:frank.shearar@angband.za.org">frank.shearar@angband.za.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On 2010/12/01 17:33, Eliot Miranda wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
<br>
<br>
On Wed, Dec 1, 2010 at 7:10 AM, Frank Shearar<br></div><div><div></div><div class="h5">
&lt;<a href="mailto:frank.shearar@angband.za.org" target="_blank">frank.shearar@angband.za.org</a> &lt;mailto:<a href="mailto:frank.shearar@angband.za.org" target="_blank">frank.shearar@angband.za.org</a>&gt;&gt; wrote:<br>

<br>
    On 2010/11/21 15:47, Frank Shearar wrote:<br>
<br>
        On 2010/11/13 17:35, Frank Shearar wrote:<br>
<br>
            Hi,<br>
<br>
            I&#39;ve been chasing down a strange bug these past few days:<br>
            <a href="http://bugs.squeak.org/view.php?id=7569" target="_blank">http://bugs.squeak.org/view.php?id=7569</a><br>
<br>
            The executive summary is this: when viewing a method in the<br>
            debugger<br>
            that refers to an instvar deleted after the Debugger<br>
            instantiated, the<br>
            CodePane shows the correct source for a fraction of a<br>
            second, and then<br>
            goes blank.<br>
<br>
            What I&#39;d expected to see was the source of the method<br>
            rendered as per<br>
            usual, and the reference to the missing instvar coloured red, to<br>
            indicate a problem. (Just like what you&#39;d see if you opened<br>
            up a Browser<br>
            on the method.)<br>
<br>
            The CodePane goes blank because the Debugger&#39;s contents<br>
            instvar is<br>
            nilled out.<br>
<br>
            CodeHolder&gt;&gt;setContentsToForceRefresh nils the instvar because<br>
            CodeHolder&gt;&gt;didCodeChangeElsewhere returns true.<br>
<br>
            That method returns true because the Debugger&#39;s<br>
            currentCompiledMethod<br>
            instvar and the compiled method according to &quot;aClass<br>
            compiledMethodAt:<br>
            aSelector&quot; aren&#39;t the same object.<br>
<br>
            And now I&#39;m a bit stuck. I know the behaviour I&#39;d expect, I<br>
            know why the<br>
            bug&#39;s happening, but how do I fix it? Does CodeHolder (or<br>
            Debugger) need<br>
            a better way of knowing whether the viewed method&#39;s changed?<br>
            (For<br>
            instance, comparing the two CompiledMethods&#39; asCommaString shows<br>
            identical contents.)<br>
<br>
<br>
        OK, I got a bit further. The Debugger&#39;s absolutely right in<br>
        saying that<br>
        the code has changed elsewhere. As soon as you delete the<br>
        instvar, the<br>
        entire class is recompiled and, in particular, the method<br>
        referencing<br>
        the deleted instvar changes.<br>
<br>
        In my tests my method #bar looks like this:<br>
<br>
        bar<br>
        self halt.<br>
        baz := 1.<br>
<br>
        with bytecodes<br>
<br>
        17 &lt;70&gt; self<br>
        18 &lt;D0&gt; send: halt<br>
        19 &lt;87&gt; pop<br>
        20 &lt;76&gt; pushConstant: 1<br>
        21 &lt;60&gt; popIntoRcvr: 0<br>
        22 &lt;78&gt; returnSelf<br>
<br>
        After deleting the instvar baz, bar&#39;s bytecodes look like this:<br>
<br>
        21 &lt;70&gt; self<br>
        22 &lt;D0&gt; send: halt<br>
        23 &lt;87&gt; pop<br>
        24 &lt;76&gt; pushConstant: 1<br>
        25 &lt;82 C1&gt; popIntoLit: baz<br>
        27 &lt;78&gt; returnSelf<br>
<br>
        I can&#39;t argue with that. It does mean that the Debugger&#39;s job is<br>
        harder.<br>
        In this particular case, nilling out the Debugger&#39;s contents is the<br>
        wrong thing to do, because it&#39;s surprising. You see the code,<br>
        see the<br>
        reference to the defunct instvar... and then your source is gone!<br>
<br>
        We fall into this hole because for most CodeHolders, when the code&#39;s<br>
        changed, self hasUnacceptedEdits will return true, and you&#39;ll<br>
        get that<br>
        red border around your code. In this case, there aren&#39;t<br>
        unaccepted edits<br>
        because the user hasn&#39;t changed code. Instead, the Debugger has<br>
        what I<br>
        suppose one might call a stale copy of the method (in contextStack).<br>
<br>
        So what should the correct behaviour be? How about a message<br>
        that says<br>
        &quot;Oops, this method has changed underneath your feet. Would you<br>
        like to<br>
        revert back to the context that called it?&quot;<br>
<br>
<br>
    I have something that works but, seeing as this is the Debugger, I&#39;d<br>
    appreciate someone else having a look.<br>
<br>
    It&#39;s in Tools-fbs.283, in the Inbox.<br>
<br>
<br>
Looks good to me, but it might be wise to check that selectedContext is<br>
not nil.  Theres&#39; an assumption that contextStackTop is always valid and<br>
I can imagine that changing.  Something like<br>
<br>
contents<br>
&quot;Depending on the current selection, different information is retrieved.<br>
Answer a string description of that information.  This information is the<br>
method in the currently selected context.&quot;<br>
<br>
^contents ifNil:<br>
[self selectedContext<br>
ifNotNil: [self selectedMessage]<br>
ifNil: [String new]]<br>
<br>
BTW, Personally I don&#39;t like the top context being shown when nothing is<br>
selected in stack list  Is contextStackTop really necessary?<br>
</div></div></blockquote>
<br>
I wondered that myself, as I hacked on this.<br>
<br>
With your change you will still see the top context when nothing&#39;s selected, at least once you have selected something. (But at first, if the debugger pops up and you hit &quot;debug&quot;, then the code pane&#39;s blank.)<br>

<br>
And you&#39;ll see that top context precisely because there&#39;s no concept of &quot;nothing selected&quot; - contextStackIndex = 0 means &quot;show contextStackTop&quot;, and contextStackIndex &gt; 0 means &quot;you&#39;ve selected something in the list of contexts&quot;.<br>
</blockquote><div><br></div><div>Right.  And IMO that&#39;s a bug.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Both your version and mine at least address <a href="http://bugs.squeak.org/view.php?id=7569" target="_blank">http://bugs.squeak.org/view.php?id=7569</a><br><font color="#888888">
<br>
frank<br>
<br>
</font></blockquote></div><br>