mirror of https://github.com/geohot/qira
cda screenshot
This commit is contained in:
parent
aa97be380a
commit
80cc24bb8f
|
@ -101,5 +101,5 @@ def display_file():
|
|||
def set_cache(cache):
|
||||
global object_cache, file_cache, xref_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"
|
||||
|
||||
|
|
|
@ -18,7 +18,8 @@ if __name__ == '__main__':
|
|||
parser.add_argument('binary', help="path 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("--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
|
||||
args = parser.parse_args()
|
||||
|
@ -28,6 +29,10 @@ if __name__ == '__main__':
|
|||
qira_config.WITH_DWARF = True
|
||||
if args.cda:
|
||||
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
|
||||
program = qira_program.Program(args.binary, args.args)
|
||||
|
|
|
@ -196,14 +196,14 @@ class Program:
|
|||
|
||||
# DWARF IS STUPIDLY COMPLICATED
|
||||
def parse_dwarf():
|
||||
files = []
|
||||
dwarves = {}
|
||||
rdwarves = {}
|
||||
|
||||
from elftools.elf.elffile import ELFFile
|
||||
elf = ELFFile(open(self.program))
|
||||
if not elf.has_dwarf_info():
|
||||
return (dwarves, rdwarves)
|
||||
files = []
|
||||
return (files, dwarves, rdwarves)
|
||||
filename = None
|
||||
di = elf.get_dwarf_info()
|
||||
for cu in di.iter_CUs():
|
||||
|
@ -233,21 +233,17 @@ class Program:
|
|||
rdwarves[filename+"#"+str(s.line)] = s.address
|
||||
except Exception as 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
|
||||
if not qira_config.WITH_CDA:
|
||||
return
|
||||
|
||||
def parse_cda():
|
||||
try:
|
||||
import cachegen
|
||||
return cachegen.parse_files(files)
|
||||
except Exception as e:
|
||||
print "CDA: cachegen failed with",e
|
||||
return None
|
||||
import cachegen
|
||||
return cachegen.parse_files(files)
|
||||
|
||||
self.cda = cachewrap("/tmp/qira_cdacaches", self.proghash, parse_cda)
|
||||
|
||||
|
|
|
@ -31,14 +31,6 @@ app = Flask(__name__)
|
|||
#app.config['DEBUG'] = True
|
||||
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):
|
||||
if a == None:
|
||||
return None
|
||||
|
@ -322,10 +314,10 @@ def run_server(largs, lprogram):
|
|||
global program
|
||||
args = largs
|
||||
program = lprogram
|
||||
try:
|
||||
if qira_config.WITH_CDA:
|
||||
import cacheserver
|
||||
app.register_blueprint(cacheserver.app)
|
||||
cacheserver.set_cache(program.cda)
|
||||
except:
|
||||
pass
|
||||
print "starting socketio server..."
|
||||
threading.Thread(target=mwpoller).start()
|
||||
socketio.run(app, port=QIRA_WEB_PORT)
|
||||
|
|
Loading…
Reference in New Issue