mirror of
https://github.com/geohot/qira
synced 2025-01-27 12:49:30 +03:00
cfgs work again
This commit is contained in:
parent
ec30cd6b8b
commit
5ac2508a1a
@ -187,13 +187,13 @@ def getstaticview(haddr, flat, flatrange):
|
||||
@app.route('/dot', methods=["POST"])
|
||||
def graph_dot():
|
||||
req = request.data
|
||||
#print "DOT REQUEST", req
|
||||
print "DOT REQUEST", req
|
||||
f = open("/tmp/in.dot", "w")
|
||||
f.write(req)
|
||||
f.close()
|
||||
os.system("dot /tmp/in.dot > /tmp/out.dot")
|
||||
ret = open("/tmp/out.dot").read()
|
||||
#print "DOT RESPONSE", ret
|
||||
print "DOT RESPONSE", ret
|
||||
return ret
|
||||
|
||||
|
||||
|
@ -10,6 +10,7 @@ from flask.ext.socketio import SocketIO, emit
|
||||
|
||||
from qira_base import *
|
||||
import json
|
||||
import os
|
||||
|
||||
# *** STATIC CALLS FROM THE FRONTEND ***
|
||||
|
||||
@ -76,6 +77,19 @@ def settags(tags):
|
||||
for i in tags[addr]:
|
||||
program.static[naddr][i] = tags[addr][i]
|
||||
|
||||
# dot as a service
|
||||
@app.route('/dot', methods=["POST"])
|
||||
def graph_dot():
|
||||
req = request.data
|
||||
#print "DOT REQUEST", req
|
||||
f = open("/tmp/in.dot", "w")
|
||||
f.write(req)
|
||||
f.close()
|
||||
os.system("dot /tmp/in.dot > /tmp/out.dot")
|
||||
ret = open("/tmp/out.dot").read()
|
||||
#print "DOT RESPONSE", ret
|
||||
return ret
|
||||
|
||||
def init(lprogram):
|
||||
global program
|
||||
program = lprogram
|
||||
|
@ -20,7 +20,7 @@ function instruction_html_from_tags(ins) {
|
||||
idump += '<span class="insaddr datainstruction addr addr_'+ins.address+'">'+ins.address+'</span> '+
|
||||
//'<div class="instructiondesc">'+hex(ins.flags)+'</div> '+
|
||||
'<div class="instructiondesc">'+highlight_instruction(ins.instruction)+'</div> '+
|
||||
'<span class="comment comment_'+ins.address+'">'+(ins.comment !== undefined ? "; "+ins.comment : "")+'</span>';
|
||||
'<span class="comment comment_'+ins.address+'">'+(ins.comment != undefined ? "; "+ins.comment : "")+'</span>';
|
||||
idump += '</div>';
|
||||
return idump;
|
||||
}
|
||||
@ -39,6 +39,42 @@ function on_function(fxn) { DS("function");
|
||||
var graph = new Graph();
|
||||
p(fxn);
|
||||
|
||||
for (var bn = 0; bn < fxn.blocks.length; bn++) {
|
||||
var bb = fxn.blocks[bn];
|
||||
if (bb.length == 0) continue;
|
||||
var addr = bb[0].address;
|
||||
var cnt = bb.length;
|
||||
|
||||
var idump = "";
|
||||
for (var i = 0; i < cnt; i++) {
|
||||
idump += instruction_html_from_tags(bb[i]);
|
||||
}
|
||||
var dom = $('<div class="basicblock" id="bb_'+addr+'">');
|
||||
|
||||
dom.html(idump);
|
||||
graph.addVertex(addr, cnt, dom[0]);
|
||||
|
||||
// add edges
|
||||
for (var i = 0; i < bb[cnt-1].dests.length; i++) {
|
||||
var dd = bb[cnt-1].dests[i];
|
||||
if (dd[1] == 3) continue;
|
||||
|
||||
var col = "blue"; // base off dd[1]
|
||||
if (bb[cnt-1].dests.length > 1 && dd[1] == 4) {
|
||||
col = "red";
|
||||
} else if (dd[1] == 1) {
|
||||
col = "green";
|
||||
}
|
||||
graph.addEdge(addr, dd[0], col);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
graph.assignLevels();
|
||||
graph.render();
|
||||
|
||||
rehighlight();
|
||||
replace_names();
|
||||
} stream.on('function', on_function);
|
||||
|
||||
function on_tags(addrs, fxn) { DS("tags");
|
||||
|
Loading…
x
Reference in New Issue
Block a user