Skip to content

Commit 53c7e41

Browse files
committed
update project results
1 parent 000ba6e commit 53c7e41

File tree

24 files changed

+198
-298
lines changed

24 files changed

+198
-298
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
# CodeHawk C Analyzer artifacts
22
semantics
33
*.i
4+
*.cch
45

56
# CodeHawk-C local configuration file
67
ConfigLocal.py
78

89
# Emacs
910
*.py~
11+
*.rst~
12+
*.c~
13+
*.css~
14+
chkc~
1015

1116
# Byte-compiled / optimized / DLL files
1217
__pycache__/
@@ -15,6 +20,7 @@ __pycache__/
1520

1621
# C extensions
1722
*.so
23+
*.o
1824

1925
# Distribution / packaging
2026
.Python

chc/api/ApiParameter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
# The MIT License (MIT)
66
#
77
# Copyright (c) 2017-2020 Kestrel Technology LLC
8-
# Copyright (c) 2020-2022 Henny Sipma
9-
# Copyright (c) 2023 Aarno Labs LLC
8+
# Copyright (c) 2020-2022 Henny B. Sipma
9+
# Copyright (c) 2023-2024 Aarno Labs LLC
1010
#
1111
# Permission is hereby granted, free of charge, to any person obtaining a copy
1212
# of this software and associated documentation files (the "Software"), to deal

