Crashfix for TelnetDebugger
by Tom Spilman · in Torque Game Builder · 12/28/2006 (12:09 pm) · 1 replies
Note: I'm cross posting this because not everyone has access to the other private forums.
I was alerted to this crash bug in the TelnetDebugger by a Torsion user. Basically if you breakpoint within a 'prefs.cs' file and do a "Step Over" on the last line, the Torque executable crashes.
This issue is a dead codeblock pointer within a breakpoint and how step works. The easiest fix was to notifiy the telnet debugger when codeblocks are unloading so that it can clear the pointers in the breakpoints. The fix is as follows...
In engine\console\codeBlock.cc replace the CodeBlock::removeFromCodeList() function with this:
Now in engine\console\telnetDebugger.h you need to add the following new function:
Finally add the new function to engine\console\telnetDebugger.cc:
That does it. This fix was developed on TGEA M4, but it should apply to all Torque C++ engines.
I was alerted to this crash bug in the TelnetDebugger by a Torsion user. Basically if you breakpoint within a 'prefs.cs' file and do a "Step Over" on the last line, the Torque executable crashes.
This issue is a dead codeblock pointer within a breakpoint and how step works. The easiest fix was to notifiy the telnet debugger when codeblocks are unloading so that it can clear the pointers in the breakpoints. The fix is as follows...
In engine\console\codeBlock.cc replace the CodeBlock::removeFromCodeList() function with this:
void CodeBlock::removeFromCodeList()
{
for(CodeBlock **walk = &smCodeBlockList; *walk; walk = &((*walk)->nextFile))
{
if(*walk == this)
{
*walk = nextFile;
// clear out all breakpoints
clearAllBreaks();
break;
}
}
// Let the telnet debugger know that this code
// block has been unloaded and that it needs to
// remove references to it.
if ( TelDebugger )
TelDebugger->clearCodeBlockPointers( this );
}Now in engine\console\telnetDebugger.h you need to add the following new function:
void process(); void popStackFrame(); void pushStackFrame(); void addAllBreakpoints(CodeBlock *code); void clearCodeBlockPointers(CodeBlock *code); // NEW FUNCTION! virtual void executionStopped(CodeBlock *code, U32 lineNumber);
Finally add the new function to engine\console\telnetDebugger.cc:
void TelnetDebugger::clearCodeBlockPointers(CodeBlock *code)
{
Breakpoint **walk = &mBreakpoints;
Breakpoint *cur;
while((cur = *walk) != NULL)
{
if(cur->code == code)
cur->code = NULL;
walk = &cur->next;
}
}That does it. This fix was developed on TGEA M4, but it should apply to all Torque C++ engines.
About the author
Tom is a programmer and co-owner of Sickhead Games, LLC.
Torque Owner Kirakorn Chimkool