@@ -21,14 +21,15 @@ Date: April 2013
2121#include < util/simplify_expr.h>
2222
2323void show_call_sequences (
24- const irep_idt &function,
25- const goto_programt &goto_program,
26- const goto_programt::const_targett start)
24+ const irep_idt &caller,
25+ const goto_programt &goto_program)
2726{
28- std::cout << " # From " << function << ' \n ' ;
29-
27+ // show calls in blocks within caller body
28+ // dfs on code blocks using stack
29+ std::cout << " # " << caller << ' \n ' ;
3030 std::stack<goto_programt::const_targett> stack;
3131 std::set<goto_programt::const_targett> seen;
32+ const goto_programt::const_targett start=goto_program.instructions .begin ();
3233
3334 if (start!=goto_program.instructions .end ())
3435 stack.push (start);
@@ -40,17 +41,14 @@ void show_call_sequences(
4041
4142 if (!seen.insert (t).second )
4243 continue ; // seen it already
43-
4444 if (t->is_function_call ())
4545 {
46- const exprt &function2 =to_code_function_call (t->code ).function ();
47- if (function2 .id ()==ID_symbol)
46+ const exprt &callee =to_code_function_call (t->code ).function ();
47+ if (callee .id ()==ID_symbol)
4848 {
49- // print pair function, function2
50- std::cout << function << " -> "
51- << to_symbol_expr (function2).get_identifier () << ' \n ' ;
49+ std::cout << caller << " -> "
50+ << to_symbol_expr (callee).get_identifier () << ' \n ' ;
5251 }
53- continue ; // abort search
5452 }
5553
5654 // get successors and add to stack
@@ -59,52 +57,16 @@ void show_call_sequences(
5957 stack.push (it);
6058 }
6159 }
62- }
63-
64- void show_call_sequences (
65- const irep_idt &function,
66- const goto_programt &goto_program)
67- {
68- // this is quadratic
69-
70- std::cout << " # " << function << ' \n ' ;
71-
72- show_call_sequences (
73- function,
74- goto_program,
75- goto_program.instructions .begin ());
76-
77- forall_goto_program_instructions (i_it, goto_program)
78- {
79- if (!i_it->is_function_call ())
80- continue ;
81-
82- const exprt &f1=to_code_function_call (i_it->code ).function ();
83-
84- if (f1.id ()!=ID_symbol)
85- continue ;
86-
87- // find any calls reachable from this one
88- goto_programt::const_targett next=i_it;
89- next++;
90-
91- show_call_sequences (
92- to_symbol_expr (f1).get_identifier (),
93- goto_program,
94- next);
95- }
96-
9760 std::cout << ' \n ' ;
9861}
99-
10062void show_call_sequences (const goto_functionst &goto_functions)
10163{
10264 // do per function
103-
65+ // show the calls in the body of the specific function
10466 forall_goto_functions (f_it, goto_functions)
10567 show_call_sequences (f_it->first , f_it->second .body );
106- }
10768
69+ }
10870class check_call_sequencet
10971{
11072public:
0 commit comments