解析失败时回退到调试目标解释器 - #357
Closed
sumneko wants to merge 0 commit into
Closed
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
当前新增的目标侧 dump 路径在 string.dump 不可用/被覆盖时可能产生 nil 错误并导致解析器崩溃,需要补齐健壮的空值与错误处理后才能安全合入。
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
该 PR 改进 Worker 侧的源码解析流程:当使用默认解释器 load 解析失败时,改为回退到调试目标进程的解释器进行解析,从而在目标使用自定义语法/改造语法的情况下仍能生成有效的行号映射,避免断点失效。
Changes:
- 在
parser.lua中引入luadebug.visitor,当默认load(content)失败时使用rdebug.load(content)在目标解释器中编译。 - 通过在目标进程中调用
string.dump(rdebug.eval)获取字节码,再走现有undump+ 行号归一化流程生成lineinfo。
File summaries
| File | Description |
|---|---|
| extension/script/backend/worker/parser.lua | 增加“默认解析失败则回退到目标解释器解析并 dump”的逻辑,用于提升断点在自定义语法场景下的可用性 |
Review details
Suppressed comments (1)
extension/script/backend/worker/parser.lua:114
log.error("ERROR:"..err)will throw iferrisnil(which can happen whendumpTargetfails without producing an error string). Usetostring(err)and/or a default message to keep error reporting from crashing the parser.
if not bin then
local log = require 'common.log'
log.error("ERROR:"..err)
return
- Files reviewed: 1/1 changed files
- Comments generated: 1
- 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
+88
to
+100
| local function dumpTarget(content) | ||
| local f, err = rdebug.load(content) | ||
| if not f then | ||
| return nil, err | ||
| end | ||
| local stringlib = rdebug.field(rdebug._G, 'string') | ||
| local dump = rdebug.field(stringlib, 'dump') | ||
| local ok, bin = rdebug.eval(dump, f) | ||
| if not ok then | ||
| return nil, bin | ||
| end | ||
| return bin | ||
| end |
Owner
|
显式指定一下比较好,此外这只能让语法解析,但是无法解决字节码不兼容的情况。 这个没必要加c++代码,以前有这个,恢复下代码就行 4520a02836d82632bcb655c65471aa63ab25c21f。 |
sumneko
force-pushed
the
fallback-target-parser
branch
from
September 2, 2026 07:48
0a4df88 to
d06ba28
Compare
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.
之前解析文件时只使用默认解释器。如果调试目标使用了自定义语法,那么将会解析失败,导致断点无法生效。
现在如果使用默认解释器解析失败,还会尝试使用调试目标的解释器进行解析。