fixed tracking

This commit is contained in:
George Hotz 2014-07-18 11:08:31 -07:00
parent 2afc4188fd
commit ac0869d1ca
5 changed files with 72 additions and 32 deletions

View File

@ -15,8 +15,6 @@ app = Flask(__name__)
socketio = SocketIO(app)
program = None
trace = None
traces = {}
run_id = 0
# ***** after this line is the new server stuff *****
@ -27,6 +25,13 @@ def forkat(forknum, clnum):
print "forkat",forknum,clnum
start_bindserver(ss2, forknum, clnum)
@socketio.on('deletefork', namespace='/qira')
def deletefork(forknum):
print "deletefork", forknum
os.unlink("/tmp/qira_logs/"+str(int(forknum)))
del program.traces[forknum]
emit('maxclnum', program.get_maxclnum())
@socketio.on('connect', namespace='/qira')
def connect():
print "client connected", program.get_maxclnum()
@ -35,14 +40,15 @@ def connect():
@socketio.on('getclnum', namespace='/qira')
def getclnum(forknum, clnum, types, limit):
if forknum not in traces:
if forknum not in program.traces:
return
trace = program.traces[forknum]
if clnum == None or types == None or limit == None:
return
ret = []
for t in types:
key = (clnum, t)
for c in traces[forknum].pydb_clnum[key]:
for c in trace.pydb_clnum[key]:
ret.append(c)
if len(ret) >= limit:
break
@ -54,24 +60,25 @@ def getclnum(forknum, clnum, types, limit):
def getchanges(forknum, address, typ):
if address == None or typ == None:
return
if forknum != -1 and forknum not in traces:
if forknum != -1 and forknum not in program.traces:
return
if forknum == -1:
ret = {}
for forknum in traces:
ret[forknum] = traces[forknum].pydb_addr[(address, typ)]
for forknum in program.traces:
ret[forknum] = program.traces[forknum].pydb_addr[(address, typ)]
emit('changes', {'forknum': forknum, 'type': typ, 'clnums': ret})
else:
emit('changes', {'type': typ, 'clnums': {forknum: traces[forknum].pydb_addr[(address, typ)]}})
emit('changes', {'type': typ, 'clnums': {forknum: program.traces[forknum].pydb_addr[(address, typ)]}})
@socketio.on('getinstructions', namespace='/qira')
def getinstructions(forknum, clstart, clend):
if forknum not in traces:
if forknum not in program.traces:
return
trace = program.traces[forknum]
if clstart == None or clend == None:
return
ret = []
pydb_clnum = traces[forknum].pydb_clnum
pydb_clnum = trace.pydb_clnum
for i in range(clstart, clend):
key = (i, 'I')
if key in pydb_clnum:
@ -80,18 +87,20 @@ def getinstructions(forknum, clstart, clend):
@socketio.on('getmemory', namespace='/qira')
def getmemory(forknum, clnum, address, ln):
if forknum not in traces:
if forknum not in program.traces:
return
trace = program.traces[forknum]
if clnum == None or address == None or ln == None:
return
dat = traces[forknum].mem.fetch(clnum, address, ln)
dat = trace.mem.fetch(clnum, address, ln)
ret = {'address': address, 'len': ln, 'dat': dat}
emit('memory', ret)
@socketio.on('getregisters', namespace='/qira')
def getregisters(forknum, clnum):
if forknum not in traces:
if forknum not in program.traces:
return
trace = program.traces[forknum]
#print "getregisters",clnum
if clnum == None:
return
@ -101,11 +110,11 @@ def getregisters(forknum, clnum):
REGS = program.tregs[0]
REGSIZE = program.tregs[1]
for i in range(0, len(REGS)):
if i*REGSIZE in traces[forknum].regs.daddr:
rret = {"name": REGS[i], "address": i*REGSIZE, "value": traces[forknum].regs.daddr[i*REGSIZE].fetch(clnum), "size": REGSIZE, "regactions": ""}
if clnum in traces[forknum].pydb_addr[(i*REGSIZE, 'R')]:
if i*REGSIZE in trace.regs.daddr:
rret = {"name": REGS[i], "address": i*REGSIZE, "value": trace.regs.daddr[i*REGSIZE].fetch(clnum), "size": REGSIZE, "regactions": ""}
if clnum in trace.pydb_addr[(i*REGSIZE, 'R')]:
rret['regactions'] += " regread"
if clnum in traces[forknum].pydb_addr[(i*REGSIZE, 'W')]:
if clnum in trace.pydb_addr[(i*REGSIZE, 'W')]:
rret['regactions'] += " regwrite"
ret.append(rret)
emit('registers', ret)
@ -158,7 +167,7 @@ def check_file(logfile, trace):
return False
def run_middleware():
global program, traces
global program
print "starting QIRA middleware"
# run loop run
@ -168,9 +177,9 @@ def run_middleware():
did_update = False
for i in os.listdir("/tmp/qira_logs/"):
i = int(i)
if i not in traces:
traces[i] = qira_trace.Trace(program, i)
if check_file("/tmp/qira_logs/"+str(i), traces[i]):
if i not in program.traces:
qira_trace.Trace(program, i)
if check_file("/tmp/qira_logs/"+str(i), program.traces[i]):
did_update = True
if did_update:

