summaryrefslogtreecommitdiffstats
path: root/libcxx/utils/sym_check/sym_diff.py
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2015-03-20 22:09:29 +0000
committerEric Fiselier <eric@efcs.ca>2015-03-20 22:09:29 +0000
commit9bf753cf07547d2a4501daea8b1cab476a310814 (patch)
tree14f2a82b86a8ea2e82ffefe930e12cfe5dd1a36a /libcxx/utils/sym_check/sym_diff.py
parentf44c06b96fbd8e5258be949e84abaac0f6fb5050 (diff)
downloadbcm5719-llvm-9bf753cf07547d2a4501daea8b1cab476a310814.tar.gz
bcm5719-llvm-9bf753cf07547d2a4501daea8b1cab476a310814.zip
Add symbol checking script to libc++ to help manage exported symbols.
Summary: Add symbol checking scripts for extracting a list of symbols from shared libraries and for comparing symbol lists for differences. Reviewers: mclow.lists, danalbert, EricWF Reviewed By: EricWF Subscribers: majnemer, emaste, cfe-commits Differential Revision: http://reviews.llvm.org/D4946 llvm-svn: 232855
Diffstat (limited to 'libcxx/utils/sym_check/sym_diff.py')
-rwxr-xr-xlibcxx/utils/sym_check/sym_diff.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/libcxx/utils/sym_check/sym_diff.py b/libcxx/utils/sym_check/sym_diff.py
new file mode 100755
index 00000000000..054c6c18e3e
--- /dev/null
+++ b/libcxx/utils/sym_check/sym_diff.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+"""
+sym_diff - Compare two symbol lists and output the differences.
+"""
+from argparse import ArgumentParser
+import sys
+from sym_check import diff, util
+
+
+def main():
+ parser = ArgumentParser(
+ description='Extract a list of symbols from a shared library.')
+ parser.add_argument(
+ '--names-only', dest='names_only',
+ help='Only print symbol names',
+ action='store_true', default=False)
+ parser.add_argument(
+ '-o', '--output', dest='output',
+ help='The output file. stdout is used if not given',
+ type=str, action='store', default=None)
+ parser.add_argument(
+ '--demangle', dest='demangle', action='store_true', default=False)
+ parser.add_argument(
+ 'old_syms', metavar='old-syms', type=str,
+ help='The file containing the old symbol list or a library')
+ parser.add_argument(
+ 'new_syms', metavar='new-syms', type=str,
+ help='The file containing the new symbol list or a library')
+ args = parser.parse_args()
+
+ old_syms_list = util.extract_or_load(args.old_syms)
+ new_syms_list = util.extract_or_load(args.new_syms)
+
+ added, removed, changed = diff.diff(old_syms_list, new_syms_list)
+ report, is_break = diff.report_diff(added, removed, changed,
+ names_only=args.names_only,
+ demangle=args.demangle)
+ if args.output is None:
+ print(report)
+ else:
+ with open(args.output, 'w') as f:
+ f.write(report + '\n')
+ sys.exit(is_break)
+
+
+if __name__ == '__main__':
+ main()
OpenPOWER on IntegriCloud