From a4cda4cb66cd928bb5810cace7fe1de26f33908f Mon Sep 17 00:00:00 2001 From: Lephenixnoir Date: Sun, 3 Sep 2023 19:20:45 +0200 Subject: [PATCH] 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. --- include/fxos/disassembly.h | 20 ++++++++++---------- lib/disassembly.cpp | 20 ++++++++++---------- lib/passes/cfg.cpp | 2 +- shell/i.cpp | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/include/fxos/disassembly.h b/include/fxos/disassembly.h index 5435330..8af8c6e 100644 --- a/include/fxos/disassembly.h +++ b/include/fxos/disassembly.h @@ -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 functions; + std::map 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 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); diff --git a/lib/disassembly.cpp b/lib/disassembly.cpp index 743c375..9a71558 100644 --- a/lib/disassembly.cpp +++ b/lib/disassembly.cpp @@ -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 */ diff --git a/lib/passes/cfg.cpp b/lib/passes/cfg.cpp index b916183..80a2805 100644 --- a/lib/passes/cfg.cpp +++ b/lib/passes/cfg.cpp @@ -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; diff --git a/shell/i.cpp b/shell/i.cpp index 6b7ca93..6787e44 100644 --- a/shell/i.cpp +++ b/shell/i.cpp @@ -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;