@@ -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,136 @@ 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
+ out << " " << state_location (step, ns) << ' \n ' ;
384
+
385
+ out << " " << messaget::red << step.comment << messaget::reset << ' \n ' ;
386
+
387
+ if (step.pc ->is_assert ())
388
+ out << " " << from_expr (ns, step.function , step.pc ->guard ) << ' \n ' ;
389
+
390
+ out << ' \n ' ;
391
+ }
392
+ break ;
393
+
394
+ case goto_trace_stept::typet::ASSIGNMENT:
395
+ if (
396
+ step.assignment_type ==
397
+ goto_trace_stept::assignment_typet::ACTUAL_PARAMETER)
398
+ {
399
+ break ;
400
+ }
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 the display name
436
+ const auto &f_symbol = ns.lookup (step.called_function );
437
+ out << f_symbol.display_name ();
438
+ }
439
+
440
+ out << ' (' ;
441
+
442
+ {
443
+ bool first = true ;
444
+ for (auto &arg : step.function_arguments )
445
+ {
446
+ if (first)
447
+ first = false ;
448
+ else
449
+ out << " , " ;
450
+
451
+ out << from_expr (ns, step.function , arg);
452
+ }
453
+ }
454
+ out << " )\n " ;
455
+ break ;
456
+
457
+ case goto_trace_stept::typet::FUNCTION_RETURN:
458
+ // upwards arrow
459
+ out << messaget::faint << u8" \u21b5 " << messaget::reset << ' \n ' ;
460
+ break ;
461
+
462
+ case goto_trace_stept::typet::ASSUME:
463
+ case goto_trace_stept::typet::LOCATION:
464
+ case goto_trace_stept::typet::GOTO:
465
+ case goto_trace_stept::typet::DECL:
466
+ case goto_trace_stept::typet::OUTPUT:
467
+ case goto_trace_stept::typet::INPUT:
468
+ case goto_trace_stept::typet::SPAWN:
469
+ case goto_trace_stept::typet::MEMORY_BARRIER:
470
+ case goto_trace_stept::typet::ATOMIC_BEGIN:
471
+ case goto_trace_stept::typet::ATOMIC_END:
472
+ case goto_trace_stept::typet::DEAD:
473
+ break ;
474
+
475
+ default :
476
+ UNREACHABLE;
477
+ }
478
+ }
479
+ }
480
+
351
481
void show_full_goto_trace (
352
482
messaget::mstreamt &out,
353
483
const namespacet &ns,
@@ -419,13 +549,14 @@ void show_full_goto_trace(
419
549
show_state_header (out, ns, step, step.step_nr , options);
420
550
}
421
551
422
- trace_value (
423
- out,
424
- ns,
425
- step.get_lhs_object (),
426
- step.full_lhs ,
427
- step.full_lhs_value ,
428
- options);
552
+ out << " " ;
553
+ trace_value (
554
+ out,
555
+ ns,
556
+ step.get_lhs_object (),
557
+ step.full_lhs ,
558
+ step.full_lhs_value ,
559
+ options);
429
560
}
430
561
break ;
431
562
@@ -437,6 +568,7 @@ void show_full_goto_trace(
437
568
show_state_header (out, ns, step, step.step_nr , options);
438
569
}
439
570
571
+ out << " " ;
440
572
trace_value (
441
573
out, ns, step.get_lhs_object (), step.full_lhs , step.full_lhs_value , options);
442
574
break ;
@@ -623,6 +755,8 @@ void show_goto_trace(
623
755
{
624
756
if (options.stack_trace )
625
757
show_goto_stack_trace (out, ns, goto_trace);
758
+ else if (options.compact_trace )
759
+ show_compact_goto_trace (out, ns, goto_trace, options);
626
760
else
627
761
show_full_goto_trace (out, ns, goto_trace, options);
628
762
}
0 commit comments