@@ -44,22 +44,6 @@ let atomic_op_equal a b = match a, b with
44
44
| CompareAndSwap _ , CompareAndSwap _ -> true
45
45
| _ -> a = b
46
46
47
- let atomic_op_str x =
48
- match x with
49
- | Start -> " start"
50
- | Make -> " make"
51
- | Get -> " get"
52
- | Set -> " set"
53
- | Exchange -> " exchange"
54
- | FetchAndAdd -> " fetch_and_add"
55
- | Spawn -> " spawn"
56
- | CompareAndSwap cas ->
57
- begin match ! cas with
58
- | Unknown -> " compare_and_swap?"
59
- | Success -> " compare_and_swap"
60
- | Failed -> " compare_and_no_swap"
61
- end
62
-
63
47
let tracing = ref false
64
48
65
49
let finished_processes = ref 0
@@ -201,11 +185,32 @@ type state_cell = {
201
185
module Step = struct
202
186
type t = proc_rec
203
187
let compare a b = Uid. compare a.proc_id b.proc_id
188
+
189
+ let atomic_op_str op arg =
190
+ let arg = match op, arg with
191
+ | _ , None -> " ?"
192
+ | Spawn , Some domain_id -> Uid. pretty domain_id
193
+ | _ , Some ptr -> Uid. to_string ptr
194
+ in
195
+ match op with
196
+ | Start -> " start"
197
+ | Spawn -> " spawn() = " ^ arg
198
+ | Make -> " make() = " ^ arg
199
+ | Get -> " get(" ^ arg ^ " )"
200
+ | Set -> " set(" ^ arg ^ " )"
201
+ | Exchange -> " exchange(" ^ arg ^ " )"
202
+ | FetchAndAdd -> " fetch_and_add(" ^ arg ^ " )"
203
+ | CompareAndSwap cas ->
204
+ begin match ! cas with
205
+ | Unknown -> " compare_and_swap(" ^ arg ^ " )"
206
+ | Success -> " compare_and_swap(" ^ arg ^ " )"
207
+ | Failed -> " compare_and_no_swap(" ^ arg ^ " )"
208
+ end
209
+
204
210
let to_string t =
205
- Printf. sprintf " %s %s(%s) "
211
+ Printf. sprintf " %s %s"
206
212
(Uid. pretty t.proc_id)
207
- (atomic_op_str t.op)
208
- (Option. value (Option. map Uid. to_string t.obj_ptr) ~default: " " )
213
+ (atomic_op_str t.op t.obj_ptr)
209
214
end
210
215
211
216
module T = Trie. Make (Step )
@@ -252,10 +257,9 @@ let print_stats trie =
252
257
Format. printf " %!"
253
258
254
259
let print_trace () =
255
- List. iter (fun { proc_id ; op ; obj_ptr } ->
256
- let last_run_ptr = Option. map Uid. to_string obj_ptr |> Option. value ~default: " " in
257
- Format. printf " Process %s: %s %s@." (Uid. pretty proc_id) (atomic_op_str op) last_run_ptr
258
- ) (List. rev ! schedule_for_checks)
260
+ List. iter
261
+ (fun step -> Format. printf " %s@." (Step. to_string step))
262
+ (List. rev ! schedule_for_checks)
259
263
260
264
261
265
let setup_run func init_schedule trie =
0 commit comments