Add ability to delete breakpoints
This commit is contained in:
parent
2f343b3772
commit
e0fbebfbc3
25
src/main.rs
25
src/main.rs
@ -492,10 +492,34 @@ fn main() -> Result<(), ReplError> {
|
||||
.with_command(
|
||||
Command::new("bp")
|
||||
.arg(Arg::new("location").help("The location to set a breakpoint at"))
|
||||
.arg(
|
||||
Arg::new("delete")
|
||||
.long("delete")
|
||||
.short('d')
|
||||
.action(ArgAction::SetTrue)
|
||||
.requires("location")
|
||||
.help("Delete the breakpoint instead of setting it"),
|
||||
)
|
||||
.help("Set a breakpoint or list current breakpoints"),
|
||||
|args, state| {
|
||||
if let Some(location) = args.get_one::<String>("location") {
|
||||
let location = parse_location(location, &state.symbol_tables)?;
|
||||
if args.get_flag("delete") {
|
||||
let deleted = match location {
|
||||
Location::Symbol((table, symbol)) => state
|
||||
.symbol_tables
|
||||
.get_mut(&table)
|
||||
.unwrap()
|
||||
.breakpoints
|
||||
.remove(&symbol),
|
||||
Location::Address(address) => state.address_breakpoints.remove(&address),
|
||||
};
|
||||
if deleted {
|
||||
Ok(None)
|
||||
} else {
|
||||
Ok(Some("No such breakpoint".to_string()))
|
||||
}
|
||||
} else {
|
||||
match location {
|
||||
Location::Symbol((table, symbol)) => state
|
||||
.symbol_tables
|
||||
@ -508,6 +532,7 @@ fn main() -> Result<(), ReplError> {
|
||||
}
|
||||
};
|
||||
Ok(None)
|
||||
}
|
||||
} else {
|
||||
let mut out = String::new();
|
||||
for (table_name, table) in &state.symbol_tables {
|
||||
|
Loading…
Reference in New Issue
Block a user