chore(tpc): 移除全部临时 DBG 日志 - VDBG(ExprGenMixin)/CTORDBG(CallGenCtor)/LISTDBG(_list)/ALLOCDBG+set/get_debug_log+set/get_alloc_src(memhub)/CLDBG+[DEPDBG](CallGenMixin)/--enable-debug-log(main)/set_alloc_src(HandlesTranslator);保留 detection 机制(前后 0xCDCD 标记+记录表探测)与 MEMBUDDY_FILL_GUARD 守卫

This commit is contained in:
TermiNexus committed 2026-08-25 15:17:51 +08:00
1 parent 769ffda04f
commit 1de7c8d2ca
7 files changed
+1911 -76

No files matched your search

-16
View File
@@ -42,27 +42,11 @@ class list[T]:
self.__elem_size__ = elem_size
self.__data__ = pool.alloc(self.__capacity__ * self.__elem_size__)
self.__iter_index__ = 0
# [LISTDBG] 诊断(用后移除):打印初始化结果,与 CTORDBG cargs 六字段
# 交叉匹配:找到 cargs 对应记录即可判断 __init__ 是否执行/写入是否正确
if memhub.get_debug_log() != 0:
stdio.printf("[LISTDBG] list-init self=%llu data=%llu cnt=%llu cap=%llu pool=%llu es=%llu iter=%llu\n",
t.CUInt64T(self), t.CUInt64T(self.__data__),
t.CUInt64T(self.__count__), t.CUInt64T(self.__capacity__),
t.CUInt64T(self.__pool__), t.CUInt64T(self.__elem_size__),
t.CUInt64T(self.__iter_index__))
def __len__(self) -> t.CSizeT:
return self.__count__
def append(self, item: T):
# [LISTDBG] 诊断(用后移除):仅首次 append(Count==0)打印,确认
# append 作用在哪个 list、Data 指针是否有效(若 cargs 覆盖发生在此
# 前后,日志能显示 append 的 self/data 与 CTORDBG cargs/d0 的对应)
if memhub.get_debug_log() != 0 and self.__count__ == 0:
stdio.printf("[LISTDBG] append-first self=%llu data=%llu cnt=%llu cap=%llu es=%llu\n",
t.CUInt64T(self), t.CUInt64T(self.__data__),
t.CUInt64T(self.__count__), t.CUInt64T(self.__capacity__),
t.CUInt64T(self.__elem_size__))
if self.__count__ >= self.__capacity__:
new_cap: t.CSizeT = self.__capacity__ * 2
new_data: t.CPtr = self.__pool__.alloc(new_cap * self.__elem_size__)
-31
View File
@@ -54,30 +54,6 @@ def _canary_pattern() -> t.CUInt64T:
lo: t.CUInt64T = t.CUInt64T(0xA5A5A5A5)
return (lo << 32) | lo
# [LISTDBG] 调试日志全局开关(默认关;命令行 --enable-debug-log 开启):
# list.__init__/append 的诊断 printf 输出量大,默认静默,仅排查时开启
_g_debug_log: int = 0
def set_debug_log(flag: int) -> None:
"""设置调试日志开关(1=开启 LISTDBG 诊断输出)"""
global _g_debug_log
_g_debug_log = flag
def get_debug_log() -> int:
"""读取调试日志开关(0=关,1=开)"""
return _g_debug_log
# [ALLOCDBG] 分配者记录:当前正在翻译的文件 sha1(Phase1Main/Translator
# 每文件翻译前设置)。alloc size==48(list 对象大小)且 --enable-debug-log
# 开启时打印块地址+src,定位"未走 list.__init__ 的异常 list"创建者
# (SlotsBugTest KwEntry cargs 只写 Data/IterIndex 的块归属)。
_g_alloc_src: str = None
def set_alloc_src(src: str) -> None:
"""设置当前翻译文件 sha1(alloc 分配者记录用)"""
global _g_alloc_src
_g_alloc_src = src
def _align_up(val: t.CSizeT, align: t.CSizeT) -> t.CSizeT:
if align == 0: return val
return (val + align - 1) & ~(align - 1)
@@ -650,13 +626,6 @@ class MemBuddy(MemManager):
fill_size: t.CSizeT = bs - MEMBUDDY_HEADER_SIZE - MEMBUDDY_CANARY
if fill_size > 0:
string.memset(result, MEMBUDDY_FILL_PATTERN, fill_size)
# [ALLOCDBG] 分配者记录:size==48(list 对象)且 --enable-debug-log
# 开启时打印 chk_stack 序号+块地址+当前翻译文件 src。序号与
# CTORDBG 的 cargs_in_block=idx 匹配 → 精确定位未走
# list.__init__ 的异常 list(如 KwEntry cargs)的分配点。
if get_debug_log() != 0 and size == 48:
stdio.printf("[ALLOCDBG] alloc48 idx=%zu block=%llu ret=%llu src=%s\n",
self.chk_depth, t.CUInt64T(block), t.CUInt64T(result), _g_alloc_src)
# 记录到 checkpoint 栈(供 reset_to 回收)
# 栈满时 stdlib.realloc 翻倍扩容(防爆满后记录缺失
# → reset 不回收 + _is_valid_ptr 栈校验退化的连锁问题)