Skip to content

Commit 19fc2a0

Browse files
committed
tmp debugging code
1 parent 4411f63 commit 19fc2a0

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/analyses/call_graph_helpers.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,30 @@ std::set<irep_idt> get_reaching_functions(
7171
return get_connected_functions(graph, function, false);
7272
}
7373

74+
#include <iostream>
7475
std::set<irep_idt> get_functions_reachable_within_n_steps(
7576
const call_grapht::directed_grapht &graph,
7677
const irep_idt &start_function,
7778
std::size_t n)
7879
{
7980
std::set<irep_idt> result;
81+
std::cout<<"GRAPH:\n";
82+
graph.output_dot(std::cout);
83+
std::cout<<"REACHABLE: ";
84+
8085

8186
if(auto start_idx = graph.get_node_index(start_function))
8287
{
8388
for(const auto &index : graph.depth_limited_search(*start_idx, n))
89+
{
8490
result.insert(graph[index].function);
91+
std::cout<<index<<" ";
92+
}
93+
std::cout<<std::endl;
8594
}
8695
else
8796
throw "unknown start function";
8897

98+
8999
return result;
90100
}

unit/analyses/call_graph.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,26 +225,30 @@ SCENARIO("call_graph",
225225

226226
THEN("We expect {A,B} to be reachable from {A} in 1 step")
227227
{
228+
call_graph_from_goto_functions.output(std::cout);
229+
exported.output_dot(std::cout);
228230
irep_idt function_name = "A";
229231
std::size_t depth = 1;
232+
std::cout<<"functions reachable within 1 step from A\n";
230233
std::set<irep_idt> reachable = get_functions_reachable_within_n_steps(
231234
exported, function_name, depth);
232235
REQUIRE(reachable.size() == 2);
233236
REQUIRE(reachable.count("A"));
234237
REQUIRE(reachable.count("B"));
235238
}
236-
THEN("We expect {A,B,C,D} to be reachable from {A} in 2 and 3 steps")
239+
THEN("We expect {B,C,D} to be reachable from {A} in 2 and 3 steps")
237240
{
238241
irep_idt function_name = "A";
239242
std::size_t depth = 2;
243+
std::cout<<"functions reachable within 2 steps from A\n";
240244
std::set<irep_idt> reachable = get_functions_reachable_within_n_steps(
241245
exported, function_name, depth);
242246
REQUIRE(reachable.size() == 4);
243247
REQUIRE(reachable.count("A"));
244248
REQUIRE(reachable.count("B"));
245249
REQUIRE(reachable.count("C"));
246250
REQUIRE(reachable.count("D"));
247-
251+
std::cout<<"functions reachable within 3 steps from A\n";
248252
depth = 3;
249253
reachable = get_functions_reachable_within_n_steps(
250254
exported, function_name, depth);
@@ -257,6 +261,7 @@ SCENARIO("call_graph",
257261

258262
THEN("We expect nothing to be reachable in 0 steps")
259263
{
264+
std::cout<<"functions reachable within 0 steps from A\n";
260265
irep_idt function_name = "A";
261266
std::size_t depth = 0;
262267
std::set<irep_idt> reachable = get_functions_reachable_within_n_steps(

0 commit comments

Comments
 (0)