#include <QtGui>
-Mainwindow::Mainwindow()
+Mainwindow::Mainwindow(const std::string& filename)
{
openAction = new QAction(tr("&Open"), this);
// saveAction = new QAction(tr("&Save"), this);
connect(listWidget, SIGNAL(currentRowChanged(int)),
stackedWidget, SLOT(setCurrentIndex(int)));
- setWindowTitle(tr("Notepad"));
+ setWindowTitle(tr("FRIDA"));
+
+ openBinary(filename);
}
void Mainwindow::quit()
QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "",
tr("Binaries (*)"));
- if (fileName != "") {
- disassembler.reset(new LLVMDisassembler(fileName.toStdString()));
+ openBinary(fileName.toStdString());
+}
+
+void Mainwindow::openBinary(const std::string& filename) {
+ if (filename != "") {
+ disassembler.reset(new LLVMDisassembler(filename));
+ disassembler->forEachFunction([&](uint64_t address, Function* fun) {
+ populateSymbolInformation(fun);
+ });
+
// curBin = new Binary(fileName.toStdString());
// std::vector<std::string> symbols = curBin->getSymbols();
}
}
-void Mainwindow::populateSymbolInformation(const std::string& sym) {
+void Mainwindow::populateSymbolInformation(Function* fun) {
QTabWidget * w = new QTabWidget();
// Listing
QGraphicsView * view = new QGraphicsView(scene);
w->addTab(view, "CFG");
- listWidget->addItem(sym.c_str());
+ listWidget->addItem(fun->getName().c_str());
stackedWidget->addWidget(w);
}