Game Development Community

How to use debug mode with torque script ?

by Philippe C · in Torque Game Engine · 05/30/2006 (10:46 am) · 11 replies

I use ubuntu dapper and torque works well.

I would like to use a debugger because i get the message "segmentation fault" after update done in the scripts

Could you tell me if a tutorial exists in order to identify where is the error in the scripts or to go step by step in the scripts and identify where the issue occurs.

I try sereral tuto (jedit, debugger.cs) but the only result that I get is to freeze my ubuntu desktop when the segmentation fault occurs => I am obliged to reboot my PC.

I
thanks


below the setting done in main.cs :

//-----------------------------------------------------------------------------
// Torque Game Engine 
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------

//$defaultGame = "show";
$defaultGame = "game";
$userMods = "creator;" @ $defaultGame;


// Open a separate console
enableWinConsole(true);

// Logging behavior; <Mode: 0,1,2>
// 0 disables console logging.
// 1 appends to existing logfile; it also closes the file
// (flushing the write buffer) after every write.
// 2 overwrites any existing logfile; it also only closes
setLogMode(2);

// Saving event game play log into journal
//saveJournal("record.log");

// Play back a journal , true = Play back a journal and issue an int3 at the end
//playJournal("record.log",false);

//------------------------------------------------------------------------------
// 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

//-----------------------------------------------------------------------------
// Support functions used to manage the mod string

function pushFront(%list, %token, %delim)
{
	if (%list !$= "")
	return %token @ %delim @ %list;
	return %token;
	}

function pushBack(%list, %token, %delim)
{
	if (%list !$= "")
	return %list @ %delim @ %token;
	return %token;
	}

function popFront(%list, %delim)
{
	return nextToken(%list, unused, %delim);
	}

//-----------------------------------------------------------------------------
// The displayHelp, onStart, onExit and parseArgs function are overriden
// by mod packages to get hooked into initialization and cleanup. 

function onStart()
{
	echo("\n onstart --------- ");
	// Default startup function
	}

function onExit()
{
	// OnExit is called directly from C++ code, whereas onStart is
	// invoked at the end of this file.
	}


function loadDir(%dir)
{
	setModPaths(pushback($userMods, %dir, ";"));
	exec(%dir @ "/main.cs");
}


function loadMods(%modPath)
{
	%modPath = nextToken(%modPath, token, ";");
	if (%modPath !$= "")
	loadMods(%modPath);
	
	if(exec(%token @ "/main.cs") != true){
		error("Error: Unable to find specified mod: " @ %token );
		$modcount--;
	}
}

dbgSetParameters( 28000, "password" );

// Load up common script base
loadDir("common");

// Execute startup scripts for each mod, starting at base and working up
loadMods($userMods);

onStart();

   // TorqueDebugPatcher begin
   doEnableDebug();
   // TorqueDebugPatcher end

#1
05/30/2006 (10:51 am)
I can recomend torsion as it had very good debugging capabilities www.sickheadgames.com
#2
05/30/2006 (12:33 pm)
Just for you information : torsion is a windows application

I search a tool for linux
#3
05/30/2006 (11:18 pm)
FYI. I hope to get Torsion on Linux soon after the official release. Can't promise anything, but it's a goal to do so.
#4
09/30/2006 (2:52 am)
I have tested the debugger provided with creator , but my PC is frozen each time that a break is performed : i am obliged to reboot.

Due to the lack of debugger on linux : I have decided to developp one in wxpython.

it will be just a debugger not an editor

5 set of functions in the torqueDebugger tools :
- telnet : connection , read and write functions
- breakpoint :select the source and put/remove a breakpoint
- debug : start,stop,break,step in, step out ...
- display the source : hightlight the line during debugging
- display the stack : list of functions called
- display the values of the variables : for the debugged function


Advises will be appreciated.
#6
09/30/2006 (5:19 am)
James, i use jedit daily

but the debugger does not work on linux ....
#7
11/12/2006 (1:25 pm)
Status on my debugger :

- GUI is finished and works
- telnet : connection , read and write functions : OK
- breakpoint :select the source and put/remove a breakpoint : OK
- localisation : ok ( translation to do)

It will be a GPL application , by this way everybody can improve it.

eviwo.free.fr/pictures/torquedebug.jpg
#8
11/15/2006 (12:53 pm)
Wow, looks great Phillipe.

I hope to see some sort of release soon, :-).
#9
12/30/2006 (9:30 am)
The debugger for torque is available in beta version :

www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=11602
#10
12/30/2006 (10:46 am)
Hi Philippe,
if you use TGE >= 1.4, the line in main.cs should be:
%cmd = "dbgSetParameters(" @ $GameDebugPort @ "," @ $GameDebugPassword @ "[b], false[/b]);";
and then it should work with JEDIT/TIDE, too... at least it does for me, I am using Ubuntu, too, and TIDEDebug works fine for me... nice app though and it has a lot more features than TIDEDebug, so I will try it, I guess :)
#11
12/30/2006 (11:57 am)
@ Stephan

your are right.

If you have proposal to improve the new debugger or new functions needed : tell me