-
Notifications
You must be signed in to change notification settings - Fork 274
Print binary values of floats #5322
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
thk123
merged 10 commits into
diffblue:develop
from
thk123:print-binary-values-of-floats
May 7, 2020
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
226b71b
Add test for printing different float values in the trace
7e5b37e
Adapt test to check for binary in trace
9384b91
Add additional tests for more types
b64757e
Pull out function for producing the full_lhs_value
e57e194
Tidy up full_lhs_value
304c92c
Adapt full_lhs_value to output binary for floating values
4049f15
Adapt the XSD to include the binary output
4fcbd37
Add folder readme for doc/assets
cdb0b78
Referenced readme in cprover docs
be6f20f
Rename variables in test to avoid clash on windows
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
This folder contains resources for the documentation. | ||
|
||
# XML Spec | ||
|
||
The folllowing files relate to the specification of the XML trace output when using the `--xml-ui` flag. | ||
|
||
## xml_spec.xsd | ||
The`xml_spec.xsd` file is an XSD specification of the trace. You can validate an | ||
output xml file from CBMC using the following invocation: | ||
|
||
```bash | ||
$ cbmc --xml-ui main.c | \ | ||
xmllint --schema xml_spec.xsd --xpath "cprover/result/goto_trace" - | ||
``` | ||
|
||
## xml_spec.tex | ||
|
||
This is a LaTeX document describing the specification of the trace. It can be compiled to pdf using: | ||
|
||
```bash | ||
$ pdflatex -shell-escape xml_spec.tex | ||
``` | ||
|
||
This requires: | ||
|
||
- texlive-latex-base | ||
- texlive-latex-extra (for minted package) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,9 +138,11 @@ possible output format. | |
``` | ||
|
||
The specification of the XML trace output can be found here: [XML | ||
Specification](https://raw.githubusercontent.com/diffblue/cbmc/develop/doc/assets/xml_spec.tex) | ||
and can be build by `pdflatex -shell-escape xml_spec.tex`. Alternatively, you | ||
view it in Markdown [here](../../../assets/xml_spec). | ||
Specification](../assets/xml_spec.tex) | ||
and can be built by `pdflatex -shell-escape xml_spec.tex`. See the [README | ||
](../assets/README.md#xml_spec.tex) for details. | ||
|
||
Alternatively, you can view it in [Markdown](../assets/xml_spec.md). | ||
|
||
### Verifying Modules | ||
|
||
|
@@ -348,4 +350,3 @@ comes with a small set of definitions, which includes functions such as | |
|
||
We also have a [list of interesting applications of | ||
CBMC](http://www.cprover.org/cbmc/applications/). | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't there be a newline here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was auto-removed on save, because there are two new lines at the end of the file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <assert.h> | ||
#include <math.h> | ||
#include <stdbool.h> | ||
|
||
int main() | ||
{ | ||
float zero = 0.0f; | ||
float one = 1.0f; | ||
float complex = 0x1p+37f; | ||
float inf = INFINITY; | ||
float nan = NAN; | ||
|
||
double dzero = 0.0; | ||
double done = 1.0; | ||
double dinf = INFINITY; | ||
double dnan = NAN; | ||
double dcomplex = -5.56268e-309; | ||
|
||
assert(false); | ||
|
||
return 0; | ||
} | ||
|
||
void test(float value) | ||
{ | ||
assert(value == 1.0f); | ||
assert(value == 0.0f); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
CORE | ||
test.c | ||
--trace --xml-ui | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
VERIFICATION FAILED | ||
<full_lhs>zero</full_lhs> | ||
<full_lhs_value binary="0{32}">0.0f</full_lhs_value> | ||
<full_lhs>one</full_lhs> | ||
<full_lhs_value binary="00111111100000000000000000000000">1.0f</full_lhs_value> | ||
<full_lhs>complex</full_lhs> | ||
<full_lhs_value binary="01010010000000000000000000000000">1\.374390e\+11f</full_lhs_value> | ||
<full_lhs>inf</full_lhs> | ||
<full_lhs_value binary="01{8}0{23}">\+INFINITY</full_lhs_value> | ||
<full_lhs>nan</full_lhs> | ||
<full_lhs_value binary="01{8}[01]*1[01]*">\+NAN</full_lhs_value> | ||
<full_lhs_value binary="[01]{32}">\+NAN</full_lhs_value> | ||
<full_lhs>dzero</full_lhs> | ||
<full_lhs_value binary="0{64}">0.0</full_lhs_value> | ||
<full_lhs>done</full_lhs> | ||
<full_lhs_value binary="001{10}0{52}">1.0</full_lhs_value> | ||
<full_lhs>dcomplex</full_lhs> | ||
<full_lhs_value binary="1000000000000011111111111111111111000111111100100110011101110111">-5\.562680e-309</full_lhs_value> | ||
<full_lhs>inf</full_lhs> | ||
<full_lhs_value binary="01{11}0{52}">\+INFINITY</full_lhs_value> | ||
<full_lhs>nan</full_lhs> | ||
<full_lhs_value binary="01{11}[01]*1[01]*">\+NAN</full_lhs_value> | ||
<full_lhs_value binary="[01]{64}">\+NAN</full_lhs_value> | ||
-- | ||
-- | ||
Checks that the binary value is printed for floating point types | ||
point types |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛏️ this could be made more precise using a XSD type where we limit this to be only [01]+