View File

@ -34,20 +34,19 @@ function abs_maxclnum() {
function update_maxclnum(clnum) {
p("update maxclnum "+clnum);
var old_maxclnum = Session.get("max_clnum");
Session.set("max_clnum", clnum);
Session.setDefault("forknum", 0);
var forknum = Session.get("forknum");
if (Session.get("max_clnum")[forknum] == undefined) return;
if (clnum[forknum] === undefined) return;
Session.setDefault("clnum", clnum[forknum][1]);
var tfmaxclnum = Session.get("max_clnum")[forknum][1];
if (tfmaxclnum == Session.get("clnum")) {
if (old_maxclnum === undefined || old_maxclnum[forknum] === undefined) return;
if (old_maxclnum[forknum][1] == Session.get("clnum")) {
// track the max changelist if you have it selected
Session.set("clnum", tfmaxclnum);
} else {
Session.setDefault("clnum", tfmaxclnum);
Session.set("clnum", clnum[forknum][1]);
}
}

View File

@ -40,17 +40,25 @@ function register_drag_zoom() {
return parseInt(fn);
}
var down = -1;
var downforknum = -1;
$("#vtimelinebox").mousedown(function(e) {
if (e.button == 1) { zoom_out_max(); }
if (e.button != 0) return;
var clnum = get_clnum(e);
if (clnum === undefined) return;
down = clnum;
downforknum = get_forknum(e);
return false;
});
$("#vtimelinebox").mouseup(function(e) {
p("mouseup");
if (e.button != 0) return;
if (e.target.id == "trash") {
stream.emit("deletefork", downforknum);
redraw_flags();
return;
}
var up = get_clnum(e);
if (up === undefined) return;
var forknum = get_forknum(e);
@ -100,6 +108,15 @@ function redraw_vtimelines(scale) {
var maxclnum = Session.get("max_clnum");
if (maxclnum === undefined) return;
// delete old ones that don't have a maxclnum anymore
$(".vtimeline").each(function(e) {
var forknum = $(this)[0].id.split("vtimeline")[1];
if (maxclnum[forknum] === undefined) {
$(this).remove();
}
});
for (forknum in maxclnum) {
var vt = $('#vtimeline'+forknum);
if (vt.length == 0) {
@ -154,6 +171,8 @@ function redraw_flags() {
}
sty += ")";
}
if (maxclnum[forknum] === undefined) continue;
var flag = $('<div id="flag'+clnum+'" class="flag" style="'+sty+'">'+clnum+'</div>');
flag[0].style.marginTop = ((clnum-Math.max(maxclnum[forknum][0], cview[0]))/cscale) + "px";
@ -233,7 +252,7 @@ stream.on('changes', function(msg) {
var clnum = Session.get('clnum');
// this should probably only be for the IDA plugin
if (msg['type'] == 'I' && clnums.indexOf(clnum) == -1 && Session.get('dirtyiaddr') == true) {
if (msg['type'] == 'I' && clnums !== undefined && clnums.indexOf(clnum) == -1 && Session.get('dirtyiaddr') == true) {
var closest = undefined;
var diff = 0;
// if these are instructions and the current clnum isn't in the list

View File

@ -44,7 +44,7 @@ body {
#vtimelinebox {
height: 100%;
position: fixed;
width: 160px;
width: 165px;
background-color: #AAAAAA;
overflow-x: scroll;
overflow-y: hidden;
@ -56,7 +56,8 @@ body {
width: 50px;
display: inline-block;
vertical-align: top;
margin-right: 5px;
margin-left: 2px;
margin-right: 2px;
position: relative;
}
@ -68,6 +69,17 @@ body {
color: gray;
}
#trash {
font-size: 20px;
font-family: monospace;
bottom: 15px;
position: fixed;
width: 165px;
text-align: center;
border-top: 1px black solid;
background-color: #777777;
}
/* everything in the right panel */
#onlypanel {
@ -76,7 +88,7 @@ body {
height: 100%;
display: inline-block;
position: fixed;
left: 160px;
left: 165px;
}
.panelthing {

View File

@ -6,6 +6,7 @@
<div id="vtimelinebox">
<!--<div class="vtimeline" id="vtimeline0"></div>
<div class="vtimeline" id="vtimeline1"></div>-->
<div id="trash">delete</div>
</div>
<div id="onlypanel">
<div id="controls">