[Vm-dev] Simulate "3+4" with InterpreterSimulator

David T. Lewis lewis at mail.msen.com
Tue Mar 23 01:29:41 UTC 2010

On Tue, Mar 23, 2010 at 11:32:43AM +1300, Michael van der Gulik wrote:
> On Tue, Mar 23, 2010 at 7:14 AM, Ang BeePeng <beepeng86 at yahoo.com> wrote:
> >
> > I have a InterpreterSimulator start up, in a workspace I type "3+4". From
> > here, I want to step through bytecode per bytecode, when I hit "print". What
> > should I do to achieve this?
> >
> > Can I debug on the interpreter in the middle of the simulation? Or perhaps I
> > need to put a "self halt" somewhere in the VM source?
> I don't really know much about the InterpreterSimulator (and congrats
> for getting it going! I never got it running...), but...
> I would look for a primitive method somewhere which would cause the
> simulated environment to stop and pop a debugger up in the host. You
> would then evaluate that in the same method as "3+4".

Try putting a self halt in Interpreter>>primitiveAdd, which should be
called when you evaluate "3+4".

The main interpreter loop is Interpreter>>interpret, which fetches
bytecodes and evaluates them. You can probably put a break in
InterpreterSimulator>>dispatchOn:in: which is called by #interpret
and simulates the big case statement that the interpreter loop
uses to dispatch bytecodes for execution.


More information about the Vm-dev mailing list