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