GameMonkey Script

GameMonkey Script Forums
It is currently Wed Nov 14, 2018 10:55 am

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: GM MSVC Debugger autoexp
PostPosted: Thu Dec 06, 2007 7:21 pm 
Offline

Joined: Fri Jan 14, 2005 2:28 am
Posts: 439
I'd like to share some extensions to the autoexp.dat file that MSVC uses to show variables in a user friendly way. This file is how MSVC2005 achieves its intuitive display of stl containers and a number of other built in complex types.

I've extended this file to allow you to see exactly what's in gmVariable, gmTableObject, gmStringObject, gmFunctionObject, as well as get some useful information from gmThread and gmMachine variables. This functionality is extremely useful in peeking into the contents of GM object when debugging, using the autos/watch windows.

All you need to do is copy the contents into your autoexp.dat and the next time you debug you should see more useful debug output for gm objects.


Attachments:
File comment: Copy and past contents of gm_autoexp.txt into your autoexp.dat that comes with MSVC. Normally located in
C:\Program Files\Microsoft Visual Studio 8\Common7\Packages\Debugger\autoexp.dat

gm_autoexp.txt [4.79 KiB]
Downloaded 433 times
Top
 Profile  
Reply with quote  
PostPosted: Thu Dec 06, 2007 7:48 pm 
Offline

Joined: Fri Jan 14, 2005 2:28 am
Posts: 439
Here's an example of what the output looks like.

Using this code as a test

Code:
int gmBlah(gmThread *a_thread)
{
   return GM_OK;
}

void main(int argc, char * argv[], char * envp[])
{
   gmMachine *pM = pM = new gmMachine;
   gmGCRootManager::Init();
   gmMachine::s_machineCallback = gmeMachineCallback;
   //pM->SetDebugMode(true);
   gmStringObject *so = pM->AllocStringObject("What Up Fool");
   gmTableObject *to = pM->AllocTableObject();
      
   gmVariable vint(50);
   gmVariable vfloat(232.f);
   gmVariable vtable(to);
   gmVariable vstring(so);
   gmVariable vnull = gmVariable::s_null;
   gmVariable vuser(pM->AllocUserObject(0,pM->CreateUserType("MyType")));
   
   to->Set(pM,0,gmVariable(600));
   to->Set(pM,1,vfloat);
   to->Set(pM,2,vuser);
   to->Set(pM,"SomeKey",vtable);
   to->Set(pM,gmVariable(7000),vstring);

   pM->ExecuteString("global SomeFunction = function() {};");
   gmVariable vscriptfunc = pM->GetGlobals()->Get(pM,"SomeFunction");

   pM->GetGlobals()->Set(pM,"SomeFunc2",gmVariable(pM->AllocFunctionObject(gmBlah)));
   gmVariable vnativefunc = pM->GetGlobals()->Get(pM,"SomeFunc2");

   gmTableObject *pMapTable = pM->AllocTableObject();
   pM->GetGlobals()->Set(pM, "Map", gmVariable(pMapTable));

   pM->ExecuteString("hi = \"somestring\"; p1 = 10; p2 = 20; p3 = 9.9; p4 = \"testparam\"; hi:SomeFunc2(p1,p2,p3,p4);");

   delete pM;
}


I get the following display in the watch window of these variables when I break into the code.

Image

Notice how all the gmVariables are displayed user friendly depending on their type, and table contents are even shown.
Also notice at the bottom how function objects display whether it is a script or native function. You will only get the name of the script function if debug mode is on, as is enabled above. With it off you will see this for script functions. "function = <no debug name, use gmMachine::SetDebugMode(true)>"

Also, if I break inside my gmBlah function, you will get useful parameter information from a_thread

Image


Top
 Profile  
Reply with quote  
PostPosted: Fri Dec 07, 2007 12:53 pm 
Offline

Joined: Mon Dec 15, 2003 1:38 pm
Posts: 707
Nice one DrEvil!


Top
 Profile  
Reply with quote  
PostPosted: Wed Mar 05, 2008 3:13 pm 
Offline

Joined: Thu Dec 20, 2007 8:55 am
Posts: 13
Thanks, very useful.


Top
 Profile  
Reply with quote  
PostPosted: Tue Sep 14, 2010 3:17 am 
Offline

Joined: Fri Jan 14, 2005 2:28 am
Posts: 439
fixed image links


Top
 Profile  
Reply with quote  
PostPosted: Fri Dec 22, 2017 8:06 am 
Offline

Joined: Mon Dec 15, 2003 1:38 pm
Posts: 707
I've made a VS2013 .natvis version, based on DrEvil's autoexp. It's in my branch.


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 28, 2018 8:37 am 
Offline

Joined: Tue Feb 20, 2018 10:38 am
Posts: 1
Hi Greg, can you link to that specifically? I must be blind or something, because I can't find it.


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 28, 2018 10:27 am 
Offline

Joined: Mon Dec 15, 2003 1:38 pm
Posts: 707
Welcome Peart, you should find it in my git repo here:
https://github.com/publicrepo/gmscript/ ... hters/MSVC


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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