Skip to content

Commit 335d815

Browse files
lucasccordeirotautschnig
authored andcommitted
added internal field to json output
Added internal field to json output so that we set it to tru as we find some specific variable that is not supposed to be shown in the counterexample trace.
1 parent e7d28c4 commit 335d815

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

src/goto-programs/goto_trace.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ class goto_trace_stept
8383
// we may choose to hide a step
8484
bool hidden;
8585

86+
// this is related to an internal expression
87+
bool internal;
88+
8689
// we categorize
8790
enum class assignment_typet { STATE, ACTUAL_PARAMETER };
8891
assignment_typet assignment_type;
@@ -127,6 +130,7 @@ class goto_trace_stept
127130
step_nr(0),
128131
type(typet::NONE),
129132
hidden(false),
133+
internal(false),
130134
assignment_type(assignment_typet::STATE),
131135
thread_nr(0),
132136
cond_value(false),

src/goto-programs/json_goto_trace.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ void convert(
5959

6060
json_failure["stepType"]=json_stringt("failure");
6161
json_failure["hidden"]=jsont::json_boolean(step.hidden);
62+
json_failure["internal"]=jsont::json_boolean(step.internal);
6263
json_failure["thread"]=json_numbert(std::to_string(step.thread_nr));
6364
json_failure["reason"]=json_stringt(id2string(step.comment));
6465
json_failure["property"]=json_stringt(id2string(property_id));
@@ -109,6 +110,7 @@ void convert(
109110
json_assignment["value"]=full_lhs_value;
110111
json_assignment["lhs"]=json_stringt(full_lhs_string);
111112
json_assignment["hidden"]=jsont::json_boolean(step.hidden);
113+
json_assignment["internal"]=jsont::json_boolean(step.internal);
112114
json_assignment["thread"]=json_numbert(std::to_string(step.thread_nr));
113115

114116
json_assignment["assignmentType"]=
@@ -126,6 +128,7 @@ void convert(
126128

127129
json_output["stepType"]=json_stringt("output");
128130
json_output["hidden"]=jsont::json_boolean(step.hidden);
131+
json_output["internal"]=jsont::json_boolean(step.internal);
129132
json_output["thread"]=json_numbert(std::to_string(step.thread_nr));
130133
json_output["outputID"]=json_stringt(id2string(step.io_id));
131134

@@ -150,6 +153,7 @@ void convert(
150153

151154
json_input["stepType"]=json_stringt("input");
152155
json_input["hidden"]=jsont::json_boolean(step.hidden);
156+
json_input["internal"]=jsont::json_boolean(step.internal);
153157
json_input["thread"]=json_numbert(std::to_string(step.thread_nr));
154158
json_input["inputID"]=json_stringt(id2string(step.io_id));
155159

@@ -178,6 +182,7 @@ void convert(
178182

179183
json_call_return["stepType"]=json_stringt(tag);
180184
json_call_return["hidden"]=jsont::json_boolean(step.hidden);
185+
json_call_return["internal"]=jsont::json_boolean(step.internal);
181186
json_call_return["thread"]=json_numbert(std::to_string(step.thread_nr));
182187

183188
const symbolt &symbol=ns.lookup(step.identifier);
@@ -201,6 +206,7 @@ void convert(
201206
json_objectt &json_location_only=dest_array.push_back().make_object();
202207
json_location_only["stepType"]=json_stringt("location-only");
203208
json_location_only["hidden"]=jsont::json_boolean(step.hidden);
209+
json_location_only["internal"]=jsont::json_boolean(step.internal);
204210
json_location_only["thread"]=
205211
json_numbert(std::to_string(step.thread_nr));
206212
json_location_only["sourceLocation"]=json_location;

src/goto-symex/build_goto_trace.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ exprt adjust_lhs_object(
111111

112112
/// set internal field for variable assignment related to dynamic_object[0-9]
113113
/// and dynamic_[0-9]_array.
114-
void hide_dynamic_object(
114+
void set_internal_dynamic_object(
115115
const exprt &expr,
116116
goto_trace_stept &goto_trace_step,
117117
const namespacet &ns)
@@ -124,39 +124,39 @@ void hide_dynamic_object(
124124
{
125125
bool result=symbol->type.get_bool("#dynamic");
126126
if(result)
127-
goto_trace_step.hidden=true;
127+
goto_trace_step.internal=true;
128128
}
129129
}
130130
else
131131
{
132132
forall_operands(it, expr)
133-
hide_dynamic_object(*it, goto_trace_step, ns);
133+
set_internal_dynamic_object(*it, goto_trace_step, ns);
134134
}
135135
}
136136

137137
/// set internal for variables assignments related to dynamic_object and CPROVER
138138
/// internal functions (e.g., __CPROVER_initialize)
139-
void update_fields_to_hidden(
139+
void update_internal_field(
140140
const symex_target_equationt::SSA_stept &SSA_step,
141141
goto_trace_stept &goto_trace_step,
142142
const namespacet &ns)
143143
{
144-
// hide dynamic_object in both lhs and rhs expressions
145-
hide_dynamic_object(SSA_step.ssa_lhs, goto_trace_step, ns);
146-
hide_dynamic_object(SSA_step.ssa_rhs, goto_trace_step, ns);
144+
// set internal for dynamic_object in both lhs and rhs expressions
145+
set_internal_dynamic_object(SSA_step.ssa_lhs, goto_trace_step, ns);
146+
set_internal_dynamic_object(SSA_step.ssa_rhs, goto_trace_step, ns);
147147

148-
// hide internal CPROVER functions (e.g., __CPROVER_initialize)
148+
// set internal field to CPROVER functions (e.g., __CPROVER_initialize)
149149
if(SSA_step.is_function_call())
150150
{
151151
if(SSA_step.source.pc->source_location.as_string().empty())
152-
goto_trace_step.hidden=true;
152+
goto_trace_step.internal=true;
153153
}
154154

155155
// set internal field to input and output steps
156156
if(goto_trace_step.type==goto_trace_stept::typet::OUTPUT ||
157157
goto_trace_step.type==goto_trace_stept::typet::INPUT)
158158
{
159-
goto_trace_step.hidden=true;
159+
goto_trace_step.internal=true;
160160
}
161161

162162
// set internal field to _start function-return step
@@ -273,8 +273,8 @@ void build_goto_trace(
273273
goto_trace_step.formatted=SSA_step.formatted;
274274
goto_trace_step.identifier=SSA_step.identifier;
275275

276-
// hide specific variables in the counterexample trace
277-
update_fields_to_hidden(SSA_step, goto_trace_step, ns);
276+
// update internal field for specific variables in the counterexample
277+
update_internal_field(SSA_step, goto_trace_step, ns);
278278

279279
goto_trace_step.assignment_type=
280280
(it->is_assignment()&&

0 commit comments

Comments
 (0)