"""Verify every IDB opens cleanly; report the broken ones. Learned the hard way: killing a run mid-write (timeout) leaves a corrupted .i64 that still LOOKS fine on disk and whose stale outputs silently persist. This check must run after any interrupted batch. """ import glob, os, sys, idapro bad=[] for elf in sorted(glob.glob('handover/elf/versions/*/*.elf')): tag=os.path.basename(elf) try: rc=idapro.open_database(elf, run_auto_analysis=False) if rc!=0: bad.append((tag,'rc=%s'%rc)); continue idapro.close_database(save=False) except Exception as e: bad.append((tag, repr(e)[:60])) print("checked %d IDBs; broken: %d"%(len(glob.glob('handover/elf/versions/*/*.elf')), len(bad))) for t,e in bad: print(" BROKEN %-44s %s"%(t,e)) open('broken_idbs.txt','w').write("\n".join(t for t,_ in bad))