def ParseDump(filename):
  """Parses a residency dump, as generated from lightweight_cygprofile.cc.

  Args:
    filename: (str) dump filename.

  Returns:
    {"start": offset, "end": offset,
     "residency": {timestamp (int): data ([bool])}}
  """
  result = {}
  with open(filename, 'r') as f:
    (start, end) = f.readline().strip().split(' ')
    result = {'start': int(start), 'end': int(end), 'residency': {}}
    for line in f:
      line = line.strip()
      timestamp, data = line.split(' ')
      data_array = [x == '1' for x in data]
      result['residency'][int(timestamp)] = data_array
  return result