Skip to content

Commit

Permalink
updates + ttest
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianbs96 committed Apr 16, 2024
1 parent 4e2d0b8 commit 16c877c
Show file tree
Hide file tree
Showing 3 changed files with 881 additions and 86 deletions.
92 changes: 69 additions & 23 deletions varats/varats/data/reports/phasar_iter_ide.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,58 @@ class PhasarBCStats():

def __init__(self, path: Path) -> None:
self._num_instructions = -1
self._num_functions = -1
self._num_addr_functions = -1
self._num_globals = -1
self._num_calls = -1
self._num_ind_calls = -1
self._num_basic_blocks = -1

with open(path, "r", encoding="utf-8") as stats_file:
for line in stats_file.readlines():
if line.startswith("> LLVM IR instructions"):
if line.startswith("LLVM IR instructions:"):
self._num_instructions = int(line.split(":")[1])
elif line.startswith("Functions:"):
self._num_functions = int(line.split(':')[1])
elif line.startswith("Address-Taken Functions:"):
self._num_addr_functions = int(line.split(':')[1])
elif line.startswith("Globals:"):
self._num_globals = int(line.split(':')[1])
elif line.startswith("Call Sites:"):
self._num_calls = int(line.split(':')[1])
elif line.startswith("Indirect Call Sites:"):
self._num_ind_calls = int(line.split(':')[1])
elif line.startswith("Basic Blocks:"):
self._num_basic_blocks = int(line.split(':')[1])

@property
def num_instructions(self) -> int:
return self._num_instructions

@property
def num_functions(self) -> int:
return self._num_functions

@property
def num_address_taken_functions(self) -> int:
return self._num_addr_functions

@property
def num_globals(self) -> int:
return self._num_globals

@property
def num_calls(self) -> int:
return self._num_calls

@property
def num_indirect_calls(self) -> int:
return self._num_ind_calls

@property
def num_basic_blocks(self) -> int:
return self._num_basic_blocks


class PhasarIterIDESolverStats():

Check failure on line 99 in varats/varats/data/reports/phasar_iter_ide.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/data/reports/phasar_iter_ide.py#L99 <115>

Missing class docstring (missing-class-docstring)
Raw output
varats/varats/data/reports/phasar_iter_ide.py:99:0: C0115: Missing class docstring (missing-class-docstring)

Check failure on line 99 in varats/varats/data/reports/phasar_iter_ide.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/data/reports/phasar_iter_ide.py#L99 <902>

Too many instance attributes (28/7) (too-many-instance-attributes)
Raw output
varats/varats/data/reports/phasar_iter_ide.py:99:0: R0902: Too many instance attributes (28/7) (too-many-instance-attributes)

Expand Down Expand Up @@ -959,33 +1001,37 @@ def get_state(report: TimeReportAggregate) -> str:
return "server"
return "dev"

if self.old_taint is not None and self.new_taint_nested is not None:
def append_relation(

Check failure on line 1004 in varats/varats/data/reports/phasar_iter_ide.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] varats/varats/data/reports/phasar_iter_ide.py#L1004

error: Function is missing a return type annotation [no-untyped-def]
Raw output
varats/varats/data/reports/phasar_iter_ide.py:1004:9: error: Function is missing a return type annotation  [no-untyped-def]
name: str, old_report: TimeReportAggregate,
new_report: TimeReportAggregate
):
nonlocal ret
nonlocal cs

new_val = get_state(new_report)
old_val = get_state(old_report)
if old_val != "oom" and old_val != "timeout" and (
new_val == "oom" or new_val == "timeout"

Check failure on line 1014 in varats/varats/data/reports/phasar_iter_ide.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/data/reports/phasar_iter_ide.py#L1014 <1714>

Consider merging these comparisons with 'in' by using 'new_val in ('oom', 'timeout')'. Use a set instead if elements are hashable. (consider-using-in)
Raw output
varats/varats/data/reports/phasar_iter_ide.py:1014:16: R1714: Consider merging these comparisons with 'in' by using 'new_val in ('oom', 'timeout')'. Use a set instead if elements are hashable. (consider-using-in)
):
print(
f"WARNING: Transition from {old_val} to {new_val} for {name} at {cs}"

Check failure on line 1017 in varats/varats/data/reports/phasar_iter_ide.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/data/reports/phasar_iter_ide.py#L1017 <301>

Line too long (89/80) (line-too-long)
Raw output
varats/varats/data/reports/phasar_iter_ide.py:1017:0: C0301: Line too long (89/80) (line-too-long)
)
ret.append({
"Analysis": "Taint",
"Old": get_state(self.old_taint),
"New": get_state(self.new_taint_nested),
"Analysis": name,
"Old": new_val,
"New": old_val,
"Target": cs,
})

if self.old_taint is not None and self.new_taint_nested is not None:
append_relation("Taint", self.old_taint, self.new_taint_nested)
if self.old_typestate is not None and self.new_typestate_nested is not None:

Check failure on line 1028 in varats/varats/data/reports/phasar_iter_ide.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/data/reports/phasar_iter_ide.py#L1028 <301>

Line too long (84/80) (line-too-long)
Raw output
varats/varats/data/reports/phasar_iter_ide.py:1028:0: C0301: Line too long (84/80) (line-too-long)
ret.append({
"Analysis": "Typestate",
"Old": get_state(self.old_typestate),
"New": get_state(self.new_typestate_nested),
"Target": cs,
})
append_relation(
"Typestate", self.old_typestate, self.new_typestate_nested
)
if self.old_lca is not None and self.new_lca_nested is not None:
ret.append({
"Analysis": "LCA",
"Old": get_state(self.old_lca),
"New": get_state(self.new_lca_nested),
"Target": cs,
})
append_relation("LCA", self.old_lca, self.new_lca_nested)
if self.old_iia is not None and self.new_iia_nested is not None:
ret.append({
"Analysis": "IIA",
"Target": cs,
"Old": get_state(self.old_iia),
"New": get_state(self.new_iia_nested),
})
append_relation("IIA", self.old_iia, self.new_iia_nested)

return ret
Loading

0 comments on commit 16c877c

Please sign in to comment.