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(cpath,'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 not cfile.has_function_by_name(args.cfunction):
        print(UP.cfunction_not_found_err_sg(cpath,args.cfile,args.cfunction))
        exit(1)

    cfunction = cfile.get_function_by_name(args.cfunction)

    if args.open:
        print(RP.function_code_open_tostring(cfunction))
    elif args.violations:
        print(RP.function_code_violation_tostring(cfunction))
    elif args.predicate:
        print(RP.function_code_predicate_tostring(cfunction,args.predicate))
    else:
        print(RP.function_code_tostring(cfunction))

    print(RP.function_proofobligation_stats_tostring(cfunction))

Beispiel #2
0
        pos[filename] = {}

    lines = []
    for filename in pairs:
        for fn in sorted(pairs[filename]):
            fnlen = len(fn)
            lines.append('\n\n' + ('*' * 10) + ' Function: ' + fn + ' ' +
                         ('*' * (70 - fnlen)))
            cfile = capp.get_file(filename)
            cfun = cfile.get_function_by_name(fn)
            ppos = [x[1] for x in pairs[filename][fn]]
            ppoids = [x.id for x in ppos]
            ppofilter = lambda ppo: (ppo.id in ppoids) and ppo.is_ppo()
            lines.append(
                RP.function_code_tostring(cfun,
                                          pofilter=ppofilter,
                                          showpreamble=False))
            spos = sum((JTS.get_associated_spos(x, capp) for x in ppos), [])
            callers = {}
            for spo in spos:
                cfun = spo.cfun
                if not cfun.name in callers:
                    callers[cfun.name] = {}
                    callers[cfun.name]['cfun'] = cfun
                    callers[cfun.name]['spos'] = []
                callers[cfun.name]['spos'].append(spo.id)
            if len(callers) > 0:
                lines.append('-' * 80)
                lines.append('Callers')
                lines.append('-' * 80)
                for fn in callers:
Beispiel #3
0
        lines.append(('Function ' + args.cfunction + ' not found in file '
                          + cfile.name + '; function names available:'))
        lines.append('-' * 80)
        for n in cfile.functionnames:
            lines.append('  ' + n)
        lines.append('*' * 80)
        print('\n'.join(lines))
        exit(0)

    cfunction = cfile.get_function_by_name(args.cfunction)

    try:

        if args.open:
            print(RP.function_code_open_tostring(cfunction))
        elif args.predicate:
            print(RP.function_code_predicate_tostring(cfunction,args.predicate,showinvs=args.showinvs))
        else:
            print(RP.function_code_tostring(cfunction,showinvs=args.showinvs))

        print(RP.function_proofobligation_stats_tostring(cfunction))

    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))
    

    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 not cfile.has_function_by_name(args.cfunction):
        print(UP.cfunction_not_found_err_sg(cpath,args.cfile,args.cfunction))
        exit(1)

    cfunction = cfile.get_function_by_name(args.cfunction)

    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.function_code_tostring(cfunction,pofilter=pofilter))