Game Development Community

dev|Pro Game Development Curriculum

TorqueScript Edit and Continue

by Tom Spilman · 10/17/2007 (12:17 pm) · 4 comments

Download Code File

This is a code modification for the TelenetDebugger to enable 'Edit and Continue' functionality in the Torsion TorqueScript IDE.


WARNING: This code is not finished and does contain bugs. We're posting it in hopes of improving it for inclusion into an official Torque release in the future.


What is Edit and Continue?

Edit and Continue was first popularized in Microsoft Visual Studio. It allows you to make changes to your code when stopped at a breakpoint and applies these changes when execution continues. This shortens the development cycle by eliminating the wasted time restarting your application when finding logic bugs in your code.

While Edit and Continue in Visual C++ is at times temperamental we believe TorqueScript is perfectly suited to rival the functionality of Edit and Continue in C#!


Whats in this patch?

First off.... always keep backups of your files or use version control software like Subversion.

The attached zip includes updated files for TGB 1.5.1 as it is a script heavy development environment which will most likely see the most benefit from this patch.

If your using another version of TGB or want to merge this with TGEA or TGE you'll have to hand merge your changes with a tool like Beyond Compare. It should be a simple merge and fully compatible with other Torque C++ engines.


How do i use it?

First download the zip attached to this resource. Copy the files in the zip to your engine\source\console folder and rebuild your game executable.

As of this writing the only TorqueScript debugger that supports this patch is Torsion. It is recommended that before you try the feature that you update to the latest Torsion beta which can be found in the Torsion forums.

There are two major features this patch enables in Torsion. The simplest, and at the time of this writing most reliable, is Set Next Statement.


farm3.static.flickr.com/2237/1595071355_996d2fb17b_o.png


This feature allows you to move the current instruction pointer to another line. Just get to a breakpoint and right click on any line to access the menu and move the instruction pointer. You can now step or continue execution from the new position.

The main feature is allowing you to change code while at a breakpoint. This feature is not as reliable as we would like, but it works in many cases. It does not simply re-exec() the script. It performs the proper steps to unlink and remove old functions and link in the new ones without executing any code. It then tries to reset the code pointer to the correct new location. Its a tricky process.

To try this just get to a breakpoint in your running game. Edit the script slightly... like add an echo statement. Now F10 to step to the next statement. You'll get the following message:


farm3.static.flickr.com/2352/1595960394_09d126ebc4_o.png


When you hit Yes Torsion saves the script file and sends a command to your patched game EXE to reload the changes. If all goes well you can now step to your new echo statement.

You should now clearly see how powerful this feature is and how it can easily cut your script debugging time in half.


What doesn't work?

As of the first posting of this resource you can sometimes crash the game EXE after a few live changes to the script. This is primarily what we're aiming to fix.

Also this code isn't magic. There are times when you have to stop, make your change, and restart the debugger. For example when adding a server side datablock that needs to be transmitted to the client (assuming your using this patch with TGE or TGEA).


How can i help?

I'm very glad you asked!

Honestly we don't have a lot of time at the moment to devote towards fixing the remaining bugs in this patch. The best way to help is by identifying bugs and posting code fixes.

Additionally providing zips with pre-patched files for TGE and TGEA would be very helpful!


Whats next?

If the community can help us stabilize this code then we'll ensure that it gets included into a future Torque update. While we'll do what we can, we're leaving some of it in your hands... "World domination through collaboration!".

Thanks and Happy Torque'ing!

Team Sickhead

www.sickheadgames.com/images/shbug_03.png

About the author

Tom is a programmer and co-owner of Sickhead Games, LLC.


#1
10/17/2007 (7:14 am)
Edit and Continue works for TGE 1.5.

The changes in compiledEval.cc are a bit difficult to find with the changes between TGB 1.5.1 and TGE 1.5, but everything else is a very simple merge
#2
10/17/2007 (9:52 am)
@James - Yea lots of little changes in compiledEval.cc... in particular in the main exec function. I tried to keep it as simple as possible, but changes to swap CodeBlocks and fixes to reload scripts within executing them made it complex. I'm open for any suggestions to simplify it.
#3
10/17/2007 (11:49 am)
It wasn't too bad, it was mostly just finding the differences between the TGE and TGB code bases. TGB 1.1.X and TGE 1.5.X were a lot more similar than TGB 1.5.X and TGE 1.5.X, like components and usage of the FrameAllocator
#4
10/17/2007 (12:31 pm)
sweet!