Skip to content

Commit

Permalink
Processing new widening loc to trace(s) info from verifier. Not displ…
Browse files Browse the repository at this point in the history
…ayed in GUI yet. Just stored in node date structure.
  • Loading branch information
jim-carciofini committed Oct 18, 2024
1 parent 0f21361 commit 6674c95
Showing 1 changed file with 49 additions and 2 deletions.
51 changes: 49 additions & 2 deletions pate_binja/pate.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,41 @@ def show_message(self, rec: Any):
self.user.show_message(str(rec))


class TraceCollection:

def __init__(self, desc: str, raw: dict):
self.desc = desc
self.allTraces = raw['all_traces']
self.cellTraces = self._extractTraceMap(raw['trace_map_cells'])
self.regTraces = self._extractTraceMap(raw['trace_map_regs'])

def _extractTraceMap(self, raw: dict):
traceMap = []
for kv in raw['map']:
traces = [self.allTraces[ti] for ti in kv['val']]
traceMap.append({'location': kv['key'], 'traces': traces})
return traceMap


class WideningInfo:

def __init__(self, raw: dict):
self.postdomain = None
self.valueTraceCollection = None
self.equalityTraceCollection = None
self.sharedEnv = None

if raw.get('name') == 'Equivalence Counter-example Traces':
for ltv in raw['contents']:
if ltv['label'] == 'Postdomain' and ltv['type'] == 'domain':
self.postdomain = ltv['value']
elif ltv['label'] == 'Value' and ltv['type'] == 'trace_collection':
self.valueTraceCollection = TraceCollection('Value', ltv['value'])
elif ltv['label'] == 'Equality' and ltv['type'] == 'trace_collection':
self.equalityTraceCollection = TraceCollection('Equality', ltv['value'])
self.sharedEnv = raw['shared_env']


class CFARNode:
exits: list[CFARNode]
finished: bool
Expand All @@ -693,7 +728,6 @@ def __init__(self, id: str, desc: str, data: dict):
(self.original_addr, self.patched_addr) = get_cfar_addr(id)
self.exits = []
self.exit_meta_data = {}
self.update_node(desc, data)
self.desc = desc
self.data = data
self.predomain = None
Expand All @@ -708,6 +742,10 @@ def __init__(self, id: str, desc: str, data: dict):
self.trace_footprint = None
self.traceConstraints = None
self.instruction_trees = None
self.wideningInfo = None

# After default initializations above, update the node
self.update_node(desc, data)

def update_node(self, desc: str, data: dict):
self.desc = desc
Expand All @@ -716,6 +754,13 @@ def update_node(self, desc: str, data: dict):
self.postdomain = get_domain(data, 'Postdomain')
self.external_postdomain = get_domain(data, 'ExternalPostDomain')

for cw in data.get('trace_node_contents', []):
content = cw['content']
if content and content.get('name') == 'Equivalence Counter-example Traces':
self.wideningInfo = WideningInfo(content)
pass


def addExit(self, node: CFARNode) -> bool:
"""Add a block exit to node if new.
Expand Down Expand Up @@ -1747,7 +1792,9 @@ def show_cfar_graph(self, graph: CFARGraph) -> None:
print()
choice = input("Show CFAR Graph (y or n)? ")
else:
choice = 'y'
# Choose which you want when no ask
#choice = 'y'
choice = 'n'

if choice == 'y':
print('\nPate CFAR Graph:\n')
Expand Down

0 comments on commit 6674c95

Please sign in to comment.