# -*- Mode: Python -*- import os import re fun_head = re.compile ('([0-9A-Fa-f]+) <([^>]+)>:') def get_instrumented_funs (path): p = os.popen ('objdump -d %s' % (path,), 'r') r = [] state = 0 while 1: line = p.readline() if not line: break if state == 0: # looking for a fun header m = fun_head.match (line) if m is not None: addr = m.group (1) name = m.group (2) state = 1 count = 0 elif state == 1: # scanning for calls to __cyg_profile_func_enter if line == '\n': state = 0 else: if line.find ('<__cyg_profile_func_enter>') != -1: r.append ((addr, name)) count += 1 if count == 20: state = 2 elif state == 2 : # ignoring lines, too far into the function if line == '\n': state = 0 return r if __name__ == '__main__': import sys l = get_instrumented_funs (sys.argv[1]) for addr, name in l: print addr, name