runa/crates/runa-core/src/execution.rs

65 lines
1.7 KiB
Rust

use serde::{Deserialize, Serialize};
use crate::SourceRange;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum StackFrameKind {
Current,
Caller,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct StackFrame {
pub kind: StackFrameKind,
/// Current instruction or caller's saved return address.
pub instruction_pointer: usize,
/// Instruction mapped to source (the call instruction for a caller).
pub source_instruction_pointer: Option<usize>,
pub function: Option<String>,
pub range: Option<SourceRange>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ExecutionInspection {
pub vm_steps: u64,
pub awaiting: bool,
pub call_depth: usize,
pub frames: Vec<StackFrame>,
pub frames_truncated: bool,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SourceBreakpoint {
/// Zero-based line in the exact installed source. Empty addresses mean unverified.
pub line: usize,
pub instruction_pointers: Vec<usize>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum DebugStopReason {
Breakpoint,
Step,
Budget,
Awaiting,
Completed,
Failed,
Removed,
}
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum StepMode {
#[default]
Into,
Over,
Out,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct DebuggerSnapshot {
pub breakpoints: Vec<SourceBreakpoint>,
pub stop_reason: Option<DebugStopReason>,
}