mirror of https://github.com/geohot/qira
we have dwarves
This commit is contained in:
parent
2d04eda8f2
commit
a546b627fd
|
@ -15,7 +15,7 @@ elif [ $(which pacman) ]; then
|
|||
fi
|
||||
|
||||
echo "installing pip packages"
|
||||
sudo $PIP install flask-socketio pillow ./qiradb
|
||||
sudo $PIP install flask-socketio pillow elftools ./qiradb
|
||||
|
||||
echo "making symlink"
|
||||
sudo ln -sf $(pwd)/qira /usr/local/bin/qira
|
||||
|
|
|
@ -89,6 +89,8 @@ class Program:
|
|||
# no traces yet
|
||||
self.traces = {}
|
||||
|
||||
self.getdwarf()
|
||||
|
||||
def clear(self):
|
||||
# probably always good to do except in development of middleware
|
||||
print "*** deleting old runs"
|
||||
|
@ -155,6 +157,39 @@ class Program:
|
|||
print "***",' '.join(eargs)
|
||||
os.execvp(self.qirabinary, eargs)
|
||||
|
||||
def getdwarf(self):
|
||||
self.dwarves = {}
|
||||
from elftools.elf.elffile import ELFFile
|
||||
elf = ELFFile(open(self.program))
|
||||
if not elf.has_dwarf_info():
|
||||
return
|
||||
|
||||
# DWARF IS STUPIDLY COMPLICATED
|
||||
di = elf.get_dwarf_info()
|
||||
for cu in di.iter_CUs():
|
||||
basedir = ''
|
||||
# get the base directory
|
||||
for die in cu.iter_DIEs():
|
||||
if die.tag == "DW_TAG_compile_unit":
|
||||
basedir = die.attributes['DW_AT_comp_dir'].value
|
||||
# get the line program?
|
||||
lp = di.line_program_for_CU(cu)
|
||||
dir_index = lp['file_entry'][0].dir_index
|
||||
if dir_index > 0:
|
||||
basedir = lp['include_directory'][dir_index-1]
|
||||
# now we have the filename
|
||||
filename = basedir + "/" + lp['file_entry'][0].name
|
||||
try:
|
||||
lines = open(filename).read().split("\n")
|
||||
except:
|
||||
print "*** couldn't find %s for DWARF", filename
|
||||
continue
|
||||
for entry in lp.get_entries():
|
||||
#print entry
|
||||
s = entry.state
|
||||
if s != None:
|
||||
self.dwarves[s.address] = (s.line, lines[s.line-1])
|
||||
|
||||
class Trace:
|
||||
def __init__(self, fn, forknum, r1, r2, r3):
|
||||
self.forknum = forknum
|
||||
|
|
|
@ -175,6 +175,8 @@ def getinstructions(forknum, clstart, clend):
|
|||
rret = rret[0]
|
||||
if rret['address'] in program.instructions:
|
||||
rret['instruction'] = program.instructions[rret['address']]
|
||||
if rret['address'] in program.dwarves:
|
||||
rret['comment'] = program.dwarves[rret['address']]
|
||||
ret.append(rret)
|
||||
emit('instructions', ret)
|
||||
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,13 @@
|
|||
int main() {
|
||||
int i;
|
||||
int j = 1;
|
||||
int k = 1;
|
||||
int l = 1;
|
||||
for (i = 1; i < 10; i++) {
|
||||
j *= i;
|
||||
k += 1;
|
||||
l += i;
|
||||
}
|
||||
printf("%d %d %d\n", j, k, l);
|
||||
}
|
||||
|
|
@ -166,7 +166,7 @@ Template.datachanges.datatype = function() {
|
|||
|
||||
Deps.autorun(function() {
|
||||
var forknum = Session.get("forknum");
|
||||
stream.emit('getclnum', forknum, Session.get('clnum'), ['L', 'S'], 2)
|
||||
stream.emit('getclnum', forknum, Session.get('clnum'), ['L', 'S'], 3)
|
||||
});
|
||||
|
||||
stream.on('clnum', function(msg) {
|
||||
|
|
|
@ -166,6 +166,12 @@ body {
|
|||
|
||||
.instruction {
|
||||
font-family: monospace;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.instructiondesc {
|
||||
min-width: 180px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.data {
|
||||
|
|
|
@ -79,7 +79,8 @@
|
|||
<div class="instruction">
|
||||
<div class="change {{ischange}}">{{clnum}}</div>
|
||||
<span class="datainstruction {{isiaddr}}">{{hexaddress}}</span>
|
||||
{{instruction}}
|
||||
<div class="instructiondesc">{{instruction}}</div>
|
||||
<span class="comment">{{comment}}</span>
|
||||
</div>
|
||||
{{/each}}
|
||||
</template>
|
||||
|
|
Loading…
Reference in New Issue