Telenet Debugger / Torsion Bug
by James Ford · in Torque Game Builder · 08/31/2007 (3:16 pm) · 3 replies
The capitalization you use when you execute your script files must match the actual file/folder capitalization, or, if it does not breakpoints specified in those files will not be hit. Although the script files will still execute and you can still step into the code if it is from an outside breakpoint, "breakpoints in a script file that is executed with capitalization not matching the actual file capitalication will not be hit."
I believe this is a new bug introduced in 1.5.1 in the telenetdebugger code.
For example, if you execute like this:
exec("./gamescripts/scriptfile.cs");
But the actual folder is "gameScripts"...
The fix involves making two changes to telenetdebugger.cc
Replace this function (this is the new version):
(Actually just the string comparison is changed)
In this function,
void TelnetDebugger::addAllBreakpoints(CodeBlock *code)
Change the beginning of the while look to look like this:
(Just the string comparison has changed)
Note: all we are doing is replacing the existing method of comparing two string table entries with a case insensitive method (dStricmp).
Edit: Or now that you are aware of the issue, just watch your capitalization when you "exec".
I believe this is a new bug introduced in 1.5.1 in the telenetdebugger code.
For example, if you execute like this:
exec("./gamescripts/scriptfile.cs");
But the actual folder is "gameScripts"...
The fix involves making two changes to telenetdebugger.cc
Replace this function (this is the new version):
(Actually just the string comparison is changed)
TelnetDebugger::Breakpoint **TelnetDebugger::findBreakpoint(StringTableEntry fileName, S32 lineNumber)
{
Breakpoint **walk = &mBreakpoints;
Breakpoint *cur;
while((cur = *walk) != NULL)
{
// TODO: This assumes that the OS file names are case
// insensitive... Torque needs a dFilenameCmp() function.
if( dStricmp( cur->fileName, fileName ) == 0 && cur->lineNumber == U32(lineNumber))
return walk;
walk = &cur->next;
}
return NULL;
}In this function,
void TelnetDebugger::addAllBreakpoints(CodeBlock *code)
Change the beginning of the while look to look like this:
(Just the string comparison has changed)
while((cur = *walk) != NULL)
{
// TODO: This assumes that the OS file names are case
// insensitive... Torque needs a dFilenameCmp() function.
if( dStricmp( cur->fileName, code->name ) == 0 )
{Note: all we are doing is replacing the existing method of comparing two string table entries with a case insensitive method (dStricmp).
Edit: Or now that you are aware of the issue, just watch your capitalization when you "exec".
About the author
http://jamesdev.info
#2
09/01/2007 (6:14 pm)
This is one of those "two wrongs seem right, but are still wrong" issues as well--exec should enforce capitalization as well (specifically for *nix and Mac).
#3
Now we only tested on Windows, but as far as i could tell exec() was working correctly. It was finding the file using the resource manager, which i believe considers case, then loading it... so that's not a bug that i know of.
The new code in 1.5.1 that assigns the file name to the codeblock uses a case sensitive string table entry on all platforms... it didn't do this before. That's what broke the StringTableEntry comparison for breakpoints. But fixing that... toggling the "case sensitive" flag when inserting the codeblock file name into the StringTable... felt like it would be subtle and a case where further bugs could be introduced.
Still adding a StringTable->insertFileString(), that takes care of case sensitivity on different platforms might be useful.
09/02/2007 (3:03 pm)
@Stephen - I consulted with Clark and Justin and they felt that this was the best fix for now. And i kinda agree that depending on the string table for these sorts of file name comparisons is dangerous. Now we only tested on Windows, but as far as i could tell exec() was working correctly. It was finding the file using the resource manager, which i believe considers case, then loading it... so that's not a bug that i know of.
The new code in 1.5.1 that assigns the file name to the codeblock uses a case sensitive string table entry on all platforms... it didn't do this before. That's what broke the StringTableEntry comparison for breakpoints. But fixing that... toggling the "case sensitive" flag when inserting the codeblock file name into the StringTable... felt like it would be subtle and a case where further bugs could be introduced.
Still adding a StringTable->insertFileString(), that takes care of case sensitivity on different platforms might be useful.
Torque Owner Spider
That is what has been happening!!!!!!!
Thank you so much for finding this and pointing it out. I was getting real frickin confused and irritated by my breakpoints not hitting.