Skip to content

Commit

Permalink
fix(debugger):
Browse files Browse the repository at this point in the history
- usize overflow in `Unit::find_place_by_pc`
- `next` step now takes into account that the debugee can finish execution while stepping
  • Loading branch information
godzie44 committed Sep 17, 2023
1 parent 9eb021b commit 927120c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/debugger/debugee/dwarf/unit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ impl Unit {
let pc = u64::from(pc);
let pos = match self.lines.binary_search_by_key(&pc, |line| line.address) {
Ok(p) => p,
Err(p) => p - 1,
Err(p) => p.saturating_sub(1),
};

self.find_place_by_idx(pos)
Expand Down
7 changes: 5 additions & 2 deletions src/debugger/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::debugger::breakpoint::Breakpoint;
use crate::debugger::debugee::dwarf::unit::PlaceDescriptorOwned;
use crate::debugger::debugee::tracer::{StopReason, TraceContext};
use crate::debugger::{Debugger, ExplorationContext};
use anyhow::anyhow;
use anyhow::{anyhow, bail};
use nix::sys::signal::Signal;

/// Result of a step, if [`SignalInterrupt`] then step process interrupted by a signal and user must know it.
Expand Down Expand Up @@ -331,14 +331,17 @@ impl Debugger {
.debug_info(new_location.pc)?
.find_place_from_pc(new_location.global_pc)?
.ok_or_else(|| anyhow!("unknown function range"))?;

if place.address != new_location.global_pc {
if let StepResult::SignalInterrupt { signal, .. } = self.step_in()? {
return Ok(StepResult::signal_interrupt(signal));
}
}
}

if self.debugee.is_exited() {
bail!("debugee exited while step execution");
}

self.expl_ctx_update_location()?;
Ok(StepResult::Done)
}
Expand Down

0 comments on commit 927120c

Please sign in to comment.