Skip to content

Commit

Permalink
Fix?
Browse files Browse the repository at this point in the history
  • Loading branch information
imbillow committed May 7, 2024
1 parent ca259a2 commit 065cae5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion il-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"

[dependencies]
chashmap = "2.2.2"
hex-slice = "0.1.4"
hex = "0.4.3"
rayon = "1.10.0"

[dependencies.rizin-rs]
Expand Down
36 changes: 28 additions & 8 deletions il-tests/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use std::cmp::min;
use std::error::Error;
use std::fmt::{Display, Formatter};

use hex_slice::AsHex;
use chashmap::CHashMap;
use hex::ToHex;

use rizin_rs::wrapper::Core;

Expand Down Expand Up @@ -38,16 +39,17 @@ impl Display for Instruction {
}
write!(
f,
"{:x} {:#08x} {}",
self.bytes.plain_hex(false),
"{} {:#08x} {}",
self.bytes.encode_hex::<String>(),
self.addr,
self.il
)
}
}

fn main() -> Result<(), Box<dyn Error>> {
// const INST_LIMIT: usize = 0x8_usize;
const INST_LIMIT: usize = 0x8_usize;
let map = CHashMap::<String, usize>::new();
let n = u32::MAX / (rayon::current_num_threads() as u32);

let pool = rayon::ThreadPoolBuilder::new().build()?;
Expand All @@ -58,14 +60,32 @@ fn main() -> Result<(), Box<dyn Error>> {
let addrs = vec![0, 0xff00];
let begin: u32 = (ctx.index() as u32) * n;

(begin..min(begin + n, u32::MAX)).for_each(|x| {
for x in begin..min(begin + n, u32::MAX) {
let b: [u8; 4] = x.to_le_bytes();
for addr in addrs.clone() {
if let Ok(inst) = Instruction::from_bytes(&core, &b, addr) {
println!("{}", inst);
let inst = Instruction::from_bytes(&core, &b, addr);
if inst.is_err() {
continue;
}
let inst = inst.unwrap();
{
if let Some(x) = map.get(&inst.inst) {
if *x > INST_LIMIT {
continue;
}
}
}
println!("{}", inst);
match map.get_mut(&inst.inst) {
None => {
map.insert_new(inst.inst, 1);
}
Some(mut k) => {
*k += 1;
}
}
}
});
}
});
pool.broadcast(|_| {});
Ok(())
Expand Down

0 comments on commit 065cae5

Please sign in to comment.