chore: 清理测试源码 DBG 插桩,.gitignore 忽略 wiki 目录
AstTest/LLvmLiteTest/SysLibTest 移除定位阶段残留的 printf/testcheck 插桩 (DBG1-DBG14),SlotsBugTest 空行清理;.gitignore 追加 /wiki/,TODO 更新。
This commit is contained in:
1 parent
921820b26a
commit
74d32a166c
6 files changed
+4
-32
No files matched your search
@@ -77,3 +77,5 @@ Undo/vmware/
|
||||
**/temp/
|
||||
**/.tpv_build/
|
||||
|
||||
# wiki
|
||||
/wiki/
|
||||
@@ -44,4 +44,4 @@ TPV 避免虚类问题,参见 ast/base.vp:224行
|
||||
TPV 虚类判断问题,参见 ast/parser.vp:2037行
|
||||
|
||||
替换式实现注入猴子,带有含函数指针检测和函数指针还原
|
||||
|
||||
高级 define(时间戳,版本,config项)
|
||||
@@ -171,25 +171,21 @@ class Point:
|
||||
|
||||
printf("Parsing comprehensive source...\n")
|
||||
|
||||
# 解析(临时插桩:拆分 ast.parse 各阶段,定位崩溃点,定位后恢复)
|
||||
# 解析
|
||||
ast._init_tables(pool)
|
||||
printf("DBG1 init_tables done\n")
|
||||
lx_dbg: t.CPtr = ast.new_lexer(pool)
|
||||
if lx_dbg == None:
|
||||
printf("FAIL: new_lexer returned None\n")
|
||||
stdlib.free(pool_mem)
|
||||
stdlib.free(dump_mem)
|
||||
return 1
|
||||
printf("DBG2 new_lexer done\n")
|
||||
ast._lexer_init(lx_dbg, src, pool)
|
||||
printf("DBG3 lexer_init done\n")
|
||||
tokens_dbg: t.CPtr = ast.tokenize(lx_dbg)
|
||||
if tokens_dbg == None:
|
||||
printf("FAIL: tokenize returned None\n")
|
||||
stdlib.free(pool_mem)
|
||||
stdlib.free(dump_mem)
|
||||
return 1
|
||||
printf("DBG4 tokenize done\n")
|
||||
tree: ast.AST | t.CPtr = ast.parse_tokens(pool, tokens_dbg)
|
||||
if tree == None:
|
||||
printf("FAIL: parse returned None\n")
|
||||
|
||||
@@ -97,50 +97,36 @@ def test_build_add(pool: memhub.MemPool | t.CPtr):
|
||||
core: llvmlite.LLVMTypeCore | t.CPtr = llvmlite.LLVMTypeCore(pool)
|
||||
mcore: llvmlite.LLVMModuleCore | t.CPtr = llvmlite.LLVMModuleCore(pool)
|
||||
ty_i32: llvmlite.LLVMType | t.CPtr = core.Int32()
|
||||
testcheck.info("DBG: step1 core/ty_i32 ok")
|
||||
|
||||
# 创建模块 + 函数
|
||||
mod: llvmlite.Module | t.CPtr = mcore.NewModule("test_add")
|
||||
testcheck.info("DBG: step2 NewModule ok")
|
||||
func: llvmlite.Function | t.CPtr = mcore.CreateFunction(mod, "add", ty_i32)
|
||||
testcheck.info("DBG: step3 CreateFunction ok")
|
||||
|
||||
# 添加参数
|
||||
mcore.AddParam(func, ty_i32, "%a")
|
||||
testcheck.info("DBG: step4 AddParam a ok")
|
||||
mcore.AddParam(func, ty_i32, "%b")
|
||||
testcheck.info("DBG: step5 AddParam b ok")
|
||||
|
||||
# 创建 entry 块
|
||||
entry: llvmlite.BasicBlock | t.CPtr = mcore.CreateBlock(func, "entry")
|
||||
testcheck.info("DBG: step6 CreateBlock ok")
|
||||
|
||||
# 创建 builder
|
||||
builder: llvmlite.IRBuilder | t.CPtr = mcore.NewBuilder(func)
|
||||
testcheck.info("DBG: step7 NewBuilder ok")
|
||||
llvmlite.position_at_end(builder, entry)
|
||||
testcheck.info("DBG: step8 position_at_end ok")
|
||||
|
||||
# 为参数创建 Value 包装
|
||||
v_a: llvmlite.Value | t.CPtr = mcore.SSAValue(ty_i32, "%a")
|
||||
testcheck.info("DBG: step9 SSAValue a ok")
|
||||
v_b: llvmlite.Value | t.CPtr = mcore.SSAValue(ty_i32, "%b")
|
||||
testcheck.info("DBG: step10 SSAValue b ok")
|
||||
|
||||
# %0 = add i32 %a, %b
|
||||
v_c: llvmlite.Value | t.CPtr = llvmlite.build_add(builder, v_a, v_b)
|
||||
testcheck.info("DBG: step11 build_add ok")
|
||||
|
||||
# ret i32 %0
|
||||
llvmlite.build_ret(builder, v_c)
|
||||
testcheck.info("DBG: step12 build_ret ok")
|
||||
|
||||
# 打印函数
|
||||
buf: t.CChar | t.CPtr = pool.alloc(4096)
|
||||
testcheck.info("DBG: step13 pool.alloc buf ok")
|
||||
buf[0] = 0
|
||||
mcore.PrintFunction(buf, 4096, func)
|
||||
testcheck.info("DBG: step14 PrintFunction ok")
|
||||
testcheck.info(buf)
|
||||
|
||||
# 验证关键内容
|
||||
|
||||
@@ -15,6 +15,5 @@ class Result:
|
||||
self.count_node: ast.AST | t.CPtr = count
|
||||
self.is_pointer: bool = flag
|
||||
|
||||
|
||||
def main() -> int:
|
||||
return 0
|
||||
@@ -34,41 +34,30 @@ TEST_MOVE: t.CDefine = "__sylibtest_moved.txt"
|
||||
|
||||
def _cleanup():
|
||||
"""清理可能残留的测试文件/目录"""
|
||||
testcheck.info("DBG: cleanup start")
|
||||
if os_backend.os_exists(TEST_DIR):
|
||||
testcheck.info("DBG: cleanup rmdir TEST_DIR")
|
||||
os.rmdir(TEST_DIR)
|
||||
testcheck.info("DBG: cleanup after TEST_DIR")
|
||||
if os_backend.os_exists(TEST_FILE):
|
||||
os_backend.os_remove(TEST_FILE)
|
||||
testcheck.info("DBG: cleanup after TEST_FILE")
|
||||
if os_backend.os_exists(TEST_COPY):
|
||||
os_backend.os_remove(TEST_COPY)
|
||||
testcheck.info("DBG: cleanup after TEST_COPY")
|
||||
if os_backend.os_exists(TEST_MOVE):
|
||||
os_backend.os_remove(TEST_MOVE)
|
||||
testcheck.info("DBG: cleanup after TEST_MOVE")
|
||||
if os_backend.os_exists(TEST_TREE):
|
||||
testcheck.info("DBG: cleanup rmtree TEST_TREE")
|
||||
shutil.rmtree(TEST_TREE)
|
||||
testcheck.info("DBG: cleanup done")
|
||||
|
||||
|
||||
def run() -> CInt:
|
||||
buf: bytes = stdlib.malloc(512)
|
||||
|
||||
testcheck.begin("SysLibTest: 系统兼容层库测试")
|
||||
testcheck.info("DBG: after begin")
|
||||
|
||||
# 清理残留
|
||||
_cleanup()
|
||||
testcheck.info("DBG: after cleanup")
|
||||
|
||||
# =============================================================================
|
||||
# 全局 MBuddy 初始化验证(在 main 中已初始化)
|
||||
# =============================================================================
|
||||
testcheck.section("全局 MBuddy 初始化验证")
|
||||
testcheck.info("DBG: after section")
|
||||
|
||||
testcheck.check(os._mbuddy != None, "os._mbuddy initialized OK", "os._mbuddy NOT initialized")
|
||||
testcheck.check(sys._mbuddy != None, "sys._mbuddy initialized OK", "sys._mbuddy NOT initialized")
|
||||
|
||||
Reference in new issue
Block a user