@@ -25,7 +25,7 @@ Author: Daniel Kroening, kroening@kroening.com
2525
2626#include < goto-programs/xml_goto_trace.h>
2727#include < goto-programs/json_goto_trace.h>
28- #include < goto-programs/graphml_goto_trace .h>
28+ #include < goto-programs/graphml_witness .h>
2929
3030#include < goto-symex/build_goto_trace.h>
3131#include < goto-symex/slice.h>
@@ -106,20 +106,40 @@ void bmct::error_trace()
106106 }
107107 break ;
108108 }
109+ }
109110
110- const std::string graphml=options.get_option (" graphml-cex" );
111- if (!graphml.empty ())
112- {
113- graphmlt cex_graph;
114- convert (ns, goto_trace, cex_graph);
111+ /* ******************************************************************\
115112
116- if (graphml==" -" )
117- write_graphml (cex_graph, std::cout);
118- else
119- {
120- std::ofstream out (graphml);
121- write_graphml (cex_graph, out);
122- }
113+ Function: bmct::output_graphml
114+
115+ Inputs:
116+
117+ Outputs:
118+
119+ Purpose: outputs witnesses in graphml format
120+
121+ \*******************************************************************/
122+
123+ void bmct::output_graphml (
124+ resultt result,
125+ const goto_functionst &goto_functions)
126+ {
127+ const std::string graphml=options.get_option (" graphml-witness" );
128+ if (graphml.empty ())
129+ return ;
130+
131+ graphml_witnesst graphml_witness (ns);
132+ if (result==UNSAFE)
133+ graphml_witness (safety_checkert::error_trace);
134+ else
135+ return ;
136+
137+ if (graphml==" -" )
138+ write_graphml (graphml_witness.graph (), std::cout);
139+ else
140+ {
141+ std::ofstream out (graphml);
142+ write_graphml (graphml_witness.graph (), out);
123143 }
124144}
125145
@@ -294,79 +314,77 @@ void bmct::show_program()
294314
295315 std::cout << " \n " << " Program constraints:" << " \n " ;
296316
297- for (symex_target_equationt::SSA_stepst::const_iterator
298- it=equation.SSA_steps .begin ();
299- it!=equation.SSA_steps .end (); it++)
317+ for (const auto &step : equation.SSA_steps )
300318 {
301- std::cout << " // " << it-> source .pc ->location_number << " " ;
302- std::cout << it-> source .pc ->source_location .as_string () << " \n " ;
319+ std::cout << " // " << step. source .pc ->location_number << " " ;
320+ std::cout << step. source .pc ->source_location .as_string () << " \n " ;
303321
304- if (it-> is_assignment ())
322+ if (step. is_assignment ())
305323 {
306324 std::string string_value;
307- languages.from_expr (it-> cond_expr , string_value);
325+ languages.from_expr (step. cond_expr , string_value);
308326 std::cout << " (" << count << " ) " << string_value << " \n " ;
309327
310- if (!it-> guard .is_true ())
328+ if (!step. guard .is_true ())
311329 {
312- languages.from_expr (it-> guard , string_value);
330+ languages.from_expr (step. guard , string_value);
313331 std::cout << std::string (i2string (count).size ()+3 , ' ' );
314332 std::cout << " guard: " << string_value << " \n " ;
315333 }
316334
317335 count++;
318336 }
319- else if (it-> is_assert ())
337+ else if (step. is_assert ())
320338 {
321339 std::string string_value;
322- languages.from_expr (it-> cond_expr , string_value);
340+ languages.from_expr (step. cond_expr , string_value);
323341 std::cout << " (" << count << " ) ASSERT("
324342 << string_value <<" ) " << " \n " ;
325343
326- if (!it-> guard .is_true ())
344+ if (!step. guard .is_true ())
327345 {
328- languages.from_expr (it-> guard , string_value);
346+ languages.from_expr (step. guard , string_value);
329347 std::cout << std::string (i2string (count).size ()+3 , ' ' );
330348 std::cout << " guard: " << string_value << " \n " ;
331349 }
332350
333351 count++;
334352 }
335- else if (it-> is_assume ())
353+ else if (step. is_assume ())
336354 {
337355 std::string string_value;
338- languages.from_expr (it-> cond_expr , string_value);
356+ languages.from_expr (step. cond_expr , string_value);
339357 std::cout << " (" << count << " ) ASSUME("
340358 << string_value <<" ) " << " \n " ;
341359
342- if (!it-> guard .is_true ())
360+ if (!step. guard .is_true ())
343361 {
344- languages.from_expr (it-> guard , string_value);
362+ languages.from_expr (step. guard , string_value);
345363 std::cout << std::string (i2string (count).size ()+3 , ' ' );
346364 std::cout << " guard: " << string_value << " \n " ;
347365 }
348366
349367 count++;
350368 }
351- else if (it-> is_constraint ())
369+ else if (step. is_constraint ())
352370 {
353371 std::string string_value;
354- languages.from_expr (it-> cond_expr , string_value);
372+ languages.from_expr (step. cond_expr , string_value);
355373 std::cout << " (" << count << " ) CONSTRAINT("
356374 << string_value <<" ) " << " \n " ;
357375
358376 count++;
359377 }
360- else if (it-> is_shared_read () || it-> is_shared_write ())
378+ else if (step. is_shared_read () || step. is_shared_write ())
361379 {
362380 std::string string_value;
363- languages.from_expr (it-> ssa_lhs , string_value);
364- std::cout << " (" << count << " ) SHARED_" << (it-> is_shared_write ()?" WRITE" :" READ" ) << " ("
381+ languages.from_expr (step. ssa_lhs , string_value);
382+ std::cout << " (" << count << " ) SHARED_" << (step. is_shared_write ()?" WRITE" :" READ" ) << " ("
365383 << string_value <<" ) " << " \n " ;
366384
367- if (!it-> guard .is_true ())
385+ if (!step. guard .is_true ())
368386 {
369- languages.from_expr (it-> guard , string_value);
387+ languages.from_expr (step. guard , string_value);
370388 std::cout << std::string (i2string (count).size ()+3 , ' ' );
371389 std::cout << " guard: " << string_value << " \n " ;
372390 }
@@ -611,6 +629,7 @@ safety_checkert::resultt bmct::stop_on_fail(
611629 dynamic_cast <bv_cbmct &>(prop_conv), equation, ns);
612630
613631 error_trace ();
632+ output_graphml (UNSAFE, goto_functions);
614633 }
615634
616635 report_failure ();
0 commit comments