Add ability to delete symbol tables

This commit is contained in:
pjht 2022-10-19 12:36:13 -05:00
parent 57f7c0fabe
commit 0ba9936f07

View File

@ -430,10 +430,26 @@ fn main() -> Result<(), ReplError> {
.requires("file")
.help("Append the file's symbols to the loaded list of symbols"),
)
.arg(
Arg::new("delete")
.long("delete")
.short('d')
.action(ArgAction::SetTrue)
.requires("file")
.conflicts_with("append")
.help("Delete the symbol table instead of loading it"),
)
.about("Load symbols from an ELF file, or list symbols if no file provided"),
|args, state| {
if let Some(file_path) = args.get_one::<String>("file") {
let table_name = Path::new(&file_path).file_name().unwrap().to_str().unwrap();
if args.get_flag("delete") {
if state.symbol_tables.remove(table_name).is_some() {
Ok(None)
} else {
Ok(Some("No such symbol table".to_string()))
}
} else {
let symbols = read_symbol_table(file_path)?;
let breakpoints = if let Some(table) = state.symbol_tables.get(table_name) {
table
@ -456,6 +472,7 @@ fn main() -> Result<(), ReplError> {
},
);
Ok(None)
}
} else {
let mut out = String::new();
for (table_name, table) in state.symbol_tables.iter() {