From d5b8a2091acc06fe3578ae0764a6c81d2c8dc901 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Fri, 6 Sep 2013 23:21:08 -0700 Subject: [PATCH] Switching tracing order to prevent skipping traces of branch instructions. --- src/xenia/cpu/global_exports.cc | 44 +++++++++---------- src/xenia/cpu/x64/x64_emitter.cc | 4 +- .../modules/xboxkrnl/xboxkrnl_memory.cc | 2 + 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/xenia/cpu/global_exports.cc b/src/xenia/cpu/global_exports.cc index fc558a843..dd408e45c 100644 --- a/src/xenia/cpu/global_exports.cc +++ b/src/xenia/cpu/global_exports.cc @@ -117,28 +117,6 @@ void _cdecl XeTraceInstruction( buffer[0] = 0; int offset = 0; - ppc::InstrData i; - i.address = (uint32_t)cia; - i.code = (uint32_t)data; - i.type = ppc::GetInstrType(i.code); - if (i.type && i.type->disassemble) { - ppc::InstrDisasm d; - i.type->disassemble(i, d); - std::string disasm; - d.Dump(disasm); - offset += xesnprintfa(buffer + offset, XECOUNT(buffer) - offset, - "%.8X %.8X %s %s", - i.address, i.code, - i.type && i.type->emit ? " " : "X", - disasm.c_str()); - } else { - offset += xesnprintfa(buffer + offset, XECOUNT(buffer) - offset, - "%.8X %.8X %s %s", - i.address, i.code, - i.type && i.type->emit ? " " : "X", - i.type ? i.type->name : ""); - } - if (FLAGS_trace_registers) { offset += xesnprintfa(buffer + offset, XECOUNT(buffer) - offset, "\n" @@ -162,6 +140,28 @@ void _cdecl XeTraceInstruction( state->r[28], state->r[29], state->r[30], state->r[31]); } + ppc::InstrData i; + i.address = (uint32_t)cia; + i.code = (uint32_t)data; + i.type = ppc::GetInstrType(i.code); + if (i.type && i.type->disassemble) { + ppc::InstrDisasm d; + i.type->disassemble(i, d); + std::string disasm; + d.Dump(disasm); + offset += xesnprintfa(buffer + offset, XECOUNT(buffer) - offset, + "%.8X %.8X %s %s", + i.address, i.code, + i.type && i.type->emit ? " " : "X", + disasm.c_str()); + } else { + offset += xesnprintfa(buffer + offset, XECOUNT(buffer) - offset, + "%.8X %.8X %s %s", + i.address, i.code, + i.type && i.type->emit ? " " : "X", + i.type ? i.type->name : ""); + } + uint32_t thread_id = state->thread_state->thread_id(); xe_log_line("", thread_id, "XeTraceInstruction", 't', buffer); diff --git a/src/xenia/cpu/x64/x64_emitter.cc b/src/xenia/cpu/x64/x64_emitter.cc index c5c461a93..c54936e32 100644 --- a/src/xenia/cpu/x64/x64_emitter.cc +++ b/src/xenia/cpu/x64/x64_emitter.cc @@ -624,6 +624,7 @@ void X64Emitter::GenerateBasicBlock(FunctionBlock* block) { typedef int (*InstrEmitter)(X64Emitter& g, X86Compiler& c, InstrData& i); InstrEmitter emit = (InstrEmitter)i.type->emit; + TraceInstruction(i); if (!i.type->emit || emit(*this, compiler_, i)) { // This printf is handy for sort/uniquify to find instructions. printf("unimplinstr %s\n", i.type->name); @@ -633,9 +634,6 @@ void X64Emitter::GenerateBasicBlock(FunctionBlock* block) { TraceInvalidInstruction(i); } - TraceInstruction(i); - } - // If we fall through, create the branch. if (block->outgoing_type == FunctionBlock::kTargetNone) { // BasicBlock* next_bb = GetNextBasicBlock(); diff --git a/src/xenia/kernel/modules/xboxkrnl/xboxkrnl_memory.cc b/src/xenia/kernel/modules/xboxkrnl/xboxkrnl_memory.cc index 83e728981..041babed8 100644 --- a/src/xenia/kernel/modules/xboxkrnl/xboxkrnl_memory.cc +++ b/src/xenia/kernel/modules/xboxkrnl/xboxkrnl_memory.cc @@ -235,6 +235,8 @@ uint32_t xeMmAllocatePhysicalMemoryEx( return 0; } + // TODO(benvanik): address should be in 0xA0000000+ range. + return base_address; }