Skip to content

Commit d6492f0

Browse files
committed
Symex trace: show implicit value associated with composite declarations
Previously when a struct- or other composite-typed variable was declared, symex_decl would initialize its individual fields, then return an L2-renamed symbol relating to the whole object. With field-sensitivity enabled, the returned symbol is e.g. my_struct!0@1#0, while anybody reading from it will read my_struct!0@1#1..field, a different symbol which to the solver is unrelated. The result was that in the trace, the declaration would show up with the value of the free symbol my_struct!0@1#0 (most likely zero, since it can't be referred to), while the rest of the trace may make it obvious that it actually had some other non-zero value. With this change we expand the struct into its constituent field symbols before recording an SSA_stept for the trace. This restores the correspondence between what the trace reads and what code reading from the struct reads.
1 parent f6ea83c commit d6492f0

File tree

4 files changed

+5
-1
lines changed

4 files changed

+5
-1
lines changed

src/goto-symex/symex_decl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ void goto_symext::symex_decl(statet &state, const symbol_exprt &expr)
5454
target.decl(
5555
state.guard.as_expr(),
5656
ssa,
57+
state.field_sensitivity.apply(ns, state, ssa, false),
5758
state.source,
5859
hidden?
5960
symex_targett::assignment_typet::HIDDEN:

src/goto-symex/symex_target.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ class symex_targett
134134
virtual void decl(
135135
const exprt &guard,
136136
const ssa_exprt &ssa_lhs,
137+
const exprt &initializer,
137138
const sourcet &source,
138139
assignment_typet assignment_type)=0;
139140

src/goto-symex/symex_target_equation.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ void symex_target_equationt::assignment(
128128
void symex_target_equationt::decl(
129129
const exprt &guard,
130130
const ssa_exprt &ssa_lhs,
131+
const exprt &initializer,
131132
const sourcet &source,
132133
assignment_typet assignment_type)
133134
{
@@ -138,7 +139,7 @@ void symex_target_equationt::decl(
138139

139140
SSA_step.guard=guard;
140141
SSA_step.ssa_lhs=ssa_lhs;
141-
SSA_step.ssa_full_lhs=ssa_lhs;
142+
SSA_step.ssa_full_lhs=initializer;
142143
SSA_step.original_full_lhs=ssa_lhs.get_original_expr();
143144
SSA_step.hidden=(assignment_type!=assignment_typet::STATE);
144145

src/goto-symex/symex_target_equation.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class symex_target_equationt:public symex_targett
7373
virtual void decl(
7474
const exprt &guard,
7575
const ssa_exprt &ssa_lhs,
76+
const exprt &initializer,
7677
const sourcet &source,
7778
assignment_typet assignment_type);
7879

0 commit comments

Comments
 (0)