Flutter Engine
The Flutter Engine
Functions
binary_size_utils Namespace Reference

Functions

def ParseNm (nm_lines)
 

Function Documentation

◆ ParseNm()

def binary_size_utils.ParseNm (   nm_lines)
Parse nm output, returning data for all relevant (to binary size)
symbols and ignoring the rest.

Args:
  nm_lines: an iterable over lines of nm output.

Yields:
  (symbol name, symbol type, symbol size, source file path).

  Path may be None if nm couldn't figure out the source file.

Definition at line 11 of file binary_size_utils.py.

11def ParseNm(nm_lines):
12 """Parse nm output, returning data for all relevant (to binary size)
13 symbols and ignoring the rest.
14
15 Args:
16 nm_lines: an iterable over lines of nm output.
17
18 Yields:
19 (symbol name, symbol type, symbol size, source file path).
20
21 Path may be None if nm couldn't figure out the source file.
22 """
23
24 # Match lines with size, symbol, optional location, optional discriminator
25 sym_re = re.compile(r'^([0-9a-f]{8,}) ' # address (8+ hex digits)
26 '([0-9a-f]{8,}) ' # size (8+ hex digits)
27 '(.) ' # symbol type, one character
28 '([^\t]+)' # symbol name, separated from next by tab
29 '(?:\t(.*):[\d\?]+)?.*$') # location
30 # Match lines with addr but no size.
31 addr_re = re.compile(r'^[0-9a-f]{8,} (.) ([^\t]+)(?:\t.*)?$')
32 # Match lines that don't have an address at all -- typically external symbols.
33 noaddr_re = re.compile(r'^ {8,} (.) (.*)$')
34 # Match lines with no symbol name, only addr and type
35 addr_only_re = re.compile(r'^[0-9a-f]{8,} (.)$')
36
37 seen_lines = set()
38 for line in nm_lines:
39 line = line.rstrip()
40 if line in seen_lines:
41 # nm outputs identical lines at times. We don't want to treat
42 # those as distinct symbols because that would make no sense.
43 continue
44 seen_lines.add(line)
45 match = sym_re.match(line)
46 if match:
47 address, size, sym_type, sym = match.groups()[0:4]
48 size = int(size, 16)
49 if sym_type in ('B', 'b'):
50 continue # skip all BSS for now.
51 path = match.group(5)
52 yield sym, sym_type, size, path, address
53 continue
54 match = addr_re.match(line)
55 if match:
56 # sym_type, sym = match.groups()[0:2]
57 continue # No size == we don't care.
58 match = noaddr_re.match(line)
59 if match:
60 sym_type, sym = match.groups()
61 if sym_type in ('U', 'w'):
62 continue # external or weak symbol
63 match = addr_only_re.match(line)
64 if match:
65 continue # Nothing to do.
66
67 # If we reach this part of the loop, there was something in the
68 # line that we didn't expect or recognize.
69 logging.warning('nm output parser failed to parse: %s', repr(line))
def ParseNm(nm_lines)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not set
Definition: switches.h:76