diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-15 23:57:01 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-15 23:57:01 +0000 |
commit | 3bfd21c131fab47b678b04f6f7bf1e3e8277f4a0 (patch) | |
tree | a8c730a0ea73be40b792fe2763df5ac13800ccd6 /tools/mac | |
parent | c4bf822d0f0fce4139499b5d2ec142da960ae712 (diff) | |
download | chromium_src-3bfd21c131fab47b678b04f6f7bf1e3e8277f4a0.zip chromium_src-3bfd21c131fab47b678b04f6f7bf1e3e8277f4a0.tar.gz chromium_src-3bfd21c131fab47b678b04f6f7bf1e3e8277f4a0.tar.bz2 |
dump-static-initializers.py for mac.
BUG=94925
TEST=none
R=jochen@chromium.org
Review URL: https://codereview.chromium.org/8776039
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@228805 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/mac')
-rwxr-xr-x | tools/mac/dump-static-initializers.py | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/tools/mac/dump-static-initializers.py b/tools/mac/dump-static-initializers.py new file mode 100755 index 0000000..9c7b91a --- /dev/null +++ b/tools/mac/dump-static-initializers.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python +# Copyright (c) 2013 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + + +import optparse +import re +import subprocess +import sys + +# Matches for example: +# [ 1] 000001ca 64 (N_SO ) 00 0000 0000000000000000 'test.cc' +dsymutil_file_re = re.compile("N_SO.*'([^']*)'") + +# Matches for example: +# [ 2] 000001d2 66 (N_OSO ) 00 0001 000000004ed856a0 '/Volumes/MacintoshHD2/src/chrome-git/src/test.o' +dsymutil_o_file_re = re.compile("N_OSO.*'([^']*)'") + +# Matches for example: +# [ 8] 00000233 24 (N_FUN ) 01 0000 0000000000001b40 '__GLOBAL__I_s' +# [185989] 00dc69ef 26 (N_STSYM ) 02 0000 00000000022e2290 '__GLOBAL__I_a' +dsymutil_re = re.compile(r"(?:N_FUN|N_STSYM).*\s[0-9a-f]*\s'__GLOBAL__I_") + +def ParseDsymutil(binary): + """Given a binary, prints source and object filenames for files with + static initializers. + """ + + child = subprocess.Popen(['dsymutil', '-s', binary], stdout=subprocess.PIPE) + for line in child.stdout: + file_match = dsymutil_file_re.search(line) + if file_match: + current_filename = file_match.group(1) + else: + o_file_match = dsymutil_o_file_re.search(line) + if o_file_match: + current_o_filename = o_file_match.group(1) + else: + match = dsymutil_re.search(line) + if match: + print current_filename + print current_o_filename + print + + +def main(): + parser = optparse.OptionParser(usage='%prog filename') + opts, args = parser.parse_args() + if len(args) != 1: + parser.error('missing filename argument') + return 1 + binary = args[0] + + ParseDsymutil(binary) + return 0 + + +if '__main__' == __name__: + sys.exit(main()) |