Parse ELF exclusively on emulation thread
This commit is contained in:
+9
-20
@@ -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])> {
|
||||
|
||||
Reference in New Issue
Block a user