Skip to content

goto traces now show pretty function names #3194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jbmc/regression/jbmc/NullPointer1/test.desc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ NullPointer1.class
--stop-on-fail
^EXIT=10$
^SIGNAL=0$
^ file NullPointer1.java line 16 function java::NullPointer1.main:\(\[Ljava/lang/String;\)V bytecode-index 9$
^ file NullPointer1\.java function NullPointer1\.main\(java\.lang\.String\[\]\) line 16 thread 0$
^VERIFICATION FAILED$
--
^warning: ignoring
2 changes: 1 addition & 1 deletion jbmc/regression/jbmc/NullPointer2/test.desc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ NullPointer2.class
--stop-on-fail
^EXIT=10$
^SIGNAL=0$
^ file NullPointer2.java line 9 function java::NullPointer2.main:\(\[Ljava/lang/String;\)V
^ file NullPointer2\.java function NullPointer2\.main\(java\.lang\.String\[\]\) line 9 thread 0
^VERIFICATION FAILED$
--
^warning: ignoring
2 changes: 1 addition & 1 deletion jbmc/regression/jbmc/NullPointer4/test.desc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ NullPointer4.class
--stop-on-fail
^EXIT=10$
^SIGNAL=0$
^ file NullPointer4.java line 6 function java::NullPointer4.main:\(\[Ljava/lang/String;\)V bytecode-index 4$
^ file NullPointer4\.java function NullPointer4\.main\(java.lang.String\[\]\) line 6 thread 0$
^VERIFICATION FAILED$
--
^warning: ignoring
52 changes: 41 additions & 11 deletions src/goto-programs/goto_trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,42 @@ void trace_value(
out << '\n';
}

static std::string
state_location(const goto_trace_stept &state, const namespacet &ns)
{
std::string result;

const auto &source_location = state.pc->source_location;

if(!source_location.get_file().empty())
result += "file " + id2string(source_location.get_file());

if(!state.function.empty())
{
const symbolt &symbol = ns.lookup(state.function);
if(!result.empty())
result += ' ';
result += "function " + id2string(symbol.display_name());
}

if(!source_location.get_line().empty())
{
if(!result.empty())
result += ' ';
result += "line " + id2string(source_location.get_line());
}

if(!result.empty())
result += ' ';
result += "thread " + std::to_string(state.thread_nr);

return result;
}

void show_state_header(
messaget::mstreamt &out,
const namespacet &ns,
const goto_trace_stept &state,
const source_locationt &source_location,
unsigned step_nr,
const trace_optionst &options)
{
Expand All @@ -294,7 +325,7 @@ void show_state_header(
else
out << "State " << step_nr;

out << ' ' << source_location << " thread " << state.thread_nr << '\n';
out << ' ' << state_location(state, ns) << '\n';
out << "----------------------------------------------------" << '\n';

if(options.show_code)
Expand Down Expand Up @@ -340,7 +371,10 @@ void show_full_goto_trace(
out << '\n';
out << messaget::red << "Violated property:" << messaget::reset << '\n';
if(!step.pc->source_location.is_nil())
out << " " << step.pc->source_location << '\n';
{
out << " " << state_location(step, ns) << '\n';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will now have an extra thread number but I suppose that's ok.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes; did contemplate that, and decided that this is desirable. There may well be a context switch just before the failing assertion.

}

out << " " << messaget::red << step.comment << messaget::reset << '\n';

if(step.pc->is_assert())
Expand Down Expand Up @@ -381,8 +415,7 @@ void show_full_goto_trace(
{
first_step=false;
prev_step_nr=step.step_nr;
show_state_header(
out, ns, step, step.pc->source_location, step.step_nr, options);
show_state_header(out, ns, step, step.step_nr, options);
}

trace_value(
Expand All @@ -400,8 +433,7 @@ void show_full_goto_trace(
{
first_step=false;
prev_step_nr=step.step_nr;
show_state_header(
out, ns, step, step.pc->source_location, step.step_nr, options);
show_state_header(out, ns, step, step.step_nr, options);
}

trace_value(
Expand All @@ -418,8 +450,7 @@ void show_full_goto_trace(
}
else
{
show_state_header(
out, ns, step, step.pc->source_location, step.step_nr, options);
show_state_header(out, ns, step, step.step_nr, options);
out << " OUTPUT " << step.io_id << ':';

for(std::list<exprt>::const_iterator
Expand All @@ -441,8 +472,7 @@ void show_full_goto_trace(
break;

case goto_trace_stept::typet::INPUT:
show_state_header(
out, ns, step, step.pc->source_location, step.step_nr, options);
show_state_header(out, ns, step, step.step_nr, options);
out << " INPUT " << step.io_id << ':';

for(std::list<exprt>::const_iterator
Expand Down