12 """Parse nm output, returning data for all relevant (to binary size)
13 symbols and ignoring the rest.
16 nm_lines: an iterable over lines of nm output.
19 (symbol name, symbol type, symbol size, source file path).
21 Path may be None if nm couldn't figure out the source file.
25 sym_re = re.compile(
r'^([0-9a-f]{8,}) '
29 '(?:\t(.*):[\d\?]+)?.*$')
31 addr_re = re.compile(
r'^[0-9a-f]{8,} (.) ([^\t]+)(?:\t.*)?$')
33 noaddr_re = re.compile(
r'^ {8,} (.) (.*)$')
35 addr_only_re = re.compile(
r'^[0-9a-f]{8,} (.)$')
40 if line
in seen_lines:
45 match = sym_re.match(line)
47 address, size, sym_type, sym = match.groups()[0:4]
49 if sym_type
in (
'B',
'b'):
52 yield sym, sym_type, size, path, address
54 match = addr_re.match(line)
58 match = noaddr_re.match(line)
60 sym_type, sym = match.groups()
61 if sym_type
in (
'U',
'w'):
63 match = addr_only_re.match(line)
69 logging.warning(
'nm output parser failed to parse: %s', repr(line))