Parse ELF exclusively on emulation thread

This commit is contained in:
2025-08-30 13:02:38 -04:00
parent e5abd48337
commit 04c92c1454
9 changed files with 182 additions and 137 deletions
+9 -20
View File
@@ -1,12 +1,12 @@
use std::{collections::HashMap, path::PathBuf};
use std::{collections::HashMap, sync::Arc};
use anyhow::{Result, bail};
use fxprof_processed_profile::LibraryInfo;
use crate::profiler::symbols::SymbolFile;
use crate::emulator::GameInfo;
pub struct ProgramState {
name: String,
symbol_file: Option<SymbolFile>,
info: Arc<GameInfo>,
call_stacks: HashMap<u16, Vec<StackFrame>>,
context_stack: Vec<u16>,
}
@@ -17,17 +17,7 @@ pub struct StackFrame {
pub const RESET_CODE: u16 = 0xfff0;
impl ProgramState {
pub async fn new(file_path: PathBuf) -> Self {
let symbol_file = SymbolFile::load(&file_path).await.ok();
let name = symbol_file
.as_ref()
.map(|f| f.name().to_string())
.or_else(|| {
file_path
.file_stem()
.map(|s| s.to_string_lossy().into_owned())
})
.unwrap_or_else(|| "game".to_string());
pub async fn new(info: Arc<GameInfo>) -> Self {
let mut call_stacks = HashMap::new();
call_stacks.insert(
RESET_CODE,
@@ -36,19 +26,18 @@ impl ProgramState {
}],
);
Self {
name,
symbol_file,
info,
call_stacks,
context_stack: vec![RESET_CODE],
}
}
pub fn name(&self) -> &str {
&self.name
self.info.name()
}
pub fn symbol_file(&self) -> Option<&SymbolFile> {
self.symbol_file.as_ref()
pub fn library_info(&self) -> &LibraryInfo {
self.info.library_info()
}
pub fn current_stack(&self) -> Option<(u16, &[StackFrame])> {