Skip to content

Commit 635fa36

Browse files
Migrate tracing system from Pretty to Format, add pp to domain files
Agent-Logs-Url: https://github.com/goblint/analyzer/sessions/fc978a58-7acb-4657-923a-8cd4ecb79445 Co-authored-by: michael-schwarz <13812333+michael-schwarz@users.noreply.github.com>
1 parent ed977a3 commit 635fa36

62 files changed

Lines changed: 574 additions & 540 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/analyses/accessAnalysis.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct
3232
emit_single_threaded := List.mem (ModifiedSinceSetjmp.Spec.name ()) activated || List.mem (PoisonVariables.Spec.name ()) activated || List.mem (UseAfterFree.Spec.name ()) activated (* TODO: some of these don't have access as dependency *)
3333

3434
let do_access (man: (D.t, G.t, C.t, V.t) man) (kind:AccessKind.t) (reach:bool) (e:exp) =
35-
if M.tracing then M.trace "access" "do_access %a %a %B" d_exp e AccessKind.pretty kind reach;
35+
if M.tracing then M.trace "access" "do_access %a %a %B" CilType.Exp.pp e AccessKind.pp kind reach;
3636
let reach_or_mpt: _ Queries.t = if reach then ReachableFrom e else MayPointTo e in
3737
let ad = man.ask reach_or_mpt in
3838
man.emit (Access {exp=e; ad; kind; reach})
@@ -42,7 +42,7 @@ struct
4242
+ [deref=true], [reach=false] - Access [exp] by dereferencing once (may-point-to), used for lval writes and shallow special accesses.
4343
+ [deref=true], [reach=true] - Access [exp] by dereferencing transitively (reachable), used for deep special accesses. *)
4444
let access_one_top ?(force=false) ?(deref=false) man (kind: AccessKind.t) reach exp =
45-
if M.tracing then M.traceli "access" "access_one_top %a (kind = %a, reach = %B, deref = %B)" CilType.Exp.pretty exp AccessKind.pretty kind reach deref;
45+
if M.tracing then M.traceli "access" "access_one_top %a (kind = %a, reach = %B, deref = %B)" CilType.Exp.pp exp AccessKind.pp kind reach deref;
4646
if force || !collect_local || !emit_single_threaded || ThreadFlag.has_ever_been_multi (Analyses.ask_of_man man) then (
4747
if deref && Cil.isPointerType (Cilfacade.typeOf exp) then (* avoid dereferencing integers to unknown pointers, which cause many spurious type-based accesses *)
4848
do_access man kind reach exp;

src/analyses/apron/relationAnalysis.apron.ml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ struct
8989
let e' = visitCilExpr visitor e in
9090
let rel = RD.add_vars st.rel (List.map RV.local (VH.to_seq_values v_ins |> List.of_seq)) in (* add temporary g#in-s *)
9191
let rel' = VH.fold (fun v v_in rel ->
92-
if M.tracing then M.trace "relation" "read_global %a %a" CilType.Varinfo.pretty v CilType.Varinfo.pretty v_in;
92+
if M.tracing then M.trace "relation" "read_global %a %a" CilType.Varinfo.pp v CilType.Varinfo.pp v_in;
9393
read_global ask getg {st with rel} v v_in (* g#in = g; *)
9494
) v_ins rel
9595
in
@@ -124,7 +124,7 @@ struct
124124

125125
let assign_from_globals_wrapper ask getg st e f =
126126
let (rel', e', v_ins) = read_globals_to_locals ask getg st e in
127-
if M.tracing then M.trace "relation" "assign_from_globals_wrapper %a" d_exp e';
127+
if M.tracing then M.trace "relation" "assign_from_globals_wrapper %a" CilType.Exp.pp e';
128128
let rel' = f rel' e' in (* x = e; *)
129129
let rel'' = RD.remove_vars rel' (List.map RV.local (VH.to_seq_values v_ins |> List.of_seq)) in (* remove temporary g#in-s *)
130130
rel''
@@ -155,7 +155,7 @@ struct
155155
v_out.vattr <- v.vattr; (*copy the attributes because the tracking may depend on them. Otherwise an assertion fails *)
156156
let st = {st with rel = RD.add_vars st.rel [RV.local v_out]} in (* add temporary g#out *)
157157
let st' = {st with rel = f st v_out} in (* g#out = e; *)
158-
if M.tracing then M.trace "relation" "write_global %a %a" CilType.Varinfo.pretty v CilType.Varinfo.pretty v_out;
158+
if M.tracing then M.trace "relation" "write_global %a %a" CilType.Varinfo.pp v CilType.Varinfo.pp v_out;
159159
let st' = write_global ask getg sideg st' v v_out in (* g = g#out; *)
160160
let rel'' = RD.remove_vars st'.rel [RV.local v_out] in (* remove temporary g#out *)
161161
{st' with rel = rel''}
@@ -192,7 +192,7 @@ struct
192192

193193
let no_overflow man exp = lazy (
194194
let res = no_overflow man exp in
195-
if M.tracing then M.tracel "no_ov" "no_ov %b exp: %a" res d_exp exp;
195+
if M.tracing then M.tracel "no_ov" "no_ov %b exp: %a" res CilType.Exp.pp exp;
196196
res
197197
)
198198

@@ -249,20 +249,20 @@ struct
249249
let assign man (lv:lval) e =
250250
let st = man.local in
251251
let simplified_e = replace_deref_exps man.ask e in
252-
if M.tracing then M.traceli "relation" "assign %a = %a (simplified to %a)" d_lval lv d_exp e d_exp simplified_e;
252+
if M.tracing then M.traceli "relation" "assign %a = %a (simplified to %a)" CilType.Lval.pp lv CilType.Exp.pp e CilType.Exp.pp simplified_e;
253253
let ask = Analyses.ask_of_man man in
254254
let r = assign_to_global_wrapper ask man.global man.sideg st lv (fun st v ->
255255
assign_from_globals_wrapper ask man.global st simplified_e (fun apr' e' ->
256-
if M.tracing then M.traceli "relation" "assign inner %a = %a (%a)" CilType.Varinfo.pretty v d_exp e' d_plainexp e';
257-
if M.tracing then M.trace "relation" "st: %a" RD.pretty apr';
256+
if M.tracing then M.traceli "relation" "assign inner %a = %a (%a)" CilType.Varinfo.pp v CilType.Exp.pp e' CilType.Exp.pp e';
257+
if M.tracing then M.trace "relation" "st: %a" RD.pp apr';
258258
let r = RD.assign_exp ask apr' (RV.local v) e' (no_overflow ask simplified_e) in
259259
let r' = assert_type_bounds ask r v in
260-
if M.tracing then M.traceu "relation" "-> %a" RD.pretty r';
260+
if M.tracing then M.traceu "relation" "-> %a" RD.pp r';
261261
r'
262262
)
263263
)
264264
in
265-
if M.tracing then M.traceu "relation" "-> %a" D.pretty r;
265+
if M.tracing then M.traceu "relation" "-> %a" D.pp r;
266266
r
267267

268268
let branch man e b =
@@ -331,7 +331,7 @@ struct
331331
| Some (Arg _) when not (List.mem_cmp Apron.Var.compare var arg_vars) -> true (* remove caller args, but keep just added args *)
332332
| _ -> false (* keep everything else (just added args, globals, global privs) *)
333333
);
334-
if M.tracing then M.tracel "combine" "relation enter newd: %a" RD.pretty new_rel;
334+
if M.tracing then M.tracel "combine" "relation enter newd: %a" RD.pp new_rel;
335335
new_rel
336336

337337
let enter man r f args =
@@ -386,11 +386,11 @@ struct
386386
let st = man.local in
387387
let reachable_from_args = reachable_from_args man args in
388388
let fundec = Node.find_fundec man.node in
389-
if M.tracing then M.tracel "combine-rel" "relation f: %a" CilType.Varinfo.pretty f.svar;
390-
if M.tracing then M.tracel "combine-rel" "relation formals: %a" (d_list "," CilType.Varinfo.pretty) f.sformals;
391-
if M.tracing then M.tracel "combine-rel" "relation args: %a" (d_list "," d_exp) args;
392-
if M.tracing then M.tracel "combine-rel" "relation st: %a" D.pretty st;
393-
if M.tracing then M.tracel "combine-rel" "relation fun_st: %a" D.pretty fun_st;
389+
if M.tracing then M.tracel "combine-rel" "relation f: %a" CilType.Varinfo.pp f.svar;
390+
if M.tracing then M.tracel "combine-rel" "relation formals: %a" (d_list "," CilType.Varinfo.pp) f.sformals;
391+
if M.tracing then M.tracel "combine-rel" "relation args: %a" (d_list "," CilType.Exp.pp) args;
392+
if M.tracing then M.tracel "combine-rel" "relation st: %a" D.pp st;
393+
if M.tracing then M.tracel "combine-rel" "relation fun_st: %a" D.pp fun_st;
394394
let new_fun_rel = RD.add_vars fun_st.rel (RD.vars st.rel) in
395395
let arg_substitutes =
396396
let filter_actuals (x,e) =
@@ -416,7 +416,7 @@ struct
416416
in
417417
let any_local_reachable = any_local_reachable fundec reachable_from_args in
418418
let arg_vars = f.sformals |> List.filter (RD.Tracked.varinfo_tracked) |> List.map RV.arg in
419-
if M.tracing then M.tracel "combine-rel" "relation remove vars: %a" (docList (GobApron.Var.pretty ())) arg_vars;
419+
if M.tracing then M.tracel "combine-rel" "relation remove vars: %a" (docList (GobApron.Var.pp ())) arg_vars;
420420
RD.remove_vars_with new_fun_rel arg_vars; (* fine to remove arg vars that also exist in caller because unify from new_rel adds them back with proper constraints *)
421421
let tainted = f_ask.f Queries.MayBeTainted in
422422
let tainted_vars = TaintPartialContexts.conv_varset tainted in
@@ -430,7 +430,7 @@ struct
430430
)
431431
in
432432
let unify_rel = RD.unify new_rel new_fun_rel in (* TODO: unify_with *)
433-
if M.tracing then M.tracel "combine-rel" "relation unifying %a %a = %a" RD.pretty new_rel RD.pretty new_fun_rel RD.pretty unify_rel;
433+
if M.tracing then M.tracel "combine-rel" "relation unifying %a %a = %a" RD.pp new_rel RD.pp new_fun_rel RD.pp unify_rel;
434434
{fun_st with rel = unify_rel}
435435

436436
let combine_assign man r fe f args fc fun_st (f_ask : Queries.ask) =
@@ -640,10 +640,10 @@ struct
640640
in
641641
match q with
642642
| EvalInt e ->
643-
if M.tracing then M.traceli "evalint" "relation query %a (%a)" d_exp e d_plainexp e;
644-
if M.tracing then M.trace "evalint" "relation st: %a" D.pretty man.local;
643+
if M.tracing then M.traceli "evalint" "relation query %a (%a)" CilType.Exp.pp e CilType.Exp.pp e;
644+
if M.tracing then M.trace "evalint" "relation st: %a" D.pp man.local;
645645
let r = eval_int e (no_overflow (Analyses.ask_of_man man) e) in
646-
if M.tracing then M.traceu "evalint" "relation query %a -> %a" d_exp e ID.pretty r;
646+
if M.tracing then M.traceu "evalint" "relation query %a -> %a" CilType.Exp.pp e ID.pp r;
647647
r
648648
| Queries.IterSysVars (vq, vf) ->
649649
let vf' x = vf (Obj.repr x) in
@@ -720,9 +720,9 @@ struct
720720
in
721721
match q with
722722
| EvalInt e ->
723-
if M.tracing then M.traceli "relation" "evalint query %a (%a), man %a" d_exp e d_plainexp e D.pretty man.local;
723+
if M.tracing then M.traceli "relation" "evalint query %a (%a), man %a" CilType.Exp.pp e CilType.Exp.pp e D.pp man.local;
724724
let r = eval_int e (no_overflow (dummyask) e) in
725-
if M.tracing then M.trace "relation" "evalint response %a -> %a" d_exp e ValueDomainQueries.ID.pretty r;
725+
if M.tracing then M.trace "relation" "evalint response %a -> %a" CilType.Exp.pp e ValueDomainQueries.ID.pp r;
726726
r
727727
|_ -> Queries.Result.top q
728728
in

0 commit comments

Comments
 (0)