Skip to content

Commit 927e48c

Browse files
Merge pull request #958 from thk123/bugfix/trace-missing-class-info
Bugfix/trace missing class info
2 parents a54d806 + 575b343 commit 927e48c

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
public class TestGenTest
2+
{
3+
public void f()
4+
{
5+
int a = 4;
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
TestGenTest.class
3+
--function TestGenTest.f --trace --cover location --json-ui
4+
"data": "java::TestGenTest",$
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring

src/util/json_expr.cpp

+12-6
Original file line numberDiff line numberDiff line change
@@ -243,14 +243,15 @@ json_objectt json(
243243

244244
if(expr.id()==ID_constant)
245245
{
246+
const constant_exprt &constant_expr=to_constant_expr(expr);
246247
if(type.id()==ID_unsignedbv ||
247248
type.id()==ID_signedbv ||
248249
type.id()==ID_c_bit_field)
249250
{
250251
std::size_t width=to_bitvector_type(type).get_width();
251252

252253
result["name"]=json_stringt("integer");
253-
result["binary"]=json_stringt(expr.get_string(ID_value));
254+
result["binary"]=json_stringt(id2string(constant_expr.get_value()));
254255
result["width"]=json_numbert(std::to_string(width));
255256

256257
const typet &underlying_type=
@@ -279,7 +280,7 @@ json_objectt json(
279280
else if(type.id()==ID_c_enum)
280281
{
281282
result["name"]=json_stringt("integer");
282-
result["binary"]=json_stringt(expr.get_string(ID_value));
283+
result["binary"]=json_stringt(id2string(constant_expr.get_value()));
283284
result["width"]=json_numbert(type.subtype().get_string(ID_width));
284285
result["c_type"]=json_stringt("enum");
285286

@@ -291,27 +292,27 @@ json_objectt json(
291292
{
292293
constant_exprt tmp;
293294
tmp.type()=ns.follow_tag(to_c_enum_tag_type(type));
294-
tmp.set_value(to_constant_expr(expr).get_value());
295+
tmp.set_value(constant_expr.get_value());
295296
return json(tmp, ns);
296297
}
297298
else if(type.id()==ID_bv)
298299
{
299300
result["name"]=json_stringt("bitvector");
300-
result["binary"]=json_stringt(expr.get_string(ID_value));
301+
result["binary"]=json_stringt(id2string(constant_expr.get_value()));
301302
}
302303
else if(type.id()==ID_fixedbv)
303304
{
304305
result["name"]=json_stringt("fixed");
305306
result["width"]=json_numbert(type.get_string(ID_width));
306-
result["binary"]=json_stringt(expr.get_string(ID_value));
307+
result["binary"]=json_stringt(id2string(constant_expr.get_value()));
307308
result["data"]=
308309
json_stringt(fixedbvt(to_constant_expr(expr)).to_ansi_c_string());
309310
}
310311
else if(type.id()==ID_floatbv)
311312
{
312313
result["name"]=json_stringt("float");
313314
result["width"]=json_numbert(type.get_string(ID_width));
314-
result["binary"]=json_stringt(expr.get_string(ID_value));
315+
result["binary"]=json_stringt(id2string(constant_expr.get_value()));
315316
result["data"]=
316317
json_stringt(ieee_floatt(to_constant_expr(expr)).to_ansi_c_string());
317318
}
@@ -347,6 +348,11 @@ json_objectt json(
347348
to_integer(to_constant_expr(expr), b);
348349
result["data"]=json_stringt(integer2string(b));
349350
}
351+
else if(type.id()==ID_string)
352+
{
353+
result["name"]=json_stringt("string");
354+
result["data"]=json_stringt(id2string(constant_expr.get_value()));
355+
}
350356
else
351357
{
352358
result["name"]=json_stringt("unknown");

0 commit comments

Comments
 (0)