GameMonkey Script

GameMonkey Script Forums
It is currently Tue Jun 18, 2019 3:23 pm

All times are UTC




Post new topic Reply to topic  [ 29 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Tue Dec 01, 2009 1:38 am 
Offline

Joined: Tue Nov 11, 2008 9:03 am
Posts: 20
DrEvil-OB wrote:
I very much plan to upload the debugger to the sourceforge repository I recently set up for GM extensions. In order to work the debugger includes some extensions to the gm debugger code, some extra instructions, etc. Sorry it's taking so long but I wanted to ensure it works to the extent that I had it working before prior to uploading it, and double check the dependencies with wx windows, maybe update that to latest wx to make it easier to get compiling. It doesn't help much to upload non working code. I'll try to get this upload this week before I go on 2 week vacation.

Ping!
:)


Last edited by Bock on Mon Feb 08, 2010 1:24 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Fri Feb 05, 2010 8:14 am 
Offline

Joined: Thu Dec 20, 2007 8:55 am
Posts: 13
Do you want to share the source code?


Top
 Profile  
Reply with quote  
PostPosted: Fri Feb 05, 2010 2:26 pm 
Offline

Joined: Fri Jan 14, 2005 2:28 am
Posts: 439
committed to gmscript ex source forge repository

it's been a long time since I had it working so I'm unsure of the status of it. I don't think there's been alot of changes that would effect it but who knows. if anyone is willing to help me bring it up to par it would be appreciated. the difficulty I think is going to be getting the dependencies compiled. it currently uses wxwidgets, and I have an environment variable set from GameMonkeyEx2008.slnenv to build it with

WXWIN=D:\code\wxWidgets-2.8.3


Top
 Profile  
Reply with quote  
PostPosted: Fri Feb 05, 2010 4:00 pm 
Offline

Joined: Fri Jan 14, 2005 2:28 am
Posts: 439
btw, if anyone knows of a reeealy light weight toolkit for building a GUI with controls for syntax highlighting, auto completion, etc like scintilla let me know. i would prefer not to carry such a large dependency on something like wxwidgets


Top
 Profile  
Reply with quote  
PostPosted: Sun Feb 21, 2010 10:08 am 
Offline

Joined: Fri Jan 14, 2005 2:28 am
Posts: 439
So I got back to work on the debugger, and rather than update it to the latest wxwidgets, I decided to give it a shot with Qt. Qt is a pretty nice gui library, and it was a breeze to port the debugger over to it. Not only is the code hugely simpler, but it has a lot of niceties that were easy to take advantage of like dockable panes and stuff.

It's still a WIP, but a good amount of the functionality is already working, and the code is checked in to the gm_ex sourceforge repository.

Image


Top
 Profile  
Reply with quote  
PostPosted: Sun Feb 21, 2010 1:31 pm 
Offline

Joined: Mon Dec 15, 2003 1:38 pm
Posts: 708
Looking great DrEvil!


Top
 Profile  
Reply with quote  
PostPosted: Fri Feb 26, 2010 1:45 am 
Offline

Joined: Thu Feb 25, 2010 6:20 pm
Posts: 3
DrEvil-OB : I successfully got your svn source, compiled everything by fetching QT and such, it looks like a nice IDE. The thing here is I am new to GameMonkey, I am on a sort of quest to find the perfect scripting language for my 3d engine. There is a point which I am missing, from the sample examples that comes with GameMonkey I fail to understand how to actually let your debugger work with my embedded GM machine. Since there is no reference in the document for such an endeavor as debugging the script that runs in my vm with your debugger, would you mind to explain the things I need to implement to make it work :)

any web site or hint would be appreciated.


Top
 Profile  
Reply with quote  
PostPosted: Fri Feb 26, 2010 5:09 am 
Offline

Joined: Fri Jan 14, 2005 2:28 am
Posts: 439
I haven't got around to an example of the application side of things, but basically you have a socket listening and hook up some basic callbacks to send and receive data. In my current application I'm using SFML, so it's not very suitable right now to commit to SVN.

I'm in the process of cleaning it up, but I'll post some snippets soon.


Top
 Profile  
Reply with quote  
PostPosted: Fri Feb 26, 2010 5:24 am 
Offline

