Skip to content

Instantly share code, notes, and snippets.

@emilio
Created September 28, 2020 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emilio/13242b4276b68240f19b1640eb5282be to your computer and use it in GitHub Desktop.
Save emilio/13242b4276b68240f19b1640eb5282be to your computer and use it in GitHub Desktop.
use std::io::{BufRead, BufReader};
fn extract_preloader(line: &str) -> u64 {
let hex = line.split("(").nth(1).unwrap().split(",").next().unwrap();
let hex = hex.trim_start_matches("0x");
u64::from_str_radix(hex, 16).unwrap()
}
fn main() {
let file = std::fs::File::open("/home/emilio/src/moz/gecko/log-unmarked").unwrap();
let mut map = std::collections::HashMap::<u64, Vec<String>>::new();
for line in BufReader::new(file).lines() {
let line = line.unwrap();
if line.starts_with("PreloaderBase::~PreloaderBase") {
map.remove(&extract_preloader(&line));
}
if line.starts_with("PreloaderBase::NotifyOpen") {
let preloader = extract_preloader(&line);
map.entry(preloader).or_default().push(line);
}
}
for (_, values) in map {
for value in values {
println!("{}", value);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment