Skip to content

Output C code from harness generation tool. #5343

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 11 commits into from
May 28, 2020

Conversation

NlightNFotis
Copy link
Contributor

  • 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).
  • My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@@ -3,7 +3,7 @@
unsigned int x;
unsigned int y;

unsigned int nondet_int()
unsigned int some_random_unsigned_integer()
Copy link
Contributor

@hannes-steffenhagen-diffblue hannes-steffenhagen-diffblue May 14, 2020

Choose a reason for hiding this comment

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

This was changed because of a dump_c() bug; It assumes that nondet_* names are available with specific meanings.

@@ -1,4 +1,4 @@
CORE
KNOWNBUG

Choose a reason for hiding this comment

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

We can work around this for now by re-enabling the old behaviour for these, but we've marked them KNOWNBUG for now because we're first trying to get the call-function harness to behave like we want it to.

@NlightNFotis NlightNFotis force-pushed the feature/harness_dirty branch 17 times, most recently from 65b63fe to aa7d1d9 Compare May 19, 2020 10:54
../ansi-c/ansi-c$(LIBEXT) \
../cpp/cpp$(LIBEXT) \
../goto-instrument/dump_c$(OBJEXT) \
../goto-instrument/goto_program2code$(OBJEXT) \

Choose a reason for hiding this comment

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

these are all needed for dump_c

@NlightNFotis NlightNFotis force-pushed the feature/harness_dirty branch 2 times, most recently from 205327f to 46f8a54 Compare May 20, 2020 15:37
Previously the `dump-c` output of recursive initialisation
wouldn't work with types that have nested const things in
them, such as pointer-to-const or array with constant elements.
@NlightNFotis NlightNFotis force-pushed the feature/harness_dirty branch from 46f8a54 to 881125f Compare May 20, 2020 16:11
@codecov
Copy link

codecov bot commented May 20, 2020

Codecov Report

Merging #5343 into develop will decrease coverage by 0.09%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #5343      +/-   ##
===========================================
- Coverage    68.16%   68.07%   -0.10%     
===========================================
  Files         1170     1170              
  Lines        96441    96477      +36     
===========================================
- Hits         65735    65672      -63     
- Misses       30706    30805      +99     
Flag Coverage Δ
#cproversmt2 42.47% <0.00%> (-0.01%) ⬇️
#regression 65.29% <100.00%> (-0.08%) ⬇️
#unit 31.76% <0.00%> (-0.01%) ⬇️
Impacted Files Coverage Δ
src/util/type.h 100.00% <ø> (ø)
...c/goto-harness/function_call_harness_generator.cpp 80.23% <100.00%> (ø)
src/goto-harness/goto_harness_parse_options.cpp 77.77% <100.00%> (+7.77%) ⬆️
...goto-harness/memory_snapshot_harness_generator.cpp 61.87% <100.00%> (-26.52%) ⬇️
src/goto-harness/recursive_initialization.cpp 87.14% <100.00%> (+0.58%) ⬆️
src/goto-harness/recursive_initialization.h 100.00% <100.00%> (ø)
src/util/type.cpp 71.42% <100.00%> (+21.42%) ⬆️
...c/goto-harness/memory_snapshot_harness_generator.h 71.05% <0.00%> (-26.32%) ⬇️
src/memory-analyzer/analyze_symbol.cpp 72.81% <0.00%> (-18.13%) ⬇️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f20278a...d8a9207. Read the comment docs.

@NlightNFotis NlightNFotis force-pushed the feature/harness_dirty branch from 43e4a83 to e5114db Compare May 21, 2020 15:00
The C output doesn't quite work with the snapshot harness at the moment
(specifically, it doesn't work with the feature to restart analysis from
a specific point in the program) so these test are marked as KNOWNBUG
for now.

Going forward we may re-enable these after fixing the feature, or
possibly do without the restarting entirely.
Modify goto-harness to output C code that corresponds
to the added harness functions and some global values.
This has been a feature request.
@NlightNFotis NlightNFotis force-pushed the feature/harness_dirty branch from e5114db to d404ae1 Compare May 22, 2020 09:10
@NlightNFotis NlightNFotis marked this pull request as ready for review May 22, 2020 09:10
@NlightNFotis NlightNFotis marked this pull request as ready for review May 22, 2020 09:34
@NlightNFotis NlightNFotis changed the title Feature/harness dirty Output C code from harness generation tool. May 26, 2020
Copy link
Contributor

@danpoe danpoe left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@chrisr-diffblue chrisr-diffblue left a comment

Choose a reason for hiding this comment

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

Mostly looks OK, but a couple of queries I'd like answered if possible?

@@ -22,6 +22,7 @@ Author: Diffblue Ltd.
#include "function_harness_generator_options.h"
#include "goto_harness_generator.h"

#define GOTO_HARNESS_PREFIX "GOTO_HARNESS"
Copy link
Contributor

Choose a reason for hiding this comment

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

I would have thought that as this is an "implementation" prefix, it should be __GOTO_HARNESS ? (i.e. double underscore at the front) ?

@@ -28,3 +28,9 @@ void type_with_subtypest::move_to_subtypes(typet &type)
sub.push_back(static_cast<const typet &>(get_nil_irep()));
sub.back().swap(type);
}

typet remove_const(typet type)
Copy link
Contributor

Choose a reason for hiding this comment

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

const argument? Or if this is modifying the argument, then why return ?

Copy link
Contributor

@hannes-steffenhagen-diffblue hannes-steffenhagen-diffblue May 28, 2020

Choose a reason for hiding this comment

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

It's returning a copy with the modification. If the argument was const we'd have to make two copies, if it was const reference we'd still have to make a copy so we don't gain anything in either case.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, I like the const just to make it explicit - and of course depending on how much this is called, an extra copy probably isn't the end of the world... But its a nitpick really on my part.

@@ -224,4 +224,8 @@ inline type_with_subtypest &to_type_with_subtypes(typet &type)
for(type_with_subtypest::subtypest::iterator it=to_type_with_subtypes(type).subtypes().begin(); \
it!=to_type_with_subtypes(type).subtypes().end(); ++it)

/// Remove const qualifier from type (if any).
/// Returns type as is if there is no const qualifier.
typet remove_const(typet type);
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I'm not sure why this is a member function rather than a static?

Before this change, we were using CPROVER_PREFIX, which was
causing some symbols to be dropped before the C code output
because of the prefix symbolising CProver internal values.
@NlightNFotis NlightNFotis force-pushed the feature/harness_dirty branch from d404ae1 to d8a9207 Compare May 28, 2020 13:46
Copy link
Contributor

@chrisr-diffblue chrisr-diffblue left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@smowton smowton left a comment

Choose a reason for hiding this comment

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

Seems ok except the hundred or so tests that get marked KNOWNBUG here -- what was the memory-snapshot thingy that got trashed?

if(component.type().get_bool(ID_C_constant))
{
return dereference_exprt{
typecast_exprt{address_of_exprt{std::move(member_expr)},
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment that this pile of stuff amounts to *(X*)&field, where field has type const X*

Copy link
Contributor

Choose a reason for hiding this comment

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

Also I take it you've tried using braced initialiser style for such things?

goto-instrument \
goto-harness \
Copy link
Contributor

Choose a reason for hiding this comment

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

Sort order was correct before

@NlightNFotis NlightNFotis merged commit 87ee713 into diffblue:develop May 28, 2020
@NlightNFotis
Copy link
Contributor Author

@smowton We are tracking the broken tests internally and through github issue #5351. The memory snapshot harness was one of the modes that the goto-harness tool supported.

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

Successfully merging this pull request may close these issues.

6 participants