<div dir="ltr">Hi Ben,<div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 3, 2016 at 6:45 AM, Ben Coman <span dir="ltr">&lt;<a href="mailto:btc@openinworld.com" target="_blank">btc@openinworld.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><br>
Is their some method I can call in the Image to cause the simulator to<br>
break into a debugger?  I want to do this right before the end block<br>
bracket, so I can trace the termination of a forked block without<br>
needing to trace over the block&#39;s statements.<br></blockquote><div><br></div><div>There is a general facility for message selectors (setBreakSelector:), either when sent in the interpreter, compiled in the JIT or not understood (setBreakMNUSelector:).</div><div>There is a generalised breakpoint facility using blocks.  In the Cogit you can specify a block that will be run on each machine instruction, e.g. </div><div><br></div><div><div><span class="" style="white-space:pre">        </span>| vm |</div><div><span class="" style="white-space:pre">        </span>vm := CogVMSimulator newWithOptions: #(#ObjectMemory #Spur32BitCoMemoryManager).</div><div><span class="" style="white-space:pre">        </span>vm desiredNumStackPages: 8.</div><div><span class="" style="white-space:pre">        </span>vm setBreakSelector: #behaviorHashOf:.</div><div><span class="" style="white-space:pre">        </span>vm openOn: (FileDirectory default fullNameFor: &#39;startreader.image&#39;).</div><div><span class="" style="white-space:pre">        </span>vm breakBlock: [:cogit | cogit processor pc = 446009</div><div><span class="" style="white-space:pre">                        </span><span style="white-space:pre">        </span><span style="white-space:pre">        </span><span class="" style="white-space:pre">        </span>and: [cogit processor edx = 3871504]].</div></div><div><br></div><div>In the interpreter there&#39;s an atEachStep block run on each bytecode.  You can have separate atEachStep: and breakBlock: blocks.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">cheers -ben<br>
<div><div><br>
On Tue, May 31, 2016 at 1:27 AM, tim Rowledge &lt;<a href="mailto:tim@rowledge.org" target="_blank">tim@rowledge.org</a>&gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt;&gt; On 30-05-2016, at 10:09 AM, Ben Coman &lt;<a href="mailto:btc@openinworld.com" target="_blank">btc@openinworld.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Mon, May 30, 2016 at 11:35 PM, Clément Bera &lt;<a href="mailto:bera.clement@gmail.com" target="_blank">bera.clement@gmail.com</a>&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I did a post out of this thread:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; <a href="https://clementbera.wordpress.com/2016/05/30/simulating-the-cog-vm/" rel="noreferrer" target="_blank">https://clementbera.wordpress.com/2016/05/30/simulating-the-cog-vm/</a><br>
&gt;&gt;<br>
&gt;&gt; Nice article Clement, thanks.<br>
&gt;&gt; One thing though, I can&#39;t think what the &quot;dis&quot; means in genAndDis: ?<br>
&gt;<br>
&gt; Ooh, ooh - I can answer that one! &quot;generate and disassemble” as in generate the code and then disassemble it and display the nicely formatted string result so you can see where it all went horribly wrong.<br>
&gt;<br>
&gt;<br>
&gt; tim<br>
&gt; --<br>
&gt; tim Rowledge; <a href="mailto:tim@rowledge.org" target="_blank">tim@rowledge.org</a>; <a href="http://www.rowledge.org/tim" rel="noreferrer" target="_blank">http://www.rowledge.org/tim</a><br>
&gt; The less time planning, the more time programming.<br>
&gt;<br>
&gt;<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div data-smartmail="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>
</div></div>