#!/usr/bin/env python import argparse import os import sys import string import rcs_utils import dynaa_utils if __name__ == '__main__': parser = argparse.ArgumentParser( description = 'Check the call graph generated based on the ' \ 'specified AA') parser.add_argument('bc', help = 'the bitcode of the program') parser.add_argument('log', help = 'the point-to log') parser.add_argument('aa', help = 'the underlying alias analysis: ' + \ str(dynaa_utils.get_aa_choices()), metavar = 'aa', choices = dynaa_utils.get_aa_choices()) args = parser.parse_args() cmd = dynaa_utils.load_all_plugins('opt') cmd = dynaa_utils.load_aa(cmd, args.aa) cmd = string.join((cmd, '-fpcg')) cmd = string.join((cmd, '-check-cg')) cmd = string.join((cmd, '-log-file', args.log)) cmd = string.join((cmd, '-disable-output', '<', args.bc)) rcs_utils.invoke(cmd)
type = int) parser.add_argument('--dir', help = 'where to put the log files (/tmp by default)', type = str, default = '/tmp') args = parser.parse_args() # Check whether the log directory exists assert os.path.exists(args.dir), args.dir + ' does not exist.' assert os.path.isdir(args.dir), args.dir + ' is not a directory.' # dynaa_clear.py # clear other log files # The script exits with the exit code of dynaa_check_aa.py. # Therefore, we use False here to avoid overwriting the exit code. rcs_utils.invoke('dynaa_clear.py ' + args.dir) # dynaa_hook_mem cmd = ' '.join(('dynaa_hook_mem.py', args.prog)) if args.all: cmd = ' '.join((cmd, '--hook-all')) rcs_utils.invoke(cmd) # run the instrumented program cmd = './' + args.prog + '.inst' if args.time_limit is not None: cmd = ' '.join(('timeout', str(args.time_limit), cmd)) cmd = ' '.join(('LOG_FILE=' + args.dir + '/pts', cmd)) timeout = rcs_utils.invoke(cmd, False) if timeout != 0: print >> sys.stderr, 'Warning: runtime error or time limit exceeded'
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)) rcs_utils.invoke(cmd)
# suited for csmith. The generated program is sometimes too large and takes # forever to run. parser.add_argument('--time-limit', help = 'time limit for the program (in seconds)', type = int) parser.add_argument('--dir', help = 'where to put the log files (default: /tmp)', type = str, default = '/tmp') args = parser.parse_args() # ng_hook_mem cmd = ' '.join(('ng_hook_mem.py', args.prog)) if args.all: cmd = ' '.join((cmd, '--hook-all')) rcs_utils.invoke(cmd) # run the instrumented program cmd = './' + args.prog + '.inst' if args.time_limit is not None: cmd = ' '.join(('timeout', str(args.time_limit), cmd)) cmd = ' '.join(('LOG_DIR=' + args.dir, cmd)) timeout = rcs_utils.invoke(cmd, False) # FIXME: could fail for other reasons if timeout != 0: print >> sys.stderr, 'Warning: runtime error or time limit exceeded' # ng_check_aa.py # use automatic globbing cmd = ' '.join(('ng_check_aa.py', args.prog + '.bc',