Skip to content

Add binary representation to all bitvector values in the xml trace #5425

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

Conversation

thomasspriggs
Copy link
Contributor

@thomasspriggs thomasspriggs commented Jul 16, 2020

Add binary representation to all bitvector values in the xml trace. The purpose of this is to provide a consistent interface for getting the values of bitvector-ed types out of the trace.

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

@hannes-steffenhagen-diffblue
Copy link
Contributor

Looks like the new regression test is crashing with an invariant violation? Also, you should probably update the actual XSD with this.

xmlt full_lhs_value(const goto_trace_stept &step, const namespacet &ns)
{
xmlt full_lhs_value{"full_lhs_value"};
xmlt xml{"full_lhs_value"};
Copy link
Contributor

Choose a reason for hiding this comment

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

⛏️ Personally don't love this name either just cos the type tells you its xml /shrug

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. I am going to make this value_xml instead.

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.

Just thoughts; no action required.

@thomasspriggs
Copy link
Contributor Author

@hannes-steffenhagen-diffblue The xsd does not need to be updated, because it already contains the binary attribute. This was already present in the xsd because it is already present for floating point values.

@thomasspriggs thomasspriggs force-pushed the tas/bit_vector_binary branch from 217469f to 5066f76 Compare July 20, 2020 13:27
@codecov
Copy link

codecov bot commented Jul 20, 2020

Codecov Report

Merging #5425 into develop will decrease coverage by 19.53%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##           develop    #5425       +/-   ##
============================================
- Coverage    68.21%   48.68%   -19.54%     
============================================
  Files         1178      945      -233     
  Lines        97542    82350    -15192     
============================================
- Hits         66537    40090    -26447     
- Misses       31005    42260    +11255     
Flag Coverage Δ
#cproversmt2 42.77% <100.00%> (+<0.01%) ⬆️
#regression ?
#unit 32.26% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/goto-programs/xml_goto_trace.cpp 87.50% <100.00%> (-10.77%) ⬇️
src/cpp/cpp_id.h 0.00% <0.00%> (-100.00%) ⬇️
src/cpp/cpp_scope.h 0.00% <0.00%> (-100.00%) ⬇️
src/cpp/cpp_token.h 0.00% <0.00%> (-100.00%) ⬇️
src/cpp/cpp_name.cpp 0.00% <0.00%> (-100.00%) ⬇️
src/cpp/cpp_util.cpp 0.00% <0.00%> (-100.00%) ⬇️
src/util/identifier.h 0.00% <0.00%> (-100.00%) ⬇️
src/cpp/cpp_is_pod.cpp 0.00% <0.00%> (-100.00%) ⬇️
src/cpp/template_map.h 0.00% <0.00%> (-100.00%) ⬇️
src/cpp/cpp_enum_type.h 0.00% <0.00%> (-100.00%) ⬇️
... and 752 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 069db73...4350cc4. Read the comment docs.

The purpose of this is to provide a consistent interface for getting the
values of bitvector-ed types out of the trace.

An existing test is updated in this commit in order for the existing
to test to match new functionality and so that every commit still passes
all tests.

There are instances when running with `--cprover-smt2` where the type of
the expression is `bitvector_typet`, but the expression is not a
`constant_exprt`. By removing the printing in this case we can avoid
breaking the partial functionality available with the `--cprover-smt2`
option.
In order to confirm that the binary is now included in the xml trace
output.

Lines may be separated with `\r\n` on windows, rather than just `\n`. So
we need to match both kinds of separator in order to be platform
independant. As we don't require the xml elements to be on separate
lines and `\s` matches both `\r` and `\n` we can let `\s*` match all the
line separators as well as any indentation characters.

`uint32_t` for example fully specifies that an integer is unsigned and
32 bits. But it could be implemented as a `typedef unsigned` or a
`typedef unsigned long`, so long as these underlying types fulfill the
requirements. Therefore the regex for this needs to match both `16u`
and `16ul` as the value.
In order to disambiguate it from `step.full_lhs_value`.
To avoid repeating ourselves and because "Which value?" is clear from
the context of the function.
To answer the question of why this is not a bug when reading the code.
Ideally there would exist a `bvrep2binary` function, but this is out of
scope of this PR.
So that the filtering is done first and we avoid building temporaries
which aren't going to be used.
Because the PR checklist says that feature changes should be documented.
@thomasspriggs thomasspriggs force-pushed the tas/bit_vector_binary branch from 02880ec to d744e2d Compare July 20, 2020 18:26
Copy link
Contributor

@hannes-steffenhagen-diffblue hannes-steffenhagen-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, thanks for addressing comments

@@ -27,15 +27,15 @@ Author: Daniel Kroening

xmlt full_lhs_value(const goto_trace_stept &step, const namespacet &ns)
{
xmlt full_lhs_value{"full_lhs_value"};
xmlt value_xml{"full_lhs_value"};

Choose a reason for hiding this comment

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

I am not sure if I agree with the reasoning of this rename. I’d probably have gone for full_lhs_value_xml instead.

if(full_lhs_value_includes_binary(step, ns))
const auto &bv_type = type_try_dynamic_cast<bitvector_typet>(value.type());
const auto &constant = expr_try_dynamic_cast<constant_exprt>(value);
if(bv_type && constant)

Choose a reason for hiding this comment

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

I did like the full_lhs_value_includes_binary name, but I suppose if the intention is to use all bitvectors for this then this is more honest.

@hannes-steffenhagen-diffblue hannes-steffenhagen-diffblue merged commit e0e293b into diffblue:develop Jul 21, 2020
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