Skip to content

Commit 879999c

Browse files
author
Daniel Kroening
committed
remove lhs_object from goto_trace_stept
1 parent 5acf313 commit 879999c

File tree

8 files changed

+81
-100
lines changed

8 files changed

+81
-100
lines changed

src/goto-programs/goto_trace.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,15 @@ void goto_trace_stept::output(
9393

9494
out << "\n";
9595

96-
if((pc->is_other() && lhs_object.is_not_nil()) || pc->is_assign())
96+
if((pc->is_other() && full_lhs.is_not_nil()) || pc->is_assign())
9797
{
98-
irep_idt identifier=lhs_object.get_object_name();
99-
out << " " << from_expr(ns, identifier, lhs_object.get_original_expr())
100-
<< " = " << from_expr(ns, identifier, lhs_object_value)
98+
auto lhs_object=get_lhs_object();
99+
100+
const irep_idt identifier=
101+
lhs_object.has_value()?lhs_object->get_identifier():irep_idt();
102+
103+
out << " " << from_expr(ns, identifier, full_lhs)
104+
<< " = " << from_expr(ns, identifier, full_lhs_value)
101105
<< "\n";
102106
}
103107
else if(pc->is_assert())
@@ -306,7 +310,7 @@ void show_goto_trace(
306310
if(step.pc->is_assign() ||
307311
step.pc->is_return() || // returns have a lhs!
308312
step.pc->is_function_call() ||
309-
(step.pc->is_other() && step.lhs_object.is_not_nil()))
313+
(step.pc->is_other() && step.full_lhs.is_not_nil()))
310314
{
311315
if(prev_step_nr!=step.step_nr || first_step)
312316
{
@@ -315,13 +319,8 @@ void show_goto_trace(
315319
show_state_header(out, step, step.pc->source_location, step.step_nr);
316320
}
317321

318-
// see if the full lhs is something clean
319-
if(is_index_member_symbol(step.full_lhs))
320-
trace_value(
321-
out, ns, step.lhs_object, step.full_lhs, step.full_lhs_value);
322-
else
323-
trace_value(
324-
out, ns, step.lhs_object, step.lhs_object, step.lhs_object_value);
322+
trace_value(
323+
out, ns, step.full_lhs, step.full_lhs_value);
325324
}
326325
break;
327326

@@ -333,7 +332,7 @@ void show_goto_trace(
333332
show_state_header(out, step, step.pc->source_location, step.step_nr);
334333
}
335334

336-
trace_value(out, ns, step.lhs_object, step.full_lhs, step.full_lhs_value);
335+
trace_value(out, ns, step.full_lhs, step.full_lhs_value);
337336
break;
338337

339338
case goto_trace_stept::typet::OUTPUT:

src/goto-programs/goto_trace.h

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ class goto_trace_stept
104104
// for assert
105105
std::string comment;
106106

107-
// the object being assigned
108-
ssa_exprt lhs_object;
109-
110-
// the full, original lhs expression
107+
// the full, original lhs expression, after dereferencing
111108
exprt full_lhs;
112109

113-
// A constant with the new value
114-
exprt lhs_object_value, full_lhs_value;
110+
// the object being assigned
111+
optionalt<symbol_exprt> get_lhs_object() const;
112+
113+
// A constant with the new value of the lhs
114+
exprt full_lhs_value;
115115

116116
// for INPUT/OUTPUT
117117
irep_idt format_string, io_id;
@@ -138,8 +138,6 @@ class goto_trace_stept
138138
cond_value(false),
139139
formatted(false)
140140
{
141-
lhs_object.make_nil();
142-
lhs_object_value.make_nil();
143141
full_lhs.make_nil();
144142
full_lhs_value.make_nil();
145143
cond_expr.make_nil();
@@ -203,8 +201,7 @@ void show_goto_trace(
203201
void trace_value(
204202
std::ostream &out,
205203
const namespacet &,
206-
const ssa_exprt &lhs_object,
207-
const exprt &full_lhs,
204+
const exprt &lhs,
208205
const exprt &value);
209206

210207

src/goto-programs/graphml_witness.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ void graphml_witnesst::operator()(const goto_tracet &goto_trace)
278278
}
279279

280280
if(it->type==goto_trace_stept::typet::ASSIGNMENT &&
281-
it->lhs_object_value.is_not_nil() &&
281+
it->full_lhs_value.is_not_nil() &&
282282
it->full_lhs.is_not_nil())
283283
{
284284
if(!it->lhs_object_value.is_constant() ||

src/goto-programs/interpreter.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -675,15 +675,7 @@ void interpretert::execute_assign()
675675
goto_trace_stept &trace_step=steps.get_last_step();
676676
assign(address, rhs);
677677
trace_step.full_lhs=code_assign.lhs();
678-
679-
// TODO: need to look at other cases on ssa_exprt
680-
// (dereference should be handled on ssa)
681-
if(ssa_exprt::can_build_identifier(trace_step.full_lhs))
682-
{
683-
trace_step.lhs_object=ssa_exprt(trace_step.full_lhs);
684-
}
685678
trace_step.full_lhs_value=get_value(trace_step.full_lhs.type(), rhs);
686-
trace_step.lhs_object_value=trace_step.full_lhs_value;
687679
}
688680
}
689681
else if(code_assign.rhs().id()==ID_side_effect)

src/goto-programs/json_goto_trace.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ void convert_decl(
7777
const jsont &json_location = conversion_dependencies.location;
7878
const namespacet &ns = conversion_dependencies.ns;
7979

80-
irep_idt identifier = step.lhs_object.get_identifier();
80+
auto lhs_object=step.get_lhs_object();
81+
82+
irep_idt identifier =
83+
lhs_object.has_value()?lhs_object->get_identifier():irep_idt();
8184

8285
json_assignment["stepType"] = json_stringt("assignment");
8386

src/goto-programs/vcd_goto_trace.cpp

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,20 @@ void output_vcd(
8989
{
9090
if(step.is_assignment())
9191
{
92-
irep_idt identifier=step.lhs_object.get_identifier();
93-
const typet &type=step.lhs_object.type();
92+
auto lhs_object=step.get_lhs_object();
93+
if(lhs_object.has_value())
94+
{
95+
irep_idt identifier=lhs_object->get_identifier();
96+
const typet &type=lhs_object->type();
9497

95-
const auto number=n.number(identifier);
98+
const auto number=n.number(identifier);
9699

97-
const mp_integer width = pointer_offset_bits(type, ns);
100+
const mp_integer width = pointer_offset_bits(type, ns);
98101

99-
if(width>=1)
100-
out << "$var reg " << width << " V" << number << " "
101-
<< identifier << " $end" << "\n";
102+
if(width>=1)
103+
out << "$var reg " << width << " V" << number << " "
104+
<< identifier << " $end" << "\n";
105+
}
102106
}
103107
}
104108

@@ -113,30 +117,34 @@ void output_vcd(
113117
{
114118
case goto_trace_stept::typet::ASSIGNMENT:
115119
{
116-
irep_idt identifier=step.lhs_object.get_identifier();
117-
const typet &type=step.lhs_object.type();
118-
119-
out << '#' << timestamp << "\n";
120-
timestamp++;
121-
122-
const auto number=n.number(identifier);
123-
124-
// booleans are special in VCD
125-
if(type.id()==ID_bool)
120+
auto lhs_object=step.get_lhs_object();
121+
if(lhs_object.has_value())
126122
{
127-
if(step.lhs_object_value.is_true())
128-
out << "1" << "V" << number << "\n";
129-
else if(step.lhs_object_value.is_false())
130-
out << "0" << "V" << number << "\n";
123+
irep_idt identifier=lhs_object->get_identifier();
124+
const typet &type=lhs_object->type();
125+
126+
out << '#' << timestamp << "\n";
127+
timestamp++;
128+
129+
const auto number=n.number(identifier);
130+
131+
// booleans are special in VCD
132+
if(type.id()==ID_bool)
133+
{
134+
if(step.full_lhs_value.is_true())
135+
out << "1" << "V" << number << "\n";
136+
else if(step.full_lhs_value.is_false())
137+
out << "0" << "V" << number << "\n";
138+
else
139+
out << "x" << "V" << number << "\n";
140+
}
131141
else
132-
out << "x" << "V" << number << "\n";
133-
}
134-
else
135-
{
136-
std::string binary=as_vcd_binary(step.lhs_object_value, ns);
142+
{
143+
std::string binary=as_vcd_binary(step.full_lhs_value, ns);
137144

138-
if(binary!="")
139-
out << "b" << binary << " V" << number << " " << "\n";
145+
if(binary!="")
146+
out << "b" << binary << " V" << number << " " << "\n";
147+
}
140148
}
141149
}
142150
break;

src/goto-programs/xml_goto_trace.cpp

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,33 @@ void convert(
7070
case goto_trace_stept::typet::ASSIGNMENT:
7171
case goto_trace_stept::typet::DECL:
7272
{
73-
irep_idt identifier=step.lhs_object.get_identifier();
73+
auto lhs_object=step.get_lhs_object();
74+
irep_idt identifier=
75+
lhs_object.has_value()?lhs_object->get_identifier():irep_idt();
7476
xmlt &xml_assignment=dest.new_element("assignment");
7577

7678
if(xml_location.name!="")
7779
xml_assignment.new_element().swap(xml_location);
7880

79-
std::string value_string, binary_string, type_string,
80-
full_lhs_string, full_lhs_value_string;
81+
{
82+
auto lhs_object=step.get_lhs_object();
83+
84+
const symbolt *symbol;
85+
86+
if(lhs_object.has_value() &&
87+
!ns.lookup(lhs_object->get_identifier(), symbol))
88+
{
89+
std::string type_string=from_type(ns, symbol->name, symbol->type);
8190

82-
if(step.lhs_object_value.is_not_nil())
83-
value_string=from_expr(ns, identifier, step.lhs_object_value);
91+
xml_assignment.set_attribute("mode", id2string(symbol->mode));
92+
xml_assignment.set_attribute("identifier", id2string(symbol->name));
93+
xml_assignment.set_attribute("base_name", id2string(symbol->base_name));
94+
xml_assignment.set_attribute("display_name", id2string(symbol->display_name()));
95+
xml_assignment.new_element("type").data=type_string;
96+
}
97+
}
98+
99+
std::string full_lhs_string, full_lhs_value_string;
84100

85101
if(step.full_lhs.is_not_nil())
86102
full_lhs_string=from_expr(ns, identifier, step.full_lhs);
@@ -89,43 +105,17 @@ void convert(
89105
full_lhs_value_string=
90106
from_expr(ns, identifier, step.full_lhs_value);
91107

92-
if(step.lhs_object_value.type().is_not_nil())
93-
type_string=
94-
from_type(ns, identifier, step.lhs_object_value.type());
95-
96-
const symbolt *symbol;
97-
irep_idt base_name, display_name;
98-
99-
if(!ns.lookup(identifier, symbol))
100-
{
101-
base_name=symbol->base_name;
102-
display_name=symbol->display_name();
103-
if(type_string=="")
104-
type_string=from_type(ns, identifier, symbol->type);
105-
106-
xml_assignment.set_attribute("mode", id2string(symbol->mode));
107-
}
108-
109-
xml_assignment.new_element("type").data=type_string;
110108
xml_assignment.new_element("full_lhs").data=full_lhs_string;
111109
xml_assignment.new_element("full_lhs_value").data=full_lhs_value_string;
112-
xml_assignment.new_element("value").data=value_string;
113110

114111
xml_assignment.set_attribute_bool("hidden", step.hidden);
115112
xml_assignment.set_attribute("thread", std::to_string(step.thread_nr));
116-
xml_assignment.set_attribute("identifier", id2string(identifier));
117-
xml_assignment.set_attribute("base_name", id2string(base_name));
118-
xml_assignment.set_attribute("display_name", id2string(display_name));
119113
xml_assignment.set_attribute("step_nr", std::to_string(step.step_nr));
120114

121115
xml_assignment.set_attribute("assignment_type",
122116
step.assignment_type==
123117
goto_trace_stept::assignment_typet::ACTUAL_PARAMETER?
124118
"actual_parameter":"state");
125-
126-
if(step.lhs_object_value.is_not_nil())
127-
xml_assignment.new_element("value_expression").
128-
new_element(xml(step.lhs_object_value, ns));
129119
}
130120
break;
131121

src/goto-symex/build_goto_trace.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,6 @@ void build_goto_trace(
265265
goto_trace_step.thread_nr=SSA_step.source.thread_nr;
266266
goto_trace_step.pc=SSA_step.source.pc;
267267
goto_trace_step.comment=SSA_step.comment;
268-
if(SSA_step.ssa_lhs.is_not_nil())
269-
goto_trace_step.lhs_object=
270-
ssa_exprt(SSA_step.ssa_lhs.get_original_expr());
271-
else
272-
goto_trace_step.lhs_object.make_nil();
273268
goto_trace_step.type=SSA_step.type;
274269
goto_trace_step.hidden=SSA_step.hidden;
275270
goto_trace_step.format_string=SSA_step.format_string;
@@ -294,9 +289,6 @@ void build_goto_trace(
294289
build_full_lhs_rec(
295290
prop_conv, ns, SSA_step.original_full_lhs, SSA_step.ssa_full_lhs);
296291

297-
if(SSA_step.ssa_lhs.is_not_nil())
298-
goto_trace_step.lhs_object_value=prop_conv.get(SSA_step.ssa_lhs);
299-
300292
if(SSA_step.ssa_full_lhs.is_not_nil())
301293
{
302294
goto_trace_step.full_lhs_value=prop_conv.get(SSA_step.ssa_full_lhs);

0 commit comments

Comments
 (0)