Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
Improve handling of unexpected breakpoints (#3493)
Browse files Browse the repository at this point in the history
* Improve handling of unexpected breakpoints

* fmt
  • Loading branch information
tevoinea committed Sep 13, 2023
1 parent d34138d commit d009476
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions src/agent/coverage/src/record/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use std::collections::BTreeMap;
use std::path::Path;

use anyhow::{anyhow, bail, Error, Result};
use anyhow::{anyhow, Error, Result};
use debuggable_module::debuginfo::{DebugInfo, Function};
use debuggable_module::load_module::LoadModule;
use debuggable_module::loader::Loader;
Expand Down Expand Up @@ -132,20 +132,24 @@ impl<'cache, 'data> WindowsRecorder<'cache, 'data> {
return Ok(());
}

let breakpoint = self.breakpoints.remove(id);

let Some(breakpoint) = breakpoint else {
let stack = dbg.get_current_stack()?;
bail!("stopped on dangling breakpoint, debuggee stack:\n{}", stack);
};

let coverage = self
.coverage
.modules
.get_mut(&breakpoint.module)
.ok_or_else(|| anyhow!("coverage not initialized for module: {}", breakpoint.module))?;

coverage.increment(breakpoint.offset);
match self.breakpoints.remove(id) {
Some(breakpoint) => {
let coverage = self
.coverage
.modules
.get_mut(&breakpoint.module)
.ok_or_else(|| {
anyhow!("coverage not initialized for module: {}", breakpoint.module)
})?;

coverage.increment(breakpoint.offset);
}
// ASAN can set breakpoints which we don't know about, meaning they're not in `self.breakpoints`
None => {
let stack = dbg.get_current_stack()?;
warn!("stopped on dangling breakpoint, debuggee stack:\n{}", stack);
}
}

Ok(())
}
Expand Down

0 comments on commit d009476

Please sign in to comment.