@@ -131,24 +131,34 @@ void goto_trace_stept::output(
131
131
// / \return a string with the numeric representation
132
132
static std::string numeric_representation (
133
133
const constant_exprt &expr,
134
+ const namespacet &ns,
134
135
const trace_optionst &options)
135
136
{
136
137
std::string result;
137
138
std::string prefix;
138
139
140
+ const typet &expr_type = expr.type ();
141
+
142
+ const typet &underlying_type =
143
+ expr_type.id () == ID_c_enum_tag
144
+ ? ns.follow_tag (to_c_enum_tag_type (expr_type)).subtype ()
145
+ : expr_type;
146
+
139
147
const irep_idt &value = expr.get_value ();
140
148
149
+ const auto width = to_bitvector_type (underlying_type).get_width ();
150
+
151
+ const mp_integer value_int = bvrep2integer (id2string (value), width, false );
152
+
141
153
if (options.hex_representation )
142
154
{
143
- const mp_integer value_int =
144
- bvrep2integer (to_constant_expr (expr).get_value (), value.size (), false );
145
155
result = integer2string (value_int, 16 );
146
156
prefix = " 0x" ;
147
157
}
148
158
else
149
159
{
160
+ result = integer2binary (value_int, width);
150
161
prefix = " 0b" ;
151
- result = id2string (value);
152
162
}
153
163
154
164
std::ostringstream oss;
@@ -185,9 +195,7 @@ std::string trace_numeric_value(
185
195
type.id ()==ID_c_enum ||
186
196
type.id ()==ID_c_enum_tag)
187
197
{
188
- const std::string &str =
189
- numeric_representation (to_constant_expr (expr), options);
190
- return str;
198
+ return numeric_representation (to_constant_expr (expr), ns, options);
191
199
}
192
200
else if (type.id ()==ID_bool)
193
201
{
0 commit comments