]> git.siccegge.de Git - frida/frida.git/commitdiff
Make function/jump targets clickable
authorChristoph Egger <siccegge@faui49man12.informatik.uni-erlangen.de>
Wed, 14 Jan 2015 17:00:28 +0000 (18:00 +0100)
committerChristoph Egger <siccegge@faui49man12.informatik.uni-erlangen.de>
Wed, 14 Jan 2015 17:00:28 +0000 (18:00 +0100)
src/disassembler/Disassembler.hxx
src/disassembler/llvm/LLVMDisassembler.cxx
src/disassembler/llvm/LLVMDisassembler.hxx
src/gui/Mainwindow.cxx
src/gui/widgets/BasicBlockWidget.cxx
src/gui/widgets/BasicBlockWidget.hxx

index 4636ed9a87aef445946d4e1d7be4610d509fc9cc..5af2eac9d96f84bcbbbaebd16b2b84ce3ee0149a 100644 (file)
@@ -20,7 +20,8 @@ public:
 
        virtual void forEachFunction(std::function<void (uint64_t, Function*)> callback) = 0;
        virtual void printEachInstruction(uint64_t start, uint64_t end,
-                                         std::function<void (uint8_t*, size_t, const std::string&)> fun) = 0;
+                                         std::function<void (uint8_t*, size_t, const std::string&,
+                                                             const std::string&)> fun) = 0;
 protected:
        virtual bool isFunctionCall(uint64_t address) = 0;
        virtual bool isJump(uint64_t address) = 0;
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;
                }
 
index 906318103bfd61aa87d67082c344f3ad13adad5b..59f73497455162c223fa5c056dea38a23408139c 100644 (file)
@@ -29,7 +29,8 @@ public:
 
        void forEachFunction(std::function<void (uint64_t, Function*)> callback);
        void 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);
 
        BasicBlock * getBasicBlock(uint64_t address) {
                return blocks[address];
index 9f1d353ab2a568c14609c051133ebf87143e62ce..5931a834f47bf69f8ce3764d438e46510098b386 100644 (file)
@@ -137,8 +137,11 @@ namespace {
                                          block->getEndAddress(),
                                          [&](uint8_t* bytes,
                                              size_t byte_count,
-                                             const std::string& line) {
-                                                 widget->addItem(bytes, byte_count, line.c_str() + 1);
+                                             const std::string& line,
+                                             const std::string& ref) {
+                                                 widget->addItem(bytes, byte_count,
+                                                                 line.c_str() + 1, // remove \t
+                                                                 ref.c_str());
                                          });
 
                BasicBlockWidget *tmp, *nextl(NULL), *nextr(NULL);
index e65b6e2a49940ea1da922be8cdb7eb4cf17ca63c..cceb2ffd26a064d57464b0b4b0df9d93bfe95abf 100644 (file)
@@ -14,7 +14,7 @@ BasicBlockWidget::BasicBlockWidget(const QString& name, BasicBlock * block)
 }
 
 void BasicBlockWidget::addItem(uint8_t* bytes, size_t num_bytes,
-                               const QString& line) {
+                               QString line, const QString& href) {
        QString bytestring;
 
        for (size_t i(0); i < num_bytes; ++i) {
@@ -28,10 +28,16 @@ void BasicBlockWidget::addItem(uint8_t* bytes, size_t num_bytes,
        if (old_text == "") {
                old_text = "<table>";
        }
+
+       line = line.toHtmlEscaped();
+       if (href != "") {
+               line = "<a href=\"" + href + "\">" + line + "</a>";
+       }
+
        QString new_text =
                old_text.remove("</table>") +
                "<tr><td>" + bytestring +
-               "</td><td>" + line.toHtmlEscaped() +
+               "</td><td>" + line +
                "</td><td>" + "" +
                "</td></tr></table>";
 
index 9b2df93551dff6f974407ac180acf2189499f005..0087e05011d6d93bdbe7758779cb80a06342cc73 100644 (file)
@@ -13,7 +13,7 @@ class BasicBlockWidget : public QGraphicsItem
 public:
        BasicBlockWidget(const QString& name, BasicBlock * block);
 
-       void addItem(uint8_t* bytes, size_t num_bytes, const QString& line);
+       void addItem(uint8_t* bytes, size_t num_bytes, QString line, const QString& href);
 
        QRectF boundingRect() const  {
                qreal penWidth = 1;