Better asserts/checks around bad function addresses.
This commit is contained in:
parent
bf9e92c027
commit
22f186d713
|
@ -36,6 +36,8 @@ void* _cdecl XeIndirectBranch(
|
||||||
// TODO(benvanik): track this statistic - this path is very slow!
|
// TODO(benvanik): track this statistic - this path is very slow!
|
||||||
Processor* processor = (Processor*)state->processor;
|
Processor* processor = (Processor*)state->processor;
|
||||||
void* target_ptr = processor->GetFunctionPointer((uint32_t)target);
|
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;
|
return target_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -244,7 +244,7 @@ FunctionSymbol* Processor::GetFunction(uint32_t address) {
|
||||||
void* Processor::GetFunctionPointer(uint32_t address) {
|
void* Processor::GetFunctionPointer(uint32_t address) {
|
||||||
// Attempt to get the function.
|
// Attempt to get the function.
|
||||||
FunctionSymbol* fn_symbol = GetFunction(address);
|
FunctionSymbol* fn_symbol = GetFunction(address);
|
||||||
if (!fn_symbol) {
|
if (!fn_symbol || fn_symbol->type == FunctionSymbol::Unknown) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -148,6 +148,8 @@ VariableSymbol* SymbolDatabase::GetOrInsertVariable(uint32_t address) {
|
||||||
}
|
}
|
||||||
|
|
||||||
FunctionSymbol* SymbolDatabase::GetFunction(uint32_t address, bool analyze) {
|
FunctionSymbol* SymbolDatabase::GetFunction(uint32_t address, bool analyze) {
|
||||||
|
XEASSERT(address);
|
||||||
|
|
||||||
SymbolMap::iterator i = symbols_.find(address);
|
SymbolMap::iterator i = symbols_.find(address);
|
||||||
if (i != symbols_.end() && i->second->symbol_type == Symbol::Function) {
|
if (i != symbols_.end() && i->second->symbol_type == Symbol::Function) {
|
||||||
return static_cast<FunctionSymbol*>(i->second);
|
return static_cast<FunctionSymbol*>(i->second);
|
||||||
|
|
|
@ -106,6 +106,8 @@ int X64Emitter::PrepareFunction(FunctionSymbol* symbol) {
|
||||||
XESUCCEED();
|
XESUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XEASSERT(symbol->type != FunctionSymbol::Unknown);
|
||||||
|
|
||||||
// Create the custom redirector function.
|
// Create the custom redirector function.
|
||||||
// This function will jump to the on-demand compilation routine to
|
// This function will jump to the on-demand compilation routine to
|
||||||
// generate the real function as required. Afterwards, it will be
|
// 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);
|
TraceInstruction(i);
|
||||||
|
|
||||||
if (!i.type) {
|
if (!i.type) {
|
||||||
|
|
Loading…
Reference in New Issue