def saveSignatures(cache, structCache, dumpname): ''' cache is {} of sig: [structs] ''' fout = file( Config.getCacheFilename( Config.CACHE_GENERATED_PY_HEADERS, dumpname), 'w') towrite = [] tuples = [(len(structs), sig, structs) for sig, structs in cache.items()] tuples.sort(reverse=True) for l, sig, structs in tuples: values = '' s = ''' # %d structs #class %s %s ''' % (len(structs), sig, structs[0].toString()) fout.write(s) fout.close()
def rewrite(structs_addrs, structCache, dumpname): ''' structs_addrs is sorted ''' structs_addrs.sort() fout = file( Config.getCacheFilename( Config.CACHE_GENERATED_PY_HEADERS_VALUES, dumpname), 'w') towrite = [] for vaddr in structs_addrs: # debug if vaddr in DEBUG_ADDRS: logging.getLogger('progressive').setLevel(logging.DEBUG) else: logging.getLogger('progressive').setLevel(logging.INFO) anon = structCache[vaddr] anon.resolvePointers() towrite.append(anon.toString()) if len(towrite) >= 10000: fout.write('\n'.join(towrite)) towrite = [] fout.write('\n'.join(towrite)) fout.close() return