|
25 | 25 |
|
26 | 26 | #include <goto-programs/xml_goto_trace.h>
|
27 | 27 | #include <goto-programs/json_goto_trace.h>
|
28 |
| -#include <goto-programs/graphml_goto_trace.h> |
| 28 | +#include <goto-programs/graphml_witness.h> |
29 | 29 |
|
30 | 30 | #include <goto-symex/build_goto_trace.h>
|
31 | 31 | #include <goto-symex/slice.h>
|
@@ -106,20 +106,40 @@ void bmct::error_trace()
|
106 | 106 | }
|
107 | 107 | break;
|
108 | 108 | }
|
| 109 | +} |
109 | 110 |
|
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 | +/*******************************************************************\ |
115 | 112 |
|
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); |
123 | 143 | }
|
124 | 144 | }
|
125 | 145 |
|
@@ -294,79 +314,77 @@ void bmct::show_program()
|
294 | 314 |
|
295 | 315 | std::cout << "\n" << "Program constraints:" << "\n";
|
296 | 316 |
|
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) |
300 | 318 | {
|
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"; |
303 | 321 |
|
304 |
| - if(it->is_assignment()) |
| 322 | + if(step.is_assignment()) |
305 | 323 | {
|
306 | 324 | std::string string_value;
|
307 |
| - languages.from_expr(it->cond_expr, string_value); |
| 325 | + languages.from_expr(step.cond_expr, string_value); |
308 | 326 | std::cout << "(" << count << ") " << string_value << "\n";
|
309 | 327 |
|
310 |
| - if(!it->guard.is_true()) |
| 328 | + if(!step.guard.is_true()) |
311 | 329 | {
|
312 |
| - languages.from_expr(it->guard, string_value); |
| 330 | + languages.from_expr(step.guard, string_value); |
313 | 331 | std::cout << std::string(i2string(count).size()+3, ' ');
|
314 | 332 | std::cout << "guard: " << string_value << "\n";
|
315 | 333 | }
|
316 | 334 |
|
317 | 335 | count++;
|
318 | 336 | }
|
319 |
| - else if(it->is_assert()) |
| 337 | + else if(step.is_assert()) |
320 | 338 | {
|
321 | 339 | std::string string_value;
|
322 |
| - languages.from_expr(it->cond_expr, string_value); |
| 340 | + languages.from_expr(step.cond_expr, string_value); |
323 | 341 | std::cout << "(" << count << ") ASSERT("
|
324 | 342 | << string_value <<") " << "\n";
|
325 | 343 |
|
326 |
| - if(!it->guard.is_true()) |
| 344 | + if(!step.guard.is_true()) |
327 | 345 | {
|
328 |
| - languages.from_expr(it->guard, string_value); |
| 346 | + languages.from_expr(step.guard, string_value); |
329 | 347 | std::cout << std::string(i2string(count).size()+3, ' ');
|
330 | 348 | std::cout << "guard: " << string_value << "\n";
|
331 | 349 | }
|
332 | 350 |
|
333 | 351 | count++;
|
334 | 352 | }
|
335 |
| - else if(it->is_assume()) |
| 353 | + else if(step.is_assume()) |
336 | 354 | {
|
337 | 355 | std::string string_value;
|
338 |
| - languages.from_expr(it->cond_expr, string_value); |
| 356 | + languages.from_expr(step.cond_expr, string_value); |
339 | 357 | std::cout << "(" << count << ") ASSUME("
|
340 | 358 | << string_value <<") " << "\n";
|
341 | 359 |
|
342 |
| - if(!it->guard.is_true()) |
| 360 | + if(!step.guard.is_true()) |
343 | 361 | {
|
344 |
| - languages.from_expr(it->guard, string_value); |
| 362 | + languages.from_expr(step.guard, string_value); |
345 | 363 | std::cout << std::string(i2string(count).size()+3, ' ');
|
346 | 364 | std::cout << "guard: " << string_value << "\n";
|
347 | 365 | }
|
348 | 366 |
|
349 | 367 | count++;
|
350 | 368 | }
|
351 |
| - else if(it->is_constraint()) |
| 369 | + else if(step.is_constraint()) |
352 | 370 | {
|
353 | 371 | std::string string_value;
|
354 |
| - languages.from_expr(it->cond_expr, string_value); |
| 372 | + languages.from_expr(step.cond_expr, string_value); |
355 | 373 | std::cout << "(" << count << ") CONSTRAINT("
|
356 | 374 | << string_value <<") " << "\n";
|
357 | 375 |
|
358 | 376 | count++;
|
359 | 377 | }
|
360 |
| - else if(it->is_shared_read() || it->is_shared_write()) |
| 378 | + else if(step.is_shared_read() || step.is_shared_write()) |
361 | 379 | {
|
362 | 380 | 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") << "(" |
365 | 383 | << string_value <<") " << "\n";
|
366 | 384 |
|
367 |
| - if(!it->guard.is_true()) |
| 385 | + if(!step.guard.is_true()) |
368 | 386 | {
|
369 |
| - languages.from_expr(it->guard, string_value); |
| 387 | + languages.from_expr(step.guard, string_value); |
370 | 388 | std::cout << std::string(i2string(count).size()+3, ' ');
|
371 | 389 | std::cout << "guard: " << string_value << "\n";
|
372 | 390 | }
|
@@ -611,6 +629,7 @@ safety_checkert::resultt bmct::stop_on_fail(
|
611 | 629 | dynamic_cast<bv_cbmct &>(prop_conv), equation, ns);
|
612 | 630 |
|
613 | 631 | error_trace();
|
| 632 | + output_graphml(UNSAFE, goto_functions); |
614 | 633 | }
|
615 | 634 |
|
616 | 635 | report_failure();
|
|
0 commit comments