virtual BasicBlock * getBasicBlock(uint64_t address) = 0;
virtual void forEachFunction(std::function<void (uint64_t, Function*)> callback) = 0;
- virtual void printEachInstruction(uint64_t start, uint64_t end, std::function<void (const std::string&)> fun) = 0;
+ virtual void printEachInstruction(uint64_t start, uint64_t end,
+ std::function<void (uint8_t*, size_t, const std::string&)> fun) = 0;
protected:
virtual bool isFunctionCall(uint64_t address) = 0;
virtual bool isJump(uint64_t address) = 0;
});
}
-void LLVMDisassembler::printEachInstruction(uint64_t start, uint64_t end, std::function<void (const std::string&)> fun) {
+void LLVMDisassembler::printEachInstruction(uint64_t start, uint64_t end,
+ std::function<void (uint8_t*, size_t, const std::string&)> fun) {
SectionRef text_section = sections[".text"];
uint64_t base_address;
text_section.getAddress(base_address);
uint8_t bytes[inst_size+2];
ref.readBytes(current_address, inst_size, bytes);
- for(uint8_t* cur = bytes; cur < bytes + inst_size; ++cur) {
- s.write_hex(*cur);
- s << ' ';
- }
- s << '\t';
IP->printInst(&inst, s, "");
- fun(s.str());
+ fun(bytes, inst_size, s.str());
} else {
- fun("Invalid Byte");
+ fun(NULL, 0, "Invalid Byte");
inst_size = 1;
}
uint64_t entryAddress();
void forEachFunction(std::function<void (uint64_t, Function*)> callback);
- void printEachInstruction(uint64_t start, uint64_t end, std::function<void (const std::string&)> fun);
+ void printEachInstruction(uint64_t start, uint64_t end,
+ std::function<void (uint8_t*, size_t, const std::string&)> fun);
BasicBlock * getBasicBlock(uint64_t address) {
return blocks[address];
widget->moveBy(100*startx, 10*(block->getStartAddress() - starty));
dis->printEachInstruction(block->getStartAddress(), block->getEndAddress(),
- [&](const std::string& line) {
- widget->addItem(line.c_str());
+ [&](uint8_t* bytes, size_t byte_count, const std::string& line) {
+ widget->addItem(bytes, byte_count, line.c_str() + 1);
});
if (block->getNextBlock(0) != 0)
: x(-5), y(-20)
, dx(270), dy(45)
, name(name) {
- _widget.setMinimumWidth(_widget.sizeHintForColumn(0) + 10);
+ _widget.setMinimumHeight(_widget.rowHeight(0) + 10);
_widget.setMaximumHeight(20);
- dx = _widget.sizeHintForColumn(0) + 20;
+ _widget.setColumnCount(3);
+ _widget.verticalHeader()->hide();
+ _widget.horizontalHeader()->hide();
+ dx = _widget.rowHeight(0) + 20;
if (dx < 270) dx = 270;
}
- void addItem(const QString& line) {
- _widget.addItem(line);
+ void addItem(uint8_t* bytes, size_t num_bytes,
+ const QString& line) {
+ size_t current_row = _widget.rowCount();
+ int column_width;
+
+ QString bytestring;
+
+ 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 += ' ';
+ }
+
+ _widget.setRowCount(current_row + 1);
+
+ _widget.setItem(current_row, 0, new QTableWidgetItem(bytestring));
+ _widget.setItem(current_row, 1, new QTableWidgetItem(line));
+ _widget.setItem(current_row, 2, new QTableWidgetItem(""));
_widget.updateGeometry();
- _widget.setMinimumWidth(_widget.sizeHintForColumn(0) + 10);
- _widget.setMinimumHeight(_widget.sizeHintForRow(0) * (1 + _widget.count()));
- _widget.setMaximumHeight(_widget.sizeHintForRow(0) * (1 + _widget.count()));
- dy = _widget.sizeHintForRow(0) * (1 + _widget.count()) + 25;
- dx = _widget.sizeHintForColumn(0) + 20;
+
+ _widget.resizeColumnToContents(0);
+ _widget.resizeColumnToContents(1);
+ _widget.resizeColumnToContents(2);
+
+ _widget.resizeRowToContents(current_row);
+
+ column_width =
+ _widget.columnWidth(0) +
+ _widget.columnWidth(1) +
+ _widget.columnWidth(2) +
+ 2;
+
+ _widget.setMinimumWidth(column_width);
+ _widget.setMinimumHeight(_widget.rowHeight(1) * (_widget.rowCount()) + 2);
+ _widget.setMaximumHeight(_widget.rowHeight(1) * (_widget.rowCount()) + 2);
+
+
+ dy = _widget.rowHeight(0) * (_widget.rowCount()) + 25;
+ dx = column_width + 10;
if (dx < 270) dx = 270;
}
}
private:
int x, y, dx, dy;
- QListWidget _widget;
+ QTableWidget _widget;
QString name;
};