File tree 4 files changed +65
-6
lines changed
regression/goto-instrument/assembly_call_graph_test 4 files changed +65
-6
lines changed Original file line number Diff line number Diff line change
1
+ #ifdef SATABS
2
+ #define assert (e ) __CPROVER_assert(e,"error")
3
+ #endif
4
+
5
+ volatile int turn ; // integer variable to hold the ID of the thread whose turn is it
6
+ int x ; // variable to test mutual exclusion
7
+ volatile int flag1 = 0 , flag2 = 0 ; // boolean flags
8
+
9
+ void * thr1 (void * arg ) { // frontend produces 12 transitions from this thread. It would be better if it would produce only 8!
10
+ flag1 = 1 ;
11
+ turn = 1 ;
12
+ __asm__ __volatile__ ("mfence" : : :"memory" );
13
+ __CPROVER_assume (! (flag2 == 1 && turn == 1 ) );
14
+ // begin: critical section
15
+ x = 0 ;
16
+ assert (x <=0 );
17
+ // end: critical section
18
+ flag1 = 0 ;
19
+ }
20
+
21
+ void * thr2 (void * arg ) {
22
+ flag2 = 1 ;
23
+ turn = 0 ;
24
+ __asm__ __volatile__ ("mfence" : : :"memory" );
25
+ __CPROVER_assume (! (flag1 == 1 && turn == 0 ) );
26
+ // begin: critical section
27
+ x = 1 ;
28
+ assert (x >=1 );
29
+ // end: critical section
30
+ flag2 = 0 ;
31
+ }
32
+
33
+ int main ()
34
+ {
35
+ __CPROVER_ASYNC_1 : thr1 (0 );
36
+ thr2 (0 );
37
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --reachable-call-graph
4
+ main -> thr1
5
+ main -> thr2
6
+ __CPROVER__start -> __CPROVER_initialize
7
+ __CPROVER__start -> main
8
+ thr1 -> __asm_mfence
9
+ thr2 -> __asm_mfence
10
+ ^EXIT=0$
11
+ ^SIGNAL=0$
12
+ --
13
+ ^warning: ignoring
Original file line number Diff line number Diff line change @@ -84,11 +84,16 @@ call_grapht::call_grapht(
84
84
{
85
85
irep_idt function=pending_stack.top ();
86
86
pending_stack.pop ();
87
- const goto_programt &goto_program=
88
- goto_functions.function_map .at (function).body ;
89
87
90
88
nodes.insert (function);
91
89
90
+ // if function is not in function_map, assume function has no body
91
+ const auto &it = goto_functions.function_map .find (function);
92
+ if (it == goto_functions.function_map .end ())
93
+ continue ;
94
+
95
+ const goto_programt &goto_program = it->second .body ;
96
+
92
97
forall_callsites (
93
98
goto_program,
94
99
[&](goto_programt::const_targett i_it, const irep_idt &callee)
Original file line number Diff line number Diff line change @@ -52,13 +52,17 @@ void slice_global_inits(goto_modelt &goto_model)
52
52
const irep_idt &id = directed_graph[node_idx].function ;
53
53
if (id == INITIALIZE_FUNCTION)
54
54
continue ;
55
- const goto_functionst::goto_functiont &goto_function
56
- =goto_functions.function_map .at (id);
57
- const goto_programt &goto_program=goto_function.body ;
55
+
56
+ // assume function has no body if it is not in the function map
57
+ const auto &it = goto_functions.function_map .find (id);
58
+ if (it == goto_functions.function_map .end ())
59
+ continue ;
60
+
61
+ const goto_programt &goto_program = it->second .body ;
58
62
59
63
forall_goto_program_instructions (i_it, goto_program)
60
64
{
61
- const codet &code= i_it->code ;
65
+ const codet &code = i_it->code ;
62
66
find_symbols (code, symbols, true , false );
63
67
const exprt &expr = i_it->guard ;
64
68
find_symbols (expr, symbols, true , false );
You can’t perform that action at this time.
0 commit comments