[cost] Log unknown functions to scuba only with an option

Reviewed By: ezgicicek

Differential Revision: D22334035

fbshipit-source-id: cbc39c0f7
master
Sungkeun Cho 4 years ago committed by Facebook GitHub Bot
parent 2756189175
commit 70233b55f1

@ -1311,6 +1311,11 @@ INTERNAL OPTIONS
--cost-issues-tests-reset --cost-issues-tests-reset
Cancel the effect of --cost-issues-tests. 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 --costs-current-reset
Cancel the effect of --costs-current. Cancel the effect of --costs-current.

@ -2025,7 +2025,15 @@ and select =
"Select bug number $(i,N). If omitted, prompt for input." "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 = and scuba_normals =
CLOpt.mk_string_map ~long:"scuba-normal" 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_issues_tests = !cost_issues_tests
and cost_scuba_logging = !cost_scuba_logging
and costs_previous = !costs_previous and costs_previous = !costs_previous
and cxx = !cxx and cxx = !cxx

@ -230,6 +230,8 @@ val costs_current : string option
val cost_issues_tests : string option val cost_issues_tests : string option
val cost_scuba_logging : bool
val costs_previous : string option val costs_previous : string option
val cxx : bool val cxx : bool

@ -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 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 execute_with_time_logging label f =
let ret_val, duration_ms = Utils.timeit ~f in let ret_val, duration_ms = Utils.timeit ~f in
let entry = LogEntry.mk_time ~label ~duration_ms in let entry = LogEntry.mk_time ~label ~duration_ms in

@ -21,6 +21,9 @@ val log_count : label:string -> value:int -> unit
val log_message : label:string -> message:string -> unit val log_message : label:string -> message:string -> unit
(** Log a [string]. Event is prefixed with ["msg."] *) (** 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 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 (** A helper to log execution time of a particular function. Use this to measure a performance of a
given function. Example: given function. Example:

@ -414,7 +414,7 @@ module TransferFunctions = struct
| _, `NotFound -> | _, `NotFound ->
(* This may happen for procedures with a biabduction model too. *) (* This may happen for procedures with a biabduction model too. *)
L.d_printfln_escaped "/!\\ Unknown call to %a" Procname.pp callee_pname ; 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) ; ~message:(F.asprintf "Unmodeled Function[Inferbo] : %a" Procname.pp callee_pname) ;
Dom.Mem.add_unknown_from ret ~callee_pname ~location mem ) ) Dom.Mem.add_unknown_from ret ~callee_pname ~location mem ) )
| Call (((id, _) as ret), fun_exp, _, location, _) -> | Call (((id, _) as ret), fun_exp, _, location, _) ->

@ -108,7 +108,7 @@ module InstrBasicCostWithReason = struct
then CostDomain.unit_cost_atomic_operation then CostDomain.unit_cost_atomic_operation
else instantiated_cost else instantiated_cost
| `NotFound -> | `NotFound ->
ScubaLogging.log_message ~label:"unmodeled_function_cost_analysis" ScubaLogging.cost_log_message ~label:"unmodeled_function_cost_analysis"
~message: ~message:
(F.asprintf "Unmodeled Function[Cost Analysis] : %a" Procname.pp (F.asprintf "Unmodeled Function[Cost Analysis] : %a" Procname.pp
callee_pname) ; callee_pname) ;
@ -191,7 +191,7 @@ module WorstCaseCost = struct
exec_node tenv extras pair |> CostDomain.plus acc ) exec_node tenv extras pair |> CostDomain.plus acc )
in in
Option.iter (CostDomain.get_operation_cost cost).top_pname_opt ~f:(fun top_pname -> 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) ; ~message:(F.asprintf "Unmodeled Function[Top Cost] : %a" Procname.pp top_pname) ;
Logging.(debug Analysis Verbose) Logging.(debug Analysis Verbose)
"@ Unmodeled Function[Top Cost]: %a@\n" Procname.pp top_pname ) ; "@ Unmodeled Function[Top Cost]: %a@\n" Procname.pp top_pname ) ;

Loading…
Cancel
Save