From ba90d00859091897b91ae587d4fac56e7228d2a2 Mon Sep 17 00:00:00 2001 From: Edward Williamson Date: Wed, 10 Dec 2014 00:55:23 -0500 Subject: [PATCH] more robust dwarf handling and better output --- static2/testing.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/static2/testing.py b/static2/testing.py index 98ad9fe9..e1e72bb8 100755 --- a/static2/testing.py +++ b/static2/testing.py @@ -31,10 +31,13 @@ warn = bcolors.WARNING + "[-]" + bcolors.ENDC def get_functions(dwarfinfo): function_starts = set() for cu in dwarfinfo.iter_CUs(): - for die in cu.iter_DIEs(): - if die.tag == "DW_TAG_subprogram": - if 'DW_AT_low_pc' in die.attributes: - function_starts.add(die.attributes['DW_AT_low_pc'].raw_value) + try: + for die in cu.iter_DIEs(): + if die.tag == "DW_TAG_subprogram": + if 'DW_AT_low_pc' in die.attributes: + function_starts.add(die.attributes['DW_AT_low_pc'].raw_value) + except: + continue return function_starts def test_files(fns,quiet=False,profile=False): @@ -76,9 +79,16 @@ def test_files(fns,quiet=False,profile=False): if len(missed) == 0: print "{} {}: {} found all {} function(s).".format(ok_green, short_fn, engine, total_fxns) else: - fmt = "{} {}: {} missed {}/{} functions: {}." - print fmt.format(warn, short_fn, engine, - len(missed), total_fxns, ", ".join(hex(fxn) for fxn in missed)) + if args.verbose: + fmt = "{} {}: {} missed {}/{} function(s): {}." + missed_s = ", ".join(hex(fxn) for fxn in missed) + print fmt.format(warn, short_fn, engine, + len(missed), total_fxns, missed_s) + else: + fmt = "{} {}: {} missed {}/{} function(s)." + print fmt.format(warn, short_fn, engine, + len(missed), total_fxns) + if __name__ == "__main__": #todo: radare and summary screen comparing total performance by engine/arch @@ -90,6 +100,8 @@ if __name__ == "__main__": help="don't warn about missing dwarf information") parser.add_argument('--profile',dest="profile",action='store_true', help='use internal profiling, output to prof.png') + parser.add_argument('--verbose',dest="verbose",action="store_true", + help='show all missed functions') args = parser.parse_args() if args.files != []: