-
Notifications
You must be signed in to change notification settings - Fork 274
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
Merged
hannes-steffenhagen-diffblue
merged 7 commits into
diffblue:develop
from
thomasspriggs:tas/bit_vector_binary
Jul 21, 2020
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
33d9e32
Add binary representation to all bitvector values in the xml trace
thomasspriggs 4db7ed0
Add test of binary inclusion in xml trace for integer values
thomasspriggs 98f139d
Rename `full_lhs_value` to `value_xml`
thomasspriggs e6174e4
Refactor to extract `step.full_lhs_value` into `value` variable
thomasspriggs 9827dc9
Explain why it is ok to use `false` for `is_signed`
thomasspriggs a1eeb59
Move nil check to top of function
thomasspriggs d744e2d
Document the additional binary in the xml file
thomasspriggs 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,30 @@ | ||
#include <assert.h> | ||
#include <inttypes.h> | ||
#include <math.h> | ||
#include <stdbool.h> | ||
#include <stddef.h> | ||
#include <stdlib.h> | ||
|
||
int main() | ||
{ | ||
int8_t i1 = 2; | ||
int16_t i2 = 3; | ||
int32_t i3 = 4; | ||
int64_t i4 = 5; | ||
|
||
int8_t in1 = -2; | ||
int16_t in2 = -3; | ||
int32_t in3 = -4; | ||
int64_t in4 = -5; | ||
|
||
uint8_t u8 = 'a'; | ||
uint16_t u16 = 8; | ||
uint32_t u32 = 16; | ||
uint64_t u64 = 32; | ||
|
||
void *ptr = malloc(1); | ||
|
||
assert(false); | ||
|
||
return 0; | ||
} |
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,22 @@ | ||
CORE | ||
test.c | ||
--trace --xml-ui | ||
activate-multi-line-match | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
VERIFICATION FAILED | ||
<full_lhs>u8</full_lhs>\s*<full_lhs_value binary="01100001">97</full_lhs_value> | ||
<full_lhs>u16</full_lhs>\s*<full_lhs_value binary="0{12}1000">8</full_lhs_value> | ||
<full_lhs>u32</full_lhs>\s*<full_lhs_value binary="0{27}10000">16ul?</full_lhs_value> | ||
<full_lhs>u64</full_lhs>\s*<full_lhs_value binary="0{58}100000">32ull?</full_lhs_value> | ||
<full_lhs>i1</full_lhs>\s*<full_lhs_value binary="0{6}10">2</full_lhs_value> | ||
<full_lhs>i2</full_lhs>\s*<full_lhs_value binary="0{14}11">3</full_lhs_value> | ||
<full_lhs>i3</full_lhs>\s*<full_lhs_value binary="0{29}100">4</full_lhs_value> | ||
<full_lhs>i4</full_lhs>\s*<full_lhs_value binary="0{61}101">5ll?</full_lhs_value> | ||
<full_lhs>in1</full_lhs>\s*<full_lhs_value binary="1{6}10">-2</full_lhs_value> | ||
<full_lhs>in2</full_lhs>\s*<full_lhs_value binary="1{14}01">-3</full_lhs_value> | ||
<full_lhs>in3</full_lhs>\s*<full_lhs_value binary="1{29}100">-4</full_lhs_value> | ||
<full_lhs>in4</full_lhs>\s*<full_lhs_value binary="1{61}011">-5ll?</full_lhs_value> | ||
-- | ||
-- | ||
Checks that the binary value is printed for integral 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
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 |
---|---|---|
|
@@ -25,31 +25,30 @@ Author: Daniel Kroening | |
#include "structured_trace_util.h" | ||
#include "xml_expr.h" | ||
|
||
bool full_lhs_value_includes_binary( | ||
const goto_trace_stept &step, | ||
const namespacet &ns) | ||
{ | ||
return can_cast_type<floatbv_typet>(step.full_lhs_value.type()); | ||
} | ||
|
||
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"}; | ||
|
||
const auto &lhs_object = step.get_lhs_object(); | ||
const irep_idt identifier = | ||
lhs_object.has_value() ? lhs_object->get_identifier() : irep_idt(); | ||
|
||
if(step.full_lhs_value.is_not_nil()) | ||
full_lhs_value.data = from_expr(ns, identifier, step.full_lhs_value); | ||
if(full_lhs_value_includes_binary(step, ns)) | ||
if(step.full_lhs_value.is_nil()) | ||
return value_xml; | ||
value_xml.data = from_expr(ns, identifier, step.full_lhs_value); | ||
|
||
const auto &bv_type = | ||
type_try_dynamic_cast<bitvector_typet>(step.full_lhs_value.type()); | ||
const auto &constant = | ||
expr_try_dynamic_cast<constant_exprt>(step.full_lhs_value); | ||
if(bv_type && constant) | ||
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. I did like the |
||
{ | ||
const auto width = to_floatbv_type(step.full_lhs_value.type()).get_width(); | ||
const auto binary_representation = integer2binary( | ||
bvrep2integer(step.full_lhs_value.get(ID_value), width, false), width); | ||
full_lhs_value.set_attribute("binary", binary_representation); | ||
const auto width = bv_type->get_width(); | ||
const auto binary_representation = | ||
integer2binary(bvrep2integer(constant->get_value(), width, false), width); | ||
value_xml.set_attribute("binary", binary_representation); | ||
} | ||
return full_lhs_value; | ||
return value_xml; | ||
} | ||
|
||
void convert( | ||
|
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.
I am not sure if I agree with the reasoning of this rename. I’d probably have gone for
full_lhs_value_xml
instead.