From be2521fe46ea6aeba6bcf1a6b81dfc742eb512e3 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Fri, 9 Oct 2026 10:08:43 +0800 Subject: [PATCH] =?UTF-8?q?chore(dbg):=20=E4=B8=B4=E6=97=B6=E9=98=B6?= =?UTF-8?q?=E6=AE=B5=E6=97=A5=E5=BF=97=E5=AE=9A=E4=BD=8D=20Phase=20A=20?= =?UTF-8?q?=E5=B4=A9=E6=BA=83=E7=82=B9=EF=BC=88=E5=AE=9A=E4=BD=8D=E5=90=8E?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 四个探针:PhaseA translating / vpi.gen / TR.enter sha1 / TR.prelude.done。用于把崩溃点夹在 解析→vpi生成→模块前言→函数体翻译 四段之间。 --- App/lib/Phase/Phase2/__init__.vp | 2 ++ App/lib/Stub/StubGen/Converter.vp | 6 ++++-- App/lib/core/Gen/Translator.vp | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/App/lib/Phase/Phase2/__init__.vp b/App/lib/Phase/Phase2/__init__.vp index 2134031..b17bec2 100644 --- a/App/lib/Phase/Phase2/__init__.vp +++ b/App/lib/Phase/Phase2/__init__.vp @@ -840,6 +840,8 @@ def RunMultiFileProject(mb: memhub.MemBuddy*, source_dir: str, temp_dir: str, ou done_flags[i] = 1 completed_this_pass += 1 continue + # [TEMP dbg] 阶段日志:定位 Phase A 崩溃点(定位后移除) + VLogger.info(f"PhaseA translating: {ent.Path}", "PhaseA") # Compute the package name (the directory part relative to source_dir) src_dir_len_pa: sizet = string.strlen(source_dir) pkg_pa: str = None diff --git a/App/lib/Stub/StubGen/Converter.vp b/App/lib/Stub/StubGen/Converter.vp index 79962c7..d56bf24 100644 --- a/App/lib/Stub/StubGen/Converter.vp +++ b/App/lib/Stub/StubGen/Converter.vp @@ -659,8 +659,10 @@ def _PyiClass(buf: bytes, buf_size: sizet, pos: sizet, cls: ast.ClassDef*, inden # _GeneratePyiFromAst - walk the AST Module and emit .vpi stub content into buf. # Returns bytes written (0 on failure); rel_path should be absolute for error attribution. -def _GeneratePyiFromAst(mb: memhub.MemBuddy*, tree: ast.AST*, rel_path: str, buf: bytes, buf_size: sizet) -> sizet: - """Generate .vpi stub content from an AST into buf""" +def _GeneratePyiFromAst(mb: memhub.MemBuddy*, tree: ast.AST*, rel_path: str, buf: bytes, buf_size: sizet) -> sizet: + """Generate .vpi stub content from an AST into buf""" + # [TEMP dbg] 阶段日志:进入 vpi 生成(定位崩溃点,定位后移除) + VLogger.info(f"vpi.gen: {rel_path}", "StubGen") if tree is None or buf is None or buf_size == 0: return 0 # Error attribution: point "current file" at the file being stubbed. Callers must pass diff --git a/App/lib/core/Gen/Translator.vp b/App/lib/core/Gen/Translator.vp index 673a146..6349d3a 100644 --- a/App/lib/core/Gen/Translator.vp +++ b/App/lib/core/Gen/Translator.vp @@ -381,6 +381,8 @@ novirtual class Translator: """Translate the AST into LLVM IR.""" if tree is None: return 1 if _mbuddy is None: return 1 + # [TEMP dbg] 阶段日志:定位崩溃点(定位后移除) + VLogger.info(f"TR.enter sha1={self.ModuleSha1}", "TR") pool: memhub.MemBuddy* = _mbuddy @@ -453,6 +455,8 @@ novirtual class Translator: # (现场:Test/NewLifetimeTest 未 import stdlib,拿不到 stdlib vpi 的 declare)。 free_func: mlirlite.Function* = mlirlite.create_declare(decl_pool, mod, "free", void_ty_decl) if free_func is not None: mlirlite.add_param(decl_pool, free_func, i8_ptr_ty, "p") + # [TEMP dbg] 阶段日志:模块前言完成(定位崩溃点,定位后移除) + VLogger.info("TR.prelude.done", "TR") # Check whether the user defined a main function has_user_main: int = 0