Torsion debugging on Mac OS X w/ Parallels
by Alex Rice · in iTorque 2D · 09/18/2008 (8:26 pm) · 14 replies
@Kalle and any other Torsion users:
Here is an walkthrough of how it is working for me. This assumes you
have Parallels with Windows and Torsion and you have a shared network
connection (the default networking for Parallels) and your network
connection is up. You need an IP address or hostname, localhost will
not work.
On your Mac, setup your TGB project and copy both the Torque Game
Builder.exe and Torque Game Builder.app into the TGB project folder. I
rename mine to MyGame.app and MyGame.exe
Quit out of Parallels and edit your VM configuration:
Shared Folders | User Defined Folders | Add folder containing your game project
Map Folders to drive letters = Yes
Launch Windows and now you should have a new drive letter X: , Y:, or
Z: etc. with your TGB game in it.
Copy the MyGame.exe to your Windows Desktop or somewhere on your C:
drive. (will be explained below)
Go back to your Mac OS X and find out your IP address with ifconfig -a
or with the Network System Prefs. You want the IP of your Mac, not of
the Parallels VM.
Launch Torsion and create a new Project with settings like this:
Project tab:
General:
Base Directory X:\ (or whatever your drive letter is)
Entry Script: main.cs
Script Scanner Extensions: cs; gui; t2d
Mods: blank
Debugging:
Address: enter your Mac's IP address or hostname here - not localhost
Password & Port: leave alone, unless you want to change them
Reload Modified Scripts: uncheck; I don't think this feature can work
Hook Code: leave as is but it won't be used
Elixir:
?
Configurations tab:
Add a new conf named TGB (or whatever) with settings like this:
General:
Executable: browse to your Desktop or C:\...\MyGame.exe.
Arguments: blank
Debugging:
Enable precompile: yes
Enable setModPaths: yes
One click Debugging: NO!
Build Exports: yes
OK now save the Torsion project to X:.
Notice we turned off one click debugging, so Torsion won't try to
inject the debug parameters on the fly. So open your toplevel main.cs
and add this line and save the file:
dbgSetParameters(6060, "password", false);
The Torsion project will use the TGB exe on your C: drive just to get
the engine exports it uses for script autocompletion. I found that if
tries to use the TGB.exe on your X: drive, Windows XP will complain
every time the exe is launched. This is why we copied the .exe to your
Desktop or C: drive above. Maybe there is a workaround for that, but
just remember the same version of the engine .exe needs to be copied
over to your C: drive. Then Windows won't complain when Torsion
launches the exe from the C: drive.
continued...
Here is an walkthrough of how it is working for me. This assumes you
have Parallels with Windows and Torsion and you have a shared network
connection (the default networking for Parallels) and your network
connection is up. You need an IP address or hostname, localhost will
not work.
On your Mac, setup your TGB project and copy both the Torque Game
Builder.exe and Torque Game Builder.app into the TGB project folder. I
rename mine to MyGame.app and MyGame.exe
Quit out of Parallels and edit your VM configuration:
Shared Folders | User Defined Folders | Add folder containing your game project
Map Folders to drive letters = Yes
Launch Windows and now you should have a new drive letter X: , Y:, or
Z: etc. with your TGB game in it.
Copy the MyGame.exe to your Windows Desktop or somewhere on your C:
drive. (will be explained below)
Go back to your Mac OS X and find out your IP address with ifconfig -a
or with the Network System Prefs. You want the IP of your Mac, not of
the Parallels VM.
Launch Torsion and create a new Project with settings like this:
Project tab:
General:
Base Directory X:\ (or whatever your drive letter is)
Entry Script: main.cs
Script Scanner Extensions: cs; gui; t2d
Mods: blank
Debugging:
Address: enter your Mac's IP address or hostname here - not localhost
Password & Port: leave alone, unless you want to change them
Reload Modified Scripts: uncheck; I don't think this feature can work
Hook Code: leave as is but it won't be used
Elixir:
?
Configurations tab:
Add a new conf named TGB (or whatever) with settings like this:
General:
Executable: browse to your Desktop or C:\...\MyGame.exe.
Arguments: blank
Debugging:
Enable precompile: yes
Enable setModPaths: yes
One click Debugging: NO!
Build Exports: yes
OK now save the Torsion project to X:.
Notice we turned off one click debugging, so Torsion won't try to
inject the debug parameters on the fly. So open your toplevel main.cs
and add this line and save the file:
dbgSetParameters(6060, "password", false);
The Torsion project will use the TGB exe on your C: drive just to get
the engine exports it uses for script autocompletion. I found that if
tries to use the TGB.exe on your X: drive, Windows XP will complain
every time the exe is launched. This is why we copied the .exe to your
Desktop or C: drive above. Maybe there is a workaround for that, but
just remember the same version of the engine .exe needs to be copied
over to your C: drive. Then Windows won't complain when Torsion
launches the exe from the C: drive.
continued...
About the author
#2
09/19/2008 (7:56 pm)
Thanks Alex! That's a major writeup, and a majorly cool trick. I appreciate the tip.
#3
Its nice to be able to use torsion while using the simulator, and on the device!
Thanks you just increasing my productivity, expect to see your name in the credits for my game :)
(NOTE: When I first posted this comment I didn't know you could debug with torsion, form the device. Its freaken sweet!)
11/29/2008 (6:33 pm)
After two weeks of not having torsion I broke down and bought Parallels and just got it installed and working. THANK YOU FOR POSTING THIS! Its nice to be able to use torsion while using the simulator, and on the device!
Thanks you just increasing my productivity, expect to see your name in the credits for my game :)
(NOTE: When I first posted this comment I didn't know you could debug with torsion, form the device. Its freaken sweet!)
#4
Also, in addition to being able to debug using Torsion on the device you can also use the command line at the bottom of Torsion to issue script commands, dump, etc.
12/02/2008 (5:42 pm)
We use VMWare to pre-compile DSO's from Torsion on our Mac.Also, in addition to being able to debug using Torsion on the device you can also use the command line at the bottom of Torsion to issue script commands, dump, etc.
#5
12/03/2008 (7:09 pm)
Any chance this would work using codeweaver?
#6
I got Torsion and parallels and everything works after following your directions.
I can now connect and debug when running on the mac.
The one thing I haven't figured out is how to do it on the device.
When I use xCode to build and go then trying to connect via Torsion it doesn't seem to connect.
Am I missing something in the Torsion configuration?
12/11/2008 (1:13 pm)
Thanks Alex, this is really cool.I got Torsion and parallels and everything works after following your directions.
I can now connect and debug when running on the mac.
The one thing I haven't figured out is how to do it on the device.
When I use xCode to build and go then trying to connect via Torsion it doesn't seem to connect.
Am I missing something in the Torsion configuration?
#7
dbgSetParameters(6060, "password", false);
Torsion does it automatically if you run the project on the same machine
12/11/2008 (2:58 pm)
Make sure this script line is executed before trying to connect with Torsion:dbgSetParameters(6060, "password", false);
Torsion does it automatically if you run the project on the same machine
#8
enableOutputDebug(true );
dbgSetParameters(6060, "password", false);
I hope it gets executed on the iPhone. it definitely works when I run the game on the Mac, and connect to it from torsion on the same machine using parallels.
12/11/2008 (4:06 pm)
I do have it in the top dir main.cs , preety much the first two lines in the code are:enableOutputDebug(true );
dbgSetParameters(6060, "password", false);
I hope it gets executed on the iPhone. it definitely works when I run the game on the Mac, and connect to it from torsion on the same machine using parallels.
#9
12/12/2008 (12:36 pm)
Are you connecting to the IP of the iPhone itself? In Torsion, when you connect to an instance on the same machine, it works because it defaults to using the loopback IP. It may seem like an obvious question, but whn I first tried to debug on the device, it's IP was assigned dynamically by the router, which it kept disconnecting/reconnecting from, so check your device's IP right before you debug to make sure it hasn't changed
#10
How do you get the device ip? the IP that I'm currently using is from the network prefs of my airport.
12/12/2008 (1:10 pm)
I don't think I connect to the iPhone IP because I don't even know how to get the IP from the device.How do you get the device ip? the IP that I'm currently using is from the network prefs of my airport.
#11
Works now. Thanks Mat
12/12/2008 (1:18 pm)
I got it. you actually go the iPhone network setting and get it from there. Works now. Thanks Mat
#12
12/12/2008 (1:27 pm)
No problem. I think remote debugging is one of Torque coolest features, definately worth the time.
#13
12/12/2008 (2:35 pm)
Absolutely. I love it.
#14
12/12/2008 (3:10 pm)
One potential tripup for those who might try this; make sure that $pref::iPhone::usesNetwork is set to true, that can easily be overlooked
Torque Owner Alex Rice
Default Studio Name
Mac filesystem. The scripts will get compiled when you run TGB on the
Mac, or when you choose any of the precompile commands in Torsion. The
precompile is nice because you can double-click right to the point in
a script where an error is! Because of the cross-platform-ity of
.dso's it doesn't matter if the scripts are compiled by the Mac or Win
engine as long as the engine versions are the same.
So go to town with Torsion, including auto-completion, cleaning .dsos,
and all the Torsion features *except* one-click debugging.
When it's time to debug, make sure TGB is running on the Mac and hit
Play Scene to launch your game. In Torsion set breakpoint(s), then
select Debug menu | Connect, make sure your IP address of your Mac is
still correct, and Connect. Then in your TGB game, play until you hit
a breakpoint, and when the game freezes, go back to your Torsion
window and you should be in the debugger! You can go back and forth as
you debug.
You can't debug the scripts at the launch of the game, you have to
connect to the game after it's running. Note the function signature:
function dbgSetParameters( int port, string password, bool waitForClient )
Don't forget to set the waitForClient parameter false.
You may set waitForClient to true, then you can debug your startup
scripts, however every time you launch your game, it is going to wait
for a debugger to connect before proceeding. That's why I run with
waitForClient set to false.
Good luck!
Alex