Remove append option from load_symbol_table

This commit is contained in:
pjht 2022-10-17 16:09:17 -05:00
parent 690a8b366b
commit c6b152a6cf

View File

@ -293,7 +293,7 @@ fn main() -> Result<(), ReplError> {
}) { }) {
for path in initial_tables { for path in initial_tables {
let path = path.as_str().expect("Symbol table path is not string"); let path = path.as_str().expect("Symbol table path is not string");
load_symbol_table(path, true, &mut symbol_tables).unwrap(); load_symbol_table(path, &mut symbol_tables).unwrap();
} }
} }
Repl::<_, Error>::new(EmuState { Repl::<_, Error>::new(EmuState {
@ -547,7 +547,10 @@ fn main() -> Result<(), ReplError> {
.about("Load symbols from an ELF file, or list symbols if no file provided"), .about("Load symbols from an ELF file, or list symbols if no file provided"),
|args, state| { |args, state| {
if let Some(file_path) = args.get_one::<String>("file") { if let Some(file_path) = args.get_one::<String>("file") {
load_symbol_table(file_path, args.get_flag("append"), &mut state.symbol_tables)?; if !args.get_flag("append") {
state.symbol_tables.clear();
}
load_symbol_table(file_path, &mut state.symbol_tables)?;
Ok(None) Ok(None)
} else { } else {
let mut out = String::new(); let mut out = String::new();
@ -594,7 +597,6 @@ fn main() -> Result<(), ReplError> {
fn load_symbol_table( fn load_symbol_table(
path: &str, path: &str,
append: bool,
symbol_tables: &mut HashMap<String, HashMap<String, Symbol>>, symbol_tables: &mut HashMap<String, HashMap<String, Symbol>>,
) -> Result<(), Error> { ) -> Result<(), Error> {
let file = let file =
@ -615,9 +617,6 @@ fn load_symbol_table(
}) })
.collect::<HashMap<_, _>>(); .collect::<HashMap<_, _>>();
let basename = Path::new(&path).file_name().unwrap().to_str().unwrap(); let basename = Path::new(&path).file_name().unwrap().to_str().unwrap();
if !append {
symbol_tables.clear();
}
symbol_tables.insert(basename.to_string(), symbols); symbol_tables.insert(basename.to_string(), symbols);
Ok(()) Ok(())
} }