@@ -25,31 +25,34 @@ Author: Daniel Kroening
2525#include " structured_trace_util.h"
2626#include " xml_expr.h"
2727
28- bool full_lhs_value_includes_binary (
29- const goto_trace_stept &step,
30- const namespacet &ns)
31- {
32- return can_cast_type<floatbv_typet>(step.full_lhs_value .type ());
33- }
34-
3528xmlt full_lhs_value (const goto_trace_stept &step, const namespacet &ns)
3629{
37- xmlt full_lhs_value{" full_lhs_value" };
30+ xmlt value_xml{" full_lhs_value" };
31+
32+ const exprt &value = step.full_lhs_value ;
33+ if (value.is_nil ())
34+ return value_xml;
3835
3936 const auto &lhs_object = step.get_lhs_object ();
4037 const irep_idt identifier =
4138 lhs_object.has_value () ? lhs_object->get_identifier () : irep_idt ();
39+ value_xml.data = from_expr (ns, identifier, value);
4240
43- if (step. full_lhs_value . is_not_nil ())
44- full_lhs_value. data = from_expr (ns, identifier, step. full_lhs_value );
45- if (full_lhs_value_includes_binary (step, ns) )
41+ const auto &bv_type = type_try_dynamic_cast<bitvector_typet>(value. type ());
42+ const auto &constant = expr_try_dynamic_cast<constant_exprt>(value );
43+ if (bv_type && constant )
4644 {
47- const auto width = to_floatbv_type (step.full_lhs_value .type ()).get_width ();
48- const auto binary_representation = integer2binary (
49- bvrep2integer (step.full_lhs_value .get (ID_value), width, false ), width);
50- full_lhs_value.set_attribute (" binary" , binary_representation);
45+ const auto width = bv_type->get_width ();
46+ // It is fine to pass `false` into the `is_signed` parameter, even for
47+ // signed values, because the subsequent conversion to binary will result
48+ // in the same value either way. E.g. if the value is `-1` for a signed 8
49+ // bit value, this will convert to `255` which is `11111111` in binary,
50+ // which is the desired result.
51+ const auto binary_representation =
52+ integer2binary (bvrep2integer (constant->get_value (), width, false ), width);
53+ value_xml.set_attribute (" binary" , binary_representation);
5154 }
52- return full_lhs_value ;
55+ return value_xml ;
5356}
5457
5558void convert (
0 commit comments