#include <sstream>
class Disassembler;
+class InformationManager;
class BasicBlock {
public:
- BasicBlock(uint64_t start_address, Disassembler * disassembler)
+ BasicBlock(uint64_t start_address, Disassembler * disassembler,
+ InformationManager* manager)
: start_address(start_address)
- , disassembler(disassembler) {
+ , disassembler(disassembler)
+ , manager(manager) {
next_blocks[0] = 0;
next_blocks[1] = 0;
}
return disassembler;
}
+ InformationManager* getManager() const {
+ return manager;
+ }
private:
uint64_t start_address;
uint64_t end_address;
Disassembler* disassembler;
+ InformationManager* manager;
uint64_t next_blocks[2];
};
#include <map>
#include "BasicBlock.hxx"
+class InformationManager;
+
class Function {
public:
- Function(const std::string& name, uint64_t start_address)
+ Function(const std::string& name, uint64_t start_address,
+ InformationManager* manager)
: name(name)
- , start_address(start_address) {
- }
+ , start_address(start_address)
+ ,manager(manager) {}
uint64_t getStartAddress() const {
return start_address;
return name;
}
+ InformationManager* getManager() const {
+ return manager;
+ }
+
void addBasicBlock(BasicBlock* block) {
_blocks.insert(std::make_pair(block->getStartAddress(), block));
}
private:
std::string name;
uint64_t start_address;
+ InformationManager * manager;
std::map<uint64_t, BasicBlock*> _blocks;
};
if (name == "") {
std::stringstream s;
s << "<Unnamed 0x" << std::hex << address << ">";
- function = new Function(s.str(), address);
+ function = new Function(s.str(), address, manager);
} else {
- function = new Function(name, address);
+ function = new Function(name, address, manager);
}
functions.insert(std::make_pair(address, function));
LOG4CXX_DEBUG(logger, "Handling function " << function->getName());
- BasicBlock * block = new BasicBlock(function->getStartAddress(), this);
+ BasicBlock * block = new BasicBlock(function->getStartAddress(), this, manager);
remaining_blocks.push(block);
blocks.insert(std::make_pair(block->getStartAddress(), block));
function->addBasicBlock(block);
} else {
current_block->setNextBlock(0, jmptarget);
if (blocks.find(jmptarget) == blocks.end()) {
- BasicBlock * block = new BasicBlock(jmptarget, this);
+ BasicBlock * block = new BasicBlock(jmptarget, this, manager);
blocks.insert(std::make_pair(block->getStartAddress(), block));
function->addBasicBlock(block);
remaining_blocks.push(block);
jmptarget = base_address + current_address + inst_size;
current_block->setNextBlock(1, jmptarget);
if (blocks.find(jmptarget) == blocks.end()) {
- BasicBlock * block = new BasicBlock(jmptarget, this);
+ BasicBlock * block = new BasicBlock(jmptarget, this, manager);
blocks.insert(std::make_pair(block->getStartAddress(), block));
function->addBasicBlock(block);
remaining_blocks.push(block);
continue;
if (!x->second.getAddress(result)) {
- Function * fun = new Function(x->first, result);
+ Function * fun = new Function(x->first, result, manager);
remaining_functions.push_back(fun);
functions.insert(std::make_pair(result, fun));
LOG4CXX_DEBUG(logger, "Disasembling " << x->first);