From b0cfd73b195e9aa7ab02f1193589719743a29e6d Mon Sep 17 00:00:00 2001 From: Martino Luca Date: Fri, 14 Sep 2018 07:00:51 -0700 Subject: [PATCH] [Perf] Emit traces alongside cost issues Reviewed By: ezgicicek Differential Revision: D9829931 fbshipit-source-id: 0edb19413 --- infer/src/backend/Differential.ml | 19 +++++++++++++------ infer/src/backend/InferPrint.mli | 3 +++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/infer/src/backend/Differential.ml b/infer/src/backend/Differential.ml index cda4e59d9..21d3d179e 100644 --- a/infer/src/backend/Differential.ml +++ b/infer/src/backend/Differential.ml @@ -129,7 +129,8 @@ let to_map key_func report = let issue_of_cost (cost_info, cost_polynomial) ~delta ~prev_cost ~curr_cost = - let source_file = SourceFile.create ~warn_on_error:false cost_info.Jsonbug_t.loc.file in + let file = cost_info.Jsonbug_t.loc.file in + let source_file = SourceFile.create ~warn_on_error:false file in let issue_type = if CostDomain.BasicCost.is_top cost_polynomial then IssueType.infinite_execution_time_call else if CostDomain.BasicCost.is_zero cost_polynomial then IssueType.zero_execution_time_call @@ -147,16 +148,22 @@ let issue_of_cost (cost_info, cost_polynomial) ~delta ~prev_cost ~curr_cost = CostDomain.BasicCost.pp_degree prev_cost CostDomain.BasicCost.pp_degree curr_cost CostDomain.BasicCost.pp cost_polynomial CostDomain.BasicCost.pp_degree cost_polynomial in + let line = cost_info.Jsonbug_t.loc.lnum in + let column = cost_info.Jsonbug_t.loc.cnum in + let trace = + [Errlog.make_trace_element 0 {Location.line; col= column; file= source_file} "" []] + in + let severity = Exceptions.Warning in { Jsonbug_j.bug_type= issue_type.IssueType.unique_id ; qualifier - ; severity= Exceptions.severity_string Exceptions.Warning + ; severity= Exceptions.severity_string severity ; visibility= Exceptions.string_of_visibility Exceptions.Exn_user - ; line= cost_info.Jsonbug_t.loc.lnum - ; column= cost_info.Jsonbug_t.loc.cnum + ; line + ; column ; procedure= cost_info.Jsonbug_t.procedure_id ; procedure_start_line= 0 - ; file= cost_info.Jsonbug_t.loc.file - ; bug_trace= [] + ; file + ; bug_trace= InferPrint.loc_trace_to_jsonbug_record trace severity ; key= "" ; node_key= None ; hash= cost_info.Jsonbug_t.hash diff --git a/infer/src/backend/InferPrint.mli b/infer/src/backend/InferPrint.mli index bf4988752..21b6a26e1 100644 --- a/infer/src/backend/InferPrint.mli +++ b/infer/src/backend/InferPrint.mli @@ -7,6 +7,9 @@ open! IStd +val loc_trace_to_jsonbug_record : + Errlog.loc_trace_elem list -> Exceptions.severity -> Jsonbug_t.json_trace_item list + val censored_reason : IssueType.t -> SourceFile.t -> string val main : report_json:string option -> unit