From f307bc9eb169dc358a1dc7e7337e5e90a718d05a Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Wed, 29 May 2013 21:45:54 -0700 Subject: [PATCH] Adding --target= and --trace_registers flags. --target=[xex|iso] makes it possible to specify the thing to run from a flagfile. --- src/xenia/cpu/cpu-private.h | 5 +--- src/xenia/cpu/cpu.cc | 9 ++----- src/xenia/cpu/global_exports.cc | 43 +++++++++++++++++--------------- src/xenia/cpu/x64/x64_emitter.cc | 4 ++- tools/xenia-run/xenia-run.cc | 22 +++++++++++++--- 5 files changed, 47 insertions(+), 36 deletions(-) diff --git a/src/xenia/cpu/cpu-private.h b/src/xenia/cpu/cpu-private.h index 5ca558aa7..992cf0856 100644 --- a/src/xenia/cpu/cpu-private.h +++ b/src/xenia/cpu/cpu-private.h @@ -14,6 +14,7 @@ DECLARE_bool(trace_instructions); +DECLARE_bool(trace_registers); DECLARE_bool(trace_branches); DECLARE_bool(trace_user_calls); DECLARE_bool(trace_kernel_calls); @@ -21,11 +22,7 @@ DECLARE_bool(trace_kernel_calls); DECLARE_string(load_module_map); DECLARE_string(dump_path); -DECLARE_bool(dump_module_bitcode); DECLARE_bool(dump_module_map); -DECLARE_bool(optimize_ir_modules); -DECLARE_bool(optimize_ir_functions); - #endif // XENIA_CPU_PRIVATE_H_ diff --git a/src/xenia/cpu/cpu.cc b/src/xenia/cpu/cpu.cc index 9e234e626..33d9e309b 100644 --- a/src/xenia/cpu/cpu.cc +++ b/src/xenia/cpu/cpu.cc @@ -13,6 +13,8 @@ // Tracing: DEFINE_bool(trace_instructions, false, "Trace all instructions."); +DEFINE_bool(trace_registers, false, + "Trace register values when tracing instructions."); DEFINE_bool(trace_branches, false, "Trace all branches."); DEFINE_bool(trace_user_calls, false, @@ -34,10 +36,3 @@ DEFINE_bool(dump_module_bitcode, true, "Writes the module bitcode both before and after optimizations."); DEFINE_bool(dump_module_map, true, "Dumps the module symbol database."); - - -// Optimizations: -DEFINE_bool(optimize_ir_modules, true, - "Whether to run LLVM optimizations on modules."); -DEFINE_bool(optimize_ir_functions, true, - "Whether to run LLVM optimizations on functions."); diff --git a/src/xenia/cpu/global_exports.cc b/src/xenia/cpu/global_exports.cc index 6d808d2d7..90dd8e96b 100644 --- a/src/xenia/cpu/global_exports.cc +++ b/src/xenia/cpu/global_exports.cc @@ -9,6 +9,7 @@ #include +#include #include #include #include @@ -102,26 +103,28 @@ void _cdecl XeTraceBranch( void _cdecl XeTraceInstruction( xe_ppc_state_t* state, uint64_t cia, uint64_t data) { - XELOGCPU( - "\n" - " lr=%.16llX ctr=%.16llX cr=%.4X xer=%.16llX\n" - " r0=%.16llX r1=%.16llX r2=%.16llX r3=%.16llX\n" - " r4=%.16llX r5=%.16llX r6=%.16llX r7=%.16llX\n" - " r8=%.16llX r9=%.16llX r10=%.16llX r11=%.16llX\n" - "r12=%.16llX r13=%.16llX r14=%.16llX r15=%.16llX\n" - "r16=%.16llX r17=%.16llX r18=%.16llX r19=%.16llX\n" - "r20=%.16llX r21=%.16llX r22=%.16llX r23=%.16llX\n" - "r24=%.16llX r25=%.16llX r26=%.16llX r27=%.16llX\n" - "r28=%.16llX r29=%.16llX r30=%.16llX r31=%.16llX\n", - state->lr, state->ctr, state->cr.value, state->xer, - state->r[0], state->r[1], state->r[2], state->r[3], - state->r[4], state->r[5], state->r[6], state->r[7], - state->r[8], state->r[9], state->r[10], state->r[11], - state->r[12], state->r[13], state->r[14], state->r[15], - state->r[16], state->r[17], state->r[18], state->r[19], - state->r[20], state->r[21], state->r[22], state->r[23], - state->r[24], state->r[25], state->r[26], state->r[27], - state->r[28], state->r[29], state->r[30], state->r[31]); + if (FLAGS_trace_registers) { + XELOGCPU( + "\n" + " lr=%.16llX ctr=%.16llX cr=%.4X xer=%.16llX\n" + " r0=%.16llX r1=%.16llX r2=%.16llX r3=%.16llX\n" + " r4=%.16llX r5=%.16llX r6=%.16llX r7=%.16llX\n" + " r8=%.16llX r9=%.16llX r10=%.16llX r11=%.16llX\n" + "r12=%.16llX r13=%.16llX r14=%.16llX r15=%.16llX\n" + "r16=%.16llX r17=%.16llX r18=%.16llX r19=%.16llX\n" + "r20=%.16llX r21=%.16llX r22=%.16llX r23=%.16llX\n" + "r24=%.16llX r25=%.16llX r26=%.16llX r27=%.16llX\n" + "r28=%.16llX r29=%.16llX r30=%.16llX r31=%.16llX\n", + state->lr, state->ctr, state->cr.value, state->xer, + state->r[0], state->r[1], state->r[2], state->r[3], + state->r[4], state->r[5], state->r[6], state->r[7], + state->r[8], state->r[9], state->r[10], state->r[11], + state->r[12], state->r[13], state->r[14], state->r[15], + state->r[16], state->r[17], state->r[18], state->r[19], + state->r[20], state->r[21], state->r[22], state->r[23], + state->r[24], state->r[25], state->r[26], state->r[27], + state->r[28], state->r[29], state->r[30], state->r[31]); + } ppc::InstrData i; i.address = (uint32_t)cia; diff --git a/src/xenia/cpu/x64/x64_emitter.cc b/src/xenia/cpu/x64/x64_emitter.cc index 8d147432a..2730367b8 100644 --- a/src/xenia/cpu/x64/x64_emitter.cc +++ b/src/xenia/cpu/x64/x64_emitter.cc @@ -228,7 +228,9 @@ int X64Emitter::MakeFunction(FunctionSymbol* symbol) { int result_code = 1; Lock(); - XELOGCPU("Compile(%s): beginning compilation...", symbol->name()); + if (FLAGS_log_codegen) { + XELOGCPU("Compile(%s): beginning compilation...", symbol->name()); + } symbol_ = symbol; fn_block_ = NULL; diff --git a/tools/xenia-run/xenia-run.cc b/tools/xenia-run/xenia-run.cc index 9116fa8b0..c75894821 100644 --- a/tools/xenia-run/xenia-run.cc +++ b/tools/xenia-run/xenia-run.cc @@ -18,6 +18,10 @@ using namespace xe::dbg; using namespace xe::kernel; +DEFINE_string(target, "", + "Specifies the target .xex or .iso to execute."); + + class Run { public: Run(); @@ -98,15 +102,25 @@ int Run::Launch(const xechar_t* path) { } } -int xenia_run(int argc, xechar_t **argv) { +int xenia_run(int argc, xechar_t** argv) { int result_code = 1; - // Grab path. - if (argc < 2) { + // Grab path from the flag or unnamed argument. + if (!FLAGS_target.size() && argc < 2) { google::ShowUsageWithFlags("xenia-run"); return 1; } - const xechar_t *path = argv[1]; + const xechar_t* path = NULL; + if (FLAGS_target.size()) { + // Passed as a named argument. + // TODO(benvanik): find something better than gflags that supports unicode. + xechar_t buffer[XE_MAX_PATH]; + XEIGNORE(xestrwiden(buffer, sizeof(buffer), FLAGS_target.c_str())); + path = buffer; + } else { + // Passed as an unnamed argument. + path = argv[1]; + } auto_ptr run = auto_ptr(new Run());