diff --git a/infer/models/c/Makefile b/infer/models/c/Makefile index 791c1aced..7bbe0e99c 100644 --- a/infer/models/c/Makefile +++ b/infer/models/c/Makefile @@ -17,7 +17,8 @@ all: install $(INFER_RESULTS): $(C_MODELS_SOURCES) $(CLANG_DEPS) # make clean in src/ in case $(CLANG_DEPS) have changed @$(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) @$(INSTALL_DATA) $(dir $(INFER_RESULTS))/specs/*.specs $(SPECS_LIB_DIR) diff --git a/infer/models/cpp/Makefile b/infer/models/cpp/Makefile index a0a18a30f..13f8be9b8 100644 --- a/infer/models/cpp/Makefile +++ b/infer/models/cpp/Makefile @@ -18,7 +18,8 @@ all: install $(INFER_RESULTS): $(CPP_MODELS_SOURCES) $(C_MODELS_SOURCES) $(CLANG_DEPS) # make clean in src/ in case $(CLANG_DEPS) have changed @$(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) @$(INSTALL_DATA) $(dir $(INFER_RESULTS))/specs/*.specs $(SPECS_LIB_DIR) diff --git a/infer/models/java/Makefile b/infer/models/java/Makefile index 7f2202003..863c36e72 100644 --- a/infer/models/java/Makefile +++ b/infer/models/java/Makefile @@ -33,7 +33,8 @@ $(INFER_REPORT): $(ANDROID_JAR) $(JACKSON_JAR) $(JAVA_DEPS) $(INFER_ANNOTATIONS_ @rm -fr $(MODELS_OUT) mkdir -p $(MODELS_OUT) @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) cd $(MODELS_OUT); jar cf ../$(MODELS_JAR) * diff --git a/infer/models/objc/Makefile b/infer/models/objc/Makefile index 4f2db986c..05ea74daf 100644 --- a/infer/models/objc/Makefile +++ b/infer/models/objc/Makefile @@ -17,7 +17,8 @@ all: install $(INFER_RESULTS): $(OBJC_MODELS_SOURCES) $(CLANG_DEPS) # make clean in src/ in case $(CLANG_DEPS) have changed @$(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) @$(INSTALL_DATA) $(dir $(INFER_RESULTS))/specs/*.specs $(SPECS_LIB_DIR) diff --git a/infer/src/backend/InferAnalyze.re b/infer/src/backend/InferAnalyze.re index 79e5b22ac..e60e72166 100644 --- a/infer/src/backend/InferAnalyze.re +++ b/infer/src/backend/InferAnalyze.re @@ -93,15 +93,18 @@ let print_stdout_legend () => { }; let main makefile => { - RegisterCheckers.register (); BuiltinDefn.init (); + RegisterCheckers.register (); switch Config.modified_targets { | Some file => MergeCapture.modified_file file | None => () }; switch Config.cluster_cmdline { - | Some fname => process_cluster_cmdline fname + | Some fname => + L.stdout "Cluster %s@." fname; + process_cluster_cmdline fname | None => + print_stdout_legend (); if Config.allow_specs_cleanup { DB.Results_dir.clean_specs_dir () }; diff --git a/infer/src/backend/InferAnalyze.rei b/infer/src/backend/InferAnalyze.rei index 159fe231f..5c39cb715 100644 --- a/infer/src/backend/InferAnalyze.rei +++ b/infer/src/backend/InferAnalyze.rei @@ -12,9 +12,5 @@ open! IStd; /** 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 */ let main: string => unit; diff --git a/infer/src/backend/InferAnalyzeExe.re b/infer/src/backend/InferAnalyzeExe.re index 82ba9a40e..e5e483ace 100644 --- a/infer/src/backend/InferAnalyzeExe.re +++ b/infer/src/backend/InferAnalyzeExe.re @@ -26,12 +26,6 @@ let register_perf_stats_report () => { 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 () = { Logging.set_log_file_identifier CommandLineOption.Analyze (Option.map f::Filename.basename Config.cluster_cmdline); @@ -43,9 +37,5 @@ let () = { Config.print_usage_exit () }; register_perf_stats_report (); - if Config.developer_mode { - Printexc.record_backtrace true - }; - print_prolog (); InferAnalyze.main Config.makefile_cmdline }; diff --git a/infer/src/backend/infer.ml b/infer/src/backend/infer.ml index 043af48b3..1079dfe68 100644 --- a/infer/src/backend/infer.ml +++ b/infer/src/backend/infer.ml @@ -225,18 +225,15 @@ let run_parallel_analysis () = let multicore_dir = Config.results_dir ^/ Config.multicore_dir_name in rmtree multicore_dir ; Unix.mkdir_p multicore_dir ; - InferAnalyze.print_stdout_legend (); InferAnalyze.main (multicore_dir ^/ "Makefile") ; - let cwd = Unix.getcwd () in - Unix.chdir multicore_dir ; run_command ~prog:"make" ~args:( + "-C" :: multicore_dir :: "-k" :: "-j" :: (string_of_int Config.jobs) :: (Option.value_map ~f:(fun l -> ["-l"; string_of_float l]) ~default:[] Config.load_average) @ (if Config.debug_mode then [] else ["-s"]) - ) (fun _ -> ()); - Unix.chdir cwd + ) (fun _ -> ()) let execute_analyze () = if Config.jobs = 1 then @@ -262,11 +259,9 @@ let report () = "--project-root"; Config.project_root; "--results-dir"; Config.results_dir ] in - match (Unix.waitpid (Unix.fork_exec ~prog ~args:(prog :: args) ())) with - | Result.Ok _ -> () - | Result.Error _ -> - L.stderr "** Error running the reporting script:@\n** %s %s@\n** See error above@." - prog (String.concat ~sep:" " args) + if is_error (Unix.waitpid (Unix.fork_exec ~prog ~args:(prog :: args) ())) then + L.stderr "** Error running the reporting script:@\n** %s %s@\n** See error above@." + prog (String.concat ~sep:" " args) let analyze = function | Buck when Config.use_compilation_database = None -> @@ -301,7 +296,6 @@ let fail_on_issue_epilogue () = | None -> () let () = - if Config.developer_mode then Printexc.record_backtrace true ; let build_cmd = IList.rev Config.rest 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 @@ -309,6 +303,7 @@ let () = create_results_dir () ; (* 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)) ; + if Config.print_builtins then Builtin.print_and_exit () ; 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, but cannot communicate with the parent make command. Since infer won't interfere with them diff --git a/infer/src/backend/mergeCapture.ml b/infer/src/backend/mergeCapture.ml index 0b8b13b34..5dc8e4575 100644 --- a/infer/src/backend/mergeCapture.ml +++ b/infer/src/backend/mergeCapture.ml @@ -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_file file = match Utils.read_file file with +let modified_file file = + match Utils.read_file file with | Some targets -> modified_targets := IList.fold_left String.Set.add String.Set.empty targets | None -> diff --git a/infer/src/backend/ondemand.ml b/infer/src/backend/ondemand.ml index a6f7d2363..ca7228a77 100644 --- a/infer/src/backend/ondemand.ml +++ b/infer/src/backend/ondemand.ml @@ -173,7 +173,7 @@ let run_proc_analysis ~propagate_exceptions analyze_proc curr_pdesc callee_pdesc postprocess source; restore_global_state old_state; with exn -> - L.stderr "@.ONDEMAND EXCEPTION %a %s@.@.BACK TRACE@.%s@!" + L.stderr "@.ONDEMAND EXCEPTION %a %s@.@.BACK TRACE@.%s@?" Procname.pp callee_pname (Exn.to_string exn) (Printexc.get_backtrace ()); diff --git a/infer/src/base/CommandLineOption.ml b/infer/src/base/CommandLineOption.ml index 640a30044..dc5bcda9e 100644 --- a/infer/src/base/CommandLineOption.ml +++ b/infer/src/base/CommandLineOption.ml @@ -547,6 +547,7 @@ let parse ?(incomplete=false) ?(accept_unknown=false) ?config_file current_exe e let usage_msg = exe_usage current_exe in let curr_usage status = + prerr_endline (String.concat_array ~sep:" " !args_to_parse) ; Arg.usage !curr_speclist usage_msg ; exit status and full_usage status = diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index 73d757dd5..6235b43ee 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -1331,6 +1331,8 @@ let post_parsing_initialization () = ); if !version <> `None then exit 0; + if !developer_mode then Printexc.record_backtrace true ; + F.set_margin !margin ; let set_minor_heap_size nMb = (* increase the minor heap size to speed up gc *) diff --git a/infer/src/base/Logging.ml b/infer/src/base/Logging.ml index dd0e33a20..29c3fb852 100644 --- a/infer/src/base/Logging.ml +++ b/infer/src/base/Logging.ml @@ -188,11 +188,9 @@ let do_err fmt_string = let err_debug fmt_string = do_print_in_debug_mode !err_formatter fmt_string -let stderr fmt_string = - do_print (Lazy.from_val F.err_formatter) fmt_string +let stderr = F.eprintf -let stdout fmt_string = - do_print (Lazy.from_val F.std_formatter) fmt_string +let stdout = F.printf (** Type of location in ml source: __POS__ *) type ml_loc = string * int * int * int