tokuglobals.py 2.04 KB
Newer Older
1 2 3 4
#!/usr/bin/python

import sys
import os
5
import stat
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
import re

def checkglobals(libname, exceptsymbols, verbose):
    badglobals = 0
    nmcmd = "nm -g " + libname
    f = os.popen(nmcmd)
    b = f.readline()
    while b != "":
        match = re.match("^([0-9a-f]+)\s(.?)\s(.*)$", b)
        if match == None:
            match = re.match("^\s+(.*)$", b)
            if match == None:
                print "unknown", b
                badglobals = 1
        else:
            type = match.group(2)
            symbol = match.group(3)
            if verbose: print type, symbol
24
            match = re.match("^toku|^__toku|^db_", symbol)
25 26 27 28 29 30 31 32 33
            if match == None and not exceptsymbols.has_key(symbol):
                print "non toku symbol=", symbol
                badglobals = 1
        b = f.readline()
    f.close()
    return badglobals

def main():
    verbose = 0
34
    libname = "libdb.so"
35 36 37
    for arg in sys.argv[1:]:
        if arg == "-v":
            verbose += 1
38 39 40 41 42 43 44 45
        elif arg[0:3] == "lib":
            libname = arg

    try: st = os.stat(libname)
    except: return 1
    mode = st[stat.ST_MODE]
    if not (mode & stat.S_IREAD): return 1

46 47 48
    exceptsymbols = {}
    for n in [ "_init", "_fini", "_end", "_edata", "__bss_start" ]:
        exceptsymbols[n] = 1
49
    for n in [ "db_env_create", "db_create", "db_strerror", "db_version", 
50 51 52 53 54 55
               "db_env_set_func_fsync", 
               "db_env_set_func_free", 
               "db_env_set_func_malloc", 
               "db_env_set_func_realloc", 
               "db_env_set_func_pwrite", 
               "db_env_set_func_write", 
56
               "db_env_set_func_loader_fwrite", 
Rich Prohaska's avatar
Rich Prohaska committed
57
               "db_env_set_checkpoint_callback", 
58
               "db_env_set_checkpoint_callback2",
Rich Prohaska's avatar
Rich Prohaska committed
59 60
               "db_env_set_recover_callback", 
               "db_env_set_recover_callback2",
61
               "db_env_enable_engine_status",
Rich Prohaska's avatar
Rich Prohaska committed
62 63
               "setup_dlmalloc", "dlfree", "dlmalloc", "dlrealloc" 
               ]:
64
        exceptsymbols[n] = 1
65
    return checkglobals(libname, exceptsymbols, verbose)
66 67
    
sys.exit(main())