tools/cygprofile/symbol_extractor.py
def _SymbolInfosFromStream(objdump_lines):
  """Parses the output of objdump, and get all the symbols from a binary.

  Args:
    objdump_lines: An iterable of lines

  Returns:
    A list of SymbolInfo.
  """
  name_to_offsets = collections.defaultdict(list)
  symbol_infos = []
  for line in objdump_lines:
    symbol_info = _FromObjdumpLine(line.decode('utf-8').rstrip('\n'))
    if symbol_info is not None:
      # On ARM the LLD linker inserts pseudo-functions (thunks) that allow
      # jumping distances farther than 16 MiB. Such thunks are known to often
      # reside on multiple offsets, they are not instrumented and hence they do
      # not reach the orderfiles. Exclude the thunk symbols from the warning.
      if not symbol_info.name.startswith('__ThumbV7PILongThunk_'):
        name_to_offsets[symbol_info.name].append(symbol_info.offset)
      symbol_infos.append(symbol_info)

  # Outlined functions are known to be repeated often, so ignore them in the
  # repeated symbol count.
  repeated_symbols = list(
      filter(lambda s: len(name_to_offsets[s]) > 1,
             (k for k in name_to_offsets.keys()
              if not k.startswith('OUTLINED_FUNCTION_'))))
  if repeated_symbols:
    # Log the first 5 repeated offsets of the first 10 repeated symbols.
    logging.warning('%d symbols repeated with multiple offsets:\n %s',
                    len(repeated_symbols), '\n '.join(
                        '{} {}'.format(sym, ' '.join(
                            str(offset) for offset in name_to_offsets[sym][:5]))
                        for sym in repeated_symbols[:10]))

  return symbol_infos
Parses the output of objdump, and get all the symbols from a binary.

  Args:
    objdump_lines: An iterable of lines

  Returns:
    A list of SymbolInfo.
  
Parses the output of objdump, and get all the symbols from a binary.
Parses the output of objdump and get all the symbols from a binary .
def _SymbolInfosFromStream(objdump_lines):
  name_to_offsets = collections.defaultdict(list)
  symbol_infos = []
  for line in objdump_lines:
    symbol_info = _FromObjdumpLine(line.decode('utf-8').rstrip('\n'))
    if symbol_info is not None:
      if not symbol_info.name.startswith('__ThumbV7PILongThunk_'):
        name_to_offsets[symbol_info.name].append(symbol_info.offset)
      symbol_infos.append(symbol_info)
  repeated_symbols = list(
      filter(lambda s: len(name_to_offsets[s]) > 1,
             (k for k in name_to_offsets.keys()
              if not k.startswith('OUTLINED_FUNCTION_'))))
  if repeated_symbols:
    logging.warning('%d symbols repeated with multiple offsets:\n %s',
                    len(repeated_symbols), '\n '.join(
                        '{} {}'.format(sym, ' '.join(
                            str(offset) for offset in name_to_offsets[sym][:5]))
                        for sym in repeated_symbols[:10]))
  return symbol_infos
def _SymbolInfosFromStream ( objdump_lines ) : name_to_offsets = collections . defaultdict ( list ) symbol_infos = [ ] for line in objdump_lines : symbol_info = _FromObjdumpLine ( line . decode ( 'utf-8' ) . rstrip ( '\n' ) ) if symbol_info is not None : if not symbol_info . name . startswith ( '__ThumbV7PILongThunk_' ) : name_to_offsets [ symbol_info . name ] . append ( symbol_info . offset ) symbol_infos . append ( symbol_info ) repeated_symbols = list ( filter ( lambda s : len ( name_to_offsets [ s ] ) > 1 , ( k for k in name_to_offsets . keys ( ) if not k . startswith ( 'OUTLINED_FUNCTION_' ) ) ) ) if repeated_symbols : logging . warning ( '%d symbols repeated with multiple offsets:\n %s' , len ( repeated_symbols ) , '\n ' . join ( '{} {}' . format ( sym , ' ' . join ( str ( offset ) for offset in name_to_offsets [ sym ] [ : 5 ] ) ) for sym in repeated_symbols [ : 10 ] ) ) return symbol_infos
Parses the output of objdump, and get all the symbols from a binary.
Parses the output of objdump and get all the symbols from a binary .
"""Parses the output of objdump, and get all the symbols from a binary.

  Args:
    objdump_lines: An iterable of lines

  Returns:
    A list of SymbolInfo.
  """ # On ARM the LLD linker inserts pseudo-functions (thunks) that allow # jumping distances farther than 16 MiB. Such thunks are known to often # reside on multiple offsets, they are not instrumented and hence they do # not reach the orderfiles. Exclude the thunk symbols from the warning. # Outlined functions are known to be repeated often, so ignore them in the # repeated symbol count. # Log the first 5 repeated offsets of the first 10 repeated symbols.
A list of SymbolInfo.
A list of SymbolInfo .
objdump_lines
An iterable of lines
An iterable of lines