Profile without ELF data

This commit is contained in:
2025-08-27 22:49:44 -04:00
parent 2936960cc9
commit 4785e5e11b
3 changed files with 34 additions and 21 deletions
+22 -7
View File
@@ -5,7 +5,8 @@ use anyhow::{Result, bail};
use crate::profiler::symbols::SymbolFile;
pub struct ProgramState {
symbol_file: SymbolFile,
name: String,
symbol_file: Option<SymbolFile>,
call_stacks: HashMap<u16, Vec<StackFrame>>,
context_stack: Vec<u16>,
}
@@ -16,8 +17,17 @@ pub struct StackFrame {
pub const RESET_CODE: u16 = 0xfff0;
impl ProgramState {
pub async fn new(file_path: PathBuf) -> Result<Self> {
let symbol_file = SymbolFile::load(&file_path).await?;
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());
let mut call_stacks = HashMap::new();
call_stacks.insert(
RESET_CODE,
@@ -25,15 +35,20 @@ impl ProgramState {
address: 0xfffffff0,
}],
);
Ok(Self {
Self {
name,
symbol_file,
call_stacks,
context_stack: vec![RESET_CODE],
})
}
}
pub fn symbol_file(&self) -> &SymbolFile {
&self.symbol_file
pub fn name(&self) -> &str {
&self.name
}
pub fn symbol_file(&self) -> Option<&SymbolFile> {
self.symbol_file.as_ref()
}
pub fn current_stack(&self) -> Option<(u16, &[StackFrame])> {