dump_app_syms.py 912 B

12345678910111213141516171819202122232425262728293031
  1. # Copyright 2015 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. # Helper script to run dump_syms on Chrome Linux executables and strip
  5. # them if needed.
  6. from __future__ import print_function
  7. import os
  8. import subprocess
  9. import sys
  10. if len(sys.argv) != 5:
  11. print("dump_app_syms.py <dump_syms_exe> <strip_binary>")
  12. print(" <binary_with_symbols> <symbols_output>")
  13. sys.exit(1)
  14. dumpsyms = sys.argv[1]
  15. strip_binary = sys.argv[2]
  16. infile = sys.argv[3]
  17. outfile = sys.argv[4]
  18. # Dump only when the output file is out-of-date.
  19. if not os.path.isfile(outfile) or \
  20. os.stat(outfile).st_mtime < os.stat(infile).st_mtime:
  21. with open(outfile, 'w') as outfileobj:
  22. subprocess.check_call([dumpsyms, '-d', infile], stdout=outfileobj)
  23. if strip_binary != '0':
  24. subprocess.check_call(['strip', infile])