debug(exprgenattr): 字段查找 arg/func 时打印 attr/类型/索引/实际字段名,定位 Thread.arg 索引错解析成 func(3) 根因

This commit is contained in:
TermiNexus committed 2026-08-26 23:40:22 +08:00
1 parent d8286295d1
commit d082bb3996
1 file changed
+12
+12
View File
@@ -789,6 +789,18 @@ class ExprGenAttr(ExprGenBase.ExprGenBase):
# 查找字段索引和类型
field_info: GenTypes.FieldEntry | t.CPtr = self.Gen.StructGen.lookup_field(
struct_ty, at.attr)
# [GAP-DIAG] 定位 th.arg=arg 字段索引错(func/arg 都解析成 3)根因:
# 打印字段名/结构体类型名/查到的索引与实际字段名
if field_info is not None \
and (string.strcmp(at.attr, "arg") == 0 or string.strcmp(at.attr, "func") == 0):
dbg_gap: str = pool.alloc(200)
if dbg_gap is not None:
ty_nm_gap: str = self.Gen.StructGen._extract_struct_name(struct_ty)
if ty_nm_gap is None:
ty_nm_gap = "?"
viperlib.snprintf(dbg_gap, 200, "[GAP] attr=%s ty=%s idx=%d fe_name=%s\n",
at.attr, ty_nm_gap, field_info.Index, field_info.Name)
stdio.printf("%s", dbg_gap)
# REnum 变体字段查找: lookup_field 失败时,尝试 REnum 别名
# REnum 结构体字段名是 _p1/_p2/...,但源码用变体字段名访问(如 ty.Pointee)
if field_info is None: