debug(tpv): 临时诊断定位 SECURITY_ATTRIBUTES 空类注册来源

- register_struct/add_field 打印 [DBG-EMP](SECURITY_ATTRIBUTES 过滤)
- ClassGenDef 空类报错改为 pending + 打印(定位期间不中断编译)
- 定位后移除
This commit is contained in:
TermiNexus committed 2026-08-29 08:42:26 +08:00
1 parent 7b81e3c7cf
commit 0a84ca8db3
2 files changed
+16 -5

No files matched your search

+7 -5
View File
@@ -85,11 +85,13 @@ class ClassGenDef(ClassGenBase.ClassGenBase):
# 仅当"类体声明了字段但 FieldCount==0"才算注册不完整(Phase A-pre 漏注册)。
if existing.FieldCount == 0 and trans._declare_only == 0:
if self.Gen.ClassGenBase._class_body_has_field(cd) != 0:
# Phase B 时字段数为 0 说明注册不完整(Phase A-pre 可能漏注册)
self.Gen.TypeGenErr.fatal_error(
node,
f"结构体已注册但字段数为0,类: {class_name},可能注册不完整",
"InternalCompilerError")
# [DBG-EMP] 临时诊断:定位空类注册来源(win32base SECURITY_ATTRIBUTES)。
# 报错期间改为 pending 延迟(不 fatal 中断多遍收敛),配合
# register_struct/add_field 的 [DBG-EMP] 打印定位谁注册了空类。
VLogger.info(f"[DBG-EMP] class={class_name} FC=0 ty={t.CUInt64T(existing.Ty)} 类体有字段", "DBG")
if trans is not None:
trans._deps_pending = 1
return 0
# 结构体已注册(Phase A-pre 多遍扫描或 Phase B 重新翻译),但仍需在当前模块中翻译方法
if existing.Ty is not None:
# Phase 1b(declare_only=0):existing.Ty 是 Phase 1a 注册的 struct_ty,
+9
View File
@@ -221,6 +221,12 @@ class StructGenMixin:
entry.Ty = struct_ty
entry.FieldCount = 0
# [DBG-EMP] 临时诊断:定位空类注册来源(win32base SECURITY_ATTRIBUTES)
if name is not None and string.strstr(name, "SECURITY_ATTRIBUTES") is not None:
sha1_s: str = "?"
if sha1 is not None:
sha1_s = sha1
VLogger.info(f"[DBG-REG] {name} sha1={sha1_s} Ty={t.CUInt64T(struct_ty)}", "DBG")
# 注册时直接设置 SHA1(避免 set_struct_sha1 跨模块同名时找错 entry)
# SHA1 同样按 StdlibAlloc 选分配源(跨 1a/1b 存活,防 strcmp 悬空)
@@ -351,6 +357,9 @@ class StructGenMixin:
return -1
idx: int = struct_entry.FieldCount
# [DBG-EMP] 临时诊断:定位空类字段添加(win32base SECURITY_ATTRIBUTES)
if struct_entry.Name is not None and string.strstr(struct_entry.Name, "SECURITY_ATTRIBUTES") is not None:
VLogger.info(f"[DBG-ADDF] {struct_entry.Name} field={field_name} idx={idx}", "DBG")
fe: GenTypes.FieldEntry | t.CPtr = self._get_field_entry(struct_entry, idx)
if fe is None:
return -1