From 1415be9153b53ede3c027cba1d538a77974a4ac6 Mon Sep 17 00:00:00 2001 From: Phoebe Nichols Date: Thu, 25 Jul 2019 06:01:05 -0700 Subject: [PATCH] Log the reverse analysis call graph for tests Summary: The reverse analysis call-graph is logged if `--debug-level-analysis` > 0, so that its value can be inspected for tests Reviewed By: jvillard Differential Revision: D16440567 fbshipit-source-id: 1ec6af1f3 --- infer/src/backend/CallGraph.ml | 7 +++++-- infer/src/backend/InferAnalyze.ml | 2 ++ infer/src/backend/SyntacticCallGraph.ml | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/infer/src/backend/CallGraph.ml b/infer/src/backend/CallGraph.ml index 679c668cb..99a05f2dc 100644 --- a/infer/src/backend/CallGraph.ml +++ b/infer/src/backend/CallGraph.ml @@ -33,10 +33,13 @@ module Node : NodeSig = struct let unset_flag n = n.flag <- false - let pp_dot fmt {id; pname; successors} = + let pp_dot fmt {id; pname; successors; flag} = let pp_id fmt id = F.fprintf fmt "N%d" id in let pp_edge fmt src dst = F.fprintf fmt " %a -> %a ;@\n" pp_id src pp_id dst in - F.fprintf fmt " %a [ label = %S ];@\n" pp_id id (F.asprintf "%a" Typ.Procname.pp pname) ; + let pp_flag fmt flag = F.fprintf fmt "%B" flag in + F.fprintf fmt " %a [ label = %S, flag = %a ];@\n" pp_id id + (F.asprintf "%a" Typ.Procname.pp pname) + pp_flag flag ; List.iter successors ~f:(pp_edge fmt id) ; F.pp_print_newline fmt () end diff --git a/infer/src/backend/InferAnalyze.ml b/infer/src/backend/InferAnalyze.ml index 0918b83bd..50fabce1c 100644 --- a/infer/src/backend/InferAnalyze.ml +++ b/infer/src/backend/InferAnalyze.ml @@ -150,6 +150,8 @@ let invalidate_changed_procedures changed_files = SourceFiles.proc_names_of_source sf |> List.iter ~f:(CallGraph.flag_reachable reverse_callgraph) ) changed_files ; + if Config.debug_level_analysis > 0 then + CallGraph.to_dotty reverse_callgraph "reverse_analysis_callgraph.dot" ; CallGraph.iter_flagged reverse_callgraph ~f:(fun node -> SpecsFiles.delete node.pname) ; (* save some memory *) CallGraph.reset reverse_callgraph diff --git a/infer/src/backend/SyntacticCallGraph.ml b/infer/src/backend/SyntacticCallGraph.ml index 03c27a9fb..530b19d6d 100644 --- a/infer/src/backend/SyntacticCallGraph.ml +++ b/infer/src/backend/SyntacticCallGraph.ml @@ -37,7 +37,7 @@ let build_from_sources g sources = SourceFiles.proc_names_of_source sf |> List.iter ~f:(CallGraph.flag_reachable g) ) ; CallGraph.remove_unflagged_and_unflag_all g ; CallGraph.trim_id_map g ; - if Config.debug_level_analysis > 0 then CallGraph.to_dotty g "callgraph.dot" ; + if Config.debug_level_analysis > 0 then CallGraph.to_dotty g "syntactic_callgraph.dot" ; L.progress "Built call graph in %a, from %d total procs, %d reachable defined procs and takes %d bytes@." Mtime.Span.pp (Mtime_clock.count time0) n_captured (CallGraph.n_procs g)