if not os.path.isdir(cpath):
        print(UP.cpath_not_found_err_msg(cpath))
        exit(1)

    sempath = os.path.join(cpath, 'semantics')
    if not os.path.isdir(sempath):
        print(UP.semantics_not_found_err_msg(cpath))
        exit(1)

    try:
        cfapp = CApplication(sempath, args.cfile)
        cfile = cfapp.get_cfile()
    except CFileNotFoundException as e:
        print(e)
        exit(0)

    try:
        if args.showcode:
            if args.open:
                print(RP.file_code_open_tostring(cfile,
                                                 showinvs=args.showinvs))
            else:
                print(RP.file_code_tostring(cfile))

        print(RP.file_proofobligation_stats_tostring(cfile))
    except IndexedTableError as e:
        print('\n' + ('*' * 80) + '\nThe analysis results format has changed' +
              '\nYou may have to re-run the analysis first: ' + '\n' + e.msg +
              '\n' + ('*' * 80))
Example #2
0
def parse():
    parser = argparse.ArgumentParser()
    parser.add_argument('cfilename',
                        help='name of kendra c file (e.g., id115.c)')
    parser.add_argument('--show_invariants',
                        help='show invariants in addition to diagnostic',
                        action='store_true')
    args = parser.parse_args()
    return args


if __name__ == '__main__':

    args = parse()
    cfilename = args.cfilename
    cpath = UF.get_kendra_cpath(cfilename)

    if cpath is None:
        print('*' * 80)
        print('Unable to find the test set for file ' + cfilename)
        print('*' * 80)
        exit(1)

    sempath = os.path.join(cpath, 'semantics')
    cfapp = CApplication(sempath, cfilename)
    cfile = cfapp.get_cfile()

    print(RP.file_code_tostring(cfile, showinvs=args.show_invariants))
    print(RP.file_proofobligation_stats_tostring(cfile))
Example #3
0
    if not os.path.isdir(cpath):
        print(UP.cpath_not_found_err_msg(cpath))
        exit(1)

    if not os.path.isfile(os.path.join(cpath,args.cfile)):
        print(UP.cfile_not_found_err_msg(cpath,args.cfile))
        exit(1)

    sempath = os.path.join(args.path, 'semantics')

    if not os.path.isdir(sempath):
        print(UP.semantics_not_found_err_msg(cpath))
        exit(1)

    cfapp = CApplication(sempath,args.cfile)
    cfile = cfapp.get_cfile()

    if args.showcode:
        if args.open and args.violations:
            def pofilter(po):return not po.is_closed() or po.is_violated()
        elif args.open:
            def pofilter(po):return not po.is_closed()
        elif args.violations:
            def pofilter(po):return po.is_violated()
        else:
            def pofilter(po):return True
        print(RP.file_code_tostring(cfile,pofilter=pofilter,showinvs=True))


    print(RP.file_proofobligation_stats_tostring(cfile))