diff --git a/src/xenia/cpu/cpu-private.h b/src/xenia/cpu/cpu-private.h index 3342c0a36..2288b6769 100644 --- a/src/xenia/cpu/cpu-private.h +++ b/src/xenia/cpu/cpu-private.h @@ -28,6 +28,10 @@ DECLARE_bool(trace_function_data); DECLARE_bool(validate_hir); DECLARE_uint64(break_on_instruction); +DECLARE_int32(break_condition_gpr); +DECLARE_uint64(break_condition_value); +DECLARE_bool(break_condition_truncate); + DECLARE_bool(break_on_debugbreak); #endif // XENIA_CPU_PRIVATE_H_ diff --git a/src/xenia/cpu/cpu.cc b/src/xenia/cpu/cpu.cc index 9366004d6..f9e24bfdf 100644 --- a/src/xenia/cpu/cpu.cc +++ b/src/xenia/cpu/cpu.cc @@ -45,4 +45,8 @@ DEFINE_bool(validate_hir, false, // Breakpoints: DEFINE_uint64(break_on_instruction, 0, "int3 before the given guest address is executed."); +DEFINE_int32(break_condition_gpr, -1, "GPR compared to"); +DEFINE_uint64(break_condition_value, 0, "value compared against"); +DEFINE_bool(break_condition_truncate, true, "truncate value to 32-bits"); + DEFINE_bool(break_on_debugbreak, true, "int3 on JITed __debugbreak requests."); diff --git a/src/xenia/cpu/frontend/ppc_hir_builder.cc b/src/xenia/cpu/frontend/ppc_hir_builder.cc index b91e73bfa..c8441b704 100644 --- a/src/xenia/cpu/frontend/ppc_hir_builder.cc +++ b/src/xenia/cpu/frontend/ppc_hir_builder.cc @@ -129,7 +129,18 @@ bool PPCHIRBuilder::Emit(FunctionInfo* symbol_info, uint32_t flags) { if (i.address == FLAGS_break_on_instruction) { Comment("--break-on-instruction target"); - DebugBreak(); + + if (FLAGS_break_condition_gpr < 0) { + DebugBreak(); + } else { + auto left = LoadGPR(FLAGS_break_condition_gpr); + auto right = LoadConstant(FLAGS_break_condition_value); + if (FLAGS_break_condition_truncate) { + left = Truncate(left, INT32_TYPE); + right = Truncate(right, INT32_TYPE); + } + TrapTrue(CompareEQ(left, right)); + } } if (!i.type->emit || emit(*this, i)) {