chc/api/InterfaceDictionary.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ def __init__(self, cfile: "CFile", xnode: Optional[ET.Element]):
104104
self.postrequest_table,
105105
self.postassume_table,
106106
self.ds_condition_table]
107-
self._objmaps: Dict[str, Callable[[], Mapping[int, IndexedTableValue]]] = {
107+
self._objmaps: Dict[
108+
str, Callable[[], Mapping[int, IndexedTableValue]]] = {
108109
"apiparam": self.get_api_parameter_map,
109110
"postassume": self.get_postassume_map,
110111
"postrequest": self.get_postrequest_map,
@@ -668,10 +669,12 @@ def objectmap_to_string(self, name: str) -> str:
668669
objmap = self._objmaps[name]()
669670
lines: List[str] = []
670671
if len(objmap) == 0:
671-
lines.append("Table is empty")
672+
lines.append(f"\nTable for {name} is empty\n")
672673
else:
674+
lines.append("index value")
675+
lines.append("-" * 80)
673676
for (ix, obj) in objmap.items():
674-
lines.append(str(ix).rjust(3) + " " + str(obj))
677+
lines.append(str(ix).rjust(3) + " " + str(obj))
675678
return "\n".join(lines)
676679
else:
677680
raise UF.CHCError(

chc/api/STerm.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,16 @@
2626
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2727
# SOFTWARE.
2828
# ------------------------------------------------------------------------------
29-
"""Object representation of sum type s_term (term in an external predicate)."""
29+
"""Object representation of sum type s_term (term in an external predicate).
30+
31+
Object representation of the corresponding OCaml sumtype: s_term_t: a term that
32+
solely refers to entities that are visible outside of a function, such as its
33+
parameters or return value.
34+
35+
The properties of a term are constructed from its indexed value in the
36+
InterfaceDictionary.
37+
38+
"""
3039
from typing import Dict, List, Optional, TYPE_CHECKING
3140
import xml.etree.ElementTree as ET
3241

chc/api/XPredicate.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,15 @@
2626
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2727
# SOFTWARE.
2828
# ------------------------------------------------------------------------------
29-
"""Object representation of sum type xpredicate_t."""
29+
"""Object representation of sum type xpredicate_t.
30+
31+
Object representation of the corresponding OCaml sumtype: xpredicate_t: a
32+
predicate over s_term_t terms (terms that are visible outside of a function).
33+
34+
The properties of an xpredicate are constructed from its indexed value in the
35+
InterfaceDictionary
36+
37+
"""
3038

3139
from typing import cast, List, Optional, TYPE_CHECKING
3240
import xml.etree.ElementTree as ET

chc/cmdline/AnalysisManager.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,17 @@ def create_app_primary_proofobligations(self, processes: int = 1) -> None:
244244

245245
def f(cfile: "CFile") -> None:
246246
cmd = self._create_file_primary_proofobligations_cmd_partial()
247-
if cfile.cfilepath is not None:
248-
cmd.extend(["-filepath", cfile.cfilepath])
249247
cmd.append(cfile.cfilename)
248+
if cfile.cfilepath is not None:
249+
cmd.extend(["-cfilepath", cfile.cfilepath])
250250
self._execute_cmd(cmd)
251+
pcfilename = (
252+
cfile.cfilename if cfile.cfilepath is None
253+
else os.path.join(cfile.cfilepath, cfile.cfilename))
254+
cfile = self.capp.get_file(pcfilename)
255+
cfile.reinitialize_tables()
256+
cfile.reload_ppos()
257+
cfile.reload_spos()
251258

252259
self.capp.iter_files_parallel(f, processes)
253260
else:

chc/cmdline/c_project/cprojectutil.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ def cproject_analyze_project(args: argparse.Namespace) -> NoReturn:
166166
# arguments
167167
tgtpath: str = args.tgtpath
168168
projectname: str = args.projectname
169+
maxprocesses: int = args.maxprocesses
169170
loglevel: str = args.loglevel
170171
logfilename: Optional[str] = args.logfilename
171172
logfilemode: str = args.logfilemode
@@ -212,30 +213,30 @@ def save_xrefs(f: "CFile") -> None:
212213
with timing("analysis"):
213214

214215
try:
215-
am.create_app_primary_proofobligations()
216+
am.create_app_primary_proofobligations(processes=maxprocesses)
216217
capp.reinitialize_tables()
217218
capp.collect_post_assumes()
218219
except UF.CHError as e:
219220
print(str(e.wrap()))
220221
exit(1)
221222

222223
for i in range(1):
223-
am.generate_and_check_app("llrvisp")
224+
am.generate_and_check_app("llrvisp", processes=maxprocesses)
224225
capp.reinitialize_tables()
225226
capp.update_spos()
226227

227228
for i in range(5):
228229
capp.update_spos()
229-
am.generate_and_check_app("llrvisp")
230+
am.generate_and_check_app("llrvisp", processes=maxprocesses)
230231
capp.reinitialize_tables()
231232

232233
timestamp = os.stat(UF.get_cchpath(targetpath, projectname)).st_ctime
233234

234235
result = RP.project_proofobligation_stats_to_dict(capp)
235236
result["timestamp"] = timestamp
236237
result["project"] = projectpath
237-
UF.save_project_summary_results(targetpath, result)
238-
UF.save_project_summary_results_as_xml(targetpath, result)
238+
UF.save_project_summary_results(targetpath, projectname, result)
239+
UF.save_project_summary_results_as_xml(targetpath, projectname, result)
239240

240241
exit(0)
241242

@@ -250,7 +251,7 @@ def cproject_report(args: argparse.Namespace) -> NoReturn:
250251
targetpath = os.path.abspath(tgtpath)
251252
projectpath = targetpath
252253

253-
result = UF.read_project_summary_results(targetpath)
254+
result = UF.read_project_summary_results(targetpath, projectname)
254255
if result is not None:
255256
print(RP.project_proofobligation_stats_dict_to_string(result))
256257
exit(0)
@@ -268,10 +269,10 @@ def cproject_report(args: argparse.Namespace) -> NoReturn:
268269
fresult = RP.project_proofobligation_stats_to_dict(capp)
269270
fresult["timestamp"] = timestamp
270271
fresult["project"] = projectpath
271-
UF.save_project_summary_results(targetpath, fresult)
272-
UF.save_project_summary_results_as_xml(targetpath, fresult)
272+
UF.save_project_summary_results(targetpath, projectname, fresult)
273+
UF.save_project_summary_results_as_xml(targetpath, projectname, fresult)
273274

274-
result = UF.read_project_summary_results(targetpath)
275+
result = UF.read_project_summary_results(targetpath, projectname)
275276
if result is not None:
276277
print(RP.project_proofobligation_stats_dict_to_string(result))
277278
else:

chc/cmdline/chkc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ import chc.cmdline.c_file.cfiletableutil as CT
6565
import chc.cmdline.c_project.cprojectutil as P
6666
import chc.cmdline.juliet.julietutil as J
6767
import chc.cmdline.kendra.kendrautil as K
68-
import chc.reporting.DictionaryTables as DT
6968

7069
from chc.util.Config import Config
7170
import chc.util.loggingutil as UL
@@ -405,8 +404,7 @@ def parse() -> argparse.Namespace:
405404
"cfilename", help="name of kendra c file (e.g., id115.c)")
406405
kendrashowfiletable.add_argument(
407406
"tablename",
408-
help="name of table",
409-
choices = DT.file_table_list())
407+
help="name of table")
410408
kendrashowfiletable.set_defaults(func=K.kendra_show_file_table)
411409

412410
# --- kendra show-function-table
@@ -417,8 +415,7 @@ def parse() -> argparse.Namespace:
417415
"functionname", help="name of function in c file (e.g., main)")
418416
kendrashowfunctiontable.add_argument(
419417
"tablename",
420-
help="name of table",
421-
choices = DT.function_table_list())
418+
help="name of table")
422419
kendrashowfunctiontable.set_defaults(func=K.kendra_show_function_table)
423420

