VS2012以上版本 C++环境查看 lua5.1 栈/Global/Registry的可视化器

来源:互联网 发布:服装营销数据分析 编辑:程序博客网 时间:2024/06/07 10:24
<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)

0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 宝贝39度不退烧怎么办 两岁多小儿突然变得口吃怎么办 百度两周岁宝宝口吃怎么办 2岁宝宝偶尔结巴怎么办 两岁宝宝说话磕巴怎么办 宝宝两岁结巴了怎么办 人多说话就紧张怎么办 小孩拉尿不叫人怎么办 2岁宝宝说话有点结巴怎么办 两岁半的宝宝说话结巴怎么办 2个月宝宝怕洗澡怎么办 2岁宝宝不喜欢喝奶粉怎么办 宝宝断奶不喜欢喝奶粉怎么办 宝宝不喜欢奶粉的味道怎么办 四个月宝宝不喜欢吃奶粉怎么办 四岁宝宝有口臭怎么办 4个月宝宝口臭怎么办 2岁宝宝有口臭是怎么办 两岁宝宝有口气怎么办 2岁宝宝口气重是什么原因怎么办 两岁宝宝口气重怎么办 两岁宝宝有口臭怎么办 两岁身高不达标怎么办 两岁宝宝82厘米怎么办 2岁幼儿说话结巴怎么办 2岁的宝宝结巴怎么办 2岁半宝宝口吃怎么办 2周岁宝宝不说话怎么办 三周岁宝宝不说话怎么办 2周岁宝宝突然说话结巴怎么办 两周岁宝宝突然说话结巴怎么办 三周岁宝宝说话突然结巴怎么办 小孩g和d不分怎么办 两岁宝宝皮肤黑怎么办 2岁宝宝肤色偏黄怎么办 2岁宝宝迷上手机怎么办 2岁宝宝说话口吃怎么办 两岁宝宝突然口吃怎么办 两岁半的宝宝还不会说话怎么办 2岁宝宝自闭症怎么办呀 新生儿又吐又拉怎么办