Skip to content

Commit acdc797

Browse files
committed
Symex: output instruction processing and loop unwinding like CBMC
Unlike CBMC, all output is enabled in debug mode only.
1 parent c69a21b commit acdc797

File tree

2 files changed

+55
-2
lines changed

2 files changed

+55
-2
lines changed

src/symex/path_search.cpp

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,19 @@ bool path_searcht::drop_state(const statet &state)
267267
{
268268
goto_programt::const_targett pc=state.get_instruction();
269269

270+
const source_locationt &source_location=pc->source_location;
271+
272+
if(!source_location.is_nil() &&
273+
last_source_location!=source_location)
274+
{
275+
debug() << "SYMEX at file " << source_location.get_file()
276+
<< " line " << source_location.get_line()
277+
<< " function " << source_location.get_function()
278+
<< eom;
279+
280+
last_source_location=source_location;
281+
}
282+
270283
// depth limit
271284
if(depth_limit_set && state.get_depth()>depth_limit)
272285
return true;
@@ -282,17 +295,55 @@ bool path_searcht::drop_state(const statet &state)
282295
// unwinding limit -- loops
283296
if(unwind_limit_set && state.get_instruction()->is_backwards_goto())
284297
{
298+
bool stop=false;
299+
285300
for(const auto &loop_info : state.unwinding_map)
286301
if(loop_info.second>unwind_limit)
287-
return true;
302+
{
303+
stop=true;
304+
break;
305+
}
306+
307+
const irep_idt id=goto_programt::loop_id(pc);
308+
path_symex_statet::unwinding_mapt::const_iterator entry=
309+
state.unwinding_map.find(state.pc());
310+
debug() << (stop?"Not unwinding":"Unwinding")
311+
<< " loop " << id << " iteration "
312+
<< (entry==state.unwinding_map.end()?-1:entry->second)
313+
<< " (" << unwind_limit << " max)"
314+
<< " " << source_location
315+
<< " thread " << state.get_current_thread() << eom;
316+
317+
if(stop)
318+
return true;
288319
}
289320

290321
// unwinding limit -- recursion
291322
if(unwind_limit_set && state.get_instruction()->is_function_call())
292323
{
324+
bool stop=false;
325+
293326
for(const auto &rec_info : state.recursion_map)
294327
if(rec_info.second>unwind_limit)
295-
return true;
328+
{
329+
stop=true;
330+
break;
331+
}
332+
333+
exprt function=to_code_function_call(pc->code).function();
334+
const irep_idt id=function.get(ID_identifier); // could be nil
335+
path_symex_statet::recursion_mapt::const_iterator entry=
336+
state.recursion_map.find(id);
337+
if(entry!=state.recursion_map.end())
338+
debug() << (stop?"Not unwinding":"Unwinding")
339+
<< " recursion " << id << " iteration "
340+
<< entry->second
341+
<< " (" << unwind_limit << " max)"
342+
<< " " << source_location
343+
<< " thread " << state.get_current_thread() << eom;
344+
345+
if(stop)
346+
return true;
296347
}
297348

298349
if(pc->is_assume() &&

src/symex/path_search.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ class path_searcht:public safety_checkert
137137
bool depth_limit_set, context_bound_set, unwind_limit_set, branch_bound_set;
138138

139139
enum class search_heuristict { DFS, BFS, LOCS } search_heuristic;
140+
141+
source_locationt last_source_location;
140142
};
141143

142144
#endif // CPROVER_SYMEX_PATH_SEARCH_H

0 commit comments

Comments
 (0)