stage0 printf的格式化统一 展开strdup

This commit is contained in:
zzy
2026-08-19 21:42:06 +08:00
parent c81a57dacb
commit d6113a5417
2 changed files with 8 additions and 5 deletions

View File

@@ -59,14 +59,14 @@ int main(int argc, const char **argv) {
/* annotate jumps / calls */ /* annotate jumps / calls */
if (ins->opcode == SPL_JMP || ins->opcode == SPL_BZ || ins->opcode == SPL_BNZ) { if (ins->opcode == SPL_JMP || ins->opcode == SPL_BZ || ins->opcode == SPL_BNZ) {
long long target = (long long)i + 1 + (long long)ins->imm; spl_vm_val_t target = i + 1 + ins->imm;
printf(" ; -> %zd", target); printf(" ; -> %zu", target);
} else if (ins->opcode == SPL_CALL) { } else if (ins->opcode == SPL_CALL) {
printf(" ; nargs=%zd, from stack", (long long)ins->imm); printf(" ; nargs=%zu, from stack", ins->imm);
} else if (ins->opcode == SPL_CALLI) { } else if (ins->opcode == SPL_CALLI) {
printf(" ; indirect call"); printf(" ; indirect call");
} else if (ins->opcode == SPL_GADDR) { } else if (ins->opcode == SPL_GADDR) {
printf(" ; gdata[%zd]", (long long)ins->imm); printf(" ; gdata[%zu]", ins->imm);
} }
printf("\n"); printf("\n");
} }

View File

@@ -599,7 +599,10 @@ void spl_vm_add_breakpoint_fn(spl_vm_t *vm, const char *name) {
for (usize i = 0; i < vec_size(vm->fn_breakpoints); i++) for (usize i = 0; i < vec_size(vm->fn_breakpoints); i++)
if (strcmp(vm->fn_breakpoints.data[i], name) == 0) if (strcmp(vm->fn_breakpoints.data[i], name) == 0)
return; return;
vec_push(vm->fn_breakpoints, strdup(name)); char *cpname = malloc(strlen(name) + 1);
Assert(cpname != NULL);
strcpy(cpname, name);
vec_push(vm->fn_breakpoints, cpname);
} }
void spl_vm_clear_breakpoints(spl_vm_t *vm) { void spl_vm_clear_breakpoints(spl_vm_t *vm) {