]> git.siccegge.de Git - frida/frida.git/blobdiff - src/disassembler/llvm/LLVMDisassembler.cxx
Make function/jump targets clickable
[frida/frida.git] / src / disassembler / llvm / LLVMDisassembler.cxx
index 7d4da0119955da9087ea2a70a5b11c4ae0e4a485..9ab28440f7f96451ef8fb5cc0e4e4b1c604ab613 100644 (file)
@@ -429,8 +429,9 @@ void LLVMDisassembler<ELFT>::forEachFunction(std::function<void (uint64_t, Funct
 
 template <typename ELFT>
 void LLVMDisassembler<ELFT>::printEachInstruction(uint64_t start, uint64_t end,
-                                            std::function<void (uint8_t*, size_t,
-                                                                const std::string&)> fun) {
+                                                  std::function<void (uint8_t*, size_t,
+                                                                         const std::string&,
+                                                                         const std::string&)> fun) {
        SectionRef text_section = sections[".text"];
        uint64_t base_address;
        text_section.getAddress(base_address);
@@ -453,17 +454,24 @@ void LLVMDisassembler<ELFT>::printEachInstruction(uint64_t start, uint64_t end,
                        ref.readBytes(current_address, inst_size, bytes);
 
                        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);
-                               IP->printInst(&inst, s, stream.str());
-                       } else
-                               IP->printInst(&inst, s, "");
+                               ref = stream.str();
+                       }
+
 
-                       fun(bytes, inst_size, s.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");
+                       fun(NULL, 0, "Invalid Byte", "");
                        inst_size = 1;
                }