维护基线
This commit is contained in:
1 parent
b51faef1cb
commit
2b4679073e
3 files changed
+27
-9
No files matched your search
@@ -298,6 +298,26 @@ _RE_DEFINE_HEAD: re.Pattern[str] = re.compile(
|
||||
_RE_DEFINE_LINE: re.Pattern[str] = re.compile(r'^define ', re.MULTILINE)
|
||||
|
||||
|
||||
def _SourceHasRealDef(src_path: str) -> bool:
|
||||
"""模块是否含有真正的 `def`(而不是只有 `extern def`)。
|
||||
|
||||
extern-only 模块(如 includes/win32/win32console.vp)里的 define 是编译器合成的转发体,
|
||||
没有源级函数体,本来就不会有 DWARF 行表;对它们发 "--traceback 未携带 DWARF" 属于误报。
|
||||
读不到源码时返回 True,保持旧行为(宁可多提示,不漏提示)。
|
||||
"""
|
||||
try:
|
||||
content, _ = parse_python_file(src_path)
|
||||
except Exception:
|
||||
return True
|
||||
if not content:
|
||||
return True
|
||||
for raw in content.splitlines():
|
||||
s: str = raw.lstrip()
|
||||
if s.startswith('def ') or s.startswith('async def '):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def _ParseDwarfLineRows(dump_text: str) -> list[tuple[int, str, int]]:
|
||||
"""从 llvm-dwarfdump 输出解析出 [(地址, 文件绝对路径, 行号)]。
|
||||
|
||||
@@ -3869,7 +3889,8 @@ class Phase2Translator:
|
||||
# (由 extern/sugar 派生、无 .vp 函数体),本就不会有源级 DI —— 按 fail-fast
|
||||
# 报错会把这类模块全部误杀;而"行号缺失"只降低可读性,不是编译正确性问题。
|
||||
if self.traceback_enabled and _RE_DEFINE_LINE.search(ll_content) \
|
||||
and '!llvm.dbg.cu' not in ll_content:
|
||||
and '!llvm.dbg.cu' not in ll_content \
|
||||
and _SourceHasRealDef(src_path):
|
||||
_vlog().warning(
|
||||
f"--traceback: include 模块 {module_name}.py 发射了 define 但 IR 未携带 "
|
||||
f"DWARF (!llvm.dbg.cu)——该模块内联帧在 Ctrl+C 栈里将只显示地址: {ll_path}")
|
||||
|
||||
Reference in new issue
Block a user