stage0 支持类gdb的调试vm手段

This commit is contained in:
zzy
2026-08-06 09:11:15 +08:00
parent ca7cf221c8
commit a56b4cbb70
6 changed files with 783 additions and 47 deletions

View File

@@ -28,9 +28,12 @@ typedef struct {
uintptr_t cp; // call pointer
uintptr_t ip; // instr pointer
int exit_code;
int trace; /* non-zero to print each instruction */
int debug; /* non-zero to enable canary checks */
int debug_addr; /* non-zero to check for low-address memory access */
int trace; /* non-zero to print each instruction */
int debug; /* non-zero to enable canary checks */
int debug_addr; /* non-zero to check for low-address memory access */
int skip_bp; /* non-zero: run_once 忽略下一次断点continue 越过当前断点指令) */
VEC(usize) breakpoints; /* ip 断点执行到该指令前暂停run_once 返回 2 */
VEC(char *) fn_breakpoints; /* 函数名断点CALL/CALLI 目标函数入口暂停) */
spl_prog_t *prog;
char error_msg[1024];
struct {
@@ -61,6 +64,13 @@ void spl_vm_set_debug(spl_vm_t *vm, int enabled);
int spl_vm_run_once(spl_vm_t *vm);
int spl_vm_run_until(spl_vm_t *vm, size_t step);
/* 断点ip 断点 / 函数名断点CALL/CALLI 目标函数入口)。命中时 run_once 返回 2。 */
void spl_vm_add_breakpoint(spl_vm_t *vm, usize ip);
void spl_vm_add_breakpoint_fn(spl_vm_t *vm, const char *name);
void spl_vm_clear_breakpoints(spl_vm_t *vm);
/* 让 run_once 执行当前指令忽略一次断点命中continue 越过当前断点用 */
void spl_vm_skip_breakpoint(spl_vm_t *vm);
void spl_vm_dump_instr(spl_vm_t *vm, spl_val_t ip);
void spl_vm_stackdump(spl_vm_t *vm, spl_val_t sp);
int spl_vm_backtrace(spl_vm_t *vm, spl_val_t fp);