Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1106)

Unified Diff: tools/mac/dump-static-initializers.py

Issue 10821035: wip Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/chrome_render_view_observer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/mac/dump-static-initializers.py
diff --git a/tools/mac/dump-static-initializers.py b/tools/mac/dump-static-initializers.py
new file mode 100644
index 0000000000000000000000000000000000000000..8178e9d0707f8f1bad89772c560a93e19e015c74
--- /dev/null
+++ b/tools/mac/dump-static-initializers.py
@@ -0,0 +1,55 @@
+#!/usr/bin/env python
+
+import optparse
+import re
+import subprocess
+import sys
+
+# Matches for example:
+# [ 1] 000001ca 64 (N_SO ) 00 0000 0000000000000000 'test.cc'
+nm_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'
+nm_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'
+nm_re = re.compile(r"(?:N_FUN|N_STSYM).*\s([0-9a-f]*)\s'__GLOBAL__I_")
+
+def ParseNm(binary):
+ """foo"""
+
+ nm = subprocess.Popen(['dsymutil', '-s', binary], stdout=subprocess.PIPE)
+ for line in nm.stdout:
+ file_match = nm_file_re.search(line)
+ if file_match:
+ current_filename = file_match.group(1)
+ else:
+ o_file_match = nm_o_file_re.search(line)
+ if o_file_match:
+ current_o_filename = o_file_match.group(1)
+ else:
+ match = nm_re.search(line)
+ if match:
+ address = match.group(1)
+ 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]
+
+ ParseNm(binary)
+ return 0
+
+
+if '__main__' == __name__:
+ sys.exit(main())
« no previous file with comments | « chrome/renderer/chrome_render_view_observer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698