From: Christoph Egger Date: Sat, 16 May 2015 13:59:50 +0000 (+0200) Subject: Remove deprecated printEachInstruction function X-Git-Tag: v0.2~27 X-Git-Url: https://git.siccegge.de//index.cgi?a=commitdiff_plain;h=5d65588185f3d19fc6fa311f642cc5fd78966087;p=frida%2Ffrida.git Remove deprecated printEachInstruction function replaced by getInstructions, no users left --- diff --git a/src/disassembler/Disassembler.hxx b/src/disassembler/Disassembler.hxx index ffcc889..7e1e3e1 100644 --- a/src/disassembler/Disassembler.hxx +++ b/src/disassembler/Disassembler.hxx @@ -20,9 +20,6 @@ public: virtual void getSymbols() = 0; virtual uint64_t entryAddress() = 0; - virtual void printEachInstruction(uint64_t start, uint64_t end, - std::function fun) = 0; virtual Function * disassembleFunctionAt(uint64_t address, const std::string& name = "") = 0; virtual std::vector getInstructions(const BasicBlock* block) = 0; }; diff --git a/src/disassembler/llvm/LLVMDisassembler.cxx b/src/disassembler/llvm/LLVMDisassembler.cxx index 831a1a9..049f1fc 100644 --- a/src/disassembler/llvm/LLVMDisassembler.cxx +++ b/src/disassembler/llvm/LLVMDisassembler.cxx @@ -694,83 +694,6 @@ std::vector LLVMDisassembler::getInstructions(const BasicBloc return result; } -template -void LLVMDisassembler::printEachInstruction(uint64_t start, uint64_t end, - std::function fun) { - SectionRef text_section = getTextSection(); - uint64_t base_address; -#if defined(LLVM_35) - text_section.getAddress(base_address); -#elif defined(LLVM_36) - base_address = text_section.getAddress(); -#endif - - uint64_t current_address = start - base_address; - - StringRef bytes; - text_section.getContents(bytes); -#if defined(LLVM_35) - StringRefMemoryObject ref(bytes); -#elif defined(LLVM_36) - ArrayRef bytearray(reinterpret_cast(bytes.data()), - bytes.size()); -#endif - - - while (current_address < end - base_address) { - uint64_t inst_size; - MCInst inst; - std::string buf; - llvm::raw_string_ostream s(buf); - - if(llvm::MCDisassembler::Success == -#if defined(LLVM_35) - DisAsm->getInstruction(inst, inst_size, ref, current_address, nulls(), nulls())) { -#elif defined(LLVM_36) - DisAsm->getInstruction(inst, inst_size, - bytearray.slice(current_address), - base_address + current_address, - nulls(), nulls())) { -#endif - - uint8_t bytes[inst_size+2]; -#if defined(LLVM_35) - ref.readBytes(current_address, inst_size, bytes); -#elif defined(LLVM_36) - size_t bytesindex(0); - for (uint8_t byte : bytearray.slice(current_address, inst_size)) { - bytes[bytesindex++] = byte; - } -#endif - - uint64_t jmptarget; - std::string ref(""); - IP->printInst(&inst, s, ""); - if (MIA->evaluateBranch(inst, current_address, inst_size, jmptarget)) { - std::stringstream stream; - if (MIA->isCall(inst)) - stream << "function:"; - else - stream << "block:"; - - stream << std::hex << (base_address + jmptarget); - ref = stream.str(); - } - - - fun(bytes, inst_size, s.str(), ref); - } else { - LOG4CXX_WARN(logger, "Invalid byte at" << std::hex << current_address + base_address); - fun(NULL, 0, "Invalid Byte", ""); - inst_size = 1; - } - - current_address += inst_size; - } -} - template SectionRef LLVMDisassembler::getTextSection() { return sections[".text"]; diff --git a/src/disassembler/llvm/LLVMDisassembler.hxx b/src/disassembler/llvm/LLVMDisassembler.hxx index d8d4056..b9fc453 100644 --- a/src/disassembler/llvm/LLVMDisassembler.hxx +++ b/src/disassembler/llvm/LLVMDisassembler.hxx @@ -26,10 +26,6 @@ public: void getSymbols() {} uint64_t entryAddress(); - void printEachInstruction(uint64_t start, uint64_t end, - std::function fun); - Function * disassembleFunctionAt(uint64_t address, const std::string& name = ""); std::vector getInstructions(const BasicBlock* block);