fix(traceback): 从 temp_dir 扫描 .vpi 定位 traceback 模块

sig_files 可能不含 include 的 .vpi;改为直接扫描 temp_dir/*.vpi 匹配 'Module: traceback',确保 main 模块拿到 Install 符号。
This commit is contained in:
TermiNexus committed 2026-10-19 18:34:34 +08:00
1 parent 2beb5d724f
commit d02e6f21e3
1 file changed
+21 -14
+21 -14
View File
@@ -2358,21 +2358,28 @@ class Phase2Translator:
# 直接调用它(不依赖 .ctors/.init_array,避免 MinGW 下 .ctors.65534 不执行)。
if self.traceback_enabled:
_tb_sha1: str | None = None
for _k, _p in self.sig_files.items():
try:
if 'traceback' in os.path.basename(_p):
_tb_sha1 = _k
break
if 'Module: traceback' in _ReadTextCached(_p)[:512]:
_tb_sha1 = _k
break
except Exception:
continue
_temp_vpi: str = getattr(self, 'temp_dir', '') or ''
if _temp_vpi and os.path.isdir(_temp_vpi):
for _fn in os.listdir(_temp_vpi):
if not _fn.endswith('.vpi'):
continue
try:
if 'Module: traceback' in _ReadTextCached(os.path.join(_temp_vpi, _fn))[:512]:
_tb_sha1 = _fn[:-4]
break
except Exception:
continue
if _tb_sha1 is None:
for _k, _p in getattr(self, '_shared_source_module_sig_files', {}).items():
if 'traceback' in str(_p):
_tb_sha1 = _k
break
for _k, _p in self.sig_files.items():
try:
if 'traceback' in os.path.basename(_p):
_tb_sha1 = _k
break
if 'Module: traceback' in _ReadTextCached(_p)[:512]:
_tb_sha1 = _k
break
except Exception:
continue
trans.translator.TracebackEnabled = self.traceback_enabled
if _tb_sha1 is not None:
trans.translator.TracebackInstallSymbol = f'{_tb_sha1}.Install'