gstreamer/codegen/code-coverage.py
Johan Dahlin 90579783ce configure.ac (PYGTK_CODEGEN): Use built in code generator again and don't require 2.3.91, 2.0.0 should do fine (FC1 o...
Original commit message from CVS:
* configure.ac (PYGTK_CODEGEN): Use built in code generator again
and don't require 2.3.91, 2.0.0 should do fine (FC1 ok, RH9 isn't)

* TODO: Update

* gst/interfaces.override, gst/play.override: Add typedef for
python < 2.3

* codegen/codegen.py: Readd :/
2004-04-16 16:53:29 +00:00

42 lines
1.3 KiB
Python
Executable file

from __future__ import generators
import sys, os
def read_symbols(file, type=None, dynamic=0):
if dynamic:
cmd = 'nm -D %s' % file
else:
cmd = 'nm %s' % file
for line in os.popen(cmd, 'r'):
if line[0] != ' ': # has an address as first bit of line
while line[0] != ' ':
line = line[1:]
while line[0] == ' ':
line = line[1:]
# we should be up to "type symbolname" now
sym_type = line[0]
symbol = line[1:].strip()
if not type or type == sym_type:
yield symbol
def main():
if len(sys.argv) != 3:
sys.stderr.write('usage: coverage-check library.so wrapper.so\n')
sys.exit(1)
library = sys.argv[1]
wrapper = sys.argv[2]
# first create a dict with all referenced symbols in the wrapper
# should really be a set, but a dict will do ...
wrapper_symbols = {}
for symbol in read_symbols(wrapper, type='U', dynamic=1):
wrapper_symbols[symbol] = 1
# now go through the library looking for matches on the defined symbols:
for symbol in read_symbols(library, type='T', dynamic=1):
if symbol[0] == '_': continue
if symbol not in wrapper_symbols:
print symbol
if __name__ == '__main__':
main()