def CodePagesToReachedSize(reached_symbol_names, page_to_symbols):
  """From page offset -> [all_symbols], return the reached portion per page.

  Args:
    reached_symbol_names: ([str]) List of reached symbol names.
    page_to_symbols: (dict) As returned by CodePagesToMangledSymbols().

  Returns:
    {page offset (int) -> {'total': int, 'reached': int}}
  """
  reached_symbol_names = set(reached_symbol_names)
  page_to_reached = {}
  for offset in page_to_symbols:
    total_size = sum(x[1] for x in page_to_symbols[offset])
    reached_size = sum(
        size_in_page for (name, size_in_page) in page_to_symbols[offset]
        if name in reached_symbol_names)
    page_to_reached[offset] = {'total': total_size, 'reached': reached_size}
  return page_to_reached