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
master
Phoebe Nichols 5 years ago committed by Facebook Github Bot
parent 09ab685c7e
commit 1415be9153

@ -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

@ -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

@ -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)

Loading…
Cancel
Save