Minor redistribution of driver functionality, and debugging improvements

Reviewed By: jeremydubreil

Differential Revision: D4364522

fbshipit-source-id: 0f5fed6
master
Josh Berdine 8 years ago committed by Facebook Github Bot
parent e58550da1d
commit 8d9f70ad47

@ -17,7 +17,8 @@ all: install
$(INFER_RESULTS): $(C_MODELS_SOURCES) $(CLANG_DEPS) $(INFER_RESULTS): $(C_MODELS_SOURCES) $(CLANG_DEPS)
# make clean in src/ in case $(CLANG_DEPS) have changed # make clean in src/ in case $(CLANG_DEPS) have changed
@$(MAKE) -C src clean @$(MAKE) -C src clean
@$(INFER_BIN) -o $(@D) --models-mode --no-failures-allowed -- $(MAKE) -C src $(call silent_on_success,\
$(INFER_BIN) -o $(@D) --models-mode --no-failures-allowed -- $(MAKE) -C src)
$(C_MODELS_FILE): $(INFER_RESULTS) $(C_MODELS_FILE): $(INFER_RESULTS)
@$(INSTALL_DATA) $(dir $(INFER_RESULTS))/specs/*.specs $(SPECS_LIB_DIR) @$(INSTALL_DATA) $(dir $(INFER_RESULTS))/specs/*.specs $(SPECS_LIB_DIR)

@ -18,7 +18,8 @@ all: install
$(INFER_RESULTS): $(CPP_MODELS_SOURCES) $(C_MODELS_SOURCES) $(CLANG_DEPS) $(INFER_RESULTS): $(CPP_MODELS_SOURCES) $(C_MODELS_SOURCES) $(CLANG_DEPS)
# make clean in src/ in case $(CLANG_DEPS) have changed # make clean in src/ in case $(CLANG_DEPS) have changed
@$(MAKE) -C src clean @$(MAKE) -C src clean
@$(INFER_BIN) -o $(@D) --models-mode --no-failures-allowed -- $(MAKE) -C src $(call silent_on_success,\
$(INFER_BIN) -o $(@D) --models-mode --no-failures-allowed -- $(MAKE) -C src)
$(CPP_MODELS_FILE): $(INFER_RESULTS) $(CPP_MODELS_FILE): $(INFER_RESULTS)
@$(INSTALL_DATA) $(dir $(INFER_RESULTS))/specs/*.specs $(SPECS_LIB_DIR) @$(INSTALL_DATA) $(dir $(INFER_RESULTS))/specs/*.specs $(SPECS_LIB_DIR)

@ -33,7 +33,8 @@ $(INFER_REPORT): $(ANDROID_JAR) $(JACKSON_JAR) $(JAVA_DEPS) $(INFER_ANNOTATIONS_
@rm -fr $(MODELS_OUT) @rm -fr $(MODELS_OUT)
mkdir -p $(MODELS_OUT) mkdir -p $(MODELS_OUT)
@rm -f $(DEPLOYED_MODELS_JAR) @rm -f $(DEPLOYED_MODELS_JAR)
$(INFER_BIN) --jobs 1 --buck --models-mode -- javac -bootclasspath $(ANDROID_JAR) -d $(MODELS_OUT) -classpath $(JACKSON_JAR):$(INFER_ANNOTATIONS_JAR) $(JAVA_SOURCES) $(call silent_on_success,\
$(INFER_BIN) --jobs 1 --buck --models-mode -- javac -bootclasspath $(ANDROID_JAR) -d $(MODELS_OUT) -classpath $(JACKSON_JAR):$(INFER_ANNOTATIONS_JAR) $(JAVA_SOURCES))
$(MODELS_JAR): $(INFER_REPORT) $(MODELS_JAR): $(INFER_REPORT)
cd $(MODELS_OUT); jar cf ../$(MODELS_JAR) * cd $(MODELS_OUT); jar cf ../$(MODELS_JAR) *

@ -17,7 +17,8 @@ all: install
$(INFER_RESULTS): $(OBJC_MODELS_SOURCES) $(CLANG_DEPS) $(INFER_RESULTS): $(OBJC_MODELS_SOURCES) $(CLANG_DEPS)
# make clean in src/ in case $(CLANG_DEPS) have changed # make clean in src/ in case $(CLANG_DEPS) have changed
@$(MAKE) -C src clean @$(MAKE) -C src clean
@$(INFER_BIN) -o $(@D) --models-mode --no-failures-allowed -- $(MAKE) -C src $(call silent_on_success,\
$(INFER_BIN) -o $(@D) --models-mode --no-failures-allowed -- $(MAKE) -C src)
$(OBJC_MODELS_FILE): $(INFER_RESULTS) $(OBJC_MODELS_FILE): $(INFER_RESULTS)
@$(INSTALL_DATA) $(dir $(INFER_RESULTS))/specs/*.specs $(SPECS_LIB_DIR) @$(INSTALL_DATA) $(dir $(INFER_RESULTS))/specs/*.specs $(SPECS_LIB_DIR)

@ -93,15 +93,18 @@ let print_stdout_legend () => {
}; };
let main makefile => { let main makefile => {
RegisterCheckers.register ();
BuiltinDefn.init (); BuiltinDefn.init ();
RegisterCheckers.register ();
switch Config.modified_targets { switch Config.modified_targets {
| Some file => MergeCapture.modified_file file | Some file => MergeCapture.modified_file file
| None => () | None => ()
}; };
switch Config.cluster_cmdline { switch Config.cluster_cmdline {
| Some fname => process_cluster_cmdline fname | Some fname =>
L.stdout "Cluster %s@." fname;
process_cluster_cmdline fname
| None => | None =>
print_stdout_legend ();
if Config.allow_specs_cleanup { if Config.allow_specs_cleanup {
DB.Results_dir.clean_specs_dir () DB.Results_dir.clean_specs_dir ()
}; };

@ -12,9 +12,5 @@ open! IStd;
/** Main module for the analysis after the capture phase */ /** Main module for the analysis after the capture phase */
/** print the legend for the symbols on stdout ('F', '.', ...) */
let print_stdout_legend: unit => unit;
/** Given a name of the Makefile to use for multicore analysis, analyze the captured code */ /** Given a name of the Makefile to use for multicore analysis, analyze the captured code */
let main: string => unit; let main: string => unit;

