-
-
Save emilio/13242b4276b68240f19b1640eb5282be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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