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