@ -26,12 +26,6 @@ let register_perf_stats_report () => {
PerfStats.register_report_at_exit stats_file PerfStats.register_report_at_exit stats_file
}; };
let print_prolog () =>
switch Config.cluster_cmdline {
| None => InferAnalyze.print_stdout_legend ()
| Some clname => L.stdout "Cluster %s@." clname
};
let () = { let () = {
Logging.set_log_file_identifier Logging.set_log_file_identifier
CommandLineOption.Analyze (Option.map f::Filename.basename Config.cluster_cmdline); CommandLineOption.Analyze (Option.map f::Filename.basename Config.cluster_cmdline);
@ -43,9 +37,5 @@ let () = {
Config.print_usage_exit () Config.print_usage_exit ()
}; };
register_perf_stats_report (); register_perf_stats_report ();
if Config.developer_mode {
Printexc.record_backtrace true
};
print_prolog ();
InferAnalyze.main Config.makefile_cmdline InferAnalyze.main Config.makefile_cmdline
}; };

@ -225,18 +225,15 @@ let run_parallel_analysis () =
let multicore_dir = Config.results_dir ^/ Config.multicore_dir_name in let multicore_dir = Config.results_dir ^/ Config.multicore_dir_name in
rmtree multicore_dir ; rmtree multicore_dir ;
Unix.mkdir_p multicore_dir ; Unix.mkdir_p multicore_dir ;
InferAnalyze.print_stdout_legend ();
InferAnalyze.main (multicore_dir ^/ "Makefile") ; InferAnalyze.main (multicore_dir ^/ "Makefile") ;
let cwd = Unix.getcwd () in
Unix.chdir multicore_dir ;
run_command run_command
~prog:"make" ~args:( ~prog:"make" ~args:(
"-C" :: multicore_dir ::
"-k" :: "-k" ::
"-j" :: (string_of_int Config.jobs) :: "-j" :: (string_of_int Config.jobs) ::
(Option.value_map ~f:(fun l -> ["-l"; string_of_float l]) ~default:[] Config.load_average) @ (Option.value_map ~f:(fun l -> ["-l"; string_of_float l]) ~default:[] Config.load_average) @
(if Config.debug_mode then [] else ["-s"]) (if Config.debug_mode then [] else ["-s"])
) (fun _ -> ()); ) (fun _ -> ())
Unix.chdir cwd
let execute_analyze () = let execute_analyze () =
if Config.jobs = 1 then if Config.jobs = 1 then
@ -262,9 +259,7 @@ let report () =
"--project-root"; Config.project_root; "--project-root"; Config.project_root;
"--results-dir"; Config.results_dir "--results-dir"; Config.results_dir
] in ] in
match (Unix.waitpid (Unix.fork_exec ~prog ~args:(prog :: args) ())) with if is_error (Unix.waitpid (Unix.fork_exec ~prog ~args:(prog :: args) ())) then
| Result.Ok _ -> ()
| Result.Error _ ->
L.stderr "** Error running the reporting script:@\n** %s %s@\n** See error above@." L.stderr "** Error running the reporting script:@\n** %s %s@\n** See error above@."
prog (String.concat ~sep:" " args) prog (String.concat ~sep:" " args)
@ -301,7 +296,6 @@ let fail_on_issue_epilogue () =
| None -> () | None -> ()
let () = let () =
if Config.developer_mode then Printexc.record_backtrace true ;
let build_cmd = IList.rev Config.rest in let build_cmd = IList.rev Config.rest in
let build_mode = match build_cmd with path :: _ -> build_mode_of_string path | [] -> Analyze in let build_mode = match build_cmd with path :: _ -> build_mode_of_string path | [] -> Analyze in
if build_mode <> Analyze && not Config.buck && not Config.reactive_mode then if build_mode <> Analyze && not Config.buck && not Config.reactive_mode then
@ -309,6 +303,7 @@ let () =
create_results_dir () ; create_results_dir () ;
(* re-set log files, as default files were in results_dir removed above *) (* re-set log files, as default files were in results_dir removed above *)
L.set_log_file_identifier Config.current_exe (Some (CLOpt.exe_name Config.current_exe)) ; L.set_log_file_identifier Config.current_exe (Some (CLOpt.exe_name Config.current_exe)) ;
if Config.print_builtins then Builtin.print_and_exit () ;
if Config.is_originator then L.do_out "%s@\n" Config.version_string ; if Config.is_originator then L.do_out "%s@\n" Config.version_string ;
(* infer might be called from a Makefile and itself uses `make` to run the analysis in parallel, (* infer might be called from a Makefile and itself uses `make` to run the analysis in parallel,
but cannot communicate with the parent make command. Since infer won't interfere with them but cannot communicate with the parent make command. Since infer won't interfere with them

@ -26,7 +26,8 @@ let infer_deps () = Filename.concat Config.results_dir Config.buck_infer_deps_fi
let modified_targets = ref String.Set.empty let modified_targets = ref String.Set.empty
let modified_file file = match Utils.read_file file with let modified_file file =
match Utils.read_file file with
| Some targets -> | Some targets ->
modified_targets := IList.fold_left String.Set.add String.Set.empty targets modified_targets := IList.fold_left String.Set.add String.Set.empty targets
| None -> | None ->

@ -173,7 +173,7 @@ let run_proc_analysis ~propagate_exceptions analyze_proc curr_pdesc callee_pdesc
postprocess source; postprocess source;
restore_global_state old_state; restore_global_state old_state;
with exn -> with exn ->
L.stderr "@.ONDEMAND EXCEPTION %a %s@.@.BACK TRACE@.%s@!" L.stderr "@.ONDEMAND EXCEPTION %a %s@.@.BACK TRACE@.%s@?"
Procname.pp callee_pname Procname.pp callee_pname
(Exn.to_string exn) (Exn.to_string exn)
(Printexc.get_backtrace ()); (Printexc.get_backtrace ());

@ -547,6 +547,7 @@ let parse ?(incomplete=false) ?(accept_unknown=false) ?config_file current_exe e
let usage_msg = exe_usage current_exe let usage_msg = exe_usage current_exe
in in
let curr_usage status = let curr_usage status =
prerr_endline (String.concat_array ~sep:" " !args_to_parse) ;
Arg.usage !curr_speclist usage_msg ; Arg.usage !curr_speclist usage_msg ;
exit status exit status
and full_usage status = and full_usage status =

@ -1331,6 +1331,8 @@ let post_parsing_initialization () =
); );
if !version <> `None then exit 0; if !version <> `None then exit 0;
if !developer_mode then Printexc.record_backtrace true ;
F.set_margin !margin ; F.set_margin !margin ;
let set_minor_heap_size nMb = (* increase the minor heap size to speed up gc *) let set_minor_heap_size nMb = (* increase the minor heap size to speed up gc *)

@ -188,11 +188,9 @@ let do_err fmt_string =
let err_debug fmt_string = let err_debug fmt_string =
do_print_in_debug_mode !err_formatter fmt_string do_print_in_debug_mode !err_formatter fmt_string
let stderr fmt_string = let stderr = F.eprintf
do_print (Lazy.from_val F.err_formatter) fmt_string
let stdout fmt_string = let stdout = F.printf
do_print (Lazy.from_val F.std_formatter) fmt_string
(** Type of location in ml source: __POS__ *) (** Type of location in ml source: __POS__ *)
type ml_loc = string * int * int * int type ml_loc = string * int * int * int

Loading…
Cancel
Save