symbolizer.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Copyright 2018 The Chromium Authors. All rights reserved.
  2. # Use of this source code is governed by a BSD-style license that can be
  3. # found in the LICENSE file.
  4. import logging
  5. import os
  6. import subprocess
  7. from common import SDK_ROOT
  8. from common import GetHostArchFromPlatform
  9. from common import GetHostToolPathFromPlatform
  10. def BuildIdsPaths(package_paths):
  11. """Generates build ids paths for symbolizer processes."""
  12. return [
  13. os.path.join(os.path.dirname(package_path), 'ids.txt')
  14. for package_path in package_paths
  15. ]
  16. def RunSymbolizer(input_fd, output_fd, ids_txt_paths):
  17. """Starts a symbolizer process.
  18. input_fd: Input file to be symbolized.
  19. output_fd: Output file for symbolizer stdout and stderr.
  20. ids_txt_paths: Path to the ids.txt files which map build IDs to
  21. unstripped binaries on the filesystem.
  22. Returns a Popen object for the started process."""
  23. symbolizer = GetHostToolPathFromPlatform('symbolizer')
  24. symbolizer_cmd = [
  25. symbolizer, '--omit-module-lines', '--build-id-dir',
  26. os.path.join(SDK_ROOT, '.build-id')
  27. ]
  28. for ids_txt in ids_txt_paths:
  29. symbolizer_cmd.extend(['--ids-txt', ids_txt])
  30. logging.debug('Running "%s".' % ' '.join(symbolizer_cmd))
  31. return subprocess.Popen(symbolizer_cmd,
  32. stdin=input_fd,
  33. stdout=output_fd,
  34. stderr=subprocess.STDOUT,
  35. close_fds=True)