新增 syntaxCompatibility 配置项:显式指定使用调试目标解释器解析源码 - #358
Open
sumneko wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The new dump/error-propagation and undump paths can mask real syntax errors and can throw on unsupported bytecode formats without graceful handling, which risks breaking breakpoint calculation.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds an opt-in syntaxCompatibility launch configuration to improve breakpoint line mapping when the debug target uses non-default Lua syntax, by optionally compiling/dumping via the target VM; also fixes a Lua 5.5 undump string-cache retention issue to avoid cross-call leakage.
Changes:
- Introduces
syntaxCompatibilityconfig plumbing (schema + i18n) and propagates it into breakpoint line-info parsing. - Restores an
eval.dump-based path to obtain dumped bytecode for line-info generation. - Resets
undump55’s internal string cache per invocation to prevent memory growth and index mismatches across parses.
File summaries
| File | Description |
|---|---|
| extension/script/backend/worker/undump.lua | Resets Lua 5.5 undump string cache per call to avoid cross-parse cache corruption/leaks. |
| extension/script/backend/worker/parser.lua | Adds optional target-VM dumping path for syntax compatibility during line-info generation. |
| extension/script/backend/worker/eval/dump.lua | New helper chunk used to compile + dump source content. |
| extension/script/backend/worker/eval.lua | Adds eval.dump generator that loads/executes the dump helper via local or target VM mechanisms. |
| extension/script/backend/worker/breakpoint.lua | Reads config.syntaxCompatibility and passes it into the parser; resets on termination. |
| extension/package.nls.json | Adds localized description for the new launch setting. |
| compile/common/package_json.lua | Adds syntaxCompatibility to the generated launch configuration schema. |
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 4
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+45
to
+61
| generate("dump", function() | ||
| if luaver.LUAVERSION <= 52 then | ||
| local compat_dump = assert(load(readfile 'backend.worker.eval.dump')) | ||
| return function(content) | ||
| local res, err = compat_dump(content) | ||
| if res then | ||
| return true, res | ||
| end | ||
| return false, err | ||
| end | ||
| else | ||
| local eval_dump = assert(rdebug.load(readfile 'backend.worker.eval.dump')) | ||
| return function(content) | ||
| return rdebug.eval(eval_dump, content, 0) | ||
| end | ||
| end | ||
| end) |
Comment on lines
+108
to
112
| if not bin then | ||
| local log = require 'common.log' | ||
| log.error("ERROR:"..err) | ||
| log.error("ERROR:"..(err or "unknown error")) | ||
| return | ||
| end |
| "lua.debug.launch.console.integratedTerminal.description": "VS Code integrated terminal.", | ||
| "lua.debug.launch.console.externalTerminal.description": "External terminal that can be configured in user settings.", | ||
| "lua.debug.launch.luaVersion.description": "Default lua version.", | ||
| "lua.debug.launch.syntaxCompatibility.description": "Use the target Lua VM to parse source syntax for breakpoint line information.", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
之前解析文件时只使用默认解释器。如果调试目标使用了自定义语法,那么将会解析失败,导致断点无法生效。
本次改动:
syntaxCompatibility(默认关闭)。开启后使用调试目标的解释器执行load+string.dump,为断点生成行号信息(恢复此前删除的 eval.dump 机制)。undump55的字符串缓存未重置问题:多次解析时缓存跨调用残留,导致内存累积与字符串索引错位。注意:该配置只能解决语法解析问题,无法解决字节码格式不兼容的情况。