Skip to content

Commit 5f68f70

Browse files
Merge pull request #4480 from peterschrammel/byte-extract-lhs-object
Get lhs_object from byte_extract for goto trace
2 parents b2d0d2c + 60b5328 commit 5f68f70

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

regression/cbmc/xml-trace/main.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <assert.h>
2+
#include <stdint.h>
3+
4+
union myunion {
5+
int64_t i;
6+
double d;
7+
};
8+
9+
void test(union myunion u)
10+
{
11+
u.i += 1;
12+
double d = u.d;
13+
assert(d != 5);
14+
}

regression/cbmc/xml-trace/test.desc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
CORE broken-smt-backend
2+
main.c
3+
--xml-ui --function test --little-endian
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
VERIFICATION FAILED
7+
<assignment assignment_type="state" base_name="u" display_name="test::u" hidden="false" identifier="test::u" mode="C" step_nr="\d+" thread="0">
8+
<location file=".*" function="test" line="\d+" working-directory=".*"/>
9+
<type>union myunion</type>
10+
<full_lhs>byte_extract_little_endian\(u, 0ll?, .*int.*\)</full_lhs>
11+
<full_lhs_value>\d+ll?</full_lhs_value>
12+
<value>\{ \.i=\d+ll? \}</value>
13+
<value_expression>
14+
<union>
15+
<member member_name="i">
16+
<integer binary="\d+" c_type=".*int.*" width="\d+">\d+</integer>
17+
</member>
18+
</union>
19+
</value_expression>
20+
</assignment>
21+
--
22+
^warning: ignoring
23+
--
24+
Tests whether the assignment XML output contains all the required elements
25+
such as identifier, full_lhs, full_lhs_value and value.

src/goto-programs/goto_trace.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Author: Daniel Kroening
1616
#include <ostream>
1717

1818
#include <util/arith_tools.h>
19+
#include <util/byte_operators.h>
1920
#include <util/format_expr.h>
2021
#include <util/range.h>
2122
#include <util/string_utils.h>
@@ -35,6 +36,12 @@ static optionalt<symbol_exprt> get_object_rec(const exprt &src)
3536
return get_object_rec(to_index_expr(src).array());
3637
else if(src.id()==ID_typecast)
3738
return get_object_rec(to_typecast_expr(src).op());
39+
else if(
40+
src.id() == ID_byte_extract_little_endian ||
41+
src.id() == ID_byte_extract_big_endian)
42+
{
43+
return get_object_rec(to_byte_extract_expr(src).op());
44+
}
3845
else
3946
return {}; // give up
4047
}

0 commit comments

Comments
 (0)