Skip to content

解析失败时回退到调试目标解释器 - #357

Closed
sumneko wants to merge 0 commit into
masterfrom
fallback-target-parser
Closed

解析失败时回退到调试目标解释器#357
sumneko wants to merge 0 commit into
masterfrom
fallback-target-parser

Conversation

@sumneko

@sumneko sumneko commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

之前解析文件时只使用默认解释器。如果调试目标使用了自定义语法,那么将会解析失败,导致断点无法生效。
现在如果使用默认解释器解析失败,还会尝试使用调试目标的解释器进行解析。

Copilot AI lite review requested due to automatic review settings September 2, 2026 03:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.dumprdebug.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 if err is nil (which can happen when dumpTarget fails without producing an error string). Use tostring(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
@actboy168

actboy168 commented Sep 2, 2026

Copy link
Copy Markdown
Owner

显式指定一下比较好,此外这只能让语法解析,但是无法解决字节码不兼容的情况。

这个没必要加c++代码,以前有这个,恢复下代码就行 4520a02836d82632bcb655c65471aa63ab25c21f。

@sumneko sumneko closed this Sep 2, 2026
@sumneko
sumneko force-pushed the fallback-target-parser branch from 0a4df88 to d06ba28 Compare September 2, 2026 07:48
@sumneko
sumneko deleted the fallback-target-parser branch September 2, 2026 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants