From 3e7900dab2b4618d0c4fbe48d312cb74666af842 Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Fri, 13 Mar 2015 14:08:36 +0100 Subject: [PATCH] More logging in LLVMDisassembler --- src/disassembler/llvm/LLVMDisassembler.cxx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/disassembler/llvm/LLVMDisassembler.cxx b/src/disassembler/llvm/LLVMDisassembler.cxx index 96d0883..96418d8 100644 --- a/src/disassembler/llvm/LLVMDisassembler.cxx +++ b/src/disassembler/llvm/LLVMDisassembler.cxx @@ -225,6 +225,11 @@ void LLVMDisassembler::disassembleFunction(Function* function) { 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(); @@ -233,8 +238,6 @@ void LLVMDisassembler::disassembleFunction(Function* function) { << 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; @@ -383,11 +386,16 @@ void LLVMDisassembler::splitBlocks(Function* function) { 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; + 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); -- 2.39.5