From 62815f08b24fcf61412ec158c36ea4444109228f Mon Sep 17 00:00:00 2001 From: ksew1 Date: Thu, 12 Feb 2026 16:58:14 +0100 Subject: [PATCH] Add support for `StepOut` Closes #12 commit-id:1f085c9b --- src/debugger.rs | 1 + src/debugger/handler.rs | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/debugger.rs b/src/debugger.rs index e75d9d3..3021b32 100644 --- a/src/debugger.rs +++ b/src/debugger.rs @@ -109,6 +109,7 @@ impl CairoDebugger { { true } + Some(StepAction::StepOut { depth }) if *depth > self.state.call_stack.depth() => true, _ => false, }; diff --git a/src/debugger/handler.rs b/src/debugger/handler.rs index 510af0d..70cc77b 100644 --- a/src/debugger/handler.rs +++ b/src/debugger/handler.rs @@ -28,6 +28,7 @@ impl From for HandlerResponse { pub enum StepAction { StepIn { prev_line: Line }, Next { depth: usize, prev_line: Line }, + StepOut { depth: usize }, } impl HandlerResponse { @@ -203,7 +204,16 @@ pub fn handle_request( Ok(ResponseBody::StepIn.into()) } Command::StepOut(_) => { - todo!() + // To handle a "step out" action, we set the step action to `StepOut`. + // We record the current call stack depth. The debugger will resume execution + // and only stop when it reaches a line in a shallower call stack depth, which + // happens when the current function returns. + let depth = state.call_stack.depth(); + if depth > 0 { + state.step_action = Some(StepAction::StepOut { depth }); + } + state.resume_execution(); + Ok(ResponseBody::StepOut.into()) } Command::Source(_) => { todo!()