Interpreter debugging in VM when changing vm primitives

Context

As a university project, we want to modify pharo vm to use the object table and see what happens.

We use pharo-vm clone from github and VMMaker. Building a VM works fine.

First, we added a primitive that returns an incremented integer:

InterpreterPrimitives>>primitiveIntegerIncrement "increments an integer" self pushInteger: self popInteger + 1 . 

and modified by StackInterpreter class>>initializePrimitiveTable accordingly

 MaxPrimitiveIndex := 576. "... and so on ..." (575 primitiveFail) (576 primitiveIntegerIncrement)) 

And it works.

Problem

When we make changes to the virtual machine, we want to test it already in SmalltalkImage, so we do not need to compile and see that it does not work.

Something like:

 StackInterpreter test: '1 inc' 

And then I can debug if the primitive is erroneous or an error occurs. Of course, much more needs to be done, but how can I achieve this?

What we tried

  • category VMMaker-InterpreterSimulation class StackInterpreterSimulator . Attempt code in comments

     DoIt ^ (StackInterpreterSimulator new openOn: Smalltalk imageName) test 

    errors:

      displayForm := 'Display has not yet been installed' asDisplayText form. 

    ByteString does not understand asDisplayText

  •  (CogVMSimulator new openOn: Smalltalk imageName) test (InterpreterSimulator new openOn: Smalltalk imageName) test 

    Mistake:

      PrimitiveFailed: primitive #basicNew: in Array class failed 

I also found this screen, but it only debugs the virtual machine from the outside using gbd: http://vimeo.com/22485382#

Our project is available here: http://smalltalkhub.com/#!/~kirstin/PharoObjectTable

Current status

We started implementing the object table. Attribute searches can go through an object table. Full support for object tables and the lack of direct pointers are very complex, since pointers are expected everywhere. Therefore, we use pointers in the object table to determine when a search should go through OT. We also found all the primitives for creating objects and added new objects to the table.

+7
smalltalk squeak vm-implementation pharo
source share
2 answers

How long is your project and how many people are you? For me, what you are trying to do is a certain job. Do you have a good knowledge of low-level behavior?

To answer your question, the main problem here is that the cog simulator is not supported in the pharo vm plug. This is because no one in the team of farons uses a simulator. We use only external debugging from gdb. In fact, pharo people work mainly on VM plugins, the VM core is mainly supported and developed by Eliot Miranda, who works on Squeak. Therefore, we inform him when there is an error in the VM core.

For your project, you will have to break it down into at least 2 steps:

step 1: get the object table to work with the VM stack

step 2: do the jit work with your object table

Please note that for step 2, I would recommend not changing the way of accessing its title, so it has a table of objects similar to VW, where you have a fixed size header on what is in the table of objects, and the fields are objects (and, possibly, header extensions) on the heap.

So, use StackVMSimulator and first create StackVM. When everything works (including context), you might consider hacking JIT. Guillermo Polito recently ported the Stack virtual machine to the build process (see PharoSVMBuilder instead of PharoVMBuilder), the guy reported problems with this builder, but you could hack it a bit to make it work.

Now, to make the simulator run on Pharo 2.0 (this is the version of the Pharo generator image you have), you need to open the monticello browser and merge the Cog package (repo MCHttpRepository: http: // source. Squeak. Org / VMMaker ') from the Eliot branch, but not the last Cog, one that is about the same day as the current VMMaker pharo-vm package, because the latest Cog and VMMaker from the Eliot branch are unstable.

An alternative is to get started with creating an Eliot image and merging things from the pharo branch. Here is information on how to create a squeak development image ( http://www.mirandabanda.org/cogblog/build-image/ ).

Then Eliot gave me this script once:

 | cos | cos := CogVMSimulator newWithOptions: #(Cogit SistaStackToRegisterMappingCogit). cos desiredNumStackPages: 8. cos openOn: 'my/favourite.image'. cos openAsMorph; toggleTranscript; halt; run 

You do not need the SistaStackToRegisterMappingCogit parameter. I think some similar script with StackVMSimulator should work.

Finally, there are some documents about the simulator, but this is only for CogSimulator (in these documents you already know how StackSimulator works, and just give you tips on how to use it with JIT): http://www.mirandabanda.org/ cogblog / 2008/12/12 / simulate-out-of-the-bochs / and in one of the videos called "Cog VM (part x)", x is 1 to 6, Eliot shows how he uses the simulator to unmount x86, prints the stack and checks the heap.

One more question, ask your questions on the pharo mailing list (pharo or pharo dev users), because no one here can notice your question (fortunately, someone pointed me your question this time).

And tell me on the pharo mailing list, if you managed to run the simulator in Pharo 2.0, some people (like me) are very interested in it. I planned to do this at some point.

Good luck Good project anyway.

+4
source share

The last time I tried to use the simulator about a year ago, I did not work. However, there are a few patches that I believe have never been integrated, which could help:

Problem 107 includes a fix for your asDisplayText problem.

+1
source share

All Articles