@@ -159,7 +159,7 @@ module Make
159159(* Some dumping stuff *)
160160 val register_type : 'loc -> CType .t -> CType .t
161161 val fmt_outcome_as_list :
162- T .t -> (CType .base -> string ) -> string -> A.RLocSet .t -> env
162+ T .t -> (CType .base -> string ) -> A.RLocSet .t -> env
163163 -> (string * string list ) list
164164 val fmt_outcome : T .t -> (CType .base -> string ) -> A.RLocSet .t -> env -> string
165165 val fmt_faults : (A .V .v, A.FaultType .t ) Fault .atom list -> string
@@ -224,7 +224,9 @@ module Make
224224 val define_label_offsets : env -> T .t -> unit
225225
226226 (* Dump definitions relating to labels in the post-condition *)
227- val dump_label_defs : Label.Full .full list -> unit
227+ val dump_label_defs :
228+ pp_faults :bool -> pp_labels :bool ->
229+ Label.Full .full list -> unit
228230
229231 (* Dump functions relating to labels in the post-condition *)
230232 val dump_label_funcs : bool -> Label.Full .full list -> int -> unit
@@ -421,10 +423,10 @@ end
421423
422424 let register_type _loc t = t (* Systematically follow given type *)
423425
424- let fmt_outcome_as_list test pp_fmt_base fmt_label rlocs env =
426+ let fmt_outcome_as_list test pp_fmt_base rlocs env =
425427 let tr_out = tr_out test in
426428 let rec pp_fmt t = match t with
427- | CType. Pointer t when CType. is_ins_t t -> [fmt_label ]
429+ | CType. Pointer t when CType. is_ins_t t -> [" %s " ; ]
428430 | CType. Pointer t when CType. is_tag t -> [" %s" ;" %s" ]
429431 | CType. Pointer _ -> [" %s" ]
430432 | CType. Base "pteval_t" ->
448450 rlocs
449451
450452 let fmt_outcome test pp_fmt_base locs env =
451- let pps = fmt_outcome_as_list test pp_fmt_base { | label :\ "P%s \" |} locs env in
453+ let pps = fmt_outcome_as_list test pp_fmt_base locs env in
452454 String. concat " "
453455 (List. map
454456 (fun (p1 ,p2 ) -> sprintf " %s=%s;" p1 (String. concat " " p2))
@@ -777,27 +779,44 @@ end
777779 O. o " "
778780 end
779781
780- let dump_label_defs lbls =
781- O.f " #define %- 25 s 0 " (instr_symb_id " UNKNOWN " ) ;
782+ let dump_label_defs ~ pp_faults ~ pp_labels lbls =
783+ O. f " #define %-25s 0" (instr_symb_id " NULL " ) ;
782784 (* Define indices for labels *)
783785 List. iteri
784786 (fun i (p ,lbl ) ->
785787 let flbl = OutUtils. fmt_lbl_var p lbl in
786788 O. f " #define %-25s %d" (instr_symb_id flbl) (i + 1 ))
787789 lbls ;
790+ O. f " #define %-25s %d"
791+ (instr_symb_id " UNKNOWN" )
792+ (List. length lbls+ 1 ) ;
788793 O. o " " ;
789- O.f " static const char * instr_symb_name[] = {" ;
790- O.oi " \" UNKNOWN\" ," ;
791- (* Define names for inst symbols *)
792- List. iter (fun (p ,lbl ) -> O. fi " \" %d:%s\" ," p lbl) lbls ;
793- O. o " };" ;
794+ (* Define names for code pointers in faults *)
795+ if pp_faults then begin
796+ O. f " static const char *instr_symb_name[] = {" ;
797+ O. oi " \" NULL\" ," ;
798+ List. iter (fun (p ,lbl ) -> O. fi " \" %d:%s\" ," p lbl) lbls ;
799+ O. oi " \" UNKNOWN\" ," ;
800+ O. o " };" ;
801+ O. o " "
802+ end ;
803+ (* Define names for code pointers in outcome *)
804+ if pp_labels then begin
805+ O. f " static const char *instr_symb_label[] = {" ;
806+ O. oi " \" 0\" ," ;
807+ List. iter
808+ (fun (p ,lbl ) -> O. fi " \" label:\\\" P%d:%s\\\"\" ," p lbl) lbls ;
809+ O. oi " \" UNKNOWN\" ," ;
810+ O. o " };"
811+ end ;
794812 O. o " "
795813
796814 let dump_label_funcs_skel do_self lbls nprocs =
797815 if do_self then
798816 O. o " static int get_instr_symb_id(ctx_t *ctx, ins_t* ins, int i) {"
799817 else
800818 O. o " static int get_instr_symb_id(ctx_t *ctx, ins_t* ins) {" ;
819+ O. fi " if (!ins) return %s;" (instr_symb_id " NULL" ) ;
801820 for p= 0 to nprocs - 1 do
802821 if List. exists (fun (p1 ,_ ) -> p = p1) lbls then begin
803822 let code = OutUtils. fmt_code p in
825844
826845 let dump_label_funcs_presi _do_self lbls _nprocs =
827846 O. o " static int get_instr_symb_id(labels_t *lbls, ins_t* pc) {" ;
847+ O. fi " if (!pc) return %s;" (instr_symb_id " NULL" ) ;
828848 List. iter
829849 (fun (p ,lbl ) ->
830850 let flbl = (OutUtils. fmt_lbl_var p lbl) in
0 commit comments