Broken, incomplete, but need to move forward with rewrite.
This commit is contained in:
@@ -105,6 +105,11 @@ FunctionBlock* FunctionSymbol::SplitBlock(uint32_t address) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void FunctionSymbol::AddCall(FunctionSymbol* source, FunctionSymbol* target) {
|
||||
source->outgoing_calls.push_back(FunctionCall(0, source, target));
|
||||
target->incoming_calls.push_back(FunctionCall(0, source, target));
|
||||
}
|
||||
|
||||
|
||||
VariableSymbol::VariableSymbol() :
|
||||
Symbol(Variable),
|
||||
|
||||
@@ -32,6 +32,10 @@ public:
|
||||
uint32_t address;
|
||||
FunctionSymbol* source;
|
||||
FunctionSymbol* target;
|
||||
|
||||
FunctionCall(uint32_t address, FunctionSymbol* source,
|
||||
FunctionSymbol* target) :
|
||||
address(address), source(source), target(target) {}
|
||||
};
|
||||
|
||||
class VariableAccess {
|
||||
@@ -39,6 +43,10 @@ public:
|
||||
uint32_t address;
|
||||
FunctionSymbol* source;
|
||||
VariableSymbol* target;
|
||||
|
||||
VariableAccess(uint32_t address, FunctionSymbol* source,
|
||||
VariableSymbol* target) :
|
||||
address(address), source(source), target(target) {}
|
||||
};
|
||||
|
||||
class Symbol {
|
||||
@@ -116,11 +124,13 @@ public:
|
||||
kernel::KernelExport* kernel_export;
|
||||
ExceptionEntrySymbol* ee;
|
||||
|
||||
std::vector<FunctionCall*> incoming_calls;
|
||||
std::vector<FunctionCall*> outgoing_calls;
|
||||
std::vector<VariableAccess*> variable_accesses;
|
||||
std::vector<FunctionCall> incoming_calls;
|
||||
std::vector<FunctionCall> outgoing_calls;
|
||||
std::vector<VariableAccess> variable_accesses;
|
||||
|
||||
std::map<uint32_t, FunctionBlock*> blocks;
|
||||
|
||||
static void AddCall(FunctionSymbol* source, FunctionSymbol* target);
|
||||
};
|
||||
|
||||
class VariableSymbol : public Symbol {
|
||||
|
||||
@@ -103,9 +103,13 @@ ExceptionEntrySymbol* SymbolDatabase::GetOrInsertExceptionEntry(
|
||||
return ee;
|
||||
}
|
||||
|
||||
FunctionSymbol* SymbolDatabase::GetOrInsertFunction(uint32_t address) {
|
||||
FunctionSymbol* SymbolDatabase::GetOrInsertFunction(
|
||||
uint32_t address, FunctionSymbol* opt_call_source) {
|
||||
FunctionSymbol* fn = GetFunction(address);
|
||||
if (fn) {
|
||||
if (opt_call_source) {
|
||||
FunctionSymbol::AddCall(opt_call_source, fn);
|
||||
}
|
||||
return fn;
|
||||
}
|
||||
|
||||
@@ -120,6 +124,11 @@ FunctionSymbol* SymbolDatabase::GetOrInsertFunction(uint32_t address) {
|
||||
function_count_++;
|
||||
symbols_.insert(SymbolMap::value_type(address, fn));
|
||||
scan_queue_.push_back(fn);
|
||||
|
||||
if (opt_call_source) {
|
||||
FunctionSymbol::AddCall(opt_call_source, fn);
|
||||
}
|
||||
|
||||
return fn;
|
||||
}
|
||||
|
||||
@@ -460,7 +469,9 @@ int SymbolDatabase::CompleteFunctionGraph(FunctionSymbol* fn) {
|
||||
// Function call.
|
||||
block->outgoing_type = FunctionBlock::kTargetFunction;
|
||||
block->outgoing_function = GetFunction(block->outgoing_address);
|
||||
if (!block->outgoing_function) {
|
||||
if (block->outgoing_function) {
|
||||
FunctionSymbol::AddCall(fn, block->outgoing_function);
|
||||
} else {
|
||||
XELOGE("call target not found: %.8X -> %.8X",
|
||||
block->end_address, block->outgoing_address);
|
||||
new_fns.push_back(block->outgoing_address);
|
||||
@@ -474,7 +485,7 @@ int SymbolDatabase::CompleteFunctionGraph(FunctionSymbol* fn) {
|
||||
(uint32_t)new_fns.size());
|
||||
for (std::vector<uint32_t>::iterator it = new_fns.begin();
|
||||
it != new_fns.end(); ++it) {
|
||||
GetOrInsertFunction(*it);
|
||||
GetOrInsertFunction(*it, fn);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,8 @@ public:
|
||||
|
||||
Symbol* GetSymbol(uint32_t address);
|
||||
ExceptionEntrySymbol* GetOrInsertExceptionEntry(uint32_t address);
|
||||
FunctionSymbol* GetOrInsertFunction(uint32_t address);
|
||||
FunctionSymbol* GetOrInsertFunction(
|
||||
uint32_t address, FunctionSymbol* opt_call_source = NULL);
|
||||
VariableSymbol* GetOrInsertVariable(uint32_t address);
|
||||
FunctionSymbol* GetFunction(uint32_t address);
|
||||
VariableSymbol* GetVariable(uint32_t address);
|
||||
|
||||
Reference in New Issue
Block a user