Joined: Thu Feb 25, 2010 6:20 pm
Posts: 3
Excellent, take your time to come with a simple example. This is all better than squirrel script, never was able to make the debugger interface with my application correctly. My goal is to come up with something intuitive yet powerful. I have been into UDK and Unity3d alot for the past 6 month and would like to have something like that for Ogre3d since I love the tech, so if I could set up a debugger interface inside the game creation tool, it would be a major step against such tools.

I tried to evaluate Mono as a scripting engine but I found it was arduous and not very elegant to integrate. The most appealing thing for mono was that csharp was compiled for better execution speed akin to unrealscript in UDK. I wish I would understand how this vm and bytecode low level stuff works, but heh, there's only such a number of hours in a day...

Anyhow thanks for the quick reply and kudos for making me check into Qt, it is really nice compared to MFC and WxWidget :)


Top
 Profile  
Reply with quote  
PostPosted: Fri Feb 26, 2010 5:51 am 
Offline

Joined: Fri Jan 14, 2005 2:28 am
Posts: 439
Ok I changed gmDebugSession some from how it was set up before. I didn't really like using function pointers and void *s for callbacks and stuff. Instead it's now an interface. For my uses, I just inherit it for my script manager.

Basically a socket listens for TCP connections, and when connected UpdateDebugSession() is called which in turn calls PumpMessage each update to process network messages.

It's a simple socket sending message, with a magic number and size header followed by the data. The debugger itself uses this scheme too and validates using the same magic number.

Here is relevant code.

Code:
void ScriptManager::EnableRemoteDebugger(bool _enable)
{
#if defined(ENABLE_REMOTE_DEBUGGER) && defined(GMDEBUG_SUPPORT)
   if(_enable && !g_RemoteDebuggerInitialized)
   {
      if(g_DebugListener.Listen(GM_DEBUGGER_PORT))
      {
         g_DebugListener.SetBlocking(false);
         g_RemoteDebuggerInitialized = true;
      }
      else
      {
         //const char *pError = XPSock_TranslateErrorLong(g_ScriptDebuggerSocket.GetLastError());
         //LOGERR("Error Initializing Remote Debug Socket, disabling");
         //LOGERR(pError);
         g_RemoteDebuggerInitialized = false;
      }
   }
   else if(g_RemoteDebuggerInitialized)
   {
      // Shut it down!
      g_DebugListener.Close();
      g_RemoteDebuggerInitialized = false;
   }
#endif
}

void ScriptManager::Update()
{
   machine->Execute((gmuint32)IGame::GetDeltaTime());

   //////////////////////////////////////////////////////////////////////////
#if defined(ENABLE_REMOTE_DEBUGGER) && defined(GMDEBUG_SUPPORT)
   if(g_RemoteDebuggerInitialized)
   {
      if(!g_DebugClient.IsValid())
      {
         sf::IPAddress addr;
         sf::Socket::Status s = g_DebugListener.Accept(g_DebugClient,&addr); s;

         if(addr.IsValid())
         {
            Utils::OutputDebug(kScript, "Remote Debugger Connected: %s", addr.ToString().c_str());
            OpenDebugSession(m_ScriptEngine);
            g_DebugClient.SetBlocking(false);
         }
      }

      if(g_DebugClient.IsValid())
      {
         UpdateDebugSession();
      }
   }
#endif
}


#if defined(ENABLE_REMOTE_DEBUGGER) && defined(GMDEBUG_SUPPORT)

struct PacketHeader {
   static const unsigned int MAGIC_NUM = 0xDEADB33F;

   const unsigned int magicNum;
   const unsigned int dataSize;
   PacketHeader( unsigned int sz ) : magicNum(MAGIC_NUM), dataSize( sz ) {}
};

String         g_RecieveBuffer;
String         g_LastCommand;

void ScriptManager::SendDebuggerMessage(const void * a_command, int a_len) {
   if(g_DebugClient.IsValid())
   {
      PacketHeader hdr( a_len );

      sf::Packet packet;
      packet.Append((const char *)&hdr, sizeof(hdr));
      packet.Append((const char *)a_command, a_len);
      if(g_DebugClient.Send(packet,false)==sf::Socket::Disconnected)
      {
         g_DebugClient.Close();
         return;
      }
      Utils::OutputDebug(kScript, "%d sent", packet.GetDataSize());
   }   
}

