X-Git-Url: https://git.siccegge.de//index.cgi?p=frida%2Ffrida.git;a=blobdiff_plain;f=src%2Fgui%2Fwidgets%2FBasicBlockWidget.cxx;h=37814014596b29e860a53778b9b09cfbc551ff33;hp=a2312c20140e596c7b86c350275433daa20de55a;hb=4443ad3e38327c776dcc68538591456d37c9ed6f;hpb=cab6494b97d1626c7b9285b69df324d9c9953614
diff --git a/src/gui/widgets/BasicBlockWidget.cxx b/src/gui/widgets/BasicBlockWidget.cxx
index a2312c2..3781401 100644
--- a/src/gui/widgets/BasicBlockWidget.cxx
+++ b/src/gui/widgets/BasicBlockWidget.cxx
@@ -68,7 +68,7 @@ BasicBlockWidget::BasicBlockWidget(const QString& name, BasicBlock * block,
, logger(log4cxx::Logger::getLogger("gui.BasicBlockWidget." + name.toStdString())) {
next[0] = NULL; next[1] = NULL;
- block->getManager()->connect_rename_function_signal([=](RenameFunctionEvent* event) {updateFunctionName(event);});
+ block->getManager()->registerRenameFunctionEvent([=](RenameFunctionEvent* event) {updateFunctionName(event);});
_widget.reset(new CustomQGraphicsTextItem("", this));
_widget->setPos(5, 20);
@@ -84,6 +84,8 @@ BasicBlockWidget::BasicBlockWidget(const QString& name, BasicBlock * block,
mainwindow->switchMainPlaneToAddress(address.toInt(NULL, 16));
}
});
+ instructions = block->getInstructions();
+ populateWidget();
}
void BasicBlockWidget::updateFunctionName(RenameFunctionEvent *event) {
@@ -111,51 +113,53 @@ void BasicBlockWidget::updateFunctionName(RenameFunctionEvent *event) {
}
}
-void BasicBlockWidget::addItem(uint8_t* bytes, size_t num_bytes,
- QString line, const QString& href) {
- QString bytestring;
+void BasicBlockWidget::populateWidget() {
int row;
-
- if (_table) {
- row = _table->rows();
- _table->appendRows(1);
- } else {
- row = 0;
- QTextTableFormat format;
- format.setBorderStyle(QTextFrameFormat::BorderStyle_None);
- format.setBorder(0);
- _table = _widget->textCursor().insertTable(1, 3, format);
- }
-
- for (size_t i(0); i < num_bytes; ++i) {
- const char * hexdigits = "0123456789ABCDEF";
- bytestring += hexdigits[(bytes[i] >> 4) & 0xF];
- bytestring += hexdigits[bytes[i] & 0xF];
- bytestring += ' ';
- }
-
- _table->cellAt(row, 0).firstCursorPosition().insertText(bytestring);
-
- line = line.replace('\t', ' ').toHtmlEscaped();
- if (href != "") {
- QStringList list = href.split(":");
- if (list[0] == "function") {
- uint64_t address = href.split(":")[1].toLongLong(NULL, 16);
- Function* fun = block->getManager()->getFunction(address);
-
- if (fun) {
- line = line.split(" ")[0] + " " + QString(fun->getName().c_str()).toHtmlEscaped();
- LOG4CXX_DEBUG(logger, "Naming function at " << address << " " << fun->getName());
+ QTextTableFormat format;
+ format.setBorderStyle(QTextFrameFormat::BorderStyle_None);
+ format.setBorder(0);
+
+ for (Instruction& inst : instructions) {
+ if (_table) {
+ row = _table->rows();
+ _table->appendRows(1);
+ } else {
+ row = 0;
+ _table = _widget->textCursor().insertTable(1, 3, format);
+ }
+ QString bytestring;
+ for (uint8_t byte : inst.getBytes()) {
+ const char * hexdigits = "0123456789ABCDEF";
+ bytestring += hexdigits[(byte >> 4) & 0xF];
+ bytestring += hexdigits[byte & 0xF];
+ bytestring += ' ';
+ }
+ _table->cellAt(row, 0).firstCursorPosition().insertText(bytestring);
+
+ QString line = inst.getText().c_str();
+ line = line.replace('\t', ' ').toHtmlEscaped();
+ if (inst.getReference() != "") {
+ QString href = inst.getReference().c_str();
+ QStringList list = href.split(":");
+ if (list[0] == "function") {
+ uint64_t address = href.split(":")[1].toLongLong(NULL, 16);
+ Function* fun = block->getManager()->getFunction(address);
+
+ if (fun) {
+ line = line.split(" ")[0] + " " + QString(fun->getName().c_str()).toHtmlEscaped();
+ LOG4CXX_DEBUG(logger, "Naming function at " << address << " " << fun->getName());
+ }
}
+ line = "" + line + "";
}
- line = "" + line + "";
- }
- _table->cellAt(row, 1).firstCursorPosition().insertHtml(line);
+ _table->cellAt(row, 1).firstCursorPosition().insertHtml(line);
+ }
}
void BasicBlockWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem*,
QWidget*) {
+ _widget->adjustSize();
width = 10 + _widget->boundingRect().width();
height = 25 + _widget->boundingRect().height();
if (width < 250) width = 250;