Switch to LinkedHashSet fir storing breakpoints
This commit is contained in:
parent
d782b79a1f
commit
1775c318bc
10
Cargo.lock
generated
10
Cargo.lock
generated
@ -408,6 +408,15 @@ version = "0.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
|
||||
|
||||
[[package]]
|
||||
name = "linked_hash_set"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "47186c6da4d81ca383c7c47c1bfc80f4b95f4720514d860a5407aaf4233f9588"
|
||||
dependencies = [
|
||||
"linked-hash-map",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.0.46"
|
||||
@ -444,6 +453,7 @@ dependencies = [
|
||||
"inventory",
|
||||
"itertools",
|
||||
"linked-hash-map",
|
||||
"linked_hash_set",
|
||||
"nullable-result",
|
||||
"parse_int",
|
||||
"paste",
|
||||
|
@ -13,6 +13,7 @@ human-repr = { version = "1.0.1", features = ["iec", "space"] }
|
||||
inventory = "0.3.1"
|
||||
itertools = "0.10.5"
|
||||
linked-hash-map = "0.5.6"
|
||||
linked_hash_set = "0.1.4"
|
||||
nullable-result = { version = "0.7.0", features=["try_trait"] }
|
||||
parse_int = "0.6.0"
|
||||
paste = "1.0.9"
|
||||
|
19
src/main.rs
19
src/main.rs
@ -23,6 +23,7 @@ use disas::DisassemblyError;
|
||||
use elf::gabi::{STT_FILE, STT_SECTION};
|
||||
use itertools::Itertools;
|
||||
use linked_hash_map::LinkedHashMap;
|
||||
use linked_hash_set::LinkedHashSet;
|
||||
use parse_int::parse;
|
||||
use reedline_repl_rs::{
|
||||
clap::{Arg, ArgAction, Command},
|
||||
@ -42,7 +43,7 @@ use std::{
|
||||
#[derive(Debug)]
|
||||
pub struct SymbolTable {
|
||||
symbols: HashMap<String, Symbol>,
|
||||
breakpoints: Vec<String>,
|
||||
breakpoints: LinkedHashSet<String>,
|
||||
}
|
||||
|
||||
pub type SymbolTables = LinkedHashMap<String, SymbolTable>;
|
||||
@ -147,7 +148,7 @@ struct EmuConfig<'a> {
|
||||
struct EmuState {
|
||||
cpu: M68K,
|
||||
symbol_tables: SymbolTables,
|
||||
address_breakpoints: Vec<u32>,
|
||||
address_breakpoints: LinkedHashSet<u32>,
|
||||
}
|
||||
|
||||
fn main() -> Result<(), ReplError> {
|
||||
@ -169,7 +170,7 @@ fn main() -> Result<(), ReplError> {
|
||||
table_name.to_string(),
|
||||
SymbolTable {
|
||||
symbols: read_symbol_table(path).unwrap(),
|
||||
breakpoints: Vec::new(),
|
||||
breakpoints: LinkedHashSet::new(),
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -177,7 +178,7 @@ fn main() -> Result<(), ReplError> {
|
||||
Repl::<_, Error>::new(EmuState {
|
||||
cpu: M68K::new(backplane),
|
||||
symbol_tables,
|
||||
address_breakpoints: Vec::new(),
|
||||
address_breakpoints: LinkedHashSet::new(),
|
||||
})
|
||||
.with_name("68KEmu")
|
||||
.with_version("0.1.0")
|
||||
@ -440,9 +441,9 @@ fn main() -> Result<(), ReplError> {
|
||||
.iter()
|
||||
.cloned()
|
||||
.filter(|sym| symbols.contains_key(sym))
|
||||
.collect::<Vec<_>>()
|
||||
.collect::<LinkedHashSet<_>>()
|
||||
} else {
|
||||
Vec::new()
|
||||
LinkedHashSet::new()
|
||||
};
|
||||
if !args.get_flag("append") {
|
||||
state.symbol_tables.clear();
|
||||
@ -552,7 +553,11 @@ fn parse_location(location: &str, symbol_tables: &SymbolTables) -> Result<Locati
|
||||
})
|
||||
}
|
||||
|
||||
fn breakpoint_set_at(addr: u32, symbol_tables: &SymbolTables, address_breakpoints: &[u32]) -> bool {
|
||||
fn breakpoint_set_at(
|
||||
addr: u32,
|
||||
symbol_tables: &SymbolTables,
|
||||
address_breakpoints: &LinkedHashSet<u32>,
|
||||
) -> bool {
|
||||
address_breakpoints.contains(&addr)
|
||||
| symbol_tables.values().any(|table| {
|
||||
table
|
||||
|
Loading…
Reference in New Issue
Block a user