@@ -23,14 +23,15 @@ Date: April 2013
23
23
#include < goto-programs/goto_model.h>
24
24
25
25
void show_call_sequences (
26
- const irep_idt &function,
27
- const goto_programt &goto_program,
28
- const goto_programt::const_targett start)
26
+ const irep_idt &caller,
27
+ const goto_programt &goto_program)
29
28
{
30
- std::cout << " # From " << function << ' \n ' ;
31
-
29
+ // show calls in blocks within caller body
30
+ // dfs on code blocks using stack
31
+ std::cout << " # " << caller << ' \n ' ;
32
32
std::stack<goto_programt::const_targett> stack;
33
33
std::set<goto_programt::const_targett> seen;
34
+ const goto_programt::const_targett start=goto_program.instructions .begin ();
34
35
35
36
if (start!=goto_program.instructions .end ())
36
37
stack.push (start);
@@ -42,17 +43,14 @@ void show_call_sequences(
42
43
43
44
if (!seen.insert (t).second )
44
45
continue ; // seen it already
45
-
46
46
if (t->is_function_call ())
47
47
{
48
- const exprt &function2 =to_code_function_call (t->code ).function ();
49
- if (function2 .id ()==ID_symbol)
48
+ const exprt &callee =to_code_function_call (t->code ).function ();
49
+ if (callee .id ()==ID_symbol)
50
50
{
51
- // print pair function, function2
52
- std::cout << function << " -> "
53
- << to_symbol_expr (function2).get_identifier () << ' \n ' ;
51
+ std::cout << caller << " -> "
52
+ << to_symbol_expr (callee).get_identifier () << ' \n ' ;
54
53
}
55
- continue ; // abort search
56
54
}
57
55
58
56
// get successors and add to stack
@@ -61,47 +59,13 @@ void show_call_sequences(
61
59
stack.push (it);
62
60
}
63
61
}
64
- }
65
-
66
- void show_call_sequences (
67
- const irep_idt &function,
68
- const goto_programt &goto_program)
69
- {
70
- // this is quadratic
71
-
72
- std::cout << " # " << function << ' \n ' ;
73
-
74
- show_call_sequences (
75
- function,
76
- goto_program,
77
- goto_program.instructions .begin ());
78
-
79
- forall_goto_program_instructions (i_it, goto_program)
80
- {
81
- if (!i_it->is_function_call ())
82
- continue ;
83
-
84
- const exprt &f1=to_code_function_call (i_it->code ).function ();
85
-
86
- if (f1.id ()!=ID_symbol)
87
- continue ;
88
-
89
- // find any calls reachable from this one
90
- goto_programt::const_targett next=i_it;
91
- next++;
92
-
93
- show_call_sequences (
94
- to_symbol_expr (f1).get_identifier (),
95
- goto_program,
96
- next);
97
- }
98
-
99
62
std::cout << ' \n ' ;
100
63
}
101
64
102
65
void show_call_sequences (const goto_modelt &goto_model)
103
66
{
104
67
// do per function
68
+ // show the calls in the body of the specific function
105
69
106
70
forall_goto_functions (f_it, goto_model.goto_functions )
107
71
show_call_sequences (f_it->first , f_it->second .body );
0 commit comments