def test_spo_proofs(self,delaytest=False): """Run analysis and check if the analysis results match the expected results. Skip the checking if delaytest is True. """ self.testresults.set_sevs() for creffile in self.get_cref_files(): creffilename = creffile.name cfilefilename = UF.get_cfile_filename(self.tgtxpath,creffilename) if not os.path.isfile(cfilefilename): raise XmlFileNotFoundError(cfilefilename) capp = CApplication(self.sempath,cfilename=creffilename,contractpath=self.contractpath) cappfile = capp.get_single_file() if creffile.has_domains(): for d in creffile.get_domains(): am = AnalysisManager(capp,onefile=True,verbose=self.verbose) am.generate_and_check_file(creffilename,d) cappfile.reinitialize_tables() spos = cappfile.get_spos() if delaytest: continue for cfun in creffile.get_functions(): fname = cfun.name funspos = [ spo for spo in spos if spo.cfun.name == fname ] refspos = cfun.get_spos() self.check_spo_proofs(creffilename,cfun,funspos,refspos)
def test_ppo_proofs(self,delaytest=False): """Run analysis and check if analysis results match expected results. Skip checking results if delaytest is true. """ if not os.path.isfile(self.config.canalyzer): raise AnalyzerMissingError(self.config.canalyzer) self.testresults.set_pevs() for creffile in self.get_cref_files(): cfilename = creffile.name cfilefilename = UF.get_cfile_filename(self.tgtxpath,cfilename) if not os.path.isfile(cfilefilename): raise XmlFileNotFoundError(cfilefilename) capp = CApplication(self.sempath,cfilename=cfilename,contractpath=self.contractpath) cfile = capp.get_single_file() # only generate invariants if required if creffile.has_domains(): for d in creffile.get_domains(): am = AnalysisManager(capp,onefile=True,verbose=self.verbose) am.generate_and_check_file(cfilename,d) cfile.reinitialize_tables() ppos = cfile.get_ppos() if delaytest: continue for cfun in creffile.get_functions(): fname = cfun.name funppos = [ ppo for ppo in ppos if ppo.cfun.name == fname ] refppos = cfun.get_ppos() self.check_ppo_proofs(cfilename,cfun,funppos,refppos)
def test_ppos(self): """Create primary proof obligations and check if created as expected.""" if not os.path.isfile(self.config.canalyzer): raise AnalyzerMissingError(self.config.canalyzer) self.testresults.set_ppos() saved = False try: for creffile in self.get_cref_files(): creffilename = creffile.name creffilefilename = UF.get_cfile_filename(self.tgtxpath,creffilename) if not os.path.isfile(creffilefilename): raise XmlFileNotFoundError(creffilefilename) capp = CApplication(self.sempath,cfilename=creffilename,contractpath=self.contractpath) am = AnalysisManager(capp,onefile=True,verbose=self.verbose) am.create_file_primary_proofobligations(creffilename) cfile = capp.get_single_file() capp.collect_post_assumes() ppos = cfile.get_ppos() for creffun in creffile.get_functions(): fname = creffun.name cfun = cfile.get_function_by_name(fname) if self.saveref: if creffun.has_ppos(): print('Ppos not created for ' + fname + ' (delete first)') else: self.create_reference_ppos(creffilename,fname,cfun.get_ppos()) saved = True else: refppos = creffun.get_ppos() funppos = [ ppo for ppo in ppos if ppo.cfun.name == fname ] if len(refppos) == len(funppos): self.testresults.add_ppo_count_success(creffilename,fname) self.check_ppos(creffilename,fname,funppos,refppos) else: self.testresults.add_ppo_count_error( creffilename,fname,len(funppos),len(refppos)) raise FunctionPPOError(creffilename + ':' + fname) except FunctionPPOError as detail: self.print_test_results() print('Function PPO error: ' + str(detail)) exit() if self.saveref and saved: self.testsetref.save() exit()
def test_spos(self,delaytest=False): """Run analysis and check if all expected spos are created.""" try: for creffile in self.get_cref_files(): self.testresults.set_spos() cfilename = creffile.name cfilefilename = UF.get_cfile_filename(self.tgtxpath,cfilename) if not os.path.isfile(cfilefilename): raise XmlFileNotFoundError(xfilefilename) capp = CApplication(self.sempath,cfilename=cfilename,contractpath=self.contractpath) cappfile = capp.get_single_file() capp.update_spos() capp.collect_post_assumes() spos = cappfile.get_spos() if delaytest: continue for cfun in creffile.get_functions(): fname = cfun.name if self.saveref: if cfun.has_spos(): print('Spos not created for ' + fname + ' in ' + cfilename + ' (delete first)') else: self.create_reference_spos(cfilename,fname,spos[fname]) else: refspos = cfun.get_spos() funspos = [ spo for spo in spos if spo.cfun.name == fname ] if funspos is None and len(refspos) == 0: self.testresults.add_spo_count_success(cfilename,fname) elif len(refspos) == len(funspos): self.testresults.add_spo_count_success(cfilename,fname) self.check_spos(cfilename,fname,funspos,refspos) else: self.testresults.add_spo_count_error( cfilename,fname,len(funspos),len(refspos)) raise FunctionSPOError(cfilename + ':' + fname + ' (' + str(len(funspos)) + ')') except FunctionSPOError as detail: self.print_test_results() print('') print('*' * 80) print('Function SPO error: ' + str(detail)) print('*' * 80) exit() if self.saveref: self.testsetref.save() exit()
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) if cfapp.has_single_file(): cfile = cfapp.get_cfile() if (args.table is None) or args.list: print(str(DT.list_file_tables())) else: print(str(DT.get_file_table(cfile, args.table))) else: print('*' * 80) print('File not found. Please make sure the test has been analyzed.') print('*' * 80) exit(1)
cpath = os.path.join(config.testdir, pdir) else: cpath = os.path.abspath(args.path) 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): success = UF.unpack_tar_file(cpath) if not success: print(UP.semantics_tar_not_found_err_msg(cpath)) exit(1) capp = CApplication(sempath) if args.contractpath is None: contractpath = os.path.join(cpath, 'ktacontracts') else: contractpath = args.contractpath ignorefns = {} if not args.ignorefile is None: if os.path.isfile(args.ignorefile): with open(args.ignorefile, 'r') as fp: headers = json.load(fp) for h in headers: for fn in headers[h]['functions']: ignorefns[fn] = h
exit(0) # check linkinfo globaldefs = os.path.join( sempath, os.path.join('ktadvance', 'globaldefinitions.xml')) if not os.path.isfile(globaldefs): print(UP.global_definitions_not_found_err_msg(cpath)) exit(0) if args.contractpath is None: contractpath = os.path.join(cpath, 'ktacontracts') else: contractpath = args.contractpath excludefiles = ['io.c', 'main_linux.c', 'std_thread.c'] capp = CApplication(sempath, contractpath=contractpath, excludefiles=excludefiles) # assume wordsize of 64 # use unreachability as a means of proof obligation discharge with timing('analysis of ' + args.path): am = AnalysisManager(capp, wordsize=64, unreachability=True, thirdpartysummaries=[UF.get_juliet_summaries()]) am.generate_and_check_app('llrvisp')
if __name__ == '__main__': header = ['open', 'api', 'rv', 'global', 'invariants', 'check-valid'] title = 'testcase ppos %open %api %rv %global %invs %checkvalid' missing = [] print('\n' + title) print('-' * 80) for t in sorted(testcases): testdir = os.path.join(zitser, t) semdir = os.path.join(testdir, 'semantics') if os.path.isdir(semdir): results = {} capp = CApplication(semdir) ppomethods = capp.get_ppo_methods() total = sum(ppomethods[m] for m in ppomethods) line = [t, str(total).rjust(8)] for m in header: if m in ppomethods: p = float(ppomethods[m]) / float(total) * 100.0 mp = '{:> 6.1f}'.format(p) line.append(mp) else: line.append('0.0'.rjust(6)) print(' '.join(line)) else: missing.append(t) if len(missing) > 0:
if __name__ == '__main__': args = parse() cpath = UF.get_juliet_testpath(args.path) 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) excludefiles = ['io.c', 'main_linux.c', 'std_thread.c'] capp = CApplication(sempath, excludefiles=excludefiles) filterout = ['io', 'main_linux', 'std_thread'] dc = ['deadcode'] def filefilter(f): return (not f in filterout) print( RP.project_proofobligation_stats_tostring(capp, extradsmethods=dc, filefilter=filefilter)) contract_condition_violations = capp.get_contract_condition_violations() if len(contract_condition_violations) > 0:
parser.add_argument( '--cfile', help='only show this file: relative filename of the c source file', default=None) parser.add_argument('--cfunction', help='only show this function: name of function', default=None) args = parser.parse_args() return args if __name__ == '__main__': args = parse() semdir = os.path.join(args.path, 'semantics') capp = CApplication(semdir) lines = [] if not args.cfile is None: cfile = capp.getfile(args.cfile) if cfile is None: print('*' * 80) print('File ' + args.cfile + ' not found in this application') print('Valid filenames for this application are: ') def f(cf): print(' - ' + cf.getfilename()) capp.fileiter(f) print('*' * 80)
if d is None: print( UP.err_msg([ 'No score key found for juliet test ', ' ' + cpath, ' Please create a score key first' ])) exit(1) sempath = os.path.join(cpath, 'semantics') if not os.path.isdir(sempath): print(UP.semantics_not_found_err_msg(cpath)) exit(1) excludefiles = ['io.c', 'main_linux.c', 'std_thread.c'] capp = CApplication(sempath, excludefiles=excludefiles) testset = JulietTestSetRef(d) if not args.test in testset.tests: print('*' * 80) print('Test ' + args.path + ' does not include test ' + args.test) print('\nTests included:') print(' ' + ','.join(sorted(testset.tests))) print('*' * 80) exit(1) test = testset.tests[args.test] cfiles = [x[0] for x in test.get_cfiles()] julietppos = JTS.get_julietppos(testset) julietppos = {x: julietppos[x] for x in julietppos if x in cfiles}
testpath = UF.get_juliet_testpath(args.path) cpath = os.path.abspath(testpath) if not os.path.isdir(cpath): print(UP.cpath_not_found_err_msg(cpath)) exit() sempath = os.path.join(testpath, 'semantics') success = UF.unpack_tar_file(cpath, True) if not success: print(UP.semantics_tar_not_found_err_msg(cpath)) exit(1) excludefiles = ['io.c', 'main_linux.c', 'std_thread.c'] capp = CApplication(sempath, excludefiles=excludefiles) linker = CLinker(capp) linker.link_compinfos() linker.link_varinfos() capp.iter_files(save_xrefs) linker.save_global_compinfos() if args.contractpath is None: contractpath = os.path.join(cpath, 'ktacontracts') else: contractpath = args.contractpath # have to reinitialize capp to get linking info properly initialized capp = CApplication(sempath, contractpath=contractpath,
if not os.path.isfile(config.canalyzer): print(UP.missing_analyzer_err_msg()) exit(1) 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)) or args.deletesemantics: success = UF.unpack_tar_file(cpath,args.deletesemantics) if not success: print(UP.semantics_tar_not_found_err_msg(cpath)) exit(1) capp = CApplication(sempath) linker = CLinker(capp) linker.linkcompinfos() linker.linkvarinfos() def savexrefs(f): capp.indexmanager.savexrefs(capp.getpath(),f.getfilename(),f.getindex()) capp.fileiter(savexrefs) linker.saveglobalcompinfos() capp = CApplication(sempath) am = AnalysisManager(capp,wordsize=32) if args.resetsemantics: am.reset()
if (not os.path.isdir(sempath)) or args.deletesemantics: success = UF.unpack_tar_file(cpath, args.deletesemantics) if not success: print(UP.semantics_tar_not_found_err_msg(cpath)) exit(1) if args.contractpath is None: contractpath = os.path.join(cpath, 'ktacontracts') else: contractpath = args.contractpath # check linkinfo globaldefs = os.path.join( sempath, os.path.join('ktadvance', 'globaldefinitions.xml')) if not os.path.isfile(globaldefs): capp = CApplication(sempath, contractpath=contractpath) linker = CLinker(capp) linker.link_compinfos() linker.link_varinfos() capp.iter_files(save_xrefs) linker.save_global_compinfos() # have to reinitialize capp to get linking info properly initialized capp = CApplication(sempath, contractpath=contractpath, candidate_contractpath=args.candidate_contractpath) am = AnalysisManager(capp, verbose=args.verbose, wordsize=args.wordsize) with timing('analysis'):
def parse(): parser = argparse.ArgumentParser() parser.add_argument('path', help='directory that holds the analysis results') parser.add_argument('--cfile', help='relative name of c file') parser.add_argument('--cfunction', help='name of function') args = parser.parse_args() return args if __name__ == '__main__': args = parse() capp = CApplication(args.path) def p(a): print(a) def q(fn): print('Function ' + fn.getname()) fn.getapi().apiassumptioniter(p) def r(f): print('File ' + f.getfilename()) f.fniter(q) if not args.cfile is None: cfile = capp.getfile(args.cfile) if not args.cfunction is None:
parser = argparse.ArgumentParser() parser.add_argument('path', help='sequence number of testcase, e.g., 231') args = parser.parse_args() return args if __name__ == '__main__': args = parse() testpath = UF.get_itc_testpath(args.path) cpath = os.path.abspath(testpath) 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): success = UF.unpack_tar_file(cpath) if not success: print(UP.semantics_tar_not_found_err_msg(cpath)) exit(1) contractpath = os.path.join(cpath, 'ktacontracts') capp = CApplication(sempath, contractpath=contractpath) def create(cfile): cfile.create_contract(contractpath) capp.iter_files(create)
args = parse() wsdata = UF.get_workshop_file_data(args.project, args.name) cpath = wsdata['path'] cfilename = wsdata['file'] 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) capp = CApplication(sempath, cfilename) pofilter = lambda (p): True if args.predicates: pofilter = lambda (p): p.get_predicate_tag() in args.predicates openppos = capp.get_open_ppos() violations = capp.get_violations() delegated = capp.get_delegated() if len(openppos) > 0: print('Open proof obligations:\n' + ('=' * 80)) print(RP.tag_file_function_pos_tostring(openppos, pofilter=pofilter)) else: print('No open proof obligations found')
args = parse() wsdata = UF.get_workshop_file_data(args.project, args.name) cpath = wsdata['path'] cfilename = wsdata['file'] 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) capp = CApplication(sempath, cfilename) cfile = capp.get_cfile() print(RP.file_proofobligation_stats_tostring(cfile)) contract_condition_violations = capp.get_contract_condition_violations() if len(contract_condition_violations) > 0: print('=' * 80) print( str(len(contract_condition_violations)) + ' CONTRACT CONDITION FAILURES') print('=' * 80) for (fn, cc) in contract_condition_violations: print(fn + ':') for (name, desc) in cc:
exit(1) def indexfile(cfile): if args.verbose: print('- ' + cfile.name) def indexfn(cfun): if not cfun.name in functionindex: functionindex[cfun.name] = [] cfunrecord = {} cfunrecord['f'] = cfile.name cfunrecord['s'] = cfun.svar.get_vstorage() functionindex[cfun.name].append(cfunrecord) cfile.iter_functions(indexfn) capp = CApplication(sempath) with timing('indexing functions'): if args.verbose: print('-' * 80) print('Indexing files ...') capp.iter_files(indexfile) if args.verbose: print('-' * 80) print('Index:') for fn in sorted(functionindex): print(' - ' + fn) for fnrec in functionindex[fn]: pstatic = ' (static)' if fnrec['s'] == 's' else ''
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # ------------------------------------------------------------------------------ import argparse import advance.util.printutil as UP from advance.app.CApplication import CApplication def parse(): parser = argparse.ArgumentParser() parser.add_argument('path',help='directory that holds ktadvance directory') args = parser.parse_args() return args if __name__ == '__main__': args = parse() capp = CApplication(args.path) cfiles = capp.getfilenames() total = 0 print(UP.reportheader('Source files included')) for f in sorted(cfiles): linecount = capp.getsrcfile(f).getlinecount() total += linecount print(UP.ljust(f,24) + ': ' + UP.rjust(linecount,6)) print('-' * 78) print('Total lines of code: ' + str(total))
if __name__ == '__main__': args = parse() cpath = UF.get_itc_testpath(args.path) 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) capp = CApplication(sempath) dc = ['deadcode'] print(RP.project_proofobligation_stats_tostring(capp, extradsmethods=dc)) contract_condition_violations = capp.get_contract_condition_violations() if len(contract_condition_violations) > 0: print('=' * 80) print( str(len(contract_condition_violations)) + ' CONTRACT CONDITION FAILURES') print('=' * 80) for (fn, cc) in contract_condition_violations: print(fn + ':') for (name, desc) in cc:
args = parse() cpath = UF.get_juliet_testpath(args.path) 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) excludefiles = ['io.c', 'main_linux.c', 'std_thread.c'] capp = CApplication(sempath, excludefiles=excludefiles) d = UF.get_juliet_reference(args.path) if d is None: print( UP.err_msg([ 'No score key found for juliet test ', ' ' + cpath, ' Please create a score key first' ])) exit(1) testset = JulietTestSetRef(d) try: julietppos = JTS.get_julietppos(testset)
if args.path in config.projects: pdir = config.projects[args.path] cpath = os.path.join(config.testdir,pdir) else: cpath = os.path.abspath(args.path) 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) capp = CApplication(sempath) timestamp = os.stat(capp.path).st_ctime try: result = RP.project_proofobligation_stats_to_dict(capp) result['timestamp'] = timestamp result['project'] = cpath UF.save_project_summary_results(cpath,result) 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 __name__ == '__main__': args = parse() cpath = UF.get_juliet_testpath(args.path) 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) capp = CApplication(sempath) lines = [] stats = {} stats['npost'] = 0 stats['nglobal'] = 0 stats['ndepppo'] = 0 stats['ndepspo'] = 0 def report_requests(fi): lines.append(fi.name) def f(fn): if fn.api.has_outstanding_requests(): lines.append(' ' + fn.name) if fn.api.has_outstanding_postcondition_requests(): lines.append(' postcondition requests:')
if __name__ == '__main__': args = parse() cpath = UF.get_zitser_testpath(args.path) 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) capp = CApplication(sempath) fns = [] opencount = 0 violationcount = 0 def v(f): global opencount global violationcount if len(f.get_violations()) > 0: fns.append(f) violationcount += len(f.get_violations()) opencount += len(f.get_open_ppos()) capp.iter_functions(v) print('~' * 80)
args = parse() cpath = UF.get_juliet_testpath(args.path) 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) excludefiles = ['io.c', 'main_linux.c', 'std_thread.c'] capp = CApplication(sempath, excludefiles=excludefiles) pofilter = lambda (p): True if args.predicates: pofilter = lambda (p): p.get_predicate_tag() in args.predicates openppos = capp.get_open_ppos() violations = capp.get_violations() delegated = capp.get_delegated() if len(openppos) > 0: print('Open proof obligations:\n' + ('=' * 80)) print(RP.tag_file_function_pos_tostring(openppos, pofilter=pofilter)) else: print('No open proof obligations found')
pdir = config.projects[args.path] cpath = os.path.join(config.testdir, pdir) else: cpath = os.path.abspath(args.path) 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:
rhlen = max(len(x) for x in JTC.testcases) allppos = [] allspos = [] sumppos = {} sumspos = {} for cwe in sorted(JTC.testcases): for t in JTC.testcases[cwe]: t = os.path.join(cwe, t) cpath = UF.get_juliet_testpath(t) sempath = os.path.join(cpath, 'semantics') if not os.path.isdir(sempath): missing.append(t) continue capp = CApplication(sempath) ppos = capp.get_ppos() spos = capp.get_spos() allppos.extend(ppos) allspos.extend(spos) sumppos[t] = RP.get_method_count(ppos) sumspos[t] = RP.get_method_count(spos) print( RP.row_method_count_tostring(sumppos, perc=True, rhlen=rhlen, header1='juliet testcase')) print('\nSupporting proof obligations\n') print( RP.row_method_count_tostring(sumspos,
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))
from advance.app.CApplication import CApplication def parse(): parser = argparse.ArgumentParser() parser.add_argument('path', help='directory that holds the analysis results') parser.add_argument('cfile', help='relative filename of the c source file') args = parser.parse_args() return args if __name__ == '__main__': args = parse() capp = CApplication(args.path) cfile = capp.getfile(args.cfile) print( UP.reportheader('Global definitions and declarations for ' + args.cfile)) print('-' * 80) print('Global type definitions') print('-' * 80) gtypes = cfile.getgtypes() for gt in sorted(gtypes, key=lambda (t): t.gettypeinfo().getname()): tinfo = gt.gettypeinfo() print( str(tinfo.gettype()) + ': ' + tinfo.getname() + ' (' + gt.getlocation().getfile() + ')')