改造Lua的debug.traceback(),让其显示栈上所有的局部变量
来源:互联网 发布:本地网络电缆被拔出 编辑:程序博客网 时间:2024/06/10 09:14
function tracebackex() local ret = "" local level = 2 ret = ret .. "stack traceback:\n" while true do --get stack info local info = debug.getinfo(level, "Sln") if not info then break end if info.what == "C" then -- C function ret = ret .. tostring(level) .. "\tC function\n" else -- Lua function ret = ret .. string.format("\t[%s]:%d in function `%s`\n", info.short_src, info.currentline, info.name or "") end --get local vars local i = 1 while true do local name, value = debug.getlocal(level, i) if not name then break end ret = ret .. "\t\t" .. name .. " =\t" .. tostringex(value, 3) .. "\n" i = i + 1 end level = level + 1 end return ret end function tostringex(v, len) if len == nil then len = 0 end local pre = string.rep('\t', len) local ret = "" if type(v) == "table" then if len > 5 then return "\t{ ... }" end local t = "" for k, v1 in pairs(v) do t = t .. "\n\t" .. pre .. tostring(k) .. ":" t = t .. tostringex(v1, len + 1) end if t == "" then ret = ret .. pre .. "{ }\t(" .. tostring(v) .. ")" else if len > 0 then ret = ret .. "\t(" .. tostring(v) .. ")\n" end ret = ret .. pre .. "{" .. t .. "\n" .. pre .. "}" end else ret = ret .. pre .. tostring(v) .. "\t(" .. type(v) .. ")" end return ret end
- 改造Lua的debug.traceback(),让其显示栈上所有的局部变量。
- 改造Lua的debug.traceback(),让其显示栈上所有的局部变量
- Lua的debug.traceback
- Lua的局部变量
- Lua的局部变量
- C++,局部变量在栈上的地址,Release 和 Debug版本是不一样的
- Lua的debug hook功能探究与改造--上篇
- 设置Eclipse可以Debug模式调试JDK源码,并显示局部变量的值
- 一个类的static变量在其所有实例化对象上是共享的
- Debug JDK source 无法查看局部变量的问题解决方案
- 解决Debug JDK8源码无法查看局部变量的问题
- 如何在eclipse中debug调试进入JDK源码及显示调试过程中的局部变量的值
- lua源码分析(局部变量的定义)
- lua学习(2)_____lua的注释和全局变量、局部变量
- 异常 axis2服务的webservice 改造让其被dubbo监控
- eclipse在debug模式下鼠标移动到变量上不显示值的问题
- eclipse在debug模式下鼠标移动到变量上不显示值的问题
- 局部变量与成员变量的同名问题&显示初始化
- MFC怎样编写后台运行的程序 (这个值得一看)
- 多点触摸 终于有了初步成果
- 如何在JSP页面中通过一个按钮,在对话框中选择一个目录而不是选择一个文件;input type=file只能选择一个文件,我想选择一个目录;做不出来项目经理要扣奖金的...............
- C语言二进制文件读写程序实现(基础)
- oracle 游标简单的总结
- 改造Lua的debug.traceback(),让其显示栈上所有的局部变量
- Struts2 <s:property /> 标签用法
- Flex 预载界面美化
- 自己的问题记录
- android控件与常用控件
- 辗转相除法求最大公约数的原理
- eclipse快捷键大全
- Http关于Get和Post的区别
- 面试题2