Game Development Community

Debugging ASAP

by Eduardo Baiao · in Torque Game Engine · 06/07/2005 (1:39 pm) · 8 replies

Hi,

I new on Torque, and I think that a good way of to know how it works is to debug the Torque Script since the first line of code. But at the moment I could not make it happen.

I'm using TIDE and I found that the debugger starts after the call for "doEnableDebug", just after the loading of "mods".

// Process command line arguments
 // TorqueDebugPatcher begin
$GameDebugEnable = false;
$GameDebugPort = 28040;
$GameDebugPassword = "password";

function doEnableDebug()
{
   // attempt to auto enable debugging
   if (!$GameDebugEnable)
   {
     echo("NOT enabling debug...");
     return;
   }

   echo("DEBUG: enabling debug on port: " @ $GameDebugPort);
   %cmd = "dbgSetParameters(" @ $GameDebugPort @ "," @ $GameDebugPassword @ ");";
   echo("DEBUG: evaluating: " @ %cmd);
   eval(%cmd);
}
// TorqueDebugPatcher end

The call for the function runs here:

// Either display the help message or startup the app.
if ($displayHelp) {
   enableWinConsole(true);
   displayHelp();
   quit();
}
else {
   onStart();
   echo("Engine initialized...");
   // TorqueDebugPatcher begin
   doEnableDebug();
   // TorqueDebugPatcher end
}


The problem is that I want to debug the loading process, and simply move the call of "doEnableDebug" to lines before the loading "mods" does not work.

Any tips on how to do that?

Thanks

#1
06/07/2005 (3:58 pm)
Try sticking trace(1) at the start of main.cs?
#2
06/07/2005 (7:14 pm)
Trace is good, but when I said that I wanted to debug, I mean "run step by step".
I set a breakpoint just after the call for "doEnabledDebug()", but the execution don't stop at this point.

Seems that the debugger needs some seconds to begin to work, or depends on other initializations before getting active.
Is it right?
#3
06/07/2005 (8:28 pm)
@Eduardo - I ran into a similar problem working on my editor/debugger. I modified dbgSetParameters() to wait until the debugger connects before returning. This allows you to set a breakpoint right after the dbgSetParameters call and have it work.
#4
06/07/2005 (8:35 pm)
Cool!
As I'm a newbie here, could you show me the code that do the "wait"?
Thanks.
#5
06/07/2005 (8:43 pm)
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. This and the rest of my changes to the TelnetDebugger should be released soon.
#6
06/08/2005 (7:52 pm)
Thanks Tom!

Now, back to study!
#7
06/09/2005 (9:23 am)
Quote:
// This would be a nice place to ::Sleep() if
// we had a platform neutral way to do it.

May I recommend boost::thread?

www.boost.org/doc/html/threads.html

It may have some STL in it, but I just see that as encouragement for you to come up with a way to include the STL in your main codebase. ;)
#8
06/09/2005 (10:19 am)
Well i ment a Torque method to do it. It's hard enough getting STL working in Torque lets not start talking boost just yet. =)