cda screenshot

This commit is contained in:
George Hotz 2014-07-30 16:24:34 -07:00
parent aa97be380a
commit 80cc24bb8f
4 changed files with 16 additions and 23 deletions

View File

@ -101,5 +101,5 @@ def display_file():
def set_cache(cache): def set_cache(cache):
global object_cache, file_cache, xref_cache global object_cache, file_cache, xref_cache
(object_cache, file_cache, xref_cache) = cache (object_cache, file_cache, xref_cache) = cache
print "read",len(file_cache),"files",len(object_cache),"objects",len(xref_cache),"xrefs" print "CDA: read",len(file_cache),"files",len(object_cache),"objects",len(xref_cache),"xrefs"

View File

@ -18,7 +18,8 @@ if __name__ == '__main__':
parser.add_argument('binary', help="path to the binary") parser.add_argument('binary', help="path to the binary")
parser.add_argument('args', nargs='*', help="arguments to the binary") parser.add_argument('args', nargs='*', help="arguments to the binary")
parser.add_argument("--dwarf", help="parse program dwarf data", action="store_true") parser.add_argument("--dwarf", help="parse program dwarf data", action="store_true")
parser.add_argument("--cda", help="use CDA to view source", action="store_true") parser.add_argument("--cda", help="use CDA to view source(implies dwarf)", action="store_true")
parser.add_argument("--flush-cache", help="flush all QIRA caches", action="store_true")
# parse arguments # parse arguments
args = parser.parse_args() args = parser.parse_args()
@ -28,6 +29,10 @@ if __name__ == '__main__':
qira_config.WITH_DWARF = True qira_config.WITH_DWARF = True
if args.cda: if args.cda:
qira_config.WITH_CDA = True qira_config.WITH_CDA = True
qira_config.WITH_DWARF = True
if args.flush_cache:
print "*** flushing caches"
os.system("rm -rfv /tmp/qira*")
# creates the file symlink, program is constant through server run # creates the file symlink, program is constant through server run
program = qira_program.Program(args.binary, args.args) program = qira_program.Program(args.binary, args.args)

View File

@ -196,14 +196,14 @@ class Program:
# DWARF IS STUPIDLY COMPLICATED # DWARF IS STUPIDLY COMPLICATED
def parse_dwarf(): def parse_dwarf():
files = []
dwarves = {} dwarves = {}
rdwarves = {} rdwarves = {}
from elftools.elf.elffile import ELFFile from elftools.elf.elffile import ELFFile
elf = ELFFile(open(self.program)) elf = ELFFile(open(self.program))
if not elf.has_dwarf_info(): if not elf.has_dwarf_info():
return (dwarves, rdwarves) return (files, dwarves, rdwarves)
files = []
filename = None filename = None
di = elf.get_dwarf_info() di = elf.get_dwarf_info()
for cu in di.iter_CUs(): for cu in di.iter_CUs():
@ -233,21 +233,17 @@ class Program:
rdwarves[filename+"#"+str(s.line)] = s.address rdwarves[filename+"#"+str(s.line)] = s.address
except Exception as e: except Exception as e:
print "DWARF: error on",filename,"got",e print "DWARF: error on",filename,"got",e
return (dwarves, rdwarves) return (files, dwarves, rdwarves)
(self.dwarves, self.rdwarves) = cachewrap("/tmp/qira_dwarfcaches", self.proghash, parse_dwarf) (files, self.dwarves, self.rdwarves) = cachewrap("/tmp/qira_dwarfcaches", self.proghash, parse_dwarf)
# cda # cda
if not qira_config.WITH_CDA: if not qira_config.WITH_CDA:
return return
def parse_cda(): def parse_cda():
try: import cachegen
import cachegen return cachegen.parse_files(files)
return cachegen.parse_files(files)
except Exception as e:
print "CDA: cachegen failed with",e
return None
self.cda = cachewrap("/tmp/qira_cdacaches", self.proghash, parse_cda) self.cda = cachewrap("/tmp/qira_cdacaches", self.proghash, parse_cda)

View File

@ -31,14 +31,6 @@ app = Flask(__name__)
#app.config['DEBUG'] = True #app.config['DEBUG'] = True
socketio = SocketIO(app) socketio = SocketIO(app)
# add cda server paths here
if qira_config.WITH_CDA:
try:
import cacheserver
app.register_blueprint(cacheserver.app)
except Exception as e:
print "CDA: load cacheserver failed with",e
def ghex(a): def ghex(a):
if a == None: if a == None:
return None return None
@ -322,10 +314,10 @@ def run_server(largs, lprogram):
global program global program
args = largs args = largs
program = lprogram program = lprogram
try: if qira_config.WITH_CDA:
import cacheserver
app.register_blueprint(cacheserver.app)
cacheserver.set_cache(program.cda) cacheserver.set_cache(program.cda)
except:
pass
print "starting socketio server..." print "starting socketio server..."
threading.Thread(target=mwpoller).start() threading.Thread(target=mwpoller).start()
socketio.run(app, port=QIRA_WEB_PORT) socketio.run(app, port=QIRA_WEB_PORT)