Skip to content

Commit 246bb00

Browse files
mihaipdingusdev
authored andcommitted
main: Guard deterministic PC logging during transitions
I happened to get a crash when running with deterministic mode because an exception occurred right when when the periodic logging timer fired, and the PC address not valid under the new mapping.
1 parent f6f8d28 commit 246bb00

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎main.cpp‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,15 @@ void run_machine(std::string machine_str, char* rom_data,
385385
// Log the PC and instruction every second to make it easier to validate
386386
// that execution is the same every time.
387387
deterministic_timer = TimerManager::get_instance()->add_cyclic_timer(MSECS_TO_NSECS(1000), [] {
388+
// We may be running after an exceptions or RFI changed the address
389+
// translation context. In those cases the PC address cannot be
390+
// translated (it would either be stale or invalid).
391+
if (exec_flags & (EXEF_EXCEPTION | EXEF_RFI)) {
392+
LOG_F(INFO, "TS=%016llu PC=0x%08x transition pending to PC=0x%08x",
393+
get_virt_time_ns(), ppc_state.pc, ppc_next_instruction_address);
394+
return;
395+
}
396+
388397
PPCDisasmContext ctx;
389398
ctx.instr_code = ppc_read_instruction(mmu_translate_imem(ppc_state.pc));
390399
ctx.instr_addr = ppc_state.pc;

0 commit comments

Comments
 (0)