]> git.siccegge.de Git - frida/frida.git/commitdiff
More logging in LLVMDisassembler
authorChristoph Egger <Christoph.Egger@fau.de>
Fri, 13 Mar 2015 13:08:36 +0000 (14:08 +0100)
committerChristoph Egger <Christoph.Egger@fau.de>
Fri, 13 Mar 2015 13:08:36 +0000 (14:08 +0100)
src/disassembler/llvm/LLVMDisassembler.cxx

index 96d08830e4f26087df5cd3feb373f5f47a781bf5..96418d86bbdded11fd4c530aef48f571c4300cd6 100644 (file)
@@ -225,6 +225,11 @@ void LLVMDisassembler<ELFT>::disassembleFunction(Function* function) {
        new_blocks.insert(std::make_pair(block->getStartAddress(), block));
        function->addBasicBlock(block);
 
        new_blocks.insert(std::make_pair(block->getStartAddress(), block));
        function->addBasicBlock(block);
 
+       uint64_t base_address, size;
+       text_section.getAddress(base_address);
+       text_section.getSize(size);
+       LOG4CXX_DEBUG(logger, "Text section at " << std::hex << base_address << " with size " << size);
+
        while (remaining_blocks.size()) {
                BasicBlock * current_block = remaining_blocks.top();
                remaining_blocks.pop();
        while (remaining_blocks.size()) {
                BasicBlock * current_block = remaining_blocks.top();
                remaining_blocks.pop();
@@ -233,8 +238,6 @@ void LLVMDisassembler<ELFT>::disassembleFunction(Function* function) {
                              << current_block->getStartAddress());
 
                uint64_t inst_size;
                              << current_block->getStartAddress());
 
                uint64_t inst_size;
-               uint64_t base_address;
-               text_section.getAddress(base_address);
                uint64_t current_address = current_block->getStartAddress() - base_address;
                while(true) {
                        MCInst inst;
                uint64_t current_address = current_block->getStartAddress() - base_address;
                while(true) {
                        MCInst inst;
@@ -383,11 +386,16 @@ void LLVMDisassembler<ELFT>::splitBlocks(Function* function) {
        text_section.getContents(bytes);
        StringRefMemoryObject ref(bytes);
 
        text_section.getContents(bytes);
        StringRefMemoryObject ref(bytes);
 
+       LOG4CXX_DEBUG(logger, "Splitting Blocks in Function " << function->getName());
        // Split blocks where jumps are going inside the block
        for (auto it = function->blocks().begin();
             it != function->blocks().end();
             ++it) {
                BasicBlock * current_block = it->second;
        // Split blocks where jumps are going inside the block
        for (auto it = function->blocks().begin();
             it != function->blocks().end();
             ++it) {
                BasicBlock * current_block = it->second;
+               if (current_block->getEndAddress() == 0) {
+                       LOG4CXX_ERROR(logger, "UNFINISHED BLOCK " << std::hex << current_block->getStartAddress());
+                       break;
+               }
                uint64_t inst_size;
                uint64_t base_address;
                text_section.getAddress(base_address);
                uint64_t inst_size;
                uint64_t base_address;
                text_section.getAddress(base_address);