@@ -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,145 @@ 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
+ // unsigned prev_step_nr=0;
363
+ // bool first_step=true;
364
+ std::size_t function_depth=0 ;
365
+
366
+ for (const auto &step : goto_trace.steps )
367
+ {
368
+ if (step.is_function_call ())
369
+ function_depth++;
370
+ else if (step.is_function_return ())
371
+ function_depth--;
372
+
373
+ // hide the hidden ones
374
+ if (step.hidden )
375
+ continue ;
376
+
377
+ switch (step.type )
378
+ {
379
+ case goto_trace_stept::typet::ASSERT:
380
+ if (!step.cond_value )
381
+ {
382
+ out << ' \n ' ;
383
+ out << messaget::red << " Violated property:" << messaget::reset << ' \n ' ;
384
+ if (!step.pc ->source_location .is_nil ())
385
+ {
386
+ out << " " << state_location (step, ns) << ' \n ' ;
387
+ }
388
+
389
+ out << " " << messaget::red << step.comment << messaget::reset << ' \n ' ;
390
+
391
+ if (step.pc ->is_assert ())
392
+ out << " " << from_expr (ns, step.function , step.pc ->guard ) << ' \n ' ;
393
+
394
+ out << ' \n ' ;
395
+ }
396
+ break ;
397
+
398
+ case goto_trace_stept::typet::ASSIGNMENT:
399
+ if (step.assignment_type == 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
407
+ << step.pc ->source_location .get_line ()
408
+ << ' :' << messaget::reset << ' ' ;
409
+ }
410
+
411
+ trace_value (
412
+ out,
413
+ ns,
414
+ step.get_lhs_object (),
415
+ step.full_lhs ,
416
+ step.full_lhs_value ,
417
+ options);
418
+ break ;
419
+
420
+ case goto_trace_stept::typet::FUNCTION_CALL:
421
+ // downwards arrow
422
+ out << " \n " << messaget::faint << u8" \u21b3 " << messaget::reset << ' ' ;
423
+ if (!step.pc ->source_location .get_file ().empty ())
424
+ {
425
+ out << messaget::faint
426
+ << step.pc ->source_location .get_file ();
427
+
428
+ if (!step.pc ->source_location .get_line ().empty ())
429
+ {
430
+ out << messaget::faint << ' :'
431
+ << step.pc ->source_location .get_line ();
432
+ }
433
+
434
+ out << messaget::reset << ' ' ;
435
+ }
436
+
437
+ {
438
+ // show pretty name until first '('
439
+ const auto &f_symbol = ns.lookup (step.called_function );
440
+ const auto display_name = id2string (f_symbol.display_name ());
441
+ const std::size_t open_par_pos = display_name.find (' (' );
442
+ out << std::string (display_name, 0 , open_par_pos);
443
+ }
444
+
445
+ out << ' (' ;
446
+
447
+ {
448
+ bool first = true ;
449
+ for (auto &arg : step.function_arguments )
450
+ {
451
+ if (first)
452
+ first = false ;
453
+ else
454
+ out << " , " ;
455
+
456
+ out << from_expr (ns, step.function , arg);
457
+ }
458
+ }
459
+ out << " )\n " ;
460
+ break ;
461
+
462
+ case goto_trace_stept::typet::FUNCTION_RETURN:
463
+ // upwards arrow
464
+ out << messaget::faint << u8" \u21b5 " << messaget::reset << ' \n ' ;
465
+ break ;
466
+
467
+ case goto_trace_stept::typet::ASSUME:
468
+ case goto_trace_stept::typet::LOCATION:
469
+ case goto_trace_stept::typet::GOTO:
470
+ case goto_trace_stept::typet::DECL:
471
+ case goto_trace_stept::typet::OUTPUT:
472
+ case goto_trace_stept::typet::INPUT:
473
+ case goto_trace_stept::typet::SPAWN:
474
+ case goto_trace_stept::typet::MEMORY_BARRIER:
475
+ case goto_trace_stept::typet::ATOMIC_BEGIN:
476
+ case goto_trace_stept::typet::ATOMIC_END:
477
+ case goto_trace_stept::typet::DEAD:
478
+ break ;
479
+
480
+ case goto_trace_stept::typet::CONSTRAINT:
481
+ case goto_trace_stept::typet::SHARED_READ:
482
+ case goto_trace_stept::typet::SHARED_WRITE:
483
+ default :
484
+ UNREACHABLE;
485
+ }
486
+ }
487
+ }
488
+
489
+
351
490
void show_full_goto_trace (
352
491
messaget::mstreamt &out,
353
492
const namespacet &ns,
@@ -419,13 +558,14 @@ void show_full_goto_trace(
419
558
show_state_header (out, ns, step, step.step_nr , options);
420
559
}
421
560
422
- trace_value (
423
- out,
424
- ns,
425
- step.get_lhs_object (),
426
- step.full_lhs ,
427
- step.full_lhs_value ,
428
- options);
561
+ out << " " ;
562
+ trace_value (
563
+ out,
564
+ ns,
565
+ step.get_lhs_object (),
566
+ step.full_lhs ,
567
+ step.full_lhs_value ,
568
+ options);
429
569
}
430
570
break ;
431
571
@@ -437,6 +577,7 @@ void show_full_goto_trace(
437
577
show_state_header (out, ns, step, step.step_nr , options);
438
578
}
439
579
580
+ out << " " ;
440
581
trace_value (
441
582
out, ns, step.get_lhs_object (), step.full_lhs , step.full_lhs_value , options);
442
583
break ;
@@ -623,6 +764,8 @@ void show_goto_trace(
623
764
{
624
765
if (options.stack_trace )
625
766
show_goto_stack_trace (out, ns, goto_trace);
767
+ else if (options.compact_trace )
768
+ show_compact_goto_trace (out, ns, goto_trace, options);
626
769
else
627
770
show_full_goto_trace (out, ns, goto_trace, options);
628
771
}
0 commit comments