Skip to content

Commit b3b88e5

Browse files
authored
Merge pull request #4609 from georgerennie/george/smtbmc_paths
smtbmc: escape path identifiers
2 parents 9479d3b + b788de9 commit b3b88e5

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

backends/smt2/smtbmc.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,6 +1454,10 @@ def write_trace(steps_start, steps_stop, index, allregs=False):
14541454
if outywfile is not None:
14551455
write_yw_trace(steps, index, allregs)
14561456

1457+
def escape_path_segment(segment):
1458+
if "." in segment:
1459+
return f"\\{segment} "
1460+
return segment
14571461

14581462
def print_failed_asserts_worker(mod, state, path, extrainfo, infomap, infokey=()):
14591463
assert mod in smt.modinfo
@@ -1464,7 +1468,8 @@ def print_failed_asserts_worker(mod, state, path, extrainfo, infomap, infokey=()
14641468

14651469
for cellname, celltype in smt.modinfo[mod].cells.items():
14661470
cell_infokey = (mod, cellname, infokey)
1467-
if print_failed_asserts_worker(celltype, "(|%s_h %s| %s)" % (mod, cellname, state), path + "." + cellname, extrainfo, infomap, cell_infokey):
1471+
cell_path = path + "." + escape_path_segment(cellname)
1472+
if print_failed_asserts_worker(celltype, "(|%s_h %s| %s)" % (mod, cellname, state), cell_path, extrainfo, infomap, cell_infokey):
14681473
found_failed_assert = True
14691474

14701475
for assertfun, assertinfo in smt.modinfo[mod].asserts.items():
@@ -1497,7 +1502,7 @@ def print_anyconsts_worker(mod, state, path):
14971502
assert mod in smt.modinfo
14981503

14991504
for cellname, celltype in smt.modinfo[mod].cells.items():
1500-
print_anyconsts_worker(celltype, "(|%s_h %s| %s)" % (mod, cellname, state), path + "." + cellname)
1505+
print_anyconsts_worker(celltype, "(|%s_h %s| %s)" % (mod, cellname, state), path + "." + escape_path_segment(cellname))
15011506

15021507
for fun, info in smt.modinfo[mod].anyconsts.items():
15031508
if info[1] is None:
@@ -1517,18 +1522,21 @@ def print_anyconsts(state):
15171522
print_anyconsts_worker(topmod, "s%d" % state, topmod)
15181523

15191524

1520-
def get_cover_list(mod, base):
1525+
def get_cover_list(mod, base, path=None):
1526+
path = path or mod
15211527
assert mod in smt.modinfo
15221528

15231529
cover_expr = list()
1530+
# A tuple of path and cell name
15241531
cover_desc = list()
15251532

15261533
for expr, desc in smt.modinfo[mod].covers.items():
15271534
cover_expr.append("(ite (|%s| %s) #b1 #b0)" % (expr, base))
1528-
cover_desc.append(desc)
1535+
cover_desc.append((path, desc))
15291536

15301537
for cell, submod in smt.modinfo[mod].cells.items():
1531-
e, d = get_cover_list(submod, "(|%s_h %s| %s)" % (mod, cell, base))
1538+
cell_path = path + "." + escape_path_segment(cell)
1539+
e, d = get_cover_list(submod, "(|%s_h %s| %s)" % (mod, cell, base), cell_path)
15321540
cover_expr += e
15331541
cover_desc += d
15341542

@@ -1544,7 +1552,8 @@ def get_assert_map(mod, base, path, key_base=()):
15441552
assert_map[(expr, key_base)] = ("(|%s| %s)" % (expr, base), path, desc)
15451553

15461554
for cell, submod in smt.modinfo[mod].cells.items():
1547-
assert_map.update(get_assert_map(submod, "(|%s_h %s| %s)" % (mod, cell, base), path + "." + cell, (mod, cell, key_base)))
1555+
cell_path = path + "." + escape_path_segment(cell)
1556+
assert_map.update(get_assert_map(submod, "(|%s_h %s| %s)" % (mod, cell, base), cell_path, (mod, cell, key_base)))
15481557

15491558
return assert_map
15501559

@@ -1903,7 +1912,9 @@ def report_tracked_assumptions(msg):
19031912
new_cover_mask.append(cover_mask[i])
19041913
continue
19051914

1906-
print_msg("Reached cover statement at %s in step %d." % (cover_desc[i], step))
1915+
path = cover_desc[i][0]
1916+
name = cover_desc[i][1]
1917+
print_msg("Reached cover statement in step %d at %s: %s" % (step, path, name))
19071918
new_cover_mask.append("0")
19081919

19091920
cover_mask = "".join(new_cover_mask)
@@ -1933,7 +1944,7 @@ def report_tracked_assumptions(msg):
19331944
if "1" in cover_mask:
19341945
for i in range(len(cover_mask)):
19351946
if cover_mask[i] == "1":
1936-
print_msg("Unreached cover statement at %s." % cover_desc[i])
1947+
print_msg("Unreached cover statement at %s: %s" % (cover_desc[i][0], cover_desc[i][1]))
19371948

19381949
else: # not tempind, covermode
19391950
active_assert_keys = get_assert_keys()

0 commit comments

Comments
 (0)