<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"><<a href="mailto:btc@openinworld.com" target="_blank">btc@openinworld.com</a>></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'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: 'startreader.image').</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'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 <<a href="mailto:tim@rowledge.org" target="_blank">tim@rowledge.org</a>> wrote:<br>
><br>
><br>
>> On 30-05-2016, at 10:09 AM, Ben Coman <<a href="mailto:btc@openinworld.com" target="_blank">btc@openinworld.com</a>> wrote:<br>
>><br>
>><br>
>> On Mon, May 30, 2016 at 11:35 PM, Clément Bera <<a href="mailto:bera.clement@gmail.com" target="_blank">bera.clement@gmail.com</a>> wrote:<br>
>>><br>
>>> I did a post out of this thread:<br>
>>><br>
>>> <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>
>><br>
>> Nice article Clement, thanks.<br>
>> One thing though, I can't think what the "dis" means in genAndDis: ?<br>
><br>
> Ooh, ooh - I can answer that one! "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>
><br>
><br>
> tim<br>
> --<br>
> 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>
> The less time planning, the more time programming.<br>
><br>
><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>