[Vm-dev] Exploring the simulator (was Re: REPL image for simulation)

Eliot Miranda eliot.miranda at gmail.com
Wed Jun 8 03:47:52 UTC 2016


Hi Ben,

On Fri, Jun 3, 2016 at 6:45 AM, Ben Coman <btc at openinworld.com> wrote:

>
> Is their some method I can call in the Image to cause the simulator to
> break into a debugger?  I want to do this right before the end block
> bracket, so I can trace the termination of a forked block without
> needing to trace over the block's statements.
>

There is a general facility for message selectors (setBreakSelector:),
either when sent in the interpreter, compiled in the JIT or not understood
(setBreakMNUSelector:).
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.

| vm |
vm := CogVMSimulator newWithOptions: #(#ObjectMemory
#Spur32BitCoMemoryManager).
vm desiredNumStackPages: 8.
vm setBreakSelector: #behaviorHashOf:.
vm openOn: (FileDirectory default fullNameFor: 'startreader.image').
vm breakBlock: [:cogit | cogit processor pc = 446009
and: [cogit processor edx = 3871504]].

In the interpreter there's an atEachStep block run on each bytecode.  You
can have separate atEachStep: and breakBlock: blocks.

cheers -ben
>
> On Tue, May 31, 2016 at 1:27 AM, tim Rowledge <tim at rowledge.org> wrote:
> >
> >
> >> On 30-05-2016, at 10:09 AM, Ben Coman <btc at openinworld.com> wrote:
> >>
> >>
> >> On Mon, May 30, 2016 at 11:35 PM, Clément Bera <bera.clement at gmail.com>
> wrote:
> >>>
> >>> I did a post out of this thread:
> >>>
> >>> https://clementbera.wordpress.com/2016/05/30/simulating-the-cog-vm/
> >>
> >> Nice article Clement, thanks.
> >> One thing though, I can't think what the "dis" means in genAndDis: ?
> >
> > 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.
> >
> >
> > tim
> > --
> > tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
> > The less time planning, the more time programming.
> >
> >
>



-- 
_,,,^..^,,,_
best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20160607/e7dbe754/attachment.htm


More information about the Vm-dev mailing list