X-Git-Url: https://git.siccegge.de//index.cgi?p=frida%2Ffrida.git;a=blobdiff_plain;f=src%2Fdisassembler%2Fllvm%2FLLVMDisassembler.cxx;h=a8c2867f50784255a27246bb10be5db9312d2e87;hp=3494b79bd8a370814d35eba28fec53db0e1543d6;hb=1d66010fc38eab99ec29d25606e3d44a3297e6e6;hpb=c55f9e2b5f5ff83817ab5187eb0122600a4c5cea diff --git a/src/disassembler/llvm/LLVMDisassembler.cxx b/src/disassembler/llvm/LLVMDisassembler.cxx index 3494b79..a8c2867 100644 --- a/src/disassembler/llvm/LLVMDisassembler.cxx +++ b/src/disassembler/llvm/LLVMDisassembler.cxx @@ -110,7 +110,20 @@ LLVMDisassembler::LLVMDisassembler(const std::string& filename) disassemble(); } +LLVMDisassembler::~LLVMDisassembler() { + std::for_each(functions.begin(), functions.end(), + [](std::pair it) { + delete it.second; + }); + std::for_each(blocks.begin(), blocks.end(), + [](std::pair it) { + delete it.second; + }); +} +/* + * TODO: If we jump into some Basic Block we need to split it there into two + */ void LLVMDisassembler::disassemble() { std::stack remaining_functions; std::stack remaining_blocks; @@ -121,9 +134,6 @@ void LLVMDisassembler::disassemble() { bool contains; SymbolRef::Type symbol_type; -/* - * TODO: If we jump into some Basic Block we need to split it there into two - */ if (text_section.containsSymbol(x->second, contains) || !contains) continue; @@ -204,6 +214,7 @@ void LLVMDisassembler::disassemble() { if (blocks.find(jmptarget) == blocks.end()) { LLVMBasicBlock * block = new LLVMBasicBlock(jmptarget); blocks.insert(std::make_pair(block->getStartAddress(), block)); + current_block->setNextBlock(0, block->getStartAddress()); remaining_blocks.push(block); } if (MIA->isConditionalBranch(inst)) { @@ -211,7 +222,9 @@ void LLVMDisassembler::disassemble() { if (blocks.find(jmptarget) == blocks.end()) { LLVMBasicBlock * block = new LLVMBasicBlock(jmptarget); blocks.insert(std::make_pair(block->getStartAddress(), block)); + current_block->setNextBlock(1, block->getStartAddress()); remaining_blocks.push(new LLVMBasicBlock(jmptarget)); + } } } } @@ -225,7 +238,6 @@ void LLVMDisassembler::disassemble() { current_block->setEndAddress(current_address + base_address); LOG4CXX_DEBUG(logger, "Finished Block at " << std::hex << current_block->getEndAddress()); - } break; } current_address += inst_size; @@ -270,9 +282,3 @@ void LLVMDisassembler::forEachFunction(std::function callback(x.first, x.second); }); } - - - -void LLVMDisassembler::generateControlFlowGraph(uint64_t address) { - -}