@@ -27,6 +27,12 @@ type patch =
2727 patch_vars : Hvar .t list
2828 }
2929
30+ (* * A type to represent known regions that may be overwritten with patch code *)
31+ type patch_space = {
32+ space_offset : int64 ;
33+ space_size : int64
34+ }
35+
3036(* The configuration for a run of the VIBES pipeline. *)
3137type t = {
3238 exe : string ; (* The filename (path) of the executable to patch. *)
@@ -35,6 +41,7 @@ type t = {
3541 max_tries : int option ; (* Optional number of CEGIS iterations to allow *)
3642 minizinc_model_filepath : string ; (* Path to a minizinc model file *)
3743 ogre : string option ;
44+ patch_spaces : patch_space list ;
3845 wp_params : Wp_params .t ;
3946}
4047
@@ -52,6 +59,7 @@ let patched_exe_filepath t : string option = t.patched_exe_filepath
5259let max_tries t : int option = t.max_tries
5360let minizinc_model_filepath t : string = t.minizinc_model_filepath
5461let ogre t : string option = t.ogre
62+ let patch_spaces t : patch_space list = t.patch_spaces
5563let wp_params t : Wp_params.t = t.wp_params
5664
5765(* For displaying a higher var. *)
@@ -94,6 +102,19 @@ let patch_to_string (p : patch) : string =
94102let patches_to_string (ps : patch list ) : string =
95103 String. concat ~sep: " ,\n " (List. map ~f: patch_to_string ps)
96104
105+ (* For displaying a patch space. *)
106+ let patch_space_to_string (p : patch_space ) : string =
107+ String. concat ~sep: " ;\n " [
108+ Printf. sprintf " {" ;
109+ Printf. sprintf " Space_offset: %s" (Int64. to_string p.space_offset);
110+ Printf. sprintf " Space_size: %s" (Int64. to_string p.space_size);
111+ Printf. sprintf " }" ;
112+ ]
113+
114+ (* For displaying a list of patch spaces *)
115+ let patch_spaces_to_string (ps : patch_space list ) : string =
116+ String. concat ~sep: " ,\n " (List. map ~f: patch_space_to_string ps)
117+
97118(* For displaying WP params. *)
98119let wp_params_to_string (wp_params : Wp_params.t ) : string =
99120 let opt (s : string option ) : string =
@@ -109,7 +130,7 @@ let wp_params_to_string (wp_params : Wp_params.t) : string =
109130 let triple_list (t_list : (string * string * string) list ) : string =
110131 lst @@ List. map t_list ~f: triple
111132 in
112- let params = [
133+ let params = [
113134 Printf. sprintf " func: %s" wp_params.func;
114135 Printf. sprintf " precond: %s" wp_params.precond;
115136 Printf. sprintf " postcond: %s" wp_params.postcond;
@@ -118,11 +139,11 @@ let wp_params_to_string (wp_params : Wp_params.t) : string =
118139 Printf. sprintf " show: %s" (lst wp_params.show);
119140 Printf. sprintf " use-fun-input-regs: %b" wp_params.use_fun_input_regs;
120141 Printf. sprintf " fun-specs: %s" (lst wp_params.fun_specs);
121- Printf. sprintf
142+ Printf. sprintf
122143 " user-fun-specs-orig: %s" (triple_list wp_params.user_func_specs_orig);
123144 Printf. sprintf
124145 " user-fun-specs-mod: %s" (triple_list wp_params.user_func_specs_mod);
125- ]
146+ ]
126147 in
127148 String. concat ~sep: " \n " params
128149
@@ -132,9 +153,13 @@ let pp (ppf : Format.formatter) t : unit =
132153 Printf. sprintf " Exe: %s" t.exe;
133154 Printf. sprintf " Patches: %s" (patches_to_string t.patches);
134155 Printf. sprintf " Output filepath: %s"
135- (Option. value t.patched_exe_filepath ~default: " none provided" );
156+ (Option. value t.patched_exe_filepath ~default: " < none provided> " );
136157 Printf. sprintf " Max tries: %d" (Option. value t.max_tries ~default: 0 );
137158 Printf. sprintf " Minizinc model: %s" t.minizinc_model_filepath;
159+ Printf. sprintf " Ogre file: %s"
160+ (Option. value t.ogre ~default: " <none provided>" );
161+ Printf. sprintf " Patch spaces: %s"
162+ (patch_spaces_to_string t.patch_spaces);
138163 Printf. sprintf " WP-params: %s" (wp_params_to_string t.wp_params);
139164 ] in
140165 Format. fprintf ppf " @[%s@]@." info
@@ -156,7 +181,8 @@ let create
156181 ~max_tries :(max_tries : int option )
157182 ~minizinc_model_filepath :(minizinc_model_filepath : string )
158183 ~ogre :(ogre : string option )
184+ ~patch_spaces :(patch_spaces : patch_space list )
159185 ~wp_params :(wp_params : Wp_params.t )
160186 : t =
161- { exe; patches; patched_exe_filepath;
162- max_tries; minizinc_model_filepath; ogre; wp_params }
187+ { exe; patches; patched_exe_filepath; max_tries;
188+ minizinc_model_filepath; ogre; patch_spaces ; wp_params }
0 commit comments