]> git.siccegge.de Git - frida/frida.git/blobdiff - src/gui/Mainwindow.cxx
Horizontally distribute BasicBlockWidgets
[frida/frida.git] / src / gui / Mainwindow.cxx
index ace89f34523d629da3bf7c1e8963c0073df03b62..f98cd60a226888da2f780af6c3dc924cdde6a45b 100644 (file)
@@ -1,6 +1,7 @@
 #include "Mainwindow.hxx"
 #include "qt.hxx"
 #include "disassembler/llvm/LLVMDisassembler.hxx"
+#include "widgets/CFGScene.hxx"
 
 #include <iostream>
 #include <sstream>
@@ -24,6 +25,10 @@ Mainwindow::Mainwindow(const std::string& filename)
     fileMenu->addSeparator();
     fileMenu->addAction(exitAction);
 
+    scripting = new ScriptingDock(tr("Scripting"), this);
+    scripting->setAllowedAreas(Qt::BottomDockWidgetArea);
+    addDockWidget(Qt::BottomDockWidgetArea, scripting);
+
     listWidget = new QListWidget();
     stackedWidget = new QStackedWidget();
     dockWidget = new QDockWidget(tr("Functions"), this);
@@ -72,7 +77,7 @@ namespace {
        BasicBlockWidget *
        local__add_basic_block(BasicBlock * block, Disassembler * dis,
                                                   std::map<uint64_t, BasicBlockWidget*>& known_blocks,
-                                                  QGraphicsScene * scene, uint64_t starty, uint64_t startx) {
+                                                  CFGScene * scene, uint64_t starty, uint64_t startx) {
 
                decltype(known_blocks.begin()) old;
                if ((old = known_blocks.find(block->getStartAddress())) != known_blocks.end())
@@ -87,7 +92,7 @@ namespace {
 
                scene->addItem(widget);
                widget->setFlag(QGraphicsItem::ItemIsMovable, true);
-               widget->moveBy(100*startx, 10*(block->getStartAddress() - starty));
+               widget->moveBy(100*startx, block->getStartAddress() - starty);
 
                dis->printEachInstruction(block->getStartAddress(), block->getEndAddress(),
                                                                  [&](uint8_t* bytes, size_t byte_count, const std::string& line) {
@@ -97,10 +102,13 @@ namespace {
                BasicBlockWidget *tmp, *nextl(NULL), *nextr(NULL);
                BasicBlock * tmpblock;
                if (block->getNextBlock(0) != 0) {
+                       int xshift = 0;
+                       if (block->getNextBlock(1) != 0)
+                               xshift = 1;
                        tmpblock = dis->getBasicBlock(block->getNextBlock(0));
                        tmp = local__add_basic_block(tmpblock, dis,
                                                                                 known_blocks,
-                                                                                scene, starty, startx+1);
+                                                                                scene, starty, startx+xshift);
                        nextl = tmp;
                        tmp->addPrevious(widget);
                }
@@ -121,7 +129,7 @@ void Mainwindow::populateSymbolInformation(Function* fun) {
     QTabWidget * w = new QTabWidget();
 
     // CFG
-    QGraphicsScene * scene = new QGraphicsScene;
+    CFGScene * scene = new CFGScene;
 
        BasicBlock * block = disassembler->getBasicBlock(fun->getStartAddress());