Skip to content

Commit f75653c

Browse files
author
Daniel Kroening
committed
goto_trace_stept now contains 'called_function' field
The previous 'function_identifier' is now 'called_function', which is a better name as it denotes the identifier of the function that is called.
1 parent d6383f2 commit f75653c

File tree

7 files changed

+54
-35
lines changed

7 files changed

+54
-35
lines changed

src/goto-programs/goto_trace.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ void goto_trace_stept::output(
8383

8484
if(is_assert() || is_assume() || is_goto())
8585
out << " (" << cond_value << ')';
86-
else if(is_function_call() || is_function_return())
87-
out << ' ' << function_identifier;
86+
else if(is_function_call())
87+
out << ' ' << called_function;
8888

8989
if(hidden)
9090
out << " hidden";
@@ -339,8 +339,7 @@ void show_full_goto_trace(
339339
out << " " << messaget::red << step.comment << messaget::reset << '\n';
340340

341341
if(step.pc->is_assert())
342-
out << " " << from_expr(ns, step.pc->function, step.pc->guard)
343-
<< '\n';
342+
out << " " << from_expr(ns, step.function, step.pc->guard) << '\n';
344343

345344
out << '\n';
346345
}
@@ -355,8 +354,7 @@ void show_full_goto_trace(
355354
out << " " << step.pc->source_location << '\n';
356355

357356
if(step.pc->is_assume())
358-
out << " " << from_expr(ns, step.pc->function, step.pc->guard)
359-
<< '\n';
357+
out << " " << from_expr(ns, step.function, step.pc->guard) << '\n';
360358

361359
out << '\n';
362360
}
@@ -426,7 +424,8 @@ void show_full_goto_trace(
426424
{
427425
if(l_it!=step.io_args.begin())
428426
out << ';';
429-
out << ' ' << from_expr(ns, step.pc->function, *l_it);
427+
428+
out << ' ' << from_expr(ns, step.function, *l_it);
430429

431430
// the binary representation
432431
out << " (" << trace_numeric_value(*l_it, ns, options) << ')';
@@ -448,7 +447,8 @@ void show_full_goto_trace(
448447
{
449448
if(l_it!=step.io_args.begin())
450449
out << ';';
451-
out << ' ' << from_expr(ns, step.pc->function, *l_it);
450+
451+
out << ' ' << from_expr(ns, step.function, *l_it);
452452

453453
// the binary representation
454454
out << " (" << trace_numeric_value(*l_it, ns, options) << ')';
@@ -461,7 +461,7 @@ void show_full_goto_trace(
461461
function_depth++;
462462
if(options.show_function_calls)
463463
{
464-
out << "\n#### Function call: " << step.function_identifier;
464+
out << "\n#### Function call: " << step.called_function;
465465
out << '(';
466466

467467
bool first = true;
@@ -472,7 +472,7 @@ void show_full_goto_trace(
472472
else
473473
out << ", ";
474474

475-
out << from_expr(ns, step.function_identifier, arg);
475+
out << from_expr(ns, step.function, arg);
476476
}
477477

478478
out << ") (depth " << function_depth << ") ####\n";
@@ -483,8 +483,8 @@ void show_full_goto_trace(
483483
function_depth--;
484484
if(options.show_function_calls)
485485
{
486-
out << "\n#### Function return: " << step.function_identifier
487-
<< " (depth " << function_depth << ") ####\n";
486+
out << "\n#### Function return from " << step.function << " (depth "
487+
<< function_depth << ") ####\n";
488488
}
489489
break;
490490

@@ -556,7 +556,7 @@ void show_goto_stack_trace(
556556
}
557557
else if(step.is_function_call())
558558
{
559-
out << " " << step.function_identifier;
559+
out << " " << step.called_function;
560560
out << '(';
561561

562562
bool first = true;
@@ -567,7 +567,7 @@ void show_goto_stack_trace(
567567
else
568568
out << ", ";
569569

570-
out << from_expr(ns, step.function_identifier, arg);
570+
out << from_expr(ns, step.function, arg);
571571
}
572572

573573
out << ')';

src/goto-programs/goto_trace.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ class goto_trace_stept
8686
enum class assignment_typet { STATE, ACTUAL_PARAMETER };
8787
assignment_typet assignment_type;
8888

89+
// The instruction that created this step
90+
// (function calls are in the caller, function returns are in the callee)
91+
irep_idt function;
8992
goto_programt::const_targett pc;
9093

9194
// this transition done by given thread number
@@ -113,8 +116,8 @@ class goto_trace_stept
113116
io_argst io_args;
114117
bool formatted;
115118

116-
// for function call/return
117-
irep_idt function_identifier;
119+
// for function calls
120+
irep_idt called_function;
118121

119122
// for function call
120123
std::vector<exprt> function_arguments;

src/goto-programs/graphml_witness.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ void graphml_witnesst::operator()(const goto_tracet &goto_trace)
284284
{
285285
xmlt &val=edge.new_element("data");
286286
val.set_attribute("key", "assumption");
287-
val.data=from_expr(ns, it->pc->function, it->full_lhs)+" = "+
288-
from_expr(ns, it->pc->function, it->full_lhs_value)+";";
287+
val.data = from_expr(ns, it->function, it->full_lhs) + " = " +
288+
from_expr(ns, it->function, it->full_lhs_value) + ";";
289289

290290
xmlt &val_s=edge.new_element("data");
291291
val_s.set_attribute("key", "assumption.scope");
@@ -296,10 +296,9 @@ void graphml_witnesst::operator()(const goto_tracet &goto_trace)
296296
{
297297
xmlt &val=edge.new_element("data");
298298
val.set_attribute("key", "sourcecode");
299-
const std::string cond =
300-
from_expr(ns, it->pc->function, it->cond_expr);
301-
const std::string neg_cond=
302-
from_expr(ns, it->pc->function, not_exprt(it->cond_expr));
299+
const std::string cond = from_expr(ns, it->function, it->cond_expr);
300+
const std::string neg_cond =
301+
from_expr(ns, it->function, not_exprt(it->cond_expr));
303302
val.data="["+(it->cond_value ? cond : neg_cond)+"]";
304303

305304
#if 0
@@ -481,7 +480,7 @@ void graphml_witnesst::operator()(const symex_target_equationt &equation)
481480
xmlt &val=edge.new_element("data");
482481
val.set_attribute("key", "sourcecode");
483482
const std::string cond =
484-
from_expr(ns, it->source.pc->function, it->cond_expr);
483+
from_expr(ns, it->source.function, it->cond_expr);
485484
val.data="["+cond+"]";
486485
}
487486

src/goto-programs/interpreter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ void interpretert::execute_function_call()
759759
const memory_cellt &cell=memory[address];
760760
#endif
761761
const irep_idt &identifier = address_to_identifier(address);
762-
trace_step.function_identifier = identifier;
762+
trace_step.called_function = identifier;
763763

764764
const goto_functionst::function_mapt::const_iterator f_it=
765765
goto_functions.function_map.find(identifier);

src/goto-programs/json_goto_trace.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,10 @@ void convert_return(
277277
json_call_return["internal"] = jsont::json_boolean(step.internal);
278278
json_call_return["thread"] = json_numbert(std::to_string(step.thread_nr));
279279

280-
const symbolt &symbol = ns.lookup(step.function_identifier);
280+
const symbolt &symbol = ns.lookup(step.function);
281281
json_objectt &json_function = json_call_return["function"].make_object();
282282
json_function["displayName"] = json_stringt(symbol.display_name());
283-
json_function["identifier"] = json_stringt(step.function_identifier);
283+
json_function["identifier"] = json_stringt(step.function);
284284
json_function["sourceLocation"] = json(symbol.location);
285285

286286
if(!location.is_null())

src/goto-programs/xml_goto_trace.cpp

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ void convert(
139139
for(const auto &arg : step.io_args)
140140
{
141141
xml_output.new_element("value").data =
142-
from_expr(ns, step.pc->function, arg);
142+
from_expr(ns, step.function, arg);
143143
xml_output.new_element("value_expression").
144144
new_element(xml(arg, ns));
145145
}
@@ -158,7 +158,7 @@ void convert(
158158
for(const auto &arg : step.io_args)
159159
{
160160
xml_input.new_element("value").data =
161-
from_expr(ns, step.pc->function, arg);
161+
from_expr(ns, step.function, arg);
162162
xml_input.new_element("value_expression").
163163
new_element(xml(arg, ns));
164164
}
@@ -169,23 +169,40 @@ void convert(
169169
break;
170170

171171
case goto_trace_stept::typet::FUNCTION_CALL:
172+
{
173+
std::string tag = "function_call";
174+
xmlt &xml_call_return = dest.new_element(tag);
175+
176+
xml_call_return.set_attribute_bool("hidden", step.hidden);
177+
xml_call_return.set_attribute("thread", std::to_string(step.thread_nr));
178+
xml_call_return.set_attribute("step_nr", std::to_string(step.step_nr));
179+
180+
const symbolt &symbol = ns.lookup(step.called_function);
181+
xmlt &xml_function = xml_call_return.new_element("function");
182+
xml_function.set_attribute(
183+
"display_name", id2string(symbol.display_name()));
184+
xml_function.set_attribute("identifier", id2string(symbol.name));
185+
xml_function.new_element() = xml(symbol.location);
186+
187+
if(xml_location.name != "")
188+
xml_call_return.new_element().swap(xml_location);
189+
}
190+
break;
191+
172192
case goto_trace_stept::typet::FUNCTION_RETURN:
173193
{
174-
std::string tag=
175-
(step.type==goto_trace_stept::typet::FUNCTION_CALL)?
176-
"function_call":"function_return";
194+
std::string tag = "function_return";
177195
xmlt &xml_call_return=dest.new_element(tag);
178196

179197
xml_call_return.set_attribute_bool("hidden", step.hidden);
180198
xml_call_return.set_attribute("thread", std::to_string(step.thread_nr));
181199
xml_call_return.set_attribute("step_nr", std::to_string(step.step_nr));
182200

183-
const symbolt &symbol = ns.lookup(step.function_identifier);
201+
const symbolt &symbol = ns.lookup(step.function);
184202
xmlt &xml_function=xml_call_return.new_element("function");
185203
xml_function.set_attribute(
186204
"display_name", id2string(symbol.display_name()));
187-
xml_function.set_attribute(
188-
"identifier", id2string(step.function_identifier));
205+
xml_function.set_attribute("identifier", id2string(step.function));
189206
xml_function.new_element()=xml(symbol.location);
190207

191208
if(xml_location.name!="")

src/goto-symex/build_goto_trace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ void build_goto_trace(
308308
goto_trace_step.format_string = SSA_step.format_string;
309309
goto_trace_step.io_id = SSA_step.io_id;
310310
goto_trace_step.formatted = SSA_step.formatted;
311-
goto_trace_step.function_identifier = SSA_step.called_function;
311+
goto_trace_step.called_function = SSA_step.called_function;
312312
goto_trace_step.function_arguments = SSA_step.converted_function_arguments;
313313

314314
for(auto &arg : goto_trace_step.function_arguments)

0 commit comments

Comments
 (0)