Skip to content
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

[TG-1404] Specific implementation of cover basic block for Java #4

Conversation

romainbrenguier
Copy link
Owner

@romainbrenguier romainbrenguier commented Feb 12, 2018

The current implementation of cover_basic_blockt does a first pass on the goto-program without using the bytecode index information, and then later select instruction for bytecode indices.
The process is a bit complicated and sometimes instruments instruction that are after an IF of the same bytecode indices, leading to wrong information about bytecode coverage.
This PR intruduce an alternative cover_basice_block_javat, which for Java use the bytecode information to determine what are the blocks of the program, and selects the first instruction with that bytecode index as a representative.
This strategy is simple and ensures each goal corresponds to a bytecode index coverage.

@romainbrenguier romainbrenguier requested a review from LAJW February 12, 2018 09:44
Copy link
Collaborator

@LAJW LAJW left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -117,4 +101,33 @@ class cover_basic_blockst : public cover_blocks_baset
std::vector<block_infot> block_infos;
};

class cover_basic_blocks_javat : public cover_blocks_baset
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd add mark cover_basic_blocks_javat as final.

@@ -28,21 +28,26 @@ Date: May 2016
void instrument_cover_goals(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this function has so many arguments, could they be packed into an instrument_cover_goals_infot struct?

{
block_infos.push_back(it);
index_to_block.insert(
std::make_pair(bytecode_index, block_infos.size() - 1));
Copy link
Collaborator

Choose a reason for hiding this comment

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

You write it as insert({ bytecode_index, block_infos.size() - 1}) or emplace(bytecode_index, block_infos.size() - 1) to avoid std::make_pair.

message_handlert &message_handler){};
};

class cover_basic_blockst : public cover_blocks_baset
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd mark cover_basic_blockst as final.

@romainbrenguier romainbrenguier force-pushed the feature/cover-basic-block-java#TG-1404 branch from 56faac0 to 0c5925a Compare February 12, 2018 13:25
@romainbrenguier romainbrenguier force-pushed the refactor/coverage-instrumentation branch from 3ef6759 to 3454ef1 Compare February 12, 2018 13:36
@romainbrenguier romainbrenguier force-pushed the refactor/coverage-instrumentation branch 4 times, most recently from efddc26 to eb6463f Compare February 13, 2018 08:58
The operator() functions in goto_symext now have explicit names.
Previous commits have overloaded these functions with several
combinations of arguments; the renaming is in preparation for a future
commit that would necessitate even more overloadings, with the same
parameter types.

Several of goto_symext's functions have been made protected rather than
public, as they are only called from the top-level goto_symext
functions.

The two_argument operator() function is removed completely, as it
was only called from a single place and was only two lines long. Its
implementation is moved to the caller.
@romainbrenguier romainbrenguier force-pushed the refactor/coverage-instrumentation branch from eb6463f to 6492b3a Compare February 13, 2018 11:29
romainbrenguier and others added 3 commits February 13, 2018 16:29
…ge-instrumentation

Refactoring in coverage instrumentation
…ogram

This was supplying synthetic --unwind parameters for each loop found in the GOTO program,
but that required early access to the GOTO code, which will not be available under symex-
driven lazy loading. Therefore we replace that pass with a handler mechanism that allows
the driver program to provide its own callback to make unwinding decisions, and use it in
JBMC to ensure that enumeration type static initialisers are unwound sufficiently.
This used to be necessary to account for stub globals and stub class fields that
were discovered during method elaboration; however, now that they are all discovered
up front there is no need.
@romainbrenguier romainbrenguier force-pushed the feature/cover-basic-block-java#TG-1404 branch from 0c5925a to f8a159d Compare February 13, 2018 16:44
@romainbrenguier romainbrenguier force-pushed the feature/cover-basic-block-java#TG-1404 branch from f8a159d to 20f8bb2 Compare February 14, 2018 07:58
smowton and others added 8 commits February 14, 2018 08:07
This sets the string refinement iteration limit to zero, i.e. unlimited.
The mechanism for providing a limit is left in place, for use probably driven
by a command-line argument by the first user to need that facility.
…recreate-initialize

Remove __CPROVER_initialize recreation
…-clinit-unwinder

Reimplement remove-static-init-loops to avoid need to inspect GOTO program
The unused capture breaks the build when compiling with clang++
>= 5.0.1.
@romainbrenguier romainbrenguier force-pushed the feature/cover-basic-block-java#TG-1404 branch from 1083f74 to f540273 Compare February 14, 2018 12:05
…ng-solver-iteration-limit

Remove string solver iteration limit
smowton and others added 22 commits February 14, 2018 14:06
Normally this situation (a reference to static field A.x, when neither A
nor any of its ancestors either define a field x or are opaque stubs) would
be an error, probably indicating a class version mismatch, but at present some
of our library models intentionally exploit this behaviour to obtain a nondet-
initialised field. Therefore for the time being we tolerate the situation,
initialising such fields in __CPROVER_initialize, as we cannot attach a synthetic
clinit method to a non-stub type.
No functional changes.
Previously clinit wrappers that had been generated but never actually called would
remain in the GOTO program as empty, uncalled functions. Now they are cleaned up
in the same way as unused user functions.
These check that direct and indirect clinit wrappers, as well as stub class synthetic
static initialisers, are removed if they are generated but not subsequently called.
These cover various permutations of static fields defined on parents, on interfaces,
and those parents and/or interfaces being opaque (stubs). They check both that
jbmc doesn't outright crash, and in some cases that jbmc correctly determines that
two static fields must be the same one, and therefore cannot differ.
…ted-static-fields

Add support for inheritence of Java static fields. Fixes TG-2457
…sed-clinits

Java frontend: clean up unused clinit symbols
The block numbers in cover_basic_blockst are obtained from
`block_info.size() - 1`, they should have type std::size_t rather than
unsigned.

Also mark const a couple of arguments that are constant.
This will allow to have two implementations for this functor.
This is a specific implementation of cover block for Java.
It uses the bytecode index to determine blocks and replace the use of
select_unique_java_bytecode_indices.
The index is checked against the size before end so there is no need to
use at there.
JBMC use to group together several lines within the same block.
This is no longer the case for the Java specific block instrumentation.
Each line is part of a different goal.
@romainbrenguier romainbrenguier force-pushed the feature/cover-basic-block-java#TG-1404 branch 3 times, most recently from 750cbfc to 788ba62 Compare February 15, 2018 09:30
This checks that coverage instrumentation assertions are added at the
first instruction with given bytecode index.
And that there is no such assertion in the middle of instructions with
same bytecode index.
@romainbrenguier romainbrenguier force-pushed the feature/cover-basic-block-java#TG-1404 branch from 788ba62 to 2ef935e Compare February 15, 2018 10:01
@romainbrenguier
Copy link
Owner Author

actual PR on cbmc diffblue#1830

romainbrenguier pushed a commit that referenced this pull request Mar 18, 2019
This global name map will be used to check what generation is currently
available for each level1 name, and shared across all states. This will
only be used when a particular state tries to find out what the next
free generation is.

The main draw of this is that all branches will now assign unique
generations that won't clash with assignments done across other
branches. One minor downside is that in VCC's the generation number
might jump sporadically (say from #4 to diffblue#40).
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.

5 participants