Debugging
by Chris Childs · in Torque Game Builder · 06/16/2005 (6:16 am) · 14 replies
Greetings,
I just bought the T2D engine yesterday and ran through the tutorial last night. I ran into problems about half way through (turned out to be the C-Style block comments I was using /* */) and started looking for a way to debug the script. I found the log file, but it appears after the your run the same script several times, it resorts back to the last known good script and nothing useful is captured in the log file (at least nothing that I found). Even after I replaced my client.cs file with the back up version, it still ran the same last state.
I was looking for some way to print debug messages but couldn't find anything. I ended up deleting the client.dso file and everything went back to normal. I replaced the original client.cs with my working copy and ran it again. This time I was able to see the errors captured in the log file and fix the problem (remove the /* */ blocks).
I was planning on adding some debug functions to the engine tonight so I could do output to a separate console window (via TCP/IP sockets). But since I am new to Torque, I thought it would be wise to at least ask first what kind of debug options are there where I can generate output debug strings and both log them and watch them in real time?
Chris Childs
I just bought the T2D engine yesterday and ran through the tutorial last night. I ran into problems about half way through (turned out to be the C-Style block comments I was using /* */) and started looking for a way to debug the script. I found the log file, but it appears after the your run the same script several times, it resorts back to the last known good script and nothing useful is captured in the log file (at least nothing that I found). Even after I replaced my client.cs file with the back up version, it still ran the same last state.
I was looking for some way to print debug messages but couldn't find anything. I ended up deleting the client.dso file and everything went back to normal. I replaced the original client.cs with my working copy and ran it again. This time I was able to see the errors captured in the log file and fix the problem (remove the /* */ blocks).
I was planning on adding some debug functions to the engine tonight so I could do output to a separate console window (via TCP/IP sockets). But since I am new to Torque, I thought it would be wise to at least ask first what kind of debug options are there where I can generate output debug strings and both log them and watch them in real time?
Chris Childs
About the author
#2
06/16/2005 (7:02 am)
That's my usual solution. Maybe not the best, but it does work.
#3
I saw the echo statement. Where does it put the output? (log file, console window, etc.)
I found two debugging editors: TIDE with JEdit, and Brain Edit Pro. Does anyone have any opinions on which one is better? (I know TIDE is free and Brain Edit Pro is not, but I can afford to buy it if it is better.) Or are there any plug-in modules that I can use with Visual Studio (6.0, .NET 2003, 2005 Beta)?
06/16/2005 (7:21 am)
After posting my question, I started doing a search of the forums for the answers. (I know, I should have did the search first. )I saw the echo statement. Where does it put the output? (log file, console window, etc.)
I found two debugging editors: TIDE with JEdit, and Brain Edit Pro. Does anyone have any opinions on which one is better? (I know TIDE is free and Brain Edit Pro is not, but I can afford to buy it if it is better.) Or are there any plug-in modules that I can use with Visual Studio (6.0, .NET 2003, 2005 Beta)?
#4
06/16/2005 (7:33 am)
Echo statements go the console, but the console output is written to the console.log file so you can view the output there as well.
#5
Also, I found a debugger directory under the common that has some code for a Remote scripting debugger support. I assume that this is what Brain Edit Pro and TIDE use to do script debugging. Has anyone else used these to write their own custom debugger? If no one has done a Visual Studio Torque Plug-In, I may take on that task. But I do not want to duplicate any effort. Or if there is a team already working on that project, I can offer my services. (I have been a software engineer for the past decade, doing everything from video device drivers to multi-media client/server applications.)
Or can you do source level debug from the console window? (set break points, step through code, etc.)
06/16/2005 (7:48 am)
How do I bring up the console window to view the output? (I'm sure I will eventually find it, but it is much easier to ask while I am looking.)Also, I found a debugger directory under the common that has some code for a Remote scripting debugger support. I assume that this is what Brain Edit Pro and TIDE use to do script debugging. Has anyone else used these to write their own custom debugger? If no one has done a Visual Studio Torque Plug-In, I may take on that task. But I do not want to duplicate any effort. Or if there is a team already working on that project, I can offer my services. (I have been a software engineer for the past decade, doing everything from video device drivers to multi-media client/server applications.)
Or can you do source level debug from the console window? (set break points, step through code, etc.)
#6
06/16/2005 (7:57 am)
I found the console tilda button '~'. I don't suppose there is a way to create a seperate console window so that it does not block the game window?
#7
Feel free to contact me or Josh via email!
06/16/2005 (8:00 am)
@Chris: if you have the expertise, time, and willingness to complete something like that (a plugin to VS for script debugging), I am just about certain that Josh Williams would like to hear your thoughts. To answer your question, there are no known script debugging apps that are designed to work with VS or any other "commercial" IDE's--and it would be hugely beneficial to the community. Feel free to contact me or Josh via email!
#8
error();
command, just like the echo(); command, except it prints bright red text to the console.
06/16/2005 (8:40 am)
Here is a creative way to handle debug messages (you can create some pretty customized systems for your game. A VS plugin would be great, I know a lot of people have wanted something like that for a while :) Also you can do the error();
command, just like the echo(); command, except it prints bright red text to the console.
#9
06/16/2005 (9:22 am)
@Matthew: Is your Debug GUI window seperate from the T2D window? In other words, can you move it out of the way so you can see everything that is happening in the game window?
#10
06/16/2005 (9:33 am)
Yes :) you can move it and minimize it even. Its fairly easy to create custom GUI's in Torque, this will help you learn how to do so as well (if you follow the tutorial), though I think it requires completing a previous one - not sure though.
#11
Also, is there an API that I can call that will force the script to stop and wait for the debugger, something like "int 3" or "int 1" for windows programming?
If I write a different debugger interface for T2D (other than the telenet debugger interface), is that something I need to talk to Melv May about whether or not it can be included with the release version of the T2D SDK?
06/20/2005 (5:39 am)
After exploring the telenet Debugger code for source level debugging, I have managed to get everything working, although I have a question about how to debug the init code. Since the telenet debugger code requires the client debugger to connect to the T2D window when it is running, how do you debug the start up scripts since that could is required to setup the T2D window in the first place?Also, is there an API that I can call that will force the script to stop and wait for the debugger, something like "int 3" or "int 1" for windows programming?
If I write a different debugger interface for T2D (other than the telenet debugger interface), is that something I need to talk to Melv May about whether or not it can be included with the release version of the T2D SDK?
#14
In TelnetDebugger.cc/cpp at the bottom the function TelnetDebugger::setDebugParameters() add the following code:
This will lock up the game until the debugger client connects. I'm going to be releasing the enhanced TelnetDebugger fairly soon which includes this as well as moving invalid breakpoints to valid lines, startup breakpoints are applied on client connection, break on a running script, fixed a bug in the "step over" function, and more i can't remember right now.
06/20/2005 (11:38 am)
Oops... ok. I assume since this is a private forum it's ok to post some code.In TelnetDebugger.cc/cpp at the bottom the function TelnetDebugger::setDebugParameters() add the following code:
// This forces a wait for a client connection and
// basically locks up the game till it gets one.
while ( mState != Connected )
{
// This would be a nice place to ::Sleep() if
// we had a platform neutral way to do it.
process();
}This will lock up the game until the debugger client connects. I'm going to be releasing the enhanced TelnetDebugger fairly soon which includes this as well as moving invalid breakpoints to valid lines, startup breakpoints are applied on client connection, break on a running script, fixed a bug in the "step over" function, and more i can't remember right now.
Torque Owner Philip Mansfield
Default Studio Name
One alternative is echo statements in your script which you can obviously use to output whatever you need.