Adding --target= and --trace_registers flags.

--target=[xex|iso] makes it possible to specify the thing to run from a
flagfile.
This commit is contained in:
Ben Vanik 2013-05-29 21:45:54 -07:00
parent 37530d1438
commit f307bc9eb1
5 changed files with 47 additions and 36 deletions

View File

@ -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_

View File

@ -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.");

View File

@ -9,6 +9,7 @@
#include <xenia/cpu/global_exports.h>
#include <xenia/cpu/cpu-private.h>
#include <xenia/cpu/processor.h>
#include <xenia/cpu/sdb.h>
#include <xenia/cpu/ppc/instr.h>
@ -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;

View File

@ -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;

View File

@ -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> run = auto_ptr<Run>(new Run());