Index: cfe/trunk/test/Analysis/exploded-graph-rewriter/constraints.dot =================================================================== --- cfe/trunk/test/Analysis/exploded-graph-rewriter/constraints.dot +++ cfe/trunk/test/Analysis/exploded-graph-rewriter/constraints.dot @@ -0,0 +1,27 @@ +// RUN: %exploded_graph_rewriter %s | FileCheck %s + +// FIXME: Substitution doesn't seem to work on Windows. +// UNSUPPORTED: system-windows + +// CHECK: Ranges: +// CHECK-SAME: +// CHECK-SAME: +// CHECK-SAME: +// CHECK-SAME: +// CHECK-SAME: +// CHECK-SAME:
reg_$0\{ [0, 0] \}
+Node0x1 [shape=record,label= + "{ + { "node_id": 1, + "pointer": "0x1", + "state_id": 2, + "program_points": [], + "program_state": { + "store": null, + "environment": null, + "constraints": [ + { "symbol": "reg_$0", "range": "{ [0, 0] }" } + ] + } + } +\l}"]; Index: cfe/trunk/test/Analysis/exploded-graph-rewriter/constraints_diff.dot =================================================================== --- cfe/trunk/test/Analysis/exploded-graph-rewriter/constraints_diff.dot +++ cfe/trunk/test/Analysis/exploded-graph-rewriter/constraints_diff.dot @@ -0,0 +1,65 @@ +// RUN: %exploded_graph_rewriter -d %s | FileCheck %s + +// FIXME: Substitution doesn't seem to work on Windows. +// UNSUPPORTED: system-windows + +Node0x1 [shape=record,label= + "{ + { "node_id": 1, + "pointer": "0x1", + "state_id": 2, + "program_points": [], + "program_state": { + "store": null, + "environment": null, + "constraints": [ + { "symbol": "reg_$0", "range": "{ [0, 10] }" } + ] + } + } +\l}"]; + +Node0x1 -> Node0x3; + +// CHECK: Node0x3 [ +// CHECK-SAME: +// CHECK-SAME: - +// CHECK-SAME: reg_$0 +// CHECK-SAME: \{ [0, 10] \} +// CHECK-SAME: +// CHECK-SAME: +// CHECK-SAME: + +// CHECK-SAME: reg_$0 +// CHECK-SAME: \{ [0, 5] \} +// CHECK-SAME: +Node0x3 [shape=record,label= + "{ + { "node_id": 3, + "pointer": "0x3", + "state_id": 4, + "program_points": [], + "program_state": { + "store": null, + "environment": null, + "constraints": [ + { "symbol": "reg_$0", "range": "{ [0, 5] }" } + ] + } + } +\l}"]; + +Node0x3 -> Node0x5; + +Node0x5 [shape=record,label= + "{ + { "node_id": 5, + "pointer": "0x5", + "state_id": 6, + "program_points": [], + "program_state": { + "store": null, + "environment": null, + "constraints": null + } + } +\l}"]; Index: cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot =================================================================== --- cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot +++ cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot @@ -33,6 +33,7 @@ "program_points": [], "program_state": { "store": null, + "constraints": null, "environment": [ { "location_context": "#0 Call", Index: cfe/trunk/test/Analysis/exploded-graph-rewriter/environment_diff.dot =================================================================== --- cfe/trunk/test/Analysis/exploded-graph-rewriter/environment_diff.dot +++ cfe/trunk/test/Analysis/exploded-graph-rewriter/environment_diff.dot @@ -12,6 +12,7 @@ "program_points": [], "program_state": { "store": null, + "constraints": null, "environment": [ { "location_context": "#0 Call", @@ -54,6 +55,7 @@ "program_points": [], "program_state": { "store": null, + "constraints": null, "environment": [ { "location_context": "#0 Call", @@ -90,6 +92,7 @@ "program_points": [], "program_state": { "store": null, + "constraints": null, "environment": [ { "location_context": "#0 Call", Index: cfe/trunk/test/Analysis/exploded-graph-rewriter/store.dot =================================================================== --- cfe/trunk/test/Analysis/exploded-graph-rewriter/store.dot +++ cfe/trunk/test/Analysis/exploded-graph-rewriter/store.dot @@ -28,6 +28,7 @@ "program_points": [], "program_state": { "environment": null, + "constraints": null, "store": [ { "cluster": "x", Index: cfe/trunk/test/Analysis/exploded-graph-rewriter/store_diff.dot =================================================================== --- cfe/trunk/test/Analysis/exploded-graph-rewriter/store_diff.dot +++ cfe/trunk/test/Analysis/exploded-graph-rewriter/store_diff.dot @@ -11,6 +11,7 @@ "program_points": [], "program_state": { "environment": null, + "constraints": null, "store": [ { "cluster": "x", @@ -52,6 +53,7 @@ "program_points": [], "program_state": { "environment": null, + "constraints": null, "store": [ { "cluster": "x", Index: cfe/trunk/utils/analyzer/exploded-graph-rewriter.py =================================================================== --- cfe/trunk/utils/analyzer/exploded-graph-rewriter.py +++ cfe/trunk/utils/analyzer/exploded-graph-rewriter.py @@ -25,6 +25,19 @@ return (removed, added) +# Represents any program state trait that is a dictionary of key-value pairs. +class GenericMap(object): + def __init__(self, generic_map): + self.generic_map = generic_map + + def diff(self, prev): + return diff_dicts(self.generic_map, prev.generic_map) + + def is_different(self, prev): + removed, added = self.diff(prev) + return len(removed) != 0 or len(added) != 0 + + # A deserialized source location. class SourceLocation(object): def __init__(self, json_loc): @@ -203,8 +216,10 @@ if json_ps['store'] is not None else None self.environment = Environment(json_ps['environment']) \ if json_ps['environment'] is not None else None + self.constraints = GenericMap(collections.OrderedDict([ + (c['symbol'], c['range']) for c in json_ps['constraints'] + ])) if json_ps['constraints'] is not None else None # TODO: Objects under construction. - # TODO: Constraint ranges. # TODO: Dynamic types of objects. # TODO: Checker messages. @@ -479,11 +494,57 @@ else: self._dump('') self.visit_store(s.store) - self._dump('
') + self._dump('') + + def visit_generic_map(self, m, prev_m=None): + self._dump('') + + def dump_pair(m, k, is_added=None): + self._dump('' + '' + '' + % (self._diff_plus_minus(is_added), + k, m.generic_map[k])) + + if prev_m is not None: + removed, added = m.diff(prev_m) + for k in removed: + dump_pair(prev_m, k, False) + for k in added: + dump_pair(m, k, True) + else: + for k in m.generic_map: + dump_pair(m, k, None) + + self._dump('
%s%s%s
') + + def visit_generic_map_in_state(self, selector, s, prev_s=None): + self._dump('' + 'Ranges: ') + m = getattr(s, selector) + if m is None: + self._dump(' Nothing!') + else: + prev_m = None + if prev_s is not None: + prev_m = getattr(prev_s, selector) + if prev_m is not None: + if m.is_different(prev_m): + self._dump('') + self.visit_generic_map(m, prev_m) + else: + self._dump(' No changes!') + if prev_m is None: + self._dump('') + self.visit_generic_map(m) + self._dump('') def visit_state(self, s, prev_s): self.visit_store_in_state(s, prev_s) + self._dump('
') self.visit_environment_in_state(s, prev_s) + self._dump('
') + self.visit_generic_map_in_state('constraints', s, prev_s) def visit_node(self, node): self._dump('%s [shape=record,label=<'