diff options
Diffstat (limited to 'focaccia.py')
| -rwxr-xr-x | focaccia.py | 42 |
1 files changed, 4 insertions, 38 deletions
diff --git a/focaccia.py b/focaccia.py index e140337..bbd1317 100755 --- a/focaccia.py +++ b/focaccia.py @@ -11,7 +11,7 @@ from focaccia.lldb_target import LLDBConcreteTarget from focaccia.parser import parse_arancini from focaccia.snapshot import ProgramState from focaccia.symbolic import SymbolicTransform, collect_symbolic_trace -from focaccia.utils import print_separator +from focaccia.utils import print_result def run_native_execution(oracle_program: str, breakpoints: Iterable[int]): """Gather snapshots from a native execution via an external debugger. @@ -42,7 +42,7 @@ def match_traces(test: list[ProgramState], truth: list[SymbolicTransform]): if not test or not truth: return [], [] - assert(test[0].read('pc') == truth[0].addr) + assert(test[0].read_register('pc') == truth[0].addr) def index(seq, target, access=lambda el: el): for i, el in enumerate(seq): @@ -52,7 +52,7 @@ def match_traces(test: list[ProgramState], truth: list[SymbolicTransform]): i = 0 for next_state in test[1:]: - next_pc = next_state.read('pc') + next_pc = next_state.read_register('pc') index_in_truth = index(truth[i:], next_pc, lambda el: el.range[1]) # If no next element (i.e. no foldable range) is found in the truth @@ -83,7 +83,7 @@ def parse_inputs(txl_path, program): txl = parse_arancini(txl_file, arch) with open(txl_path, "r") as txl_file: - breakpoints = [state.read('PC') for state in txl] + breakpoints = [state.read_register('PC') for state in txl] ref = run_native_execution(program, breakpoints) return txl, ref @@ -124,40 +124,6 @@ def parse_arguments(): args = parser.parse_args() return args -def print_result(result, min_severity: ErrorSeverity): - shown = 0 - suppressed = 0 - - for res in result: - pc = res['pc'] - print_separator() - print(f'For PC={hex(pc)}') - print_separator() - - # Filter errors by severity - errs = [e for e in res['errors'] if e.severity >= min_severity] - suppressed += len(res['errors']) - len(errs) - shown += len(errs) - - # Print all non-suppressed errors - for n, err in enumerate(errs, start=1): - print(f' {n:2}. {err}') - - if errs: - print() - print(f'Expected transformation: {res["ref"]}') - print(f'Actual transformation: {res["txl"]}') - else: - print('No errors found.') - - print() - print('#' * 60) - print(f'Found {shown} errors.') - print(f'Suppressed {suppressed} low-priority errors' - f' (showing {min_severity} and higher).') - print('#' * 60) - print() - def main(): verbosity = { 'verbose': ErrorTypes.INFO, |