@@ -647,68 +647,78 @@ void goto_symext::symex_goto_retrace(statet &state)
647
647
648
648
// goto or next depends on input trace from user
649
649
bool choose_goto;
650
- bool default_choice;
651
- static int retrace_index = 0 ;
652
- if (retrace_index < static_cast <int >(symex_config.retrace_input .size ()))
650
+ static size_t retrace_index = 0 ;
651
+ if (retrace_index < symex_config.retrace_input .size ())
653
652
{
654
653
choose_goto = symex_config.retrace_input [retrace_index] == ' 1' ;
655
- default_choice = false ;
656
- retrace_index++;
657
654
}
658
655
else
659
656
{
660
657
choose_goto = false ;
661
- default_choice = true ;
662
658
}
659
+ retrace_index++;
663
660
664
661
// print goto choice
665
- if (true ){
666
- source_locationt cur = state.source .pc ->source_location ();
667
- source_locationt goto_dest = goto_target->source_location ();
668
- source_locationt next_dest = next_instruction->source_location ();
669
- source_locationt t_dest = choose_goto ? goto_dest : next_dest;
670
- source_locationt nt_dest = choose_goto ? next_dest : goto_dest;
671
-
672
- auto cur_file = cur.get_file ();
673
- if (cur_file.empty ()) cur_file = " <unknown>" ;
674
- auto t_file = t_dest.get_file ();
675
- if (t_file.empty ()) t_file = " <unknown>" ;
676
- auto nt_file = nt_dest.get_file ();
677
- if (nt_file.empty ()) nt_file = " <unknown>" ;
678
-
679
- // print nothing when files are the same
680
- if (cur_file == t_file) t_file = " " ;
681
- if (cur_file == nt_file) nt_file = " " ;
682
-
683
- auto cur_line = cur.get_line ();
684
- if (cur_line.empty ()) cur_line = " ?" ;
685
- auto t_line = t_dest.get_line ();
686
- if (t_line.empty ()) t_line = " ?" ;
687
- auto nt_line = nt_dest.get_line ();
688
- if (nt_line.empty ()) nt_line = " ?" ;
689
-
690
- std::string mode = default_choice ? " Retrace* " : " Retrace " ;
691
- std::string desc = choose_goto ? " 1/GOTO" : " 0/NEXT" ;
692
-
693
- std::string padding_1 = std::string (abs (3 -cur_line.size ()), ' ' );
694
- std::string padding_2 = std::string (abs (3 -t_line.size ()), ' ' );
695
-
696
- log.status () << mode << desc
697
- << " at " << cur_file << " :" << cur_line << padding_1
698
- << " to " << t_file << " :" << t_line << padding_2
699
- << " (not " << nt_file << " :" << nt_line << " )"
700
- << log.eom ;
701
- }
662
+ log.conditional_output (
663
+ log.status (),
664
+ [this , &state, &goto_target, &next_instruction, choose_goto](messaget::mstreamt &mstream) {
665
+ source_locationt cur = state.source .pc ->source_location ();
666
+ source_locationt goto_dest = goto_target->source_location ();
667
+ source_locationt next_dest = next_instruction->source_location ();
668
+ source_locationt t_dest = choose_goto ? goto_dest : next_dest;
669
+ source_locationt nt_dest = choose_goto ? next_dest : goto_dest;
670
+
671
+ auto cur_file = cur.get_file ();
672
+ if (cur_file.empty ()) cur_file = " <unknown>" ;
673
+ auto t_file = t_dest.get_file ();
674
+ if (t_file.empty ()) t_file = " <unknown>" ;
675
+ auto nt_file = nt_dest.get_file ();
676
+ if (nt_file.empty ()) nt_file = " <unknown>" ;
677
+
678
+ // print nothing when files are the same
679
+ if (cur_file == t_file) t_file = " " ;
680
+ if (cur_file == nt_file) nt_file = " " ;
681
+
682
+ auto cur_line = cur.get_line ();
683
+ if (cur_line.empty ()) cur_line = " ?" ;
684
+ auto t_line = t_dest.get_line ();
685
+ if (t_line.empty ()) t_line = " ?" ;
686
+ auto nt_line = nt_dest.get_line ();
687
+ if (nt_line.empty ()) nt_line = " ?" ;
688
+
689
+ std::string head = symex_config.retrace_input ;
690
+ // add 0s in case input trace was shorter
691
+ head.resize (retrace_index-1 , ' 0' );
692
+ std::string decision = choose_goto ? " 1" : " 0" ;
693
+
694
+ std::string step = choose_goto ? " goto " : " next " ;
695
+
696
+ std::string padding_1 = cur_line.size () < 3
697
+ ? std::string (3 -cur_line.size (), ' ' )
698
+ : " " ;
699
+ std::string padding_2 = t_line.size () < 3
700
+ ? std::string (3 -t_line.size (), ' ' )
701
+ : " " ;
702
+
703
+ mstream << " Retrace " << head << messaget::bold << decision << messaget::reset
704
+ << " at " << cur_file << " :" << cur_line << padding_1
705
+ << step << t_file << " :" << t_line << padding_2
706
+ << " (not " << nt_file << " :" << nt_line << " )"
707
+ << messaget::eom;
708
+ });
702
709
703
710
// warn when not following unconditional goto
704
711
if (new_guard.is_true () && !choose_goto)
705
712
{
706
- log.warning () << " Retrace input \033 [31minconsistent\033 [0m: 0/NEXT although guard is true!"
707
- << log.eom ;
713
+ log.result () << " Retrace input " << messaget::red << " inconsistent" << messaget::reset
714
+ << " : 0/next although guard is true!"
715
+ << log.eom ;
708
716
}
709
717
else if (new_guard.is_false () && choose_goto)
710
718
{
711
- log.warning () << " Retrace input inconsistent: 1/GOTO although guard is false!" << log.eom ;
719
+ log.result () << " Retrace input " << messaget::red << " inconsistent" << messaget::reset
720
+ << " : 1/goto although guard is false!"
721
+ << log.eom ;
712
722
}
713
723
714
724
symex_targett::sourcet original_source=state.source ;
@@ -773,15 +783,11 @@ void goto_symext::symex_goto_retrace(statet &state)
773
783
{
774
784
symex_assume_l2 (state, guard_expr);
775
785
state.guard .add (guard_expr);
776
- log.debug () << " Following jump target"
777
- << log.eom ;
778
786
}
779
787
else
780
788
{
781
789
symex_assume_l2 (state, boolean_negate (guard_expr));
782
790
state.guard .add (boolean_negate (guard_expr));
783
- log.debug () << " Following next instruction"
784
- << log.eom ;
785
791
}
786
792
return ;
787
793
}
0 commit comments