virtual void forEachFunction(std::function<void (uint64_t, Function*)> callback) = 0;
virtual void printEachInstruction(uint64_t start, uint64_t end,
- std::function<void (uint8_t*, size_t, const std::string&)> fun) = 0;
+ std::function<void (uint8_t*, size_t, const std::string&,
+ const std::string&)> fun) = 0;
protected:
virtual bool isFunctionCall(uint64_t address) = 0;
virtual bool isJump(uint64_t address) = 0;
template <typename ELFT>
void LLVMDisassembler<ELFT>::printEachInstruction(uint64_t start, uint64_t end,
- std::function<void (uint8_t*, size_t,
- const std::string&)> fun) {
+ std::function<void (uint8_t*, size_t,
+ const std::string&,
+ const std::string&)> fun) {
SectionRef text_section = sections[".text"];
uint64_t base_address;
text_section.getAddress(base_address);
ref.readBytes(current_address, inst_size, bytes);
uint64_t jmptarget;
+ std::string ref("");
+ IP->printInst(&inst, s, "");
if (MIA->evaluateBranch(inst, current_address, inst_size, jmptarget)) {
std::stringstream stream;
+ if (MIA->isCall(inst))
+ stream << "function:";
+ else
+ stream << "block:";
+
stream << std::hex << (base_address + jmptarget);
- IP->printInst(&inst, s, stream.str());
- } else
- IP->printInst(&inst, s, "");
+ ref = stream.str();
+ }
+
- fun(bytes, inst_size, s.str());
+ fun(bytes, inst_size, s.str(), ref);
} else {
LOG4CXX_WARN(logger, "Invalid byte at" << std::hex << current_address + base_address);
- fun(NULL, 0, "Invalid Byte");
+ fun(NULL, 0, "Invalid Byte", "");
inst_size = 1;
}
void forEachFunction(std::function<void (uint64_t, Function*)> callback);
void printEachInstruction(uint64_t start, uint64_t end,
- std::function<void (uint8_t*, size_t, const std::string&)> fun);
+ std::function<void (uint8_t*, size_t, const std::string&,
+ const std::string&)> fun);
BasicBlock * getBasicBlock(uint64_t address) {
return blocks[address];
block->getEndAddress(),
[&](uint8_t* bytes,
size_t byte_count,
- const std::string& line) {
- widget->addItem(bytes, byte_count, line.c_str() + 1);
+ 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);
}
void BasicBlockWidget::addItem(uint8_t* bytes, size_t num_bytes,
- const QString& line) {
+ QString line, const QString& href) {
QString bytestring;
for (size_t i(0); i < num_bytes; ++i) {
if (old_text == "") {
old_text = "<table>";
}
+
+ line = line.toHtmlEscaped();
+ if (href != "") {
+ line = "<a href=\"" + href + "\">" + line + "</a>";
+ }
+
QString new_text =
old_text.remove("</table>") +
"<tr><td>" + bytestring +
- "</td><td>" + line.toHtmlEscaped() +
+ "</td><td>" + line +
"</td><td>" + "" +
"</td></tr></table>";
public:
BasicBlockWidget(const QString& name, BasicBlock * block);
- void addItem(uint8_t* bytes, size_t num_bytes, const QString& line);
+ void addItem(uint8_t* bytes, size_t num_bytes, QString line, const QString& href);
QRectF boundingRect() const {
qreal penWidth = 1;