diff --git a/src/xenia/cpu/global_exports.cc b/src/xenia/cpu/global_exports.cc index 36c0354ec..6d808d2d7 100644 --- a/src/xenia/cpu/global_exports.cc +++ b/src/xenia/cpu/global_exports.cc @@ -36,6 +36,8 @@ void* _cdecl XeIndirectBranch( // TODO(benvanik): track this statistic - this path is very slow! Processor* processor = (Processor*)state->processor; void* target_ptr = processor->GetFunctionPointer((uint32_t)target); + // target_ptr will be null when the given target is not a function. + XEASSERTNOTNULL(target_ptr); return target_ptr; } diff --git a/src/xenia/cpu/processor.cc b/src/xenia/cpu/processor.cc index fbf644002..76b0a4459 100644 --- a/src/xenia/cpu/processor.cc +++ b/src/xenia/cpu/processor.cc @@ -244,7 +244,7 @@ FunctionSymbol* Processor::GetFunction(uint32_t address) { void* Processor::GetFunctionPointer(uint32_t address) { // Attempt to get the function. FunctionSymbol* fn_symbol = GetFunction(address); - if (!fn_symbol) { + if (!fn_symbol || fn_symbol->type == FunctionSymbol::Unknown) { return NULL; } diff --git a/src/xenia/cpu/sdb/symbol_database.cc b/src/xenia/cpu/sdb/symbol_database.cc index dd5f329bd..c0548d39d 100644 --- a/src/xenia/cpu/sdb/symbol_database.cc +++ b/src/xenia/cpu/sdb/symbol_database.cc @@ -148,6 +148,8 @@ VariableSymbol* SymbolDatabase::GetOrInsertVariable(uint32_t address) { } FunctionSymbol* SymbolDatabase::GetFunction(uint32_t address, bool analyze) { + XEASSERT(address); + SymbolMap::iterator i = symbols_.find(address); if (i != symbols_.end() && i->second->symbol_type == Symbol::Function) { return static_cast(i->second); diff --git a/src/xenia/cpu/x64/x64_emitter.cc b/src/xenia/cpu/x64/x64_emitter.cc index 7a73587af..0b5268d2e 100644 --- a/src/xenia/cpu/x64/x64_emitter.cc +++ b/src/xenia/cpu/x64/x64_emitter.cc @@ -106,6 +106,8 @@ int X64Emitter::PrepareFunction(FunctionSymbol* symbol) { XESUCCEED(); } + XEASSERT(symbol->type != FunctionSymbol::Unknown); + // Create the custom redirector function. // This function will jump to the on-demand compilation routine to // generate the real function as required. Afterwards, it will be @@ -592,6 +594,10 @@ void X64Emitter::GenerateBasicBlock(FunctionBlock* block) { } } + if (FLAGS_log_codegen) { + fflush(stdout); + } + TraceInstruction(i); if (!i.type) {