Skip to content

formatting of debug output of traces #2182

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
May 14, 2018
Merged
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
61 changes: 23 additions & 38 deletions src/goto-programs/goto_trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Author: Daniel Kroening
#include <ostream>

#include <util/arith_tools.h>
#include <util/format_expr.h>
#include <util/symbol.h>

#include <ansi-c/printf_formatter.h>
Expand Down Expand Up @@ -61,61 +62,45 @@ void goto_trace_stept::output(
UNREACHABLE;
}

if(type==typet::ASSERT || type==typet::ASSUME || type==typet::GOTO)
if(is_assert() || is_assume() || is_goto())
out << " (" << cond_value << ")";
else if(is_function_call() || is_function_return())
out << ' ' << identifier;

if(hidden)
out << " hidden";

out << "\n";
out << '\n';

if(is_assignment())
{
out << " " << format(full_lhs)
<< " = " << format(full_lhs_value)
<< '\n';
}

if(!pc->source_location.is_nil())
out << pc->source_location << "\n";

if(pc->is_goto())
out << "GOTO ";
else if(pc->is_assume())
out << "ASSUME ";
else if(pc->is_assert())
out << "ASSERT ";
else if(pc->is_dead())
out << "DEAD ";
else if(pc->is_other())
out << "OTHER ";
else if(pc->is_assign())
out << "ASSIGN ";
else if(pc->is_decl())
out << "DECL ";
else if(pc->is_function_call())
out << "CALL ";
else
out << "(?) ";
out << pc->source_location << '\n';

out << "\n";
out << pc->type << '\n';
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this one changed but the switch statement at the top of this method isn't?

Copy link
Member Author

Choose a reason for hiding this comment

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

Switching over something different!


if((pc->is_other() && lhs_object.is_not_nil()) || pc->is_assign())
{
irep_idt identifier=lhs_object.get_object_name();
out << " " << from_expr(ns, identifier, lhs_object.get_original_expr())
<< " = " << from_expr(ns, identifier, lhs_object_value)
<< "\n";
}
else if(pc->is_assert())
if(pc->is_assert())
{
if(!cond_value)
{
out << "Violated property:" << "\n";
out << "Violated property:" << '\n';
if(pc->source_location.is_nil())
out << " " << pc->source_location << "\n";
out << " " << pc->source_location << '\n';

if(comment!="")
out << " " << comment << "\n";
out << " " << from_expr(ns, pc->function, pc->guard) << "\n";
out << "\n";
if(!comment.empty())
out << " " << comment << '\n';

out << " " << format(pc->guard) << '\n';
Copy link
Collaborator

@tautschnig tautschnig May 14, 2018

Choose a reason for hiding this comment

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

I'm not convinced there is value in making the debug output language-independent when the plain-text user-directed output is and should remain language-specific? Clarified by @peterschrammel's comment.

out << '\n';
}
}

out << "\n";
out << '\n';
}

std::string trace_value_binary(
Expand Down