Skip to content

added --compact-trace option [blocks: #3459] #3458

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 29, 2018
Merged

Conversation

kroening
Copy link
Member

@kroening kroening commented Nov 24, 2018

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

// show pretty name until first '('
const auto &f_symbol = ns.lookup(step.called_function);
const auto display_name = id2string(f_symbol.display_name());
const std::size_t open_par_pos = display_name.find('(');
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the idea behind this filtering?

Copy link
Member Author

Choose a reason for hiding this comment

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

A pretty name might be some_function(int, int); we want to show some_function(123, 456)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why would the symbol's name include the type of the arguments? Is that in case of templates? But then operator() would not be handled correctly. I feel I'm missing something.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, will drop for now

const trace_optionst &options)
{
// unsigned prev_step_nr=0;
// bool first_step=true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -125,7 +125,21 @@ void goto_symext::parameter_assignments(
}
}

symex_assign(state, code_assignt(lhs, rhs));
assignment_typet assignment_type;
Copy link
Collaborator

Choose a reason for hiding this comment

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

In #3459 it says that this PR might be a candidate to test this, but there isn't a test here either?

Copy link
Member Author

Choose a reason for hiding this comment

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

Now there! (Note absence of assignments to parameters in the trace).

Copy link
Collaborator

Choose a reason for hiding this comment

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

The test just seems to test what should be there, but does not have any pattern describing strings that should not occur (other than the usual "warning: ignoring")?!

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, will revert to the state without #3459, and will then add the test there (after this one here is merged). The diff is then obvious.

@kroening kroening force-pushed the compact-trace branch 2 times, most recently from 0a87ae5 to cfc1954 Compare November 24, 2018 22:28
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

✔️
Passed Diffblue compatibility checks (cbmc commit: cfc1954).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/92451767

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

✔️
Passed Diffblue compatibility checks (cbmc commit: bc61922).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/92461159

Copy link
Collaborator

@tautschnig tautschnig left a comment

Choose a reason for hiding this comment

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

Various minor notes, otherwise looks ok.

if(
step.assignment_type ==
goto_trace_stept::assignment_typet::ACTUAL_PARAMETER)
break;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Braces, please.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

cmdline.isset("trace") || cmdline.isset("stack-trace") ||
cmdline.isset("stop-on-fail"))
cmdline.isset("trace") || cmdline.isset("compact-trace") ||
cmdline.isset("stack-trace") || cmdline.isset("stop-on-fail"))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add braces for readability.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

if(!step.pc->source_location.is_nil())
{
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.

No braces needed (usually a nit pick, but here it's inconsistent with a few lines further down).

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

{
// show pretty name
const auto &f_symbol = ns.lookup(step.called_function);
out << f_symbol.display_name();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually the above comment might just add confusion: symbolt has a pretty_name...

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

case goto_trace_stept::typet::CONSTRAINT:
case goto_trace_stept::typet::SHARED_READ:
case goto_trace_stept::typet::SHARED_WRITE:
default:
Copy link
Collaborator

Choose a reason for hiding this comment

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

This shouldn't be necessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@tautschnig tautschnig assigned kroening and unassigned tautschnig Nov 28, 2018
@tautschnig tautschnig changed the title added --compact-trace option added --compact-trace option [blocks: #3459] Nov 28, 2018
@kroening kroening force-pushed the compact-trace branch 2 times, most recently from 7603bec to 3b3e027 Compare November 28, 2018 21:22

case goto_trace_stept::typet::FUNCTION_CALL:
// downwards arrow
out << "\n" << messaget::faint << u8"\u21b3" << messaget::reset << ' ';
Copy link
Member

Choose a reason for hiding this comment

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

could be '\n'

out << '(';

{
bool first = true;
Copy link
Member

Choose a reason for hiding this comment

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

💡
The pattern is very simple, but given the number of times we have this in the code base, it could be worth introducing something like this:

join(
  step.function_arguments.begin(), step.function_arguments.end(), 
  [](arg) {out << from_expr(ns, step.function, arg);},
  []() {out << ", ";});

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you can already do this:

auto arg_strings = make_range(step.function_arguments).map<std::string>(
  [&this](const exprt &arg) { return from_expr(ns, step.function, e); });
join_strings(out, arg_strings.begin(), arg_strings.end(), ", ");

And if the above works we should likely use it in lots of places :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

The range type doesn't have a difference_type, and thus, that doesn't work.

Separate PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

This offers a denser way of viewing traces.  The rationale is that traces
are getting longer; furthermore, the new format makes it easier to spot
function calls and the actual function parameters.
@kroening kroening merged commit 31060e1 into develop Nov 29, 2018
@kroening kroening deleted the compact-trace branch November 29, 2018 02:03
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

✔️
Passed Diffblue compatibility checks (cbmc commit: b62ffe9).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/92941108

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants