diff --git a/infer/man/man1/infer-full.txt b/infer/man/man1/infer-full.txt index 20d9351fc..c008d3a13 100644 --- a/infer/man/man1/infer-full.txt +++ b/infer/man/man1/infer-full.txt @@ -1311,6 +1311,11 @@ INTERNAL OPTIONS --cost-issues-tests-reset Cancel the effect of --cost-issues-tests. + --cost-scuba-logging + Activates: Log unknown functions to scuba in cost/inferbo + checkers; also sets --scuba-logging. (Conversely: + --no-cost-scuba-logging) + --costs-current-reset Cancel the effect of --costs-current. diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index 4a42052b8..e43c0683f 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -2025,7 +2025,15 @@ and select = "Select bug number $(i,N). If omitted, prompt for input." -and scuba_logging = CLOpt.mk_bool ~long:"scuba-logging" "(direct) logging to scuba " +and scuba_logging, cost_scuba_logging = + let scuba_logging = CLOpt.mk_bool ~long:"scuba-logging" "(direct) logging to scuba" in + let cost_scuba_logging = + CLOpt.mk_bool_group ~long:"cost-scuba-logging" + "Log unknown functions to scuba in cost/inferbo checkers; also sets $(b,--scuba-logging)." + [scuba_logging] [] + in + (scuba_logging, cost_scuba_logging) + and scuba_normals = CLOpt.mk_string_map ~long:"scuba-normal" @@ -2683,6 +2691,8 @@ and costs_current = !costs_current and cost_issues_tests = !cost_issues_tests +and cost_scuba_logging = !cost_scuba_logging + and costs_previous = !costs_previous and cxx = !cxx diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index 6cddfffcb..c64b11c8a 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -230,6 +230,8 @@ val costs_current : string option val cost_issues_tests : string option +val cost_scuba_logging : bool + val costs_previous : string option val cxx : bool diff --git a/infer/src/base/ScubaLogging.ml b/infer/src/base/ScubaLogging.ml index db1986d6b..33bbeea6a 100644 --- a/infer/src/base/ScubaLogging.ml +++ b/infer/src/base/ScubaLogging.ml @@ -72,6 +72,8 @@ let log_count ~label ~value = log_one (LogEntry.mk_count ~label ~value) let log_message ~label ~message = log_one (LogEntry.mk_string ~label ~message) +let cost_log_message ~label ~message = if Config.cost_scuba_logging then log_message ~label ~message + let execute_with_time_logging label f = let ret_val, duration_ms = Utils.timeit ~f in let entry = LogEntry.mk_time ~label ~duration_ms in diff --git a/infer/src/base/ScubaLogging.mli b/infer/src/base/ScubaLogging.mli index 47cfdcd49..749601e33 100644 --- a/infer/src/base/ScubaLogging.mli +++ b/infer/src/base/ScubaLogging.mli @@ -21,6 +21,9 @@ val log_count : label:string -> value:int -> unit val log_message : label:string -> message:string -> unit (** Log a [string]. Event is prefixed with ["msg."] *) +val cost_log_message : label:string -> message:string -> unit +(** Similar to [log_message], but log only when [--cost-scuba-logging] option is given. *) + val execute_with_time_logging : string -> (unit -> 'a) -> 'a (** A helper to log execution time of a particular function. Use this to measure a performance of a given function. Example: diff --git a/infer/src/bufferoverrun/bufferOverrunAnalysis.ml b/infer/src/bufferoverrun/bufferOverrunAnalysis.ml index a1ca26e60..599706b1c 100644 --- a/infer/src/bufferoverrun/bufferOverrunAnalysis.ml +++ b/infer/src/bufferoverrun/bufferOverrunAnalysis.ml @@ -414,7 +414,7 @@ module TransferFunctions = struct | _, `NotFound -> (* This may happen for procedures with a biabduction model too. *) L.d_printfln_escaped "/!\\ Unknown call to %a" Procname.pp callee_pname ; - ScubaLogging.log_message ~label:"unmodeled_function_inferbo" + ScubaLogging.cost_log_message ~label:"unmodeled_function_inferbo" ~message:(F.asprintf "Unmodeled Function[Inferbo] : %a" Procname.pp callee_pname) ; Dom.Mem.add_unknown_from ret ~callee_pname ~location mem ) ) | Call (((id, _) as ret), fun_exp, _, location, _) -> diff --git a/infer/src/cost/cost.ml b/infer/src/cost/cost.ml index 517a27a96..10010930c 100644 --- a/infer/src/cost/cost.ml +++ b/infer/src/cost/cost.ml @@ -108,7 +108,7 @@ module InstrBasicCostWithReason = struct then CostDomain.unit_cost_atomic_operation else instantiated_cost | `NotFound -> - ScubaLogging.log_message ~label:"unmodeled_function_cost_analysis" + ScubaLogging.cost_log_message ~label:"unmodeled_function_cost_analysis" ~message: (F.asprintf "Unmodeled Function[Cost Analysis] : %a" Procname.pp callee_pname) ; @@ -191,7 +191,7 @@ module WorstCaseCost = struct exec_node tenv extras pair |> CostDomain.plus acc ) in Option.iter (CostDomain.get_operation_cost cost).top_pname_opt ~f:(fun top_pname -> - ScubaLogging.log_message ~label:"unmodeled_function_top_cost" + ScubaLogging.cost_log_message ~label:"unmodeled_function_top_cost" ~message:(F.asprintf "Unmodeled Function[Top Cost] : %a" Procname.pp top_pname) ; Logging.(debug Analysis Verbose) "@ Unmodeled Function[Top Cost]: %a@\n" Procname.pp top_pname ) ;