Skip to content

Added basic block source lines to source_locationt #3967

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
Feb 8, 2019

Conversation

tautschnig
Copy link
Collaborator

This is a rebased version of #1439.

Block coverage obtained with "cbmc --cover locations" now reports the file name
and line number of every line of source code contributing to a basic block in
the "description" field of the xml output. (The lines contributing to a block
can come from multiple files via function inlining and definitions in include
files, so reporting line numbers alone is not sufficient.)

  • 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.

Copy link
Collaborator

@martin-cs martin-cs left a comment

Choose a reason for hiding this comment

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

Seems reasonable. I wonder if @peterschrammel or whoever is in charge of Diffblue's test case generator wants to comment as this seems like the kind of thing that would change their output.

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: 31727ed).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/98753027

{
if(loc.get_file().empty() || loc.is_built_in())
return;
std::string file = id2string(loc.get_file());
Copy link
Contributor

Choose a reason for hiding this comment

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

Const ref?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Indeed, done.

std::string file = id2string(loc.get_file());

// the function of a source location can fail to be set
std::string func = id2string(loc.get_function());
Copy link
Contributor

Choose a reason for hiding this comment

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

const ref?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

block 5 \(lines main.c:main:20\): SATISFIED
block 6 \(lines main.c:main:15,21,22\): SATISFIED
block 7 \(lines main.c:main:24,25\): SATISFIED
block 1 \(lines main.c:foo:6,7,8,9\): SATISFIED
Copy link
Member

Choose a reason for hiding this comment

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

Suggest to use util/format_number_range for a more compact representation

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, we should do that. As Mark explained in #1439 we have a tool (to be open sourced) that uses this information, so I'll first make sure it can cope with both the explicit enumeration as well as the ranges.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In practice, blocks are so small it makes almost no difference.

But the essential thing is to continue listing filename-numberset pairs, because the lines contributing to a block can come from more than one file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That should be preserved, yes. The only change (and really the only change that was necessary to the regression tests) is that instead of 6,7,8,9 we now print 6-9.

@tautschnig tautschnig self-assigned this Jan 29, 2019
@tautschnig tautschnig removed their assignment Jan 30, 2019
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.

🚫
This PR failed Diffblue compatibility checks (cbmc commit: b70f696).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/99099532
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.

Common spurious failures:

  • the cbmc commit has disappeared in the mean time (e.g. in a force-push)
  • the author is not in the list of contributors (e.g. first-time contributors).

The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.

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: b3209a0).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/99113365

@tautschnig
Copy link
Collaborator Author

Marking do-not-merge: I would like to ask for explicit approval that this doesn't break TG (as this PR changes the output) and also I need to co-ordinate the merge on our end.

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: b1a2804).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/99575601

@tautschnig
Copy link
Collaborator Author

Thanks @jeannielynnmoulton! This PR is now rebased.

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.

🚫
This PR failed Diffblue compatibility checks (cbmc commit: 77ae56c).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/99673839
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.

Common spurious failures:

  • the cbmc commit has disappeared in the mean time (e.g. in a force-push)
  • the author is not in the list of contributors (e.g. first-time contributors).

The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.

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: a51d007).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/99704188

@jeannielynnmoulton
Copy link
Contributor

jeannielynnmoulton commented Feb 7, 2019

@tautschnig I've had to update some tests on test-gen for this change, but it doesn't seem to break anything. The one curious thing that I see is that some lines are blank like this:

[java::Test.privateStatic:(I)I.coverage.1] file Test.java line 28 function java::Test.privateStatic:(I)I bytecode-index 1 block 1 (lines ): SATISFIED

Is this expected?

@jeannielynnmoulton
Copy link
Contributor

Bump passes. It would be good to get an answer to the above question before this is merged though.

@tautschnig
Copy link
Collaborator Author

Thanks @jeannielynnmoulton - I'll look into this, it is reproducible on one of the regression tests.

@tautschnig
Copy link
Collaborator Author

@jeannielynnmoulton Thank you very much for not letting me be lazy - I have now added code to cover_basic_blocks_javat to actually hold the desired info, not just the non-Java one... May I ask you to do another test run as the output should now be non-empty? (It certainly is non-empty in the jdiff test included in the repository.)

Block coverage obtained with "cbmc --cover locations" now reports the file name
and line number of every line of source code contributing to a basic block in
the "description" field of the xml output. (The lines contributing to a block
can come from multiple files via function inlining and definitions in include
files, so reporting line numbers alone is not sufficient.)
@jeannielynnmoulton
Copy link
Contributor

@tautschnig Seems to be non-empty now. [java::Test.privateStatic:(I)I.coverage.1] file Test.java line 28 function java::Test.privateStatic:(I)I bytecode-index 1 block 1 (lines Test.java:java::Test.privateStatic:(I)I:28): SATISFIED

@tautschnig
Copy link
Collaborator Author

@jeannielynnmoulton Many thanks for confirming! Does it still pass TG tests, or should I hold back on merging this one (once Travis has settled)?

@jeannielynnmoulton
Copy link
Contributor

jeannielynnmoulton commented Feb 8, 2019

I'm updating the tests to be more specific so we don't have the blank lines regression. I'll run CI one more time to be safe and let you know when it's safe to merge. (Sorry about closing the PR accidentally, my laptop track pad is so sensitive)

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: 01f4ee2).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/100217199

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: 01f4ee2).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/100219604

@jeannielynnmoulton
Copy link
Contributor

@tautschnig Bump passed!

@tautschnig tautschnig merged commit cdaeb50 into diffblue:develop Feb 8, 2019
@tautschnig tautschnig deleted the 1439-rebased branch February 8, 2019 13:57
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.

8 participants