Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/debugger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ impl CairoDebugger {
{
true
}
Some(StepAction::StepOut { depth }) if *depth > self.state.call_stack.depth() => true,
_ => false,
};

Expand Down
12 changes: 11 additions & 1 deletion src/debugger/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ impl From<ResponseBody> for HandlerResponse {
pub enum StepAction {
StepIn { prev_line: Line },
Next { depth: usize, prev_line: Line },
StepOut { depth: usize },
}

impl HandlerResponse {
Expand Down Expand Up @@ -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!()
Expand Down