fxos: rename Function -> OldFunction
This prepares the introduction of a new program model different enough from the original that I'd rather build it on the side than progressively update the current one.
This commit is contained in:
parent
b5d7947958
commit
a4cda4cb66
|
@ -106,10 +106,10 @@ struct Instruction
|
|||
// Dynamic information on functions
|
||||
//---
|
||||
|
||||
struct Function
|
||||
struct OldFunction
|
||||
{
|
||||
/* Create a bare function with no detailed information */
|
||||
Function(uint32_t pc);
|
||||
OldFunction(uint32_t pc);
|
||||
|
||||
/* Function's entry point */
|
||||
uint32_t address;
|
||||
|
@ -186,14 +186,14 @@ struct Disassembly
|
|||
|
||||
// Function information
|
||||
|
||||
std::map<uint32_t, Function> functions;
|
||||
std::map<uint32_t, OldFunction> functions;
|
||||
|
||||
/* Check whether a function is defined at PC */
|
||||
bool hasFunctionAt(uint32_t pc);
|
||||
/* Find a function by address; returns nullptr if not yet defined */
|
||||
Function *getFunctionAt(uint32_t pc);
|
||||
OldFunction *getFunctionAt(uint32_t pc);
|
||||
/* Find a function and create it empty if it's not yet defined */
|
||||
Function *getOrCreateFunctionAt(uint32_t pc);
|
||||
OldFunction *getOrCreateFunctionAt(uint32_t pc);
|
||||
|
||||
|
||||
// Claim information
|
||||
|
@ -247,17 +247,17 @@ public:
|
|||
bool analyzeAllFunctions();
|
||||
|
||||
/* Analyze a function */
|
||||
virtual bool analyzeFunction(Function &func) = 0;
|
||||
virtual bool analyzeFunction(OldFunction &func) = 0;
|
||||
bool analyzeFunction(uint32_t pc);
|
||||
|
||||
/* Analyze a function and its subfunctions, recursively */
|
||||
bool analyzeFunctionRecursively(Function &func);
|
||||
bool analyzeFunctionRecursively(OldFunction &func);
|
||||
bool analyzeFunctionRecursively(uint32_t pc);
|
||||
|
||||
/* For custom analysis function: enqueue subfunctions. The update variant
|
||||
enqueues them even if they were already seen. */
|
||||
void enqueueSubfunctions(Function &func);
|
||||
void updateSubfunctions(Function &func);
|
||||
void enqueueSubfunctions(OldFunction &func);
|
||||
void updateSubfunctions(OldFunction &func);
|
||||
|
||||
private:
|
||||
Queue<uint32_t> m_queue;
|
||||
|
@ -282,7 +282,7 @@ public:
|
|||
|
||||
/* Analyze a function by following its CFG */
|
||||
using FunctionPass::analyzeFunction;
|
||||
bool analyzeFunction(Function &func) override;
|
||||
bool analyzeFunction(OldFunction &func) override;
|
||||
|
||||
/* Analyze an anonymous function; just assume one starts at PC */
|
||||
bool analyzeAnonymousFunction(uint32_t pc);
|
||||
|
|
|
@ -55,7 +55,7 @@ Instruction::Instruction(uint16_t opcode):
|
|||
// Function information
|
||||
//---
|
||||
|
||||
Function::Function(uint32_t pc): address {pc}
|
||||
OldFunction::OldFunction(uint32_t pc): address {pc}
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ bool Disassembly::hasFunctionAt(uint32_t pc)
|
|||
return this->functions.count(pc) > 0;
|
||||
}
|
||||
|
||||
Function *Disassembly::getFunctionAt(uint32_t pc)
|
||||
OldFunction *Disassembly::getFunctionAt(uint32_t pc)
|
||||
{
|
||||
auto it = this->functions.find(pc);
|
||||
|
||||
|
@ -154,10 +154,10 @@ Function *Disassembly::getFunctionAt(uint32_t pc)
|
|||
return &it->second;
|
||||
}
|
||||
|
||||
Function *Disassembly::getOrCreateFunctionAt(uint32_t pc)
|
||||
OldFunction *Disassembly::getOrCreateFunctionAt(uint32_t pc)
|
||||
{
|
||||
if(!this->hasFunctionAt(pc)) {
|
||||
Function f(pc);
|
||||
OldFunction f(pc);
|
||||
this->functions.insert({pc, f});
|
||||
}
|
||||
return this->getFunctionAt(pc);
|
||||
|
@ -269,7 +269,7 @@ bool FunctionPass::analyzeAllFunctions()
|
|||
|
||||
bool FunctionPass::analyzeFunction(uint32_t pc)
|
||||
{
|
||||
Function *func = m_disasm.getFunctionAt(pc);
|
||||
OldFunction *func = m_disasm.getFunctionAt(pc);
|
||||
if(!func) {
|
||||
FxOS_log(ERR, "no function at 0x%08x", pc);
|
||||
return false;
|
||||
|
@ -277,7 +277,7 @@ bool FunctionPass::analyzeFunction(uint32_t pc)
|
|||
return this->analyzeFunction(*func);
|
||||
}
|
||||
|
||||
bool FunctionPass::analyzeFunctionRecursively(Function &func)
|
||||
bool FunctionPass::analyzeFunctionRecursively(OldFunction &func)
|
||||
{
|
||||
return this->analyzeFunctionRecursively(func.address);
|
||||
}
|
||||
|
@ -289,7 +289,7 @@ bool FunctionPass::analyzeFunctionRecursively(uint32_t pc)
|
|||
|
||||
while(!m_queue.empty()) {
|
||||
uint32_t pc = m_queue.pop();
|
||||
Function *next = m_disasm.getFunctionAt(pc);
|
||||
OldFunction *next = m_disasm.getFunctionAt(pc);
|
||||
if(this->analyzeFunction(*next))
|
||||
this->enqueueSubfunctions(*next);
|
||||
else
|
||||
|
@ -299,13 +299,13 @@ bool FunctionPass::analyzeFunctionRecursively(uint32_t pc)
|
|||
return ok;
|
||||
}
|
||||
|
||||
void FunctionPass::enqueueSubfunctions(Function &func)
|
||||
void FunctionPass::enqueueSubfunctions(OldFunction &func)
|
||||
{
|
||||
for(uint32_t pc: func.callTargets)
|
||||
m_queue.enqueue(pc);
|
||||
}
|
||||
|
||||
void FunctionPass::updateSubfunctions(Function &func)
|
||||
void FunctionPass::updateSubfunctions(OldFunction &func)
|
||||
{
|
||||
for(uint32_t pc: func.callTargets)
|
||||
m_queue.update(pc);
|
||||
|
@ -335,7 +335,7 @@ bool InstructionPass::analyzeAllInstructions()
|
|||
return ok;
|
||||
}
|
||||
|
||||
bool InstructionPass::analyzeFunction(Function &func)
|
||||
bool InstructionPass::analyzeFunction(OldFunction &func)
|
||||
{
|
||||
/* We don't have any function-specific information to pass yet, so we can
|
||||
fall back to the anonymous version */
|
||||
|
|
|
@ -103,7 +103,7 @@ bool CfgPass::exploreFunction(uint32_t pc)
|
|||
m_lastFunction = pc;
|
||||
m_claimedInstructions.clear();
|
||||
|
||||
Function *func = m_disasm.getOrCreateFunctionAt(pc);
|
||||
OldFunction *func = m_disasm.getOrCreateFunctionAt(pc);
|
||||
if(!this->analyzeFunction(pc))
|
||||
return false;
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ void _if(Session &session, struct _if_args const &args)
|
|||
}
|
||||
|
||||
for(uint32_t address: args.addresses) {
|
||||
Function *func = disasm.getFunctionAt(address);
|
||||
OldFunction *func = disasm.getFunctionAt(address);
|
||||
if(!func) {
|
||||
FxOS_log(ERR, "no function at 0x{:08x}", address);
|
||||
continue;
|
||||
|
|
Loading…
Reference in New Issue