Skip to content

Commit

Permalink
Add --addr2line for bb2fline
Browse files Browse the repository at this point in the history
  • Loading branch information
KanRobert committed Sep 7, 2024
1 parent c5568a5 commit be2f9c7
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions bb2fline.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from collections import defaultdict
from subprocess import PIPE

def bb_to_fline(bb_csv, binary):
def bb_to_fline(bb_csv, binary, addr2line):
assert bb_csv.endswith('bb.csv'), 'not normalized name'
f_csv = bb_csv[:-6] + 'f.csv'
line_csv = bb_csv[:-6] + 'line.csv'
Expand All @@ -24,7 +24,7 @@ def bb_to_fline(bb_csv, binary):

for bb in bb_reader:
entry = bb['entry']
addr2line_cmd = f'addr2line -e {binary} -a {entry} -f'
addr2line_cmd = f'{addr2line} -e {binary} -a {entry} -f'
fline = subprocess.run(addr2line_cmd.split(), stdout=PIPE, stderr=PIPE, check=True)
# Assume output looks like:
#
Expand Down Expand Up @@ -60,10 +60,12 @@ def bb_to_fline(bb_csv, binary):

if __name__ == '__main__':
parser = argparse.ArgumentParser(
description='Get function & line profiling info from basic block info (CSV format).')
parser.add_argument('bb_csv', action='store', help='Input bb CSV file')
parser.add_argument('binary', action='store', help='Profiled binary')
description='Get function & line profiling info from basic block info (CSV format), where entry, execution, exit are required')
parser.add_argument('bb_csv', help='input bb CSV file')
parser.add_argument('binary', help='profiled binary')
parser.add_argument('--addr2line', default='addr2line', help='path of addr2line (this is needed if dwarf format of binary is not supported by system addr2line)')
args = parser.parse_args()
bb_csv = args.bb_csv
binary = args.binary
bb_to_fline(bb_csv, binary)
addr2line = args.addr2line
bb_to_fline(bb_csv, binary, addr2line)

0 comments on commit be2f9c7

Please sign in to comment.