X-Git-Url: https://git.siccegge.de//index.cgi?a=blobdiff_plain;f=src%2Fgui%2FMainwindow.cxx;h=46ce2e98562a24cca3b63c460a935529a979de48;hb=fd23bef07ee9d7adb3337d095f78adc6e0b18078;hp=5fd57aa74a404157b2603b2d09ba7ba72e3a320c;hpb=9e283567ac56a6433e832d0fa38cf534a0cb8f9f;p=frida%2Ffrida.git diff --git a/src/gui/Mainwindow.cxx b/src/gui/Mainwindow.cxx index 5fd57aa..46ce2e9 100644 --- a/src/gui/Mainwindow.cxx +++ b/src/gui/Mainwindow.cxx @@ -18,14 +18,17 @@ namespace { } Mainwindow::Mainwindow(InformationManager* mgr) - : manager(mgr) { + : manager(mgr) + , logger(log4cxx::Logger::getLogger("Mainwindow")) { openAction = new QAction(tr("&Open"), this); // saveAction = new QAction(tr("&Save"), this); exitAction = new QAction(tr("E&xit"), this); - connect(openAction, SIGNAL(triggered()), this, SLOT(open())); + connect(openAction, SIGNAL(triggered()), + this, SLOT(open())); // connect(saveAction, SIGNAL(triggered()), this, SLOT(save())); - connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit())); + connect(exitAction, SIGNAL(triggered()), + qApp, SLOT(quit())); fileMenu = menuBar()->addMenu(tr("&File")); fileMenu->addAction(openAction); @@ -52,6 +55,10 @@ Mainwindow::Mainwindow(InformationManager* mgr) setWindowTitle(tr("FRIDA")); mgr->connect_new_function_signal([&] (Function* fun) {addFunction(fun);}); + mgr->connect_new_dyn_symbol_signal([&] (const std::string& name) { + auto item = new QListWidgetItem(name.c_str(), listWidget); + item->setBackground(QBrush(QColor(0xff, 0xdd, 0xdd))); + }); } void Mainwindow::quit() @@ -84,11 +91,16 @@ void Mainwindow::addFunction(Function* fun) { CFGScene * scene = new CFGScene; Disassembler * dis = manager->getDisassembler(); - std::cerr << dis << std::endl; - BasicBlock * block = dis->getBasicBlock(fun->getStartAddress()); - local__add_basic_block(block, manager->getDisassembler(), blocks, scene, block->getStartAddress(), 100); + uint64_t start_address(std::numeric_limits::max()); + for (auto b : fun->blocks()) { + if (b.first < start_address) + start_address = b.first; + } + + local__add_basic_block(block, manager->getDisassembler(), blocks, scene, + start_address, 100); QGraphicsView * view = new QGraphicsView(scene); w->addTab(view, "CFG"); @@ -125,9 +137,15 @@ namespace { widget->setFlag(QGraphicsItem::ItemIsMovable, true); widget->moveBy(100*startx, block->getStartAddress() - starty); - dis->printEachInstruction(block->getStartAddress(), block->getEndAddress(), - [&](uint8_t* bytes, size_t byte_count, const std::string& line) { - widget->addItem(bytes, byte_count, line.c_str() + 1); + dis->printEachInstruction(block->getStartAddress(), + block->getEndAddress(), + [&](uint8_t* bytes, + size_t byte_count, + 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);