Skip to content

Commit 0610eaf

Browse files
author
Daniel Kroening
committed
use display_name() to show function in goto traces
1 parent f75653c commit 0610eaf

File tree

1 file changed

+41
-11
lines changed

1 file changed

+41
-11
lines changed

src/goto-programs/goto_trace.cpp

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,42 @@ void trace_value(
274274
out << '\n';
275275
}
276276

277+
static std::string
278+
state_location(const goto_trace_stept &state, const namespacet &ns)
279+
{
280+
std::string result;
281+
282+
const auto &source_location = state.pc->source_location;
283+
284+
if(!source_location.get_file().empty())
285+
result += "file " + id2string(source_location.get_file());
286+
287+
if(!state.function.empty())
288+
{
289+
const symbolt &symbol = ns.lookup(state.function);
290+
if(!result.empty())
291+
result += ' ';
292+
result += "function " + id2string(symbol.display_name());
293+
}
294+
295+
if(!source_location.get_line().empty())
296+
{
297+
if(!result.empty())
298+
result += ' ';
299+
result += " line " + id2string(source_location.get_line());
300+
}
301+
302+
if(!result.empty())
303+
result += ' ';
304+
result += "thread " + std::to_string(state.thread_nr);
305+
306+
return result;
307+
}
308+
277309
void show_state_header(
278310
messaget::mstreamt &out,
279311
const namespacet &ns,
280312
const goto_trace_stept &state,
281-
const source_locationt &source_location,
282313
unsigned step_nr,
283314
const trace_optionst &options)
284315
{
@@ -289,7 +320,7 @@ void show_state_header(
289320
else
290321
out << "State " << step_nr;
291322

292-
out << ' ' << source_location << " thread " << state.thread_nr << '\n';
323+
out << state_location(state, ns) << '\n';
293324
out << "----------------------------------------------------" << '\n';
294325

295326
if(options.show_code)
@@ -335,7 +366,10 @@ void show_full_goto_trace(
335366
out << '\n';
336367
out << messaget::red << "Violated property:" << messaget::reset << '\n';
337368
if(!step.pc->source_location.is_nil())
338-
out << " " << step.pc->source_location << '\n';
369+
{
370+
out << " " << state_location(step, ns) << '\n';
371+
}
372+
339373
out << " " << messaget::red << step.comment << messaget::reset << '\n';
340374

341375
if(step.pc->is_assert())
@@ -376,8 +410,7 @@ void show_full_goto_trace(
376410
{
377411
first_step=false;
378412
prev_step_nr=step.step_nr;
379-
show_state_header(
380-
out, ns, step, step.pc->source_location, step.step_nr, options);
413+
show_state_header(out, ns, step, step.step_nr, options);
381414
}
382415

383416
trace_value(
@@ -395,8 +428,7 @@ void show_full_goto_trace(
395428
{
396429
first_step=false;
397430
prev_step_nr=step.step_nr;
398-
show_state_header(
399-
out, ns, step, step.pc->source_location, step.step_nr, options);
431+
show_state_header(out, ns, step, step.step_nr, options);
400432
}
401433

402434
trace_value(
@@ -413,8 +445,7 @@ void show_full_goto_trace(
413445
}
414446
else
415447
{
416-
show_state_header(
417-
out, ns, step, step.pc->source_location, step.step_nr, options);
448+
show_state_header(out, ns, step, step.step_nr, options);
418449
out << " OUTPUT " << step.io_id << ':';
419450

420451
for(std::list<exprt>::const_iterator
@@ -436,8 +467,7 @@ void show_full_goto_trace(
436467
break;
437468

438469
case goto_trace_stept::typet::INPUT:
439-
show_state_header(
440-
out, ns, step, step.pc->source_location, step.step_nr, options);
470+
show_state_header(out, ns, step, step.step_nr, options);
441471
out << " INPUT " << step.io_id << ':';
442472

443473
for(std::list<exprt>::const_iterator

0 commit comments

Comments
 (0)