Game Development Community

TelnetDebugger crash fix

by Tom Spilman · in Torque Game Engine · 07/26/2006 (7:09 pm) · 2 replies

I've been trying to get a new TelnetDebugger update out, but i'm swamped with stuff. This is a fix, which will be included in the next update, fixes a not-so-frequent crash bug when you hit a breakpoint. In TelnetDebugger.cc replace TelnetDebugger::breakProcess() with these two functions (you also need to add TelnetDebugger::sendBreak() to the TelnetDebugger class header):

void TelnetDebugger::breakProcess()
{
   // Send out a break with the full stack.
   sendBreak();

   mProgramPaused = true;
   while(mProgramPaused)
   {
      Platform::sleep(10);
      checkDebugRecv();
      if(mDebugSocket == InvalidSocket)
      {
         mProgramPaused = false;
         removeAllBreakpoints();
         debugContinue();
         return;
      }
   }
}

void TelnetDebugger::sendBreak()
{
   // echo out the break
   send("BREAK");
   char buffer[MaxCommandSize];
   char scope[MaxCommandSize];

   S32 last = 0;

   for(S32 i = (S32) gEvalState.stack.size() - 1; i >= last; i--)
   {
      CodeBlock *code = gEvalState.stack[i]->code;
      const char *file = "<none>";
      if (code && code->name && code->name[0])
         file = code->name;

      Namespace *ns = gEvalState.stack[i]->scopeNamespace;
      scope[0] = 0;
      if ( ns ) {
         
         if ( ns->mParent && ns->mParent->mPackage && ns->mParent->mPackage[0] ) {
            dStrcat( scope, ns->mParent->mPackage );
            dStrcat( scope, "::" );
         }
         if ( ns->mName && ns->mName[0] ) {
            dStrcat( scope, ns->mName );
            dStrcat( scope, "::" );
         }
      }

      const char *function = gEvalState.stack[i]->scopeName;
      if ((!function) || (!function[0]))
         function = "<none>";
      dStrcat( scope, function );

      U32 line=0, inst;
      U32 ip = gEvalState.stack[i]->ip;
      if (code)
         code->findBreakLine(ip, line, inst);
      dSprintf(buffer, MaxCommandSize, " %s %d %s", file, line, scope);
      send(buffer);
   }

   send("\r\n");
}

I've been running with this fix for a few weeks, but other features have kept me from updating. I had to get this out there now as i want to be sure it makes it into TGB 1.1.1.

About the author

Tom is a programmer and co-owner of Sickhead Games, LLC.


#1
07/27/2006 (11:28 am)
Tom,

This has been fixed in 1.1.1 release, thanks again!

Cheers,
-Justin
#2
07/28/2006 (12:48 am)
Ok... i suck. :/