Include inline functions when profiling

This commit is contained in:
2025-08-31 23:01:50 -04:00
parent 04c92c1454
commit 841ded3bee
9 changed files with 342 additions and 52 deletions
+17 -2
View File
@@ -6,7 +6,9 @@ use std::{
use anyhow::Result;
use tokio::{select, sync::mpsc};
use crate::emulator::{EmulatorClient, EmulatorCommand, GameInfo, ProfileEvent, SimEvent, SimId};
use crate::emulator::{
EmulatorClient, EmulatorCommand, GameInfo, InlineStack, ProfileEvent, SimEvent, SimId,
};
use recording::Recording;
use state::ProgramState;
@@ -131,11 +133,18 @@ async fn run_profile(
async fn handle_event(event: ProfileEvent, session: &mut ProfilerSession) -> Result<()> {
match event {
ProfileEvent::Start { info } => session.start_profiling(info).await,
ProfileEvent::Update { cycles, event } => {
ProfileEvent::Update {
cycles,
event,
inline_stack,
} => {
session.track_elapsed_cycles(cycles);
if let Some(event) = event {
session.track_event(event)?;
}
if let Some(stack) = inline_stack {
session.track_inline_stack(stack);
}
}
}
Ok(())
@@ -233,6 +242,12 @@ impl ProfilerSession {
}
}
fn track_inline_stack(&mut self, inline_stack: InlineStack) {
if let Some(program) = &mut self.program {
program.track_inline_stack(inline_stack);
}
}
fn start_recording(&mut self) {
if let Some(program) = &self.program {
self.recording = Some(Recording::new(program));