Ensure old tab state is cleared between iterations of run-benchmark
[WebKit-https.git] / Tools / Scripts / check-for-invalid-symbols-in-version-script
1 #!/usr/bin/env python
2
3 import subprocess
4 import sys
5
6 def script_symbols(script):
7     symbols = []
8     in_symbols = False
9     with open(script, 'r') as f:
10         for line in f.readlines():
11             if in_symbols:
12                 if line.lstrip() == '};\n':
13                     break
14                 line = line.lstrip()
15                 line = line.rstrip('\n')
16                 line = line.rstrip(';')
17                 symbols.append(line.strip('"'))
18             elif line.lstrip() == 'extern "C++" {\n':
19                 in_symbols = True
20     return symbols
21
22 if len(sys.argv) < 3:
23     print "Usage: %s script lib" % sys.argv[0]
24     sys.exit(1)
25
26
27 symbols = script_symbols(sys.argv[1])
28 p = subprocess.Popen(['objdump', '-t', '-C', sys.argv[2]], stdout=subprocess.PIPE)
29 data = p.communicate()[0]
30
31 symbols = []
32 for symbol in script_symbols(sys.argv[1]):
33     if symbol not in data:
34         symbols.append(symbol)
35
36 if symbols:
37     print 'The following symbols are in version script %s and not in library %s' % (sys.argv[1], sys.argv[2])
38     print '\n'.join(sorted(symbols))
39     sys.exit(1)
40
41 sys.exit(0)