Comments (5)
function this.getHookOffset()
if hookLib ~= nil then
return HOOK_LEVEL;
end
local funclayer = 0;
repeat
local info = debug.getinfo(funclayer, "SlLnf");
if info ~= nil and info.func == this.real_hook_process then
return funclayer;
end
funclayer = funclayer + 1;
until not info
return 0;
end
-- dataProcess里面
local hookOffset = this.getHookOffset(); --去除偏移量
local stackId = this.curStackId - 1 + hookOffset;
local varTable = this.getVariable(stackId, true);
msgTab.info = varTable;
我自己本地改了一下,获取real_hook_process的层级再减一下,就知道真实的堆栈层级了
from luapanda.
最近有点忙,刚看到消息。
非常感谢提出这个问题。我回顾了一下代码,这里确实是一个bug。因为 getSpecificFunctionStackLevel
会从栈顶开始逐层查找函数对应的栈帧,当一个函数存在于两个栈帧中,其中的局部变量处理就只会展示最上层栈帧的。同时这个错误有可能出现在 watch 窗口。
之所以会需要 getSpecificFunctionStackLevel
这个函数修正偏移,原因是在 lua 栈中,可能存在存在穿插 native 堆栈的情况。但是把堆栈信息发送给 vscode 时,把 native 栈过滤掉了( 参考 getStackTable()
,它的返回值就是前端获得的堆栈)。于是出现了 vscode 发到后端的堆栈并不是实际 stackId 的情况。
总的来说,可以考虑在构建前端堆栈时,不去除 native 原生栈,这样可以保持前后端堆栈对应。 如果保持过滤 native 栈,就要在后端建立映射表。
最近做了一些 js 相关的工作,也参考了下 js 调试器,后续我更倾向于保留 native 堆栈。
from luapanda.
其实就是调用 real_hook_process 里面,有可能多次递归调用 receiveMessage,dataProcess这几个函数,导致真实的 lua 层数距离断点所在的层数偏移不固定,只要从 real_hook_process 所在层数去算就能过滤掉所有 debugger 的层数了
from luapanda.
我画了张图表达上面的方案,这样改很好,这部分代码后面会使用你的方案修改。
上面我说得是另一个场景,即 lua 用户栈嵌套原生栈帧的问题。之前的处理方案不太好,容易引发变量和栈帧不匹配的bug,我最近一起优化。
from luapanda.
fix 9bb31aa
from luapanda.
Related Issues (20)
- 断点以后,显示变量的值不对,所有的变量值都是一样的,这应该是一个BUG HOT 1
- 调试器没有找到文件 lua.lua 。 请检查launch.json文件中lua后缀是否配置正确, 以及VSCode打开的工程是否正确 HOT 4
- 协程coroutine.wrap()创建,断点断不住 HOT 4
- Windows下配置luanch.json启动参数program时, 路径带有空格则启动失败. HOT 1
- Socket 无法通信导致ReGetSockFail HOT 1
- libpdebug.lua找不到是什么原因 HOT 1
- UE5蓝图使用Luajit,在Load的时候会直接崩溃,你们有碰到类似的问题吗? HOT 1
- 关于 lua 5.3/5.4 无法建立连接的问题 HOT 1
- 打开包含大量文件的目录,插件会coredump HOT 3
- 关于Arm架构 lipDebug支持的问题 HOT 1
- 关于在5.4下使用luapanda
- 反转C-S后,内网环境下,远程调试连接不上 HOT 1
- Lua Debug 插件和 LuaPanda 插件 attach 模式会互相冲突,导致无法断点,或者断点失效问题 HOT 1
- 更新到vscode 1.82后,插件报错无法运行 HOT 5
- 使用了distinguishSameNameFile=true,truncatedOPath过滤公共串后,同名文件正则识别错误(没有处理"["、"]") HOT 2
- 没有 用于IntlliSense的cpp 菜单 HOT 2
- 希望在独立脚本执行的lanuch配置中,可以使用args的参数 HOT 3
- 打开LuaPanda会出现这个问题 Connection to server got closed. Server will not be restarted. HOT 1
- F12 not work HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from luapanda.