@@ -264,7 +264,7 @@ void trace_value(
264
264
if (lhs_object.has_value ())
265
265
identifier=lhs_object->get_identifier ();
266
266
267
- out << " " << from_expr (ns, identifier, full_lhs) << ' =' ;
267
+ out << from_expr (ns, identifier, full_lhs) << ' =' ;
268
268
269
269
if (value.is_nil ())
270
270
out << " (assignment removed)" ;
@@ -348,6 +348,142 @@ bool is_index_member_symbol(const exprt &src)
348
348
return false ;
349
349
}
350
350
351
+ // / \brief show a compact variant of the goto trace on the console
352
+ // / \param out the output stream
353
+ // / \param ns the namespace
354
+ // / \param goto_trace the trace to be shown
355
+ // / \param options any options, e.g., numerical representation
356
+ void show_compact_goto_trace (
357
+ messaget::mstreamt &out,
358
+ const namespacet &ns,
359
+ const goto_tracet &goto_trace,
360
+ const trace_optionst &options)
361
+ {
362
+ std::size_t function_depth = 0 ;
363
+
364
+ for (const auto &step : goto_trace.steps )
365
+ {
366
+ if (step.is_function_call ())
367
+ function_depth++;
368
+ else if (step.is_function_return ())
369
+ function_depth--;
370
+
371
+ // hide the hidden ones
372
+ if (step.hidden )
373
+ continue ;
374
+
375
+ switch (step.type )
376
+ {
377
+ case goto_trace_stept::typet::ASSERT:
378
+ if (!step.cond_value )
379
+ {
380
+ out << ' \n ' ;
381
+ out << messaget::red << " Violated property:" << messaget::reset << ' \n ' ;
382
+ if (!step.pc ->source_location .is_nil ())
383
+ {
384
+ out << " " << state_location (step, ns) << ' \n ' ;
385
+ }
386
+
387
+ out << " " << messaget::red << step.comment << messaget::reset << ' \n ' ;
388
+
389
+ if (step.pc ->is_assert ())
390
+ out << " " << from_expr (ns, step.function , step.pc ->guard ) << ' \n ' ;
391
+
392
+ out << ' \n ' ;
393
+ }
394
+ break ;
395
+
396
+ case goto_trace_stept::typet::ASSIGNMENT:
397
+ if (
398
+ step.assignment_type ==
399
+ goto_trace_stept::assignment_typet::ACTUAL_PARAMETER)
400
+ break ;
401
+
402
+ out << " " ;
403
+
404
+ if (!step.pc ->source_location .get_line ().empty ())
405
+ {
406
+ out << messaget::faint << step.pc ->source_location .get_line () << ' :'
407
+ << messaget::reset << ' ' ;
408
+ }
409
+
410
+ trace_value (
411
+ out,
412
+ ns,
413
+ step.get_lhs_object (),
414
+ step.full_lhs ,
415
+ step.full_lhs_value ,
416
+ options);
417
+ break ;
418
+
419
+ case goto_trace_stept::typet::FUNCTION_CALL:
420
+ // downwards arrow
421
+ out << " \n " << messaget::faint << u8" \u21b3 " << messaget::reset << ' ' ;
422
+ if (!step.pc ->source_location .get_file ().empty ())
423
+ {
424
+ out << messaget::faint << step.pc ->source_location .get_file ();
425
+
426
+ if (!step.pc ->source_location .get_line ().empty ())
427
+ {
428
+ out << messaget::faint << ' :' << step.pc ->source_location .get_line ();
429
+ }
430
+
431
+ out << messaget::reset << ' ' ;
432
+ }
433
+
434
+ {
435
+ // show pretty name until first '(' to cut off
436
+ // decorated identifiers, e.g., func(int, int)
437
+ const auto &f_symbol = ns.lookup (step.called_function );
438
+ const auto display_name = id2string (f_symbol.display_name ());
439
+ const std::size_t open_par_pos = display_name.find (' (' );
440
+ out << std::string (display_name, 0 , open_par_pos);
441
+ }
442
+
443
+ out << ' (' ;
444
+
445
+ {
446
+ bool first = true ;
447
+ for (auto &arg : step.function_arguments )
448
+ {
449
+ if (first)
450
+ first = false ;
451
+ else
452
+ out << " , " ;
453
+
454
+ out << from_expr (ns, step.function , arg);
455
+ }
456
+ }
457
+ out << " )\n " ;
458
+ break ;
459
+
460
+ case goto_trace_stept::typet::FUNCTION_RETURN:
461
+ // upwards arrow
462
+ out << messaget::faint << u8" \u21b5 " << messaget::reset << ' \n ' ;
463
+ break ;
464
+
465
+ case goto_trace_stept::typet::ASSUME:
466
+ case goto_trace_stept::typet::LOCATION:
467
+ case goto_trace_stept::typet::GOTO:
468
+ case goto_trace_stept::typet::DECL:
469
+ case goto_trace_stept::typet::OUTPUT:
470
+ case goto_trace_stept::typet::INPUT:
471
+ case goto_trace_stept::typet::SPAWN:
472
+ case goto_trace_stept::typet::MEMORY_BARRIER:
473
+ case goto_trace_stept::typet::ATOMIC_BEGIN:
474
+ case goto_trace_stept::typet::ATOMIC_END:
475
+ case goto_trace_stept::typet::DEAD:
476
+ break ;
477
+
478
+ case goto_trace_stept::typet::CONSTRAINT:
479
+ case goto_trace_stept::typet::SHARED_READ:
480
+ case goto_trace_stept::typet::SHARED_WRITE:
481
+ default :
482
+ UNREACHABLE;
483
+ }
484
+ }
485
+ }
486
+
351
487
void show_full_goto_trace (
352
488
messaget::mstreamt &out,
353
489
const namespacet &ns,
@@ -419,13 +555,14 @@ void show_full_goto_trace(
419
555
show_state_header (out, ns, step, step.step_nr , options);
420
556
}
421
557
422
- trace_value (
423
- out,
424
- ns,
425
- step.get_lhs_object (),
426
- step.full_lhs ,
427
- step.full_lhs_value ,
428
- options);
558
+ out << " " ;
559
+ trace_value (
560
+ out,
561
+ ns,
562
+ step.get_lhs_object (),
563
+ step.full_lhs ,
564
+ step.full_lhs_value ,
565
+ options);
429
566
}
430
567
break ;
431
568
@@ -437,6 +574,7 @@ void show_full_goto_trace(
437
574
show_state_header (out, ns, step, step.step_nr , options);
438
575
}
439
576
577
+ out << " " ;
440
578
trace_value (
441
579
out, ns, step.get_lhs_object (), step.full_lhs , step.full_lhs_value , options);
442
580
break ;
@@ -623,6 +761,8 @@ void show_goto_trace(
623
761
{
624
762
if (options.stack_trace )
625
763
show_goto_stack_trace (out, ns, goto_trace);
764
+ else if (options.compact_trace )
765
+ show_compact_goto_trace (out, ns, goto_trace, options);
626
766
else
627
767
show_full_goto_trace (out, ns, goto_trace, options);
628
768
}
0 commit comments