Converting logging to ASCII and other Windows fixes.
This commit is contained in:
@@ -311,7 +311,7 @@ void FunctionGenerator::GenerateBasicBlock(FunctionBlock* block) {
|
||||
}
|
||||
|
||||
if (!i.type) {
|
||||
XELOGCPU(XT("Invalid instruction %.8X %.8X"), ia, i.code);
|
||||
XELOGCPU("Invalid instruction %.8X %.8X", ia, i.code);
|
||||
SpillRegisters();
|
||||
b.CreateCall3(
|
||||
invalidInstruction,
|
||||
@@ -344,7 +344,7 @@ void FunctionGenerator::GenerateBasicBlock(FunctionBlock* block) {
|
||||
// This printf is handy for sort/uniquify to find instructions.
|
||||
//printf("unimplinstr %s\n", i.type->name);
|
||||
|
||||
XELOGCPU(XT("Unimplemented instr %.8X %.8X %s"),
|
||||
XELOGCPU("Unimplemented instr %.8X %.8X %s",
|
||||
ia, i.code, i.type->name);
|
||||
SpillRegisters();
|
||||
b.CreateCall3(
|
||||
@@ -363,7 +363,7 @@ void FunctionGenerator::GenerateBasicBlock(FunctionBlock* block) {
|
||||
} else if (block->outgoing_type == FunctionBlock::kTargetUnknown) {
|
||||
// Hrm.
|
||||
// TODO(benvanik): assert this doesn't occur - means a bad sdb run!
|
||||
XELOGCPU(XT("SDB function scan error in %.8X: bb %.8X has unknown exit"),
|
||||
XELOGCPU("SDB function scan error in %.8X: bb %.8X has unknown exit",
|
||||
fn_->start_address, block->start_address);
|
||||
b.CreateRetVoid();
|
||||
}
|
||||
@@ -396,7 +396,7 @@ BasicBlock* FunctionGenerator::GetReturnBasicBlock() {
|
||||
Function* FunctionGenerator::GetFunction(FunctionSymbol* fn) {
|
||||
Function* result = gen_module_->getFunction(StringRef(fn->name()));
|
||||
if (!result) {
|
||||
XELOGE(XT("Static function not found: %.8X %s"),
|
||||
XELOGE("Static function not found: %.8X %s",
|
||||
fn->start_address, fn->name());
|
||||
}
|
||||
XEASSERTNOTNULL(result);
|
||||
|
||||
@@ -95,7 +95,7 @@ int ModuleGenerator::Generate() {
|
||||
// value (so that we can call it), the second actually builds the function.
|
||||
std::vector<FunctionSymbol*> functions;
|
||||
if (!sdb_->GetAllFunctions(functions)) {
|
||||
XELOGI(XT("Beginning prep of %ld functions..."), functions.size());
|
||||
XELOGI("Beginning prep of %ld functions...", functions.size());
|
||||
for (std::vector<FunctionSymbol*>::iterator it = functions.begin();
|
||||
it != functions.end(); ++it) {
|
||||
FunctionSymbol* fn = *it;
|
||||
@@ -115,20 +115,20 @@ int ModuleGenerator::Generate() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
XELOGI(XT("Function prep complete"));
|
||||
XELOGI("Function prep complete");
|
||||
}
|
||||
|
||||
// Build out all the user functions.
|
||||
size_t n = 0;
|
||||
XELOGI(XT("Beginning generation of %ld functions..."), functions.size());
|
||||
XELOGI("Beginning generation of %ld functions...", functions.size());
|
||||
for (std::map<uint32_t, CodegenFunction*>::iterator it =
|
||||
functions_.begin(); it != functions_.end(); ++it, ++n) {
|
||||
FunctionSymbol* symbol = it->second->symbol;
|
||||
XELOGI(XT("Generating %ld/%ld %.8X %s"),
|
||||
XELOGI("Generating %ld/%ld %.8X %s",
|
||||
n, functions_.size(), symbol->start_address, symbol->name());
|
||||
BuildFunction(it->second);
|
||||
}
|
||||
XELOGI(XT("Function generation complete"));
|
||||
XELOGI("Function generation complete");
|
||||
|
||||
di_builder_->finalize();
|
||||
|
||||
|
||||
@@ -292,7 +292,7 @@ int ExecModule::Init() {
|
||||
} else {
|
||||
// Not implemented - write with a dummy value.
|
||||
*slot = XESWAP32BE(0xDEADBEEF);
|
||||
XELOGCPU(XT("WARNING: imported a variable with no value: %s"),
|
||||
XELOGCPU("WARNING: imported a variable with no value: %s",
|
||||
kernel_export->name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,12 +33,12 @@ namespace {
|
||||
|
||||
|
||||
void XeTrap(xe_ppc_state_t* state, uint32_t cia) {
|
||||
XELOGE(XT("TRAP"));
|
||||
XELOGE("TRAP");
|
||||
XEASSERTALWAYS();
|
||||
}
|
||||
|
||||
void XeIndirectBranch(xe_ppc_state_t* state, uint64_t target, uint64_t br_ia) {
|
||||
XELOGCPU(XT("INDIRECT BRANCH %.8X -> %.8X"),
|
||||
XELOGCPU("INDIRECT BRANCH %.8X -> %.8X",
|
||||
(uint32_t)br_ia, (uint32_t)target);
|
||||
XEASSERTALWAYS();
|
||||
}
|
||||
@@ -50,43 +50,43 @@ void XeInvalidInstruction(xe_ppc_state_t* state, uint32_t cia, uint32_t data) {
|
||||
i.type = ppc::GetInstrType(i.code);
|
||||
|
||||
if (!i.type) {
|
||||
XELOGCPU(XT("INVALID INSTRUCTION %.8X: %.8X ???"),
|
||||
XELOGCPU("INVALID INSTRUCTION %.8X: %.8X ???",
|
||||
i.address, i.code);
|
||||
} else if (i.type->disassemble) {
|
||||
ppc::InstrDisasm d;
|
||||
i.type->disassemble(i, d);
|
||||
std::string disasm;
|
||||
d.Dump(disasm);
|
||||
XELOGCPU(XT("INVALID INSTRUCTION %.8X: %.8X %s"),
|
||||
XELOGCPU("INVALID INSTRUCTION %.8X: %.8X %s",
|
||||
i.address, i.code, disasm.c_str());
|
||||
} else {
|
||||
XELOGCPU(XT("INVALID INSTRUCTION %.8X: %.8X %s"),
|
||||
XELOGCPU("INVALID INSTRUCTION %.8X: %.8X %s",
|
||||
i.address, i.code, i.type->name);
|
||||
}
|
||||
}
|
||||
|
||||
void XeAccessViolation(xe_ppc_state_t* state, uint32_t cia, uint64_t ea) {
|
||||
XELOGE(XT("INVALID ACCESS %.8X: tried to touch %.8X"),
|
||||
XELOGE("INVALID ACCESS %.8X: tried to touch %.8X",
|
||||
cia, (uint32_t)ea);
|
||||
XEASSERTALWAYS();
|
||||
}
|
||||
|
||||
void XeTraceKernelCall(xe_ppc_state_t* state, uint64_t cia, uint64_t call_ia,
|
||||
KernelExport* kernel_export) {
|
||||
XELOGCPU(XT("TRACE: %.8X -> k.%.8X (%s)"),
|
||||
XELOGCPU("TRACE: %.8X -> k.%.8X (%s)",
|
||||
(uint32_t)call_ia - 4, (uint32_t)cia,
|
||||
kernel_export ? kernel_export->name : "unknown");
|
||||
}
|
||||
|
||||
void XeTraceUserCall(xe_ppc_state_t* state, uint64_t cia, uint64_t call_ia,
|
||||
FunctionSymbol* fn) {
|
||||
XELOGCPU(XT("TRACE: %.8X -> u.%.8X (%s)"),
|
||||
XELOGCPU("TRACE: %.8X -> u.%.8X (%s)",
|
||||
(uint32_t)call_ia - 4, (uint32_t)cia, fn->name());
|
||||
}
|
||||
|
||||
void XeTraceInstruction(xe_ppc_state_t* state, uint32_t cia, uint32_t data) {
|
||||
ppc::InstrType* type = ppc::GetInstrType(data);
|
||||
XELOGCPU(XT("TRACE: %.8X %.8X %s %s"),
|
||||
XELOGCPU("TRACE: %.8X %.8X %s %s",
|
||||
cia, data,
|
||||
type && type->emit ? " " : "X",
|
||||
type ? type->name : "<unknown>");
|
||||
|
||||
@@ -199,7 +199,7 @@ int Processor::Execute(ThreadState* thread_state, uint32_t address) {
|
||||
// Find the function to execute.
|
||||
Function* f = GetFunction(address);
|
||||
if (!f) {
|
||||
XELOGCPU(XT("Failed to find function %.8X to execute."), address);
|
||||
XELOGCPU("Failed to find function %.8X to execute.", address);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ int SymbolDatabase::Analyze() {
|
||||
++it) {
|
||||
if (it->second->symbol_type == Symbol::Function) {
|
||||
if (fn->type == FunctionSymbol::Unknown) {
|
||||
XELOGE(XT("UNKNOWN FN %.8X"), fn->start_address);
|
||||
XELOGE("UNKNOWN FN %.8X", fn->start_address);
|
||||
}
|
||||
if (CompleteFunctionGraph(static_cast<FunctionSymbol*>(it->second))) {
|
||||
needs_another_pass = true;
|
||||
@@ -111,7 +111,7 @@ FunctionSymbol* SymbolDatabase::GetOrInsertFunction(uint32_t address) {
|
||||
|
||||
// Ignore values outside of the .text range.
|
||||
if (!IsValueInTextRange(address)) {
|
||||
XELOGSDB(XT("Ignoring function outside of .text: %.8X"), address);
|
||||
XELOGSDB("Ignoring function outside of .text: %.8X", address);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ int SymbolDatabase::AnalyzeFunction(FunctionSymbol* fn) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
XELOGSDB(XT("Analyzing function %.8X..."), fn->start_address);
|
||||
XELOGSDB("Analyzing function %.8X...", fn->start_address);
|
||||
|
||||
// Set a default name, if it hasn't been named already.
|
||||
if (!fn->name()) {
|
||||
@@ -258,7 +258,7 @@ int SymbolDatabase::AnalyzeFunction(FunctionSymbol* fn) {
|
||||
// If we fetched 0 assume that we somehow hit one of the awesome
|
||||
// 'no really we meant to end after that bl' functions.
|
||||
if (!i.code) {
|
||||
XELOGSDB(XT("function end %.8X (0x00000000 read)"), addr);
|
||||
XELOGSDB("function end %.8X (0x00000000 read)", addr);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -277,18 +277,17 @@ int SymbolDatabase::AnalyzeFunction(FunctionSymbol* fn) {
|
||||
// Invalid instruction.
|
||||
// We can just ignore it because there's (very little)/no chance it'll
|
||||
// affect flow control.
|
||||
XELOGSDB(XT("Invalid instruction at %.8X: %.8X"), addr, i.code);
|
||||
XELOGSDB("Invalid instruction at %.8X: %.8X", addr, i.code);
|
||||
} else if (i.code == 0x4E800020) {
|
||||
// blr -- unconditional branch to LR.
|
||||
// This is generally a return.
|
||||
block->outgoing_type = FunctionBlock::kTargetLR;
|
||||
if (furthest_target > addr) {
|
||||
// Remaining targets within function, not end.
|
||||
XELOGSDB(XT("ignoring blr %.8X (branch to %.8X)"), addr,
|
||||
furthest_target);
|
||||
XELOGSDB("ignoring blr %.8X (branch to %.8X)", addr, furthest_target);
|
||||
} else {
|
||||
// Function end point.
|
||||
XELOGSDB(XT("function end %.8X"), addr);
|
||||
XELOGSDB("function end %.8X", addr);
|
||||
ends_fn = true;
|
||||
}
|
||||
ends_block = true;
|
||||
@@ -298,11 +297,11 @@ int SymbolDatabase::AnalyzeFunction(FunctionSymbol* fn) {
|
||||
block->outgoing_type = FunctionBlock::kTargetCTR;
|
||||
if (furthest_target > addr) {
|
||||
// Remaining targets within function, not end.
|
||||
XELOGSDB(XT("ignoring bctr %.8X (branch to %.8X)"), addr,
|
||||
XELOGSDB("ignoring bctr %.8X (branch to %.8X)", addr,
|
||||
furthest_target);
|
||||
} else {
|
||||
// Function end point.
|
||||
XELOGSDB(XT("function end %.8X"), addr);
|
||||
XELOGSDB("function end %.8X", addr);
|
||||
ends_fn = true;
|
||||
}
|
||||
ends_block = true;
|
||||
@@ -312,17 +311,17 @@ int SymbolDatabase::AnalyzeFunction(FunctionSymbol* fn) {
|
||||
block->outgoing_address = target;
|
||||
|
||||
if (i.I.LK) {
|
||||
XELOGSDB(XT("bl %.8X -> %.8X"), addr, target);
|
||||
XELOGSDB("bl %.8X -> %.8X", addr, target);
|
||||
|
||||
// Queue call target if needed.
|
||||
GetOrInsertFunction(target);
|
||||
} else {
|
||||
XELOGSDB(XT("b %.8X -> %.8X"), addr, target);
|
||||
XELOGSDB("b %.8X -> %.8X", addr, target);
|
||||
// If the target is back into the function and there's no further target
|
||||
// we are at the end of a function.
|
||||
if (target >= fn->start_address &&
|
||||
target < addr && furthest_target <= addr) {
|
||||
XELOGSDB(XT("function end %.8X (back b)"), addr);
|
||||
XELOGSDB("function end %.8X (back b)", addr);
|
||||
ends_fn = true;
|
||||
}
|
||||
|
||||
@@ -332,7 +331,7 @@ int SymbolDatabase::AnalyzeFunction(FunctionSymbol* fn) {
|
||||
// it.
|
||||
if (!ends_fn &&
|
||||
furthest_target <= addr && IsRestGprLr(target)) {
|
||||
XELOGSDB(XT("function end %.8X (__restgprlr_*)"), addr);
|
||||
XELOGSDB("function end %.8X (__restgprlr_*)", addr);
|
||||
ends_fn = true;
|
||||
}
|
||||
|
||||
@@ -351,14 +350,14 @@ int SymbolDatabase::AnalyzeFunction(FunctionSymbol* fn) {
|
||||
uint32_t target = XEEXTS16(i.B.BD << 2) + (i.B.AA ? 0 : (int32_t)addr);
|
||||
block->outgoing_address = target;
|
||||
if (i.B.LK) {
|
||||
XELOGSDB(XT("bcl %.8X -> %.8X"), addr, target);
|
||||
XELOGSDB("bcl %.8X -> %.8X", addr, target);
|
||||
|
||||
// Queue call target if needed.
|
||||
// TODO(benvanik): see if this is correct - not sure anyone makes
|
||||
// function calls with bcl.
|
||||
//GetOrInsertFunction(target);
|
||||
} else {
|
||||
XELOGSDB(XT("bc %.8X -> %.8X"), addr, target);
|
||||
XELOGSDB("bc %.8X -> %.8X", addr, target);
|
||||
|
||||
// TODO(benvanik): GetOrInsertFunction? it's likely a BB
|
||||
|
||||
@@ -369,18 +368,18 @@ int SymbolDatabase::AnalyzeFunction(FunctionSymbol* fn) {
|
||||
// bclr/bclrl
|
||||
block->outgoing_type = FunctionBlock::kTargetLR;
|
||||
if (i.XL.LK) {
|
||||
XELOGSDB(XT("bclrl %.8X"), addr);
|
||||
XELOGSDB("bclrl %.8X", addr);
|
||||
} else {
|
||||
XELOGSDB(XT("bclr %.8X"), addr);
|
||||
XELOGSDB("bclr %.8X", addr);
|
||||
}
|
||||
ends_block = true;
|
||||
} else if (i.type->opcode == 0x4C000420) {
|
||||
// bcctr/bcctrl
|
||||
block->outgoing_type = FunctionBlock::kTargetCTR;
|
||||
if (i.XL.LK) {
|
||||
XELOGSDB(XT("bcctrl %.8X"), addr);
|
||||
XELOGSDB("bcctrl %.8X", addr);
|
||||
} else {
|
||||
XELOGSDB(XT("bcctr %.8X"), addr);
|
||||
XELOGSDB("bcctr %.8X", addr);
|
||||
}
|
||||
ends_block = true;
|
||||
}
|
||||
@@ -400,7 +399,7 @@ int SymbolDatabase::AnalyzeFunction(FunctionSymbol* fn) {
|
||||
addr += 4;
|
||||
if (fn->end_address && addr > fn->end_address) {
|
||||
// Hmm....
|
||||
XELOGSDB(XT("Ran over function bounds! %.8X-%.8X"),
|
||||
XELOGSDB("Ran over function bounds! %.8X-%.8X",
|
||||
fn->start_address, fn->end_address);
|
||||
break;
|
||||
}
|
||||
@@ -411,8 +410,8 @@ int SymbolDatabase::AnalyzeFunction(FunctionSymbol* fn) {
|
||||
// from someplace valid (like method hints) this may indicate an error.
|
||||
// It's also possible that we guessed in hole-filling and there's another
|
||||
// function below this one.
|
||||
XELOGSDB(XT("Function ran under: %.8X-%.8X ended at %.8X"),
|
||||
fn->start_address, fn->end_address, addr + 4);
|
||||
XELOGSDB("Function ran under: %.8X-%.8X ended at %.8X",
|
||||
fn->start_address, fn->end_address, addr + 4);
|
||||
}
|
||||
fn->end_address = addr;
|
||||
|
||||
@@ -424,7 +423,7 @@ int SymbolDatabase::AnalyzeFunction(FunctionSymbol* fn) {
|
||||
// - if present, flag function as needing a stack
|
||||
// - record prolog/epilog lengths/stack size/etc
|
||||
|
||||
XELOGSDB(XT("Finished analyzing %.8X"), fn->start_address);
|
||||
XELOGSDB("Finished analyzing %.8X", fn->start_address);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -454,7 +453,7 @@ int SymbolDatabase::CompleteFunctionGraph(FunctionSymbol* fn) {
|
||||
block->outgoing_block = fn->SplitBlock(block->outgoing_address);
|
||||
}
|
||||
if (!block->outgoing_block) {
|
||||
XELOGE(XT("block target not found: %.8X"), block->outgoing_address);
|
||||
XELOGE("block target not found: %.8X", block->outgoing_address);
|
||||
XEASSERTALWAYS();
|
||||
}
|
||||
} else {
|
||||
@@ -462,7 +461,7 @@ int SymbolDatabase::CompleteFunctionGraph(FunctionSymbol* fn) {
|
||||
block->outgoing_type = FunctionBlock::kTargetFunction;
|
||||
block->outgoing_function = GetFunction(block->outgoing_address);
|
||||
if (!block->outgoing_function) {
|
||||
XELOGE(XT("call target not found: %.8X -> %.8X"),
|
||||
XELOGE("call target not found: %.8X -> %.8X",
|
||||
block->end_address, block->outgoing_address);
|
||||
new_fns.push_back(block->outgoing_address);
|
||||
}
|
||||
@@ -471,7 +470,7 @@ int SymbolDatabase::CompleteFunctionGraph(FunctionSymbol* fn) {
|
||||
}
|
||||
|
||||
if (new_fns.size()) {
|
||||
XELOGW(XT("Repeat analysis required to find %d new functions"),
|
||||
XELOGW("Repeat analysis required to find %d new functions",
|
||||
(uint32_t)new_fns.size());
|
||||
for (std::vector<uint32_t>::iterator it = new_fns.begin();
|
||||
it != new_fns.end(); ++it) {
|
||||
@@ -584,7 +583,7 @@ int SymbolDatabase::FlushQueue() {
|
||||
FunctionSymbol* fn = scan_queue_.front();
|
||||
scan_queue_.pop_front();
|
||||
if (AnalyzeFunction(fn)) {
|
||||
XELOGSDB(XT("Aborting analysis!"));
|
||||
XELOGSDB("Aborting analysis!");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -654,7 +653,7 @@ void SymbolDatabase::ReadMap(const char* file_name) {
|
||||
// Function was not found via analysis.
|
||||
// We don't want to add it here as that would make us require maps to
|
||||
// get working.
|
||||
XELOGSDB(XT("MAP DIFF: function %.8X %s not found during analysis"),
|
||||
XELOGSDB("MAP DIFF: function %.8X %s not found during analysis",
|
||||
addr, name.c_str());
|
||||
} else {
|
||||
// Add a new variable.
|
||||
|
||||
Reference in New Issue
Block a user