Game Development Community

Command Line Debug Options

by Chris Childs · in Torque Game Builder · 06/27/2005 (1:05 pm) · 3 replies

I would like to formally request that a command line option be added to the Torque executable to configure a Torque Script debug session.

The command line argument would supply the target machine's IP address, the debug port and the password information that is used in the console dbgSetParameters call and then waits for the debugger to connect before beginning to process the first Torque Script file. (The debugger would be responsible for starting the process again.)

#1
06/28/2005 (1:36 am)
@Chirs - I solved this in our debugger/editor by having it inject 3 lines into the top of the main.cs file when it launches the exe. It's smart and won't insert it twice and will remove the line when the debugger is stopped. It works well on any version of Torque that still has a main.cs in the root folder, but i haven't yet dealt with doing fixups on breakpoint positions when the entire script is shifted down by 3 lines. I'm fairly close to getting this all worked out and released.

Back to your point. I thought about lobbying GG for an official patch to all Torque Platform products to add a command line way to launch the debugger. For me my issue was that it wouldn't work with apps which are based on older Torque projects. Also it's not as flexible as injecting actual code into the file.
#2
06/28/2005 (7:58 am)
@Tom Although it can be done by the method you are suggesting, and accounting for the offset changes would not be a problem, it would simplify things greatly if there was a command line option to initiate a debug session. Since this forum is for suggestions, I figured it does not hurt to ask.

Although this feature would be in the release version of the 2D engine, if accepted and implemented, it would be nice if it was also added to the 3D engine and then made available as a patch for current users. That way, development products that use this new functionality could require the user to get the latest patch for there development environment and either rebuild their engine with the patch or use the default binaries with the patch included.

I'm sure that the people who would be using the products that use this functionality would be willing to get the updated patches from Garage Games that offer this functionality, so backward compatibility would not be an issue.
#3
06/28/2005 (8:46 am)
Now that i think of it some more it isn't such a difficult thing to do in any of the engines. It's just a change to main.cs:

// ****************************************************
		// Debugger.
		// ****************************************************
      case "-debugger":
		 $argUsed[$i]++;
		 if ( ($Game::argc - $i) > 2 )
		 {
			dbgSetParameters( $Game::argv[$i+1], $Game::argv[$i+2] );
			$argUsed[$i+1]++;
         $argUsed[$i+2]++;
			$i+=2;
		 }
		 else
			error("Error: Missing command line argument. Usage: -debugger <port> <password>");

It's a fairly simple change... one that you could even add for the user automaticly if "-debugger" is not found when scanning main.cs. Still the only fault with this is that the debugger doesn't start until that command line argument is processed. This is another reason why i chose to inject code at the top of main.cs... so that main.cs could be debugged as well.