<pre class="html" name="code"><?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="lua_State">
<DisplayString>lua_State</DisplayString>
<Expand>
<Item Name="[stack size]">top-base</Item>
<IndexListItems>
<Size>top-base</Size>
<ValueNode>base[$i]</ValueNode>
</IndexListItems>
<Item Name="[globals]">l_gt</Item>
<Item Name="[registry]">l_G->l_registry</Item>
<Item Name="[call]" Condition="ci->func->tt!=0">ci->func</Item>
<IndexListItems>
<Size>ci - base_ci-1</Size>
<ValueNode>base_ci[$i+1].func</ValueNode>
</IndexListItems>
</Expand>
</Type>
<Type Name="Node">
<DisplayString>{i_key} 〓 {i_val}</DisplayString>
<Expand>
<Item Name="[key]" Condition="i_key.tvk.tt==5">i_key.tvk</Item>
<Item Name="[val]">i_val</Item>
<ExpandedItem Condition="i_key.tvk.tt!=5 && i_val.tt==5">i_val</ExpandedItem>
</Expand>
</Type>
<Type Name="lua_Node">
<DisplayString Condition="i_val.tt==0">{i_key} ×</DisplayString>
<DisplayString>{i_key} 〓 {i_val}</DisplayString>
<Expand>
<Item Name="[key]" Condition="i_key.tvk.tt==5">i_key.tvk</Item>
<Item Name="[val]" Condition="i_key.tvk.tt==5">i_val</Item>
<ExpandedItem Condition="i_key.tvk.tt!=5 && i_val.tt==5">i_val</ExpandedItem>
</Expand>
</Type>
<Type Name="lua_TValue">
<DisplayString Condition="tt==0">NIL</DisplayString>
<DisplayString Condition="tt==1">{(bool)value.b}</DisplayString>
<DisplayString Condition="tt==2">{value.p} lightuserdata</DisplayString>
<DisplayString Condition="tt==3">number={value.n}</DisplayString>
<DisplayString Condition="tt==4">{value.gc->ts}</DisplayString>
<DisplayString Condition="tt==5">{value.gc->h}</DisplayString>
<DisplayString Condition="tt==6">{value.gc->cl}</DisplayString>
<DisplayString Condition="tt==7">{value.gc->u}</DisplayString>
<DisplayString Condition="tt==8">thread {value.gc->th}</DisplayString>
<DisplayString>empty</DisplayString>
<Expand>
<Item Name="[lightuserdata]" Condition="tt==2">(const char *)value.p</Item>
<Item Name="[function]" Condition="tt==6">value.gc->cl</Item>
<Item Name="[userdata]" Condition="tt==7">value.gc->u</Item>
<Item Name="[thread]" Condition="tt==8">value.gc->th</Item>
<ExpandedItem Condition="tt==5">value.gc->h</ExpandedItem>
<Item Name="[原始视图table]" Condition="tt==5">value.gc->h</Item>
</Expand>
</Type>
<Type Name="Udata">
<DisplayString>userdata</DisplayString>
</Type>
<Type Name="CClosure">
<DisplayString>C++ function {f}</DisplayString>
</Type>
<Type Name="LClosure">
<DisplayString>Lua function {*p->source} : line {*p->lineinfo, d}</DisplayString>
</Type>
<Type Name="Closure">
<DisplayString Condition="c.isC">{c}</DisplayString>
<DisplayString Condition="!c.isC">{l}</DisplayString>
</Type>
<Type Name="Table">
<DisplayString>Table 数组元素个数:{sizearray,d}, 哈希元素空间:{1<<lsizenode,d}</DisplayString>
<Expand>
<Item Name="metatable元表" Condition="metatable!=0">metatable</Item>
<IndexListItems>
<Size>sizearray</Size>
<ValueNode>array[$i]</ValueNode>
</IndexListItems>
<Item Name="■数组哈希分割线■" Condition="sizearray!=0">0</Item>
<IndexListItems>
<Size>1<<lsizenode</Size>
<ValueNode>node[$i]</ValueNode>
</IndexListItems>
</Expand>
</Type>
<Type Name="TString">
<DisplayString>{(const char *)(&tsv+sizeof(*this)/sizeof(tsv)),s8}</DisplayString>
<StringView>(const char *)(&tsv+sizeof(*this)/sizeof(tsv)),s8</StringView>
</Type>
<Type Name="TKey">
<DisplayString>{tvk}</DisplayString>
</Type>
<Type Name="ZLua::LuaLocalRef">
<DisplayString>{L->base[m_stackIndex-1]}</DisplayString>
<Expand>
<Item Name="StackIndex">m_stackIndex</Item>
<ExpandedItem >L->base[m_stackIndex-1]</ExpandedItem>
</Expand>
</Type>
<Type Name="ZLua::LuaLocalTableRef">
<DisplayString>{L->base[m_stackIndex-1]}</DisplayString>
<Expand>
<Item Name="StackIndex">m_stackIndex</Item>
<ExpandedItem >L->base[m_stackIndex-1]</ExpandedItem>
</Expand>
</Type>
<Type Name="ZLua::LuaRegistryRef">
<DisplayString>{L->l_G->l_registry.value.gc->h.array[m_ref-1]}</DisplayString>
<Expand>
<Item Name="Table">L->l_G->l_registry.value.gc->h.array[m_ref-1]</Item>
</Expand>
</Type>
<Type Name="ZLua::LuaDependencyPropertyTable">
<DisplayString>{L->l_G->l_registry.value.gc->h.array[m_tableRef-1].value.gc->h}</DisplayString>
<Expand>
<Item Name="Table">L->l_G->l_registry.value.gc->h.array[m_tableRef-1].value.gc->h</Item>
</Expand>
</Type>
</AutoVisualizer>
将上述代码保存为lua.natvis,放入Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Packages\Debugger\Visualizers(你的地址也许不同,可以尝试搜索硬盘stl.natvis)或者C:\Users\用户名\Documents\Visual Studio 2013\Visualizers\
请注意是找到文件夹,不要自己创建。
然后在vs c++环境下,选项要关闭 选项-编辑并继续 功能(这两功能不兼容……)
这样你就也许可以在c++代码中查看lua_State变量了,可以展开查看Registry注册表或全局表
失败的话,你也许要在lua.h后面加载lstate.h文件
(以上配置文件仅支持5.1,若需要5.2请自行翻墙访问http://blog.basemetalgames.com/2013/05/lua-natvis.html)