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
+4 -6
View File
@@ -1,5 +1,4 @@
use std::{
path::PathBuf,
sync::{Arc, Mutex},
thread,
};
@@ -7,13 +6,12 @@ use std::{
use anyhow::Result;
use tokio::{select, sync::mpsc};
use crate::emulator::{EmulatorClient, EmulatorCommand, ProfileEvent, SimEvent, SimId};
use crate::emulator::{EmulatorClient, EmulatorCommand, GameInfo, ProfileEvent, SimEvent, SimId};
use recording::Recording;
use state::ProgramState;
mod recording;
mod state;
mod symbols;
pub struct Profiler {
sim_id: SimId,
@@ -132,7 +130,7 @@ async fn run_profile(
async fn handle_event(event: ProfileEvent, session: &mut ProfilerSession) -> Result<()> {
match event {
ProfileEvent::Start { file_path } => session.start_profiling(file_path).await,
ProfileEvent::Start { info } => session.start_profiling(info).await,
ProfileEvent::Update { cycles, event } => {
session.track_elapsed_cycles(cycles);
if let Some(event) = event {
@@ -199,8 +197,8 @@ impl ProfilerSession {
}
}
async fn start_profiling(&mut self, file_path: PathBuf) {
let program = ProgramState::new(file_path).await;
async fn start_profiling(&mut self, info: Arc<GameInfo>) {
let program = ProgramState::new(info).await;
let recording = if self.recording.is_some() {
Some(Recording::new(&program))
} else {