@@ -241,13 +241,59 @@ static bool contains_symbol_prefix(const exprt &expr, const std::string &prefix)
241
241
// / counterexample witness
242
242
void graphml_witnesst::operator ()(const goto_tracet &goto_trace)
243
243
{
244
+ unsigned int max_thread_idx=0U ;
245
+ bool trace_has_violation=false ;
246
+ for (goto_tracet::stepst::const_iterator it=goto_trace.steps .begin ();
247
+ it!=goto_trace.steps .end ();
248
+ ++it)
249
+ {
250
+ if (it->thread_nr >max_thread_idx)
251
+ max_thread_idx=it->thread_nr ;
252
+ if (it->type ==goto_trace_stept::typet::ASSERT && !it->cond_value )
253
+ trace_has_violation=true ;
254
+ }
255
+
244
256
graphml.key_values [" sourcecodelang" ]=" C" ;
245
257
246
258
const graphmlt::node_indext sink=graphml.add_node ();
247
259
graphml[sink].node_name =" sink" ;
248
260
graphml[sink].is_violation =false ;
249
261
graphml[sink].has_invariant =false ;
250
262
263
+ if (max_thread_idx > 0U && trace_has_violation)
264
+ {
265
+ std::vector<graphmlt::node_indext> nodes;
266
+
267
+ for (unsigned int i=0U ; i<=max_thread_idx+1U ; ++i)
268
+ {
269
+ nodes.push_back (graphml.add_node ());
270
+ graphml[nodes.back ()].node_name =" N" + std::to_string (i);
271
+ graphml[nodes.back ()].is_violation =(i==max_thread_idx+1U ) ? true : false ;
272
+ graphml[nodes.back ()].has_invariant =false ;
273
+ }
274
+
275
+ for (auto it=nodes.cbegin (); std::next (it)!=nodes.cend (); ++it)
276
+ {
277
+ xmlt edge (" edge" );
278
+ edge.set_attribute (" source" , graphml[*it].node_name );
279
+ edge.set_attribute (" target" , graphml[*std::next (it)].node_name );
280
+ const auto thread_id=std::distance (nodes.cbegin (), it);
281
+ xmlt &data=edge.new_element (" data" );
282
+ data.set_attribute (" key" , " createThread" );
283
+ data.data =std::to_string (thread_id);
284
+ if (thread_id==0 )
285
+ {
286
+ xmlt &data=edge.new_element (" data" );
287
+ data.set_attribute (" key" , " enterFunction" );
288
+ data.data =" main" ;
289
+ }
290
+ graphml[*std::next (it)].in [*it].xml_node =edge;
291
+ graphml[*it].out [*std::next (it)].xml_node =edge;
292
+ }
293
+
294
+ return ;
295
+ }
296
+
251
297
// step numbers start at 1
252
298
std::vector<std::size_t > step_to_node (goto_trace.steps .size ()+1 , 0 );
253
299
0 commit comments