424421
# --------------------------------------------------------------- juliet ---
@@ -1296,6 +1293,11 @@ def parse() -> argparse.Namespace:
12961293
"tgtpath", help="directory that contains the analysis results")
12971294
cprojectanalyze.add_argument(
12981295
"projectname", help="name of the project")
1296+
cprojectanalyze.add_argument(
1297+
"--maxprocesses",
1298+
help="number of files to process in parallel",
1299+
type=int,
1300+
default=1)
12991301
cprojectanalyze.add_argument(
13001302
"--loglevel", "-log",
13011303
choices=UL.LogLevel.options(),

chc/cmdline/juliet/julietutil.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ def filefilter(filename: str) -> bool:
404404
capp, filefilter=filefilter)
405405
result["timestamp"] = timestamp
406406
result["path"] = capp.projectpath
407-
UF.save_project_summary_results(capp.targetpath, result)
407+
UF.save_project_summary_results(capp.targetpath, "juliet", result)
408408
except Exception as e:
409409
print(str(e))
410410
exit(1)
@@ -488,7 +488,7 @@ def juliet_report(args: argparse.Namespace) -> NoReturn:
488488
excludefiles = ["io.c", "main_linux.c", "std_thread.c"]
489489
targetpath = projectpath
490490

491-
summary = UF.read_project_summary_results(targetpath)
491+
summary = UF.read_project_summary_results(targetpath, "juliet")
492492
if summary is not None:
493493
print(RP.project_proofobligation_stats_dict_to_string(summary))
494494
exit(0)
@@ -1026,7 +1026,7 @@ def juliet_project_dashboard(args: argparse.Namespace) -> NoReturn:
10261026
for test in testcases[cwe]:
10271027
pname = f"{cwe}:{test}"
10281028
path = UF.get_juliet_testpath(cwe, test)
1029-
results = UF.read_project_summary_results(path)
1029+
results = UF.read_project_summary_results(path, "juliet")
10301030
if results is None:
10311031
nosummary.append(pname)
10321032
continue

chc/cmdline/kendra/kendrautil.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
from chc.cmdline.kendra.TestSetRef import TestSetRef
4242
from chc.cmdline.ParseManager import ParseManager
4343

44-
import chc.reporting.DictionaryTables as DT
4544
import chc.reporting.ProofObligations as RP
4645

4746
import chc.util.fileutil as UF

0 commit comments

Comments
 (0)