feat: 超时崩溃记录带 last-pc 现场(pc/opcode/帧深)

This commit is contained in:
2026-09-26 10:20:27 +00:00
parent 9da825e845
commit 736d9220d5
7 changed files with 125 additions and 26 deletions
+17
View File
@@ -1,6 +1,8 @@
//! dispatch 主循环:逐指令解码与 OpCode 臂分派、执行期 GC 安全点、
//! 步数/分配上限采样与二元运算宏 `binary_arith!`。
use std::io::Write;
use num_traits::Zero;
use oxide_bytecode::opcode::{self, OpCode};
use oxide_runtime_api as coercion;
@@ -216,6 +218,21 @@ impl Vm {
eprintln!("pc={pc:4} {op:>16} rd={rd} a={a} b={b}");
}
// last-pc 现场:开启时每 2^16 指令追加写一行 pc/opcode/flat_id/frames,
// 供监督者超时/崩溃杀子进程后读回挂死点(精度 = 距挂死点 2^16 指令内);
// 关闭时零输出零分配。
if let Some(watch) = self.pc_watch.as_ref() {
if (steps & 0xFFFF) == 0 {
let line =
format!("pc={pc} op={op} flat_id={} frames={}\n", self.active_flat_id, self.frames.len());
let _ = std::fs::OpenOptions::new()
.create(true)
.append(true)
.open(watch)
.and_then(|mut f| f.write_all(line.as_bytes()));
}
}
match op {
OpCode::NOP => {}