Game Development Community

A way to view the TS VM opcode stack?

by Demolishun · in Torque 3D Professional · 07/08/2012 (2:45 pm) · 2 replies

I am working on converting the TS VM (Torque Script Virtual Machine) to use a vector list rather than a switch statement. I have it partially working right now, but I am running into an issue and I am not sure how to debug it.

Is there a way to view the stack, opcode trace, or something similar?

Right now I am trying to track the instruction pointer and am getting really confused. I think the problem is a stack not getting updated, a variable not getting updated, or some other issue.

The area where the code is getting stuck at is when the main.cs script in the game directory where the script runs the recursive loadDirs() function. It just keeps running the same script even though it looks like it is recursing the token string properly. It just starts over after the first call to levels/main.cs. Or it is an issue with the instruction pointer not getting updated.

I am hoping someone here at GG understands the VM at this level.

For testing I have the original VM setup to run if I don't #define a value, and the new VM set to run if I define a value. So I can test either setup to try and see what is going on.

Now that I think about this I wonder if the callstack is not getting updated properly...

About the author

I love programming, I love programming things that go click, whirr, boom. For organized T3D Links visit: http://demolishun.com/?page_id=67


#1
07/10/2012 (12:38 am)
I am making some headway on this. Apparently I cannot get away from a certain global variable, and possibly some other global variables. So my hope of removing globals is being dashed. I will attempt to put them back in and see if things improve.

I have also found a way to determine what is happening in the VM stack. I have found I can start a debug location if I know where the IP will be for certain chunks of opcodes. I can use this to provide opcode traces so I can determine what the VM is doing when it all goes to heck.
#2
07/12/2012 (2:02 pm)
I am getting closer to a solution on this. I found that when I run the code on the new opcode parser it will take a different execution path than when I run it on the stock parser. So once I track down why it is doing that then it should move on to the next problem or just start to work.