Skip to content

Commit 73d688d

Browse files
author
Daniel Kroening
authored
Merge pull request diffblue#2270 from peterschrammel/fix-stub-identifiers
Prefix identifiers in stubs with function name
2 parents 13a1afc + 9e9f251 commit 73d688d

File tree

8 files changed

+75
-5
lines changed

8 files changed

+75
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
public class Opaque extends Exception
2+
{
3+
public static Opaque static_field;
4+
public Opaque field;
5+
6+
public Opaque(Opaque o) {
7+
}
8+
9+
public static Opaque static_method(Opaque o) {
10+
return o;
11+
}
12+
13+
public Opaque[] method(Opaque[] o) {
14+
return o;
15+
}
16+
}
635 Bytes
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
public class Test
2+
{
3+
public static void f00(Opaque z)
4+
{
5+
try {
6+
Opaque x = new Opaque(Opaque.static_field);
7+
Opaque[] a = {Opaque.static_method(x.field), z};
8+
Opaque[] y = x.method(a);
9+
throw y[0];
10+
} catch(Opaque o) {
11+
}
12+
}
13+
public Opaque f01(Opaque z)
14+
{
15+
try {
16+
Opaque x = new Opaque(Opaque.static_field);
17+
Opaque[] a = {Opaque.static_method(x.field), z};
18+
Opaque[] y = x.method(a);
19+
throw y[0];
20+
} catch(Opaque o) {
21+
return o;
22+
}
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
CORE symex-driven-lazy-loading-expected-failure
2+
Test.class
3+
--show-symbol-table
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^Symbol\.*: java::Opaque\.static_method:\(LOpaque;\)LOpaque;::malloc_site\$[0-3]?$
7+
^Symbol\.*: java::Opaque\.method:\(\[LOpaque;\)\[LOpaque;::malloc_site\$[0-3]?$
8+
--
9+
^Symbol\.*: malloc_site
10+
^Symbol\.*: to_construct
11+
^Symbol\.*: to_return
12+
^Symbol\.*: this
13+
^Symbol\.*: caught_exception
14+
^Symbol\.*: anonlocal
15+
^Symbol\.*: stub_ignored_arg
16+
^Symbol\.*: #return_value
17+
^Symbol\.*: return_tmp
18+
^Symbol\.*: new_tmp
19+
^Symbol\.*: tmp_new_data_array
20+
^Symbol\.*: newarray_tmp
21+
--
22+
Does not work with symex-driven lazy loading because we want to check the
23+
symbol table for the entire program.

jbmc/src/java_bytecode/java_entry_point.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,14 @@ static void java_static_lifetime_init(
119119
symbol_table_baset &symbol_table,
120120
const source_locationt &source_location,
121121
bool assume_init_pointers_not_null,
122-
const object_factory_parameterst &object_factory_parameters,
122+
object_factory_parameterst object_factory_parameters,
123123
const select_pointer_typet &pointer_type_selector,
124124
bool string_refinement_enabled,
125125
message_handlert &message_handler)
126126
{
127127
symbolt &initialize_symbol=*symbol_table.get_writeable(INITIALIZE_FUNCTION);
128128
code_blockt &code_block=to_code_block(to_code(initialize_symbol.value));
129+
object_factory_parameters.function_id = initialize_symbol.name;
129130

130131
// We need to zero out all static variables, or nondet-initialize if they're
131132
// external. Iterate over a copy of the symtab, as its iterators are

jbmc/src/java_bytecode/java_object_factory.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1471,7 +1471,7 @@ exprt object_factory(
14711471
const irep_idt base_name,
14721472
code_blockt &init_code,
14731473
symbol_table_baset &symbol_table,
1474-
const object_factory_parameterst &parameters,
1474+
object_factory_parameterst parameters,
14751475
allocation_typet alloc_type,
14761476
const source_locationt &loc,
14771477
const select_pointer_typet &pointer_type_selector)
@@ -1486,6 +1486,7 @@ exprt object_factory(
14861486
main_symbol.base_name=base_name;
14871487
main_symbol.type=type;
14881488
main_symbol.location=loc;
1489+
parameters.function_id = goto_functionst::entry_point();
14891490

14901491
exprt object=main_symbol.symbol_expr();
14911492

jbmc/src/java_bytecode/java_object_factory.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ exprt object_factory(
9191
const irep_idt base_name,
9292
code_blockt &init_code,
9393
symbol_table_baset &symbol_table,
94-
const object_factory_parameterst &parameters,
94+
object_factory_parameterst parameters,
9595
allocation_typet alloc_type,
9696
const source_locationt &location,
9797
const select_pointer_typet &pointer_type_selector);

jbmc/src/java_bytecode/simple_method_stubbing.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class java_simple_method_stubst
3939
const typet &expected_type,
4040
const exprt &ptr,
4141
const source_locationt &loc,
42+
const irep_idt &function_id,
4243
code_blockt &parent_block,
4344
unsigned insert_before_index,
4445
bool is_constructor,
@@ -77,6 +78,7 @@ void java_simple_method_stubst::create_method_stub_at(
7778
const typet &expected_type,
7879
const exprt &ptr,
7980
const source_locationt &loc,
81+
const irep_idt &function_id,
8082
code_blockt &parent_block,
8183
const unsigned insert_before_index,
8284
const bool is_constructor,
@@ -112,6 +114,7 @@ void java_simple_method_stubst::create_method_stub_at(
112114

113115
// Generate new instructions.
114116
code_blockt new_instructions;
117+
parameters.function_id = function_id;
115118
gen_nondet_init(
116119
to_init,
117120
new_instructions,
@@ -158,7 +161,7 @@ void java_simple_method_stubst::create_method_stub(symbolt &symbol)
158161
const typet &this_type = this_argument.type();
159162
symbolt &init_symbol = get_fresh_aux_symbol(
160163
this_type,
161-
"to_construct",
164+
id2string(symbol.name),
162165
"to_construct",
163166
synthesized_source_location,
164167
ID_java,
@@ -172,6 +175,7 @@ void java_simple_method_stubst::create_method_stub(symbolt &symbol)
172175
this_type,
173176
init_symbol_expression,
174177
synthesized_source_location,
178+
symbol.name,
175179
new_instructions,
176180
1,
177181
true,
@@ -184,7 +188,7 @@ void java_simple_method_stubst::create_method_stub(symbolt &symbol)
184188
{
185189
symbolt &to_return_symbol = get_fresh_aux_symbol(
186190
required_return_type,
187-
"to_return",
191+
id2string(symbol.name),
188192
"to_return",
189193
synthesized_source_location,
190194
ID_java,
@@ -211,6 +215,7 @@ void java_simple_method_stubst::create_method_stub(symbolt &symbol)
211215
required_return_type,
212216
to_return,
213217
synthesized_source_location,
218+
symbol.name,
214219
new_instructions,
215220
0,
216221
false,

0 commit comments

Comments
 (0)