]> git.siccegge.de Git - frida/frida.git/blobdiff - src/gui/widgets/BasicBlockWidget.cxx
Highlight jumptargets
[frida/frida.git] / src / gui / widgets / BasicBlockWidget.cxx
index ee3b7afc0048ead4a014630349187602ea61b2a4..de97c51d521c92b6cfc36d1871102a0b31cd221e 100644 (file)
@@ -1,4 +1,5 @@
 #include "BasicBlockWidget.hxx"
+#include "CFGScene.hxx"
 #include "gui/Mainwindow.hxx"
 #include "gui/dialogs/SimpleStringDialog.hxx"
 #include "core/BasicBlock.hxx"
@@ -103,7 +104,7 @@ void CustomQGraphicsTextItem::adjustSize() {
 BasicBlockWidget::BasicBlockWidget(const QString& name, BasicBlock * block,
                                    Mainwindow * mainwindow)
        : width(200), height(45), name(name)
-       , _table(NULL)
+       , currentColor(defaultColor), _table(NULL)
        , block(block), mainwindow(mainwindow)
        , logger(log4cxx::Logger::getLogger("gui.BasicBlockWidget." + name.toStdString())) {
        next[0] = NULL; next[1] = NULL;
@@ -122,6 +123,21 @@ BasicBlockWidget::BasicBlockWidget(const QString& name, BasicBlock * block,
                                 if (str.startsWith("function:")) {
                                         QString address = str.remove("function:");
                                         mainwindow->switchMainPlaneToAddress(address.toInt(NULL, 16));
+                                } else if (str.startsWith("block:")) {
+                                        QString address = str.remove("block:");
+
+                                        /* next[0] is always the jumptarget. On a
+                                         * conditional jump, next[1] also
+                                         * contains the following instruction
+                                         *
+                                         * TODO: Verify we're switching to the
+                                         *       right block -- the target
+                                         *       address matches the next blocks
+                                         *       start address
+                                         */
+                                        LOG4CXX_TRACE(logger, "Highlighting block at Address " << address.toStdString()
+                                                      << " BasicBlockWidget " << std::hex << next[0]);
+                                        ((CFGScene*)this->scene())->highlightBlock(next[0]);
                                 }
                         });
        instructions = block->getInstructions();
@@ -251,7 +267,7 @@ void BasicBlockWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem*,
        height = 25 + _widget->boundingRect().height();
        if (width < 250) width = 250;
 
-       painter->fillRect(0, 0, width, height, QColor(0xcc, 0xcc, 0xff, 0xff));
+       painter->fillRect(0, 0, width, height, currentColor);
        painter->setPen(QColor(0x00, 0x00, 0xff, 0xff));
        painter->drawRect(0, 0, width, height);
        painter->drawText(5, 15, name);