def load_all_plugins(cmd): cmd = rcs_utils.load_all_plugins(cmd) cmd = rcs_utils.load_plugin(cmd, 'libDynAAUtils') cmd = rcs_utils.load_plugin(cmd, 'DynAAAnalyses') cmd = rcs_utils.load_plugin(cmd, 'DynAACheckers') cmd = rcs_utils.load_plugin(cmd, 'DynAAInstrumenters') return cmd
def load_all_plugins(cmd): cmd = rcs_utils.load_all_plugins(cmd) cmd = rcs_utils.load_plugin(cmd, 'libDynAAUtils') cmd = rcs_utils.load_plugin(cmd, 'libDynAAAnalyses') cmd = rcs_utils.load_plugin(cmd, 'libDynAACheckers') cmd = rcs_utils.load_plugin(cmd, 'libDynAAInstrumenters') cmd = rcs_utils.load_plugin(cmd, 'libDynAATransforms') return cmd
def load_aa(cmd, *aas): for aa in aas: # Some AAs require additional plugins. if aa == 'ds-aa': cmd = rcs_utils.load_plugin(cmd, 'LLVMDataStructure') elif aa == 'anders-aa' or aa == 'su-aa': cmd = rcs_utils.load_plugin(cmd, 'RCSAndersens') elif aa == 'bc2bdd-aa': if not os.path.exists('bc2bdd.conf'): sys.stderr.write('\033[0;31m') print >> sys.stderr, 'Error: bc2bdd-aa requires bc2bdd.conf,', print >> sys.stderr, 'which cannot be found in the current', print >> sys.stderr, 'directory.' sys.stderr.write('\033[m') sys.exit(1) cmd = rcs_utils.load_plugin(cmd, 'bc2bdd') cmd = string.join((cmd, '-' + aa)) return cmd
if __name__ == '__main__': parser = argparse.ArgumentParser( description = 'Rebuild the point-to graph from a point-to log') parser.add_argument('bc', help = 'the bitcode of the program') parser.add_argument('log', help = 'the point-to log') parser.add_argument('-o', metavar = 'output', help = 'the output .dot file', required = True) parser.add_argument('--dsaa', help = 'use DSAA as a reference', action = 'store_true') args = parser.parse_args() cmd = dynaa_utils.load_all_plugins('opt') if args.dsaa: # Use DSAA cmd = rcs_utils.load_plugin(cmd, 'LLVMDataStructure') cmd = string.join((cmd, '-tbaa')) cmd = string.join((cmd, '-basicaa')) cmd = string.join((cmd, '-ds-aa')) cmd = string.join((cmd, '-basic-pa')) cmd = string.join((cmd, '-draw-point-to')) else: # Use DynamicPointerAnalysis cmd = string.join((cmd, '-dyn-pa')) cmd = string.join((cmd, '-draw-point-to')) cmd = string.join((cmd, '-log-file', args.log)) cmd = string.join((cmd, '-dot', args.o)) cmd = string.join((cmd, '-pointer-stats')) cmd = string.join((cmd, '-disable-output')) cmd = string.join((cmd, '<', args.bc))
#!/usr/bin/env python import os import sys import rcs_utils import argparse if __name__ == "__main__": parser = argparse.ArgumentParser(description="compile .lm to .filter") parser.add_argument("bc", help="the bitcode file") parser.add_argument("lm", help=".lm file") args = parser.parse_args() if not args.lm.endswith(".lm"): print >>sys.stderr, "The input file should end with .lm" sys.exit(1) # TODO: loom_utils.load_all_plugins cmd = rcs_utils.load_plugin("opt", "RCSID") cmd = rcs_utils.load_plugin(cmd, "LoomCompiler") cmd = " ".join((cmd, "-compile")) cmd = " ".join((cmd, "-lm", args.lm)) cmd = " ".join((cmd, "-analyze", "-q")) cmd = " ".join((cmd, "<", args.bc)) cmd = " ".join((cmd, ">", os.path.splitext(args.lm)[0] + ".filter")) rcs_utils.invoke(cmd)
if __name__ == '__main__': parser = argparse.ArgumentParser( description = 'Rebuild the point-to graph from a point-to log') parser.add_argument('bc', help = 'the bitcode of the program') parser.add_argument('log', help = 'the point-to log') parser.add_argument('-o', metavar = 'output', help = 'the output .dot file', required = True) parser.add_argument('--dsaa', help = 'use DSAA as a reference', action = 'store_true') args = parser.parse_args() cmd = ng_utils.load_all_plugins('opt') if args.dsaa: # Use DSAA cmd = rcs_utils.load_plugin(cmd, 'LLVMDataStructure') cmd = string.join((cmd, '-tbaa')) cmd = string.join((cmd, '-basicaa')) cmd = string.join((cmd, '-ds-aa')) cmd = string.join((cmd, '-basic-pa')) cmd = string.join((cmd, '-draw-point-to')) else: # Use DynamicPointerAnalysis cmd = string.join((cmd, '-dyn-pa')) cmd = string.join((cmd, '-draw-point-to')) cmd = string.join((cmd, '-log-file', args.log)) cmd = string.join((cmd, '-dot', args.o)) cmd = string.join((cmd, '-pointer-stats')) cmd = string.join((cmd, '-disable-output')) cmd = string.join((cmd, '<', args.bc))
metavar = 'aa', choices = aa_choices) parser.add_argument('id1', help = 'the first ID', type = int) parser.add_argument('id2', help = 'the second ID', type = int) parser.add_argument('--ins', action = 'store_true', help = 'Set it if <id1> and <id2> are instruction IDs ' \ 'instead of value IDs (default: false)') parser.add_argument('--debug', action = 'store_true', help = 'Set it if you want debug output (default: false)') args = parser.parse_args() cmd = rcs_utils.load_all_plugins('opt') # Some AAs require additional plugins. # TODO: Should be specified in a configuration file. if args.aa == 'ds-aa': cmd = rcs_utils.load_plugin(cmd, 'LLVMDataStructure') # cmd = string.join((cmd, '-debug')) elif args.aa == 'anders-aa': cmd = rcs_utils.load_plugin(cmd, 'RCSAndersens') elif args.aa == 'bc2bdd-aa': if not os.path.exists('bc2bdd.conf'): sys.stderr.write('\033[1;31m') print >> sys.stderr, 'Error: bc2bdd-aa requires bc2bdd.conf, ' \ 'which cannot be found in the current directory.' sys.stderr.write('\033[m') sys.exit(1) cmd = rcs_utils.load_plugin(cmd, 'bc2bdd') cmd = string.join((cmd, '-' + args.aa)) cmd = string.join((cmd, '-test-aa')) if not args.ins:
import os import rcs_utils import argparse if __name__ == '__main__': parser = argparse.ArgumentParser( description = 'insert Loom update engine to the program') parser.add_argument('prog', help = 'the program name (e.g. mysqld)') args = parser.parse_args() instrumented_bc = args.prog + '.loom.bc' instrumented_exe = args.prog + '.loom' # TODO: loom_utils.load_all_plugins cmd = rcs_utils.load_plugin('opt', 'RCSID') cmd = rcs_utils.load_plugin(cmd, 'RCSCFG') cmd = rcs_utils.load_plugin(cmd, 'libLoomUtils') cmd = rcs_utils.load_plugin(cmd, 'LoomAnalysis') cmd = rcs_utils.load_plugin(cmd, 'LoomInstrumenter') cmd = ' '.join((cmd, '-break-crit-invokes', '-insert-checks', '-clone-bbs')) cmd = ' '.join((cmd, '-o', instrumented_bc)) cmd = ' '.join((cmd, '<', args.prog + '.bc')) rcs_utils.invoke(cmd) cmd = ' '.join(('clang++', instrumented_bc, rcs_utils.get_libdir() + '/libLoomUpdateEngine.a', rcs_utils.get_libdir() + '/libLoomUtils.a', '-o', instrumented_exe, '-g', '-O3')) linking_flags = rcs_utils.get_linking_flags(args.prog)
import os import rcs_utils import argparse if __name__ == '__main__': parser = argparse.ArgumentParser( description='insert Loom update engine to the program') parser.add_argument('prog', help='the program name (e.g. mysqld)') args = parser.parse_args() instrumented_bc = args.prog + '.loom.bc' instrumented_exe = args.prog + '.loom' # TODO: loom_utils.load_all_plugins cmd = rcs_utils.load_plugin('opt', 'RCSID') cmd = rcs_utils.load_plugin(cmd, 'RCSCFG') cmd = rcs_utils.load_plugin(cmd, 'libLoomUtils') cmd = rcs_utils.load_plugin(cmd, 'LoomAnalysis') cmd = rcs_utils.load_plugin(cmd, 'LoomInstrumenter') cmd = ' '.join( (cmd, '-break-crit-invokes', '-insert-checks', '-clone-bbs')) cmd = ' '.join((cmd, '-o', instrumented_bc)) cmd = ' '.join((cmd, '<', args.prog + '.bc')) rcs_utils.invoke(cmd) cmd = ' '.join(('clang++', instrumented_bc, rcs_utils.get_libdir() + '/libLoomUpdateEngine.a', rcs_utils.get_libdir() + '/libLoomUtils.a', '-o', instrumented_exe, '-g', '-O3')) linking_flags = rcs_utils.get_linking_flags(args.prog)
parser.add_argument('id1', help='the first ID', type=int) parser.add_argument('id2', help='the second ID', type=int) parser.add_argument('--ins', action = 'store_true', help = 'Set it if <id1> and <id2> are instruction IDs ' \ 'instead of value IDs (default: false)') parser.add_argument( '--debug', action='store_true', help='Set it if you want debug output (default: false)') args = parser.parse_args() cmd = rcs_utils.load_all_plugins('opt') # Some AAs require additional plugins. # TODO: Should be specified in a configuration file. if args.aa == 'ds-aa': cmd = rcs_utils.load_plugin(cmd, 'LLVMDataStructure') # cmd = string.join((cmd, '-debug')) elif args.aa == 'anders-aa': cmd = rcs_utils.load_plugin(cmd, 'RCSAndersens') elif args.aa == 'bc2bdd-aa': if not os.path.exists('bc2bdd.conf'): sys.stderr.write('\033[1;31m') print >> sys.stderr, 'Error: bc2bdd-aa requires bc2bdd.conf, ' \ 'which cannot be found in the current directory.' sys.stderr.write('\033[m') sys.exit(1) cmd = rcs_utils.load_plugin(cmd, 'bc2bdd') cmd = string.join((cmd, '-' + args.aa)) cmd = string.join((cmd, '-test-aa')) if not args.ins:
#!/usr/bin/env python import os import sys import rcs_utils import argparse if __name__ == '__main__': parser = argparse.ArgumentParser(description = 'compile .lm to .filter') parser.add_argument('bc', help = 'the bitcode file') parser.add_argument('lm', help = '.lm file') args = parser.parse_args() if not args.lm.endswith('.lm'): print >> sys.stderr, 'The input file should end with .lm' sys.exit(1) # TODO: loom_utils.load_all_plugins cmd = rcs_utils.load_plugin('opt', 'RCSID') cmd = rcs_utils.load_plugin(cmd, 'LoomCompiler') cmd = ' '.join((cmd, '-compile')) cmd = ' '.join((cmd, '-lm', args.lm)) cmd = ' '.join((cmd, '-analyze', '-q')) cmd = ' '.join((cmd, '<', args.bc)) cmd = ' '.join((cmd, '>', os.path.splitext(args.lm)[0] + '.filter')) rcs_utils.invoke(cmd)