GameMonkey Script
http://www.gmscript.com/gamemonkey/forum/

GM MSVC Debugger autoexp
http://www.gmscript.com/gamemonkey/forum/viewtopic.php?f=14&t=332
Page 1 of 1

Author:  DrEvil-OB [ Thu Dec 06, 2007 7:21 pm ]
Post subject:  GM MSVC Debugger autoexp

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 550 times

Author:  DrEvil-OB [ Thu Dec 06, 2007 7:48 pm ]
Post subject:  Re: GM MSVC Debugger autoexp

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

Author:  Greg [ Fri Dec 07, 2007 12:53 pm ]
Post subject:  Re: GM MSVC Debugger autoexp

Nice one DrEvil!

Author:  bull [ Wed Mar 05, 2008 3:13 pm ]
Post subject:  Re: GM MSVC Debugger autoexp

Thanks, very useful.

Author:  DrEvil-OB [ Tue Sep 14, 2010 3:17 am ]
Post subject:  Re: GM MSVC Debugger autoexp

fixed image links

Author:  Greg [ Fri Dec 22, 2017 8:06 am ]
Post subject:  Re: GM MSVC Debugger autoexp

I've made a VS2013 .natvis version, based on DrEvil's autoexp. It's in my branch.

Author:  Peart [ Wed Feb 28, 2018 8:37 am ]
Post subject:  Re: GM MSVC Debugger autoexp

Hi Greg, can you link to that specifically? I must be blind or something, because I can't find it.

Author:  Greg [ Wed Feb 28, 2018 10:27 am ]
Post subject:  Re: GM MSVC Debugger autoexp

Welcome Peart, you should find it in my git repo here:
https://github.com/publicrepo/gmscript/ ... hters/MSVC

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/