const void * ScriptManager::PumpDebuggerMessage(int &a_len) {
   // grab all the data from the network we can
   enum { BufferSize = 4096 };
   char inBuffer[BufferSize];
   std::size_t inSize = 0;
   do
   {
      if(g_DebugClient.Receive(inBuffer,BufferSize,inSize)==sf::Socket::Done)
      {
         Utils::OutputDebug(kScript, Utils::VA("%d recieved", inSize));
         if(inSize>0)
            g_RecieveBuffer.append(inBuffer, inSize);
      }
   } while ( inSize > 0 );

   // see if we have an entire packets worth of data waiting
   const char * dataPtr = g_RecieveBuffer.c_str();
   const PacketHeader * hdr = reinterpret_cast<const PacketHeader *>(dataPtr);
   dataPtr += sizeof(PacketHeader);
   if ( hdr->magicNum != PacketHeader::MAGIC_NUM ) {
      // ERROR! Malformed Packet!
      return NULL;
   }

   if ( g_RecieveBuffer.size() >= hdr->dataSize+sizeof(PacketHeader) ) {
      a_len = hdr->dataSize;
      g_LastCommand.resize(0);
      g_LastCommand.append( dataPtr, hdr->dataSize );
      g_RecieveBuffer.erase( 0, hdr->dataSize + sizeof(PacketHeader) );
      return g_LastCommand.c_str();
   }
   return NULL;
}

#endif


Top
 Profile  
Reply with quote  
PostPosted: Fri Feb 26, 2010 8:12 pm 
Offline

Joined: Thu Feb 25, 2010 6:20 pm
Posts: 3
So if I only include the normal gm headers (as stated into the faqs) and implement a small tcp interface (btw did you use Qt network libs for that in your client ?) and I follow your supplied code, The UpdateDebugSession is found in gmDebug.h (which seems to be the debug client) should take care of all debugging messages ?

On a side note, I do not know if you knew of the following links :

download visual studio SDK
-------------------------------------------------------
http://www.microsoft.com/downloads/deta ... laylang=en

Introduction to the Visual Studio Shell
-------------------------------------------------------
http://msdn.microsoft.com/en-us/vsx2008 ... 33751.aspx

Visual Studio 2008 Shell (isolated mode) with Service Pack 1 Redistributable Package
http://www.microsoft.com/downloads/deta ... eaef69e927

Visual Studio Debugger Extensibility
------------------------------------------------------
http://msdn.microsoft.com/en-us/library/bb161718.aspx

Visual Studio Debug Engine Sample
------------------------------------------------------
http://code.msdn.microsoft.com/debugenginesample

Two weeks ago Epic released the debug interface to the UDK Unreal3 executable and since Nfringe (used to debug Unrealscript whitin VS) costed 15k a licence, I wanted to look into making a debugger for VS. I checked the code for debugging squirrel apps under VS2008 (you can find it in the squirrel forum) and it would look easy for somebody with some experience in that field to actually program a debugger for VS, I know from the readme file that the creator of squirrel adapted the Debug sample successfully.

Again thanks for your time, hope the following links helps you out. Although my knowledge of Debuggers are limited, its an area I am curious about. Let me know if you have some intention of making a VS debugger for GameMonkey, it would be a nice introduction for me in the world of debuggers.


Top
 Profile  
Reply with quote  
PostPosted: Mon Mar 01, 2010 3:07 am 
Offline

Joined: Fri Jan 14, 2005 2:28 am
Posts: 439
I probably wont bother doing an MSVC debugger, there isn't much value to tieing it to a particular IDE imo.

I used SFML for the 'client' side, though I may at some point change it to use Qt as well.


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 17, 2011 11:41 am 
Offline

Joined: Fri Jun 19, 2009 12:39 pm
Posts: 31
Ping!

I've been doing some work with GM of late, and figured that a debugger would be useful. After trying the debugger that ships with the source package (runs, connects but doesn't really seem to work?) I decided to see what was going on in the world of smart people, doing stuff with gm.

Any updates on the status of your GM debugger Dr Evil? Is it in a useable state? Something we can download from sourceforge and start using on our own?

** edit **

I should add, that the debugger bundled with the gm package seems to work "ok". As it turns out, it was completely my fault for the application not doing stuff properly. A bit of a big re-write later, and it's all working super nice...well...sort of.


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 08, 2011 3:22 am 
Offline

Joined: Fri Jan 14, 2005 2:28 am
Posts: 439
My debugger basically requires my version of gm, which I call gm_ex. It's an extended version with which I extended debugger functionality and stuff, so unfortunately my debugger will only work with that.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 29 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group