diagnose(tpv): Phase A 依赖探针别名解析修复 + ClassGenDef/MatchGenMixin 崩溃定位诊断
- Phase2 PhaseA-DBG 探针:精确匹配失败后后缀匹配(别名=基名如 GenTypes→lib.core.Gen.GenTypes),t/c 内置模块跳过,改名别名标'未解析'而非'缺失',消息头改'依赖探测明细' - ClassGenDef 两个 _deps_pending 置位点加 [PHASEADBG] 打印(父类未注册 class/parent、字段注解未解析 class/field/annot_kind) - MatchGenMixin _handle_renum_match 加 [MATCHDBG] 打印(renum 元信息 + 第一/二遍 case 列表快照对比,定位 REnum match 崩溃的列表破坏点)
This commit is contained in:
1 parent
0ffe99e722
commit
60afcf1168
3 files changed
+50
-8
No files matched your search
@@ -735,34 +735,47 @@ def RunMultiFileProject(mb: memhub.MemBuddy | t.CPtr,
|
||||
continue
|
||||
string.strncpy(im_dp_buf, tr_a._imported_modules + im_dp_start, im_dp_mod_len)
|
||||
im_dp_buf[im_dp_mod_len] = '\0'
|
||||
# 别名/基名解析:精确匹配 → 后缀匹配(import X as Y 且 Y==X 基名时命中,
|
||||
# 如 GenTypes → lib.core.Gen.GenTypes;改名别名如 HT→HandlesTranslator 不命中)
|
||||
im_dp_sha1: str = StubMergerStore.LookupSha1ByModName(im_dp_buf)
|
||||
im_dp_missing: int = 1
|
||||
if im_dp_sha1 is None:
|
||||
im_dp_sha1 = StubMergerStore.LookupSha1ByModNameSuffix(im_dp_buf)
|
||||
im_dp_resolved: int = 0
|
||||
im_dp_missing: int = 0
|
||||
if im_dp_sha1 is not None:
|
||||
im_dp_resolved = 1
|
||||
im_dp_txt: str = StubMergerCollect._sliced_path(
|
||||
temp_dir, td_len_pa, im_dp_sha1, "text.ll")
|
||||
if im_dp_txt is not None:
|
||||
im_dp_f: fileio.File | t.CPtr = fileio.File(im_dp_txt, fileio.MODE.R)
|
||||
if not im_dp_f.closed:
|
||||
if im_dp_f.closed:
|
||||
im_dp_missing = 1
|
||||
else:
|
||||
im_dp_f.close()
|
||||
im_dp_missing = 0
|
||||
stdlib.free(im_dp_txt)
|
||||
if im_dp_missing != 0:
|
||||
else:
|
||||
im_dp_missing = 1
|
||||
else:
|
||||
# 内置模块(t/c)不生成 text.ll,解析不到不算缺失
|
||||
if string.strcmp(im_dp_buf, "t") == 0 or string.strcmp(im_dp_buf, "c") == 0:
|
||||
im_dp_resolved = 2
|
||||
if im_dp_missing != 0 or im_dp_resolved == 0:
|
||||
if md_cnt > 0 and string.strlen(miss_dp) < 700:
|
||||
string.strcat(miss_dp, ", ")
|
||||
if string.strlen(miss_dp) < 700:
|
||||
if im_dp_sha1 is not None:
|
||||
if im_dp_missing != 0:
|
||||
viperlib.snprintf(miss_dp + string.strlen(miss_dp),
|
||||
768 - string.strlen(miss_dp),
|
||||
"%s(%s)", im_dp_buf, im_dp_sha1)
|
||||
"%s(%s)缺text.ll", im_dp_buf, im_dp_sha1)
|
||||
else:
|
||||
viperlib.snprintf(miss_dp + string.strlen(miss_dp),
|
||||
768 - string.strlen(miss_dp),
|
||||
"%s(sha1?)", im_dp_buf)
|
||||
"%s(未解析-改名别名?)", im_dp_buf)
|
||||
md_cnt += 1
|
||||
stdlib.free(im_dp_buf)
|
||||
if md_cnt > 0:
|
||||
viperlib.snprintf(fb_dp, 1024,
|
||||
"Phase A 依赖未就绪,下遍重试: %s | 缺失 text.ll 的直接依赖: %s",
|
||||
"Phase A 依赖未就绪,下遍重试: %s | 依赖探测明细: %s",
|
||||
ent.Path, miss_dp)
|
||||
else:
|
||||
viperlib.snprintf(fb_dp, 1024,
|
||||
|
||||
@@ -228,6 +228,8 @@ class ClassGenDef(ClassGenBase.ClassGenBase):
|
||||
# L422-426 / FuncGenMixin L482-483),不致命,本遍文件不写盘。
|
||||
if trans is not None:
|
||||
trans._deps_pending = 1
|
||||
# [PHASEADBG] 临时诊断:父类未注册即 pending 的根因(用后移除)
|
||||
stdio.printf("[PHASEADBG] 父类未注册: class=%s parent=%s\n", class_name, pname)
|
||||
return 0
|
||||
pfc: int = parent_entry.FieldCount
|
||||
for pfi in range(pfc):
|
||||
@@ -362,6 +364,12 @@ class ClassGenDef(ClassGenBase.ClassGenBase):
|
||||
# 翻译: <file>,请检查依赖模块是否已编译/注册"),不静默掩盖。
|
||||
if trans is not None:
|
||||
trans._deps_pending = 1
|
||||
# [PHASEADBG] 临时诊断:字段注解类型未解析即 pending 的根因(用后移除)
|
||||
dbg_ak: t.CInt = -1
|
||||
if aa.annotation is not None:
|
||||
dbg_ak = aa.annotation.kind()
|
||||
stdio.printf("[PHASEADBG] 字段类型未解析: class=%s field=%s annot_kind=%d\n",
|
||||
class_name, tgt.id, dbg_ak)
|
||||
return 0
|
||||
# 旧行为:fast-fail NameError(已移除——Phase A 依赖未就绪时
|
||||
# 误报真实错误,中断多遍收敛;真实错误交给收敛检查兜底)
|
||||
|
||||
@@ -5,6 +5,7 @@ from stdint import *
|
||||
import ast
|
||||
import llvmlite
|
||||
import memhub
|
||||
import stdio
|
||||
import string
|
||||
import viperlib
|
||||
import lib.core.Handles.HandlesTranslator as HT
|
||||
@@ -364,6 +365,11 @@ class MatchGenMixin:
|
||||
self.Gen.TypeGenErr.fatal_error(node, "match cases 缺失", "TypeError")
|
||||
case_count: t.CSizeT = len(cases_list)
|
||||
|
||||
# [MATCHDBG] 临时诊断:match 元信息(对比崩溃对应文件/语句;用后移除)
|
||||
stdio.printf("[MATCHDBG] renum_match node=%llx renum=%s subject=%llx cases=%llx count=%zu\n",
|
||||
t.CUInt64T(node), renum_name, t.CUInt64T(subject_ptr),
|
||||
t.CUInt64T(cases_list), case_count)
|
||||
|
||||
# BB 指针数组、case 值指针数组、default 标记数组、nobreak 标记数组
|
||||
bb_arr: t.CSizeT | t.CPtr = pool.alloc(8 * MAX_MATCH_CASES)
|
||||
cv_arr: t.CSizeT | t.CPtr = pool.alloc(8 * MAX_MATCH_CASES)
|
||||
@@ -448,6 +454,17 @@ class MatchGenMixin:
|
||||
body_list: list[ast.AST | t.CPtr] | t.CPtr = mc.children
|
||||
nb: int = self._has_no_break(body_list)
|
||||
|
||||
# [MATCHDBG] 临时诊断:第一遍记录 case 快照(对比第二遍,定位列表破坏点;用后移除)
|
||||
dbg_bl_len: t.CInt = -1
|
||||
dbg_first0: t.CSizeT = 0
|
||||
if body_list is not None:
|
||||
dbg_bl_len = t.CInt(len(body_list))
|
||||
if dbg_bl_len > 0:
|
||||
dbg_first0 = t.CUInt64T(body_list.get(0))
|
||||
stdio.printf("[MATCHDBG] pass1 i=%d mc=%llx pat=%llx children=%llx len=%d data0=%llx\n",
|
||||
i, t.CUInt64T(mc), t.CUInt64T(pat),
|
||||
t.CUInt64T(body_list), dbg_bl_len, dbg_first0)
|
||||
|
||||
# 存入数组
|
||||
if collected < MAX_MATCH_CASES:
|
||||
bb_arr[collected] = t.CSizeT(bb)
|
||||
@@ -524,6 +541,10 @@ class MatchGenMixin:
|
||||
bi: int = 0
|
||||
while bi < bc:
|
||||
stmt: ast.AST | t.CPtr = body_list.get(bi)
|
||||
# [MATCHDBG] 临时诊断:第二遍逐条打印(对比 pass1 快照;用后移除)
|
||||
stdio.printf("[MATCHDBG] pass2 i=%d bi=%d bc=%zu mc=%llx children=%llx stmt=%llx\n",
|
||||
i, bi, bc, t.CUInt64T(mc),
|
||||
t.CUInt64T(body_list), t.CUInt64T(stmt))
|
||||
if stmt is not None:
|
||||
self.Gen.StmtGen.translate_stmt(trans, stmt)
|
||||
bi = bi + 1
|
||||
|
||||
Reference in new issue
Block a user