From c6161045740f2738d5807436bf497f8245d62e90 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Mon, 25 May 2015 11:09:00 -0700 Subject: [PATCH] Tracing help. --- docs/instruction_tracing.md | 34 ++++++++++++++++++++++++ src/xenia/cpu/backend/x64/x64_tracers.cc | 21 ++++++++++----- 2 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 docs/instruction_tracing.md diff --git a/docs/instruction_tracing.md b/docs/instruction_tracing.md new file mode 100644 index 000000000..45b9042a3 --- /dev/null +++ b/docs/instruction_tracing.md @@ -0,0 +1,34 @@ +In x64_tracers.cc: + +Enable tracing: +``` +#define ITRACE 1 <--- for only ppc instructions +#define DTRACE 1 <--- add HIR data +``` + +If tracing data, run with the following flags: +``` +--store_all_context_values +``` + +By default, tracing will start at the beginning and only for the specified +thread. + +Change traced thread by thread creation ID: +``` +#define TARGET_THREAD 4 +``` + +To only trace at a certain point, change default trace flag to false: +``` +bool trace_enabled = true; +``` +Add a breakpoint: +``` +--break_on_instruction=0x821009A4 +``` +On break, add the following to the Watch window and set it to true: +``` +xe::cpu::backend::x64::trace_enabled +``` +Continue, and watch stuff appear in the log. diff --git a/src/xenia/cpu/backend/x64/x64_tracers.cc b/src/xenia/cpu/backend/x64/x64_tracers.cc index e3da7a440..2f90fe09c 100644 --- a/src/xenia/cpu/backend/x64/x64_tracers.cc +++ b/src/xenia/cpu/backend/x64/x64_tracers.cc @@ -26,16 +26,25 @@ namespace x64 { #define ITRACE 0 #define DTRACE 0 -#define TARGET_THREAD 1 +#define TARGET_THREAD 4 -#define IFLUSH() \ - if (thread_state->thread_id() == TARGET_THREAD) fflush(stdout) +bool trace_enabled = true; + +#if !DTRACE +#define IFLUSH() \ + if (trace_enabled && thread_state->thread_id() == TARGET_THREAD) \ + fflush(stdout) +#else +#define IFLUSH() +#endif #define IPRINT \ - if (thread_state->thread_id() == TARGET_THREAD) printf -#define DFLUSH() IFLUSH() + if (trace_enabled && thread_state->thread_id() == TARGET_THREAD) printf +#define DFLUSH() \ + if (trace_enabled && thread_state->thread_id() == TARGET_THREAD) \ + fflush(stdout) #define DPRINT \ DFLUSH(); \ - if (thread_state->thread_id() == TARGET_THREAD) printf + if (trace_enabled && thread_state->thread_id() == TARGET_THREAD) printf uint32_t GetTracingMode() { uint32_t mode = 0;