[logs] Add the callee clang_method_kind and the callee source file to the skip logs

Reviewed By: mbouaziz

Differential Revision: D7935152

fbshipit-source-id: 85cc319
master
Dulma Churchill 7 years ago committed by Facebook Github Bot
parent 6ca1b69b6f
commit 7bbf349a76

@ -134,6 +134,8 @@ let create_analysis_stats_row base record =
type call_trace =
{ call_location: Location.t
; call_result: string
; callee_clang_method_kind: string option
; callee_source_file: SourceFile.t option
; callee_name: string
; caller_name: string
; lang: string
@ -148,6 +150,9 @@ let create_call_trace_row base record =
[string_of_int record.call_location.line; ":"; string_of_int record.call_location.col])
|> add_string ~key:"source_file" ~data:(SourceFile.to_rel_path record.call_location.file)
|> add_string ~key:"call_result" ~data:record.call_result
|> add_string_opt ~key:"callee_clang_method_kind" ~data:record.callee_clang_method_kind
|> add_string_opt ~key:"callee_source_file"
~data:(Option.map ~f:SourceFile.to_rel_path record.callee_source_file)
|> add_string ~key:"callee_name" ~data:record.callee_name
|> add_string ~key:"caller_name" ~data:record.caller_name
|> add_string ~key:"lang" ~data:record.lang |> add_string_opt ~key:"reason" ~data:record.reason

@ -30,6 +30,8 @@ type analysis_stats =
type call_trace =
{ call_location: Location.t
; call_result: string
; callee_clang_method_kind: string option
; callee_source_file: SourceFile.t option
; callee_name: string
; caller_name: string
; lang: string

@ -1086,8 +1086,8 @@ let rec sym_exec exe_env tenv current_pdesc instr_ (prop_: Prop.normal Prop.t) p
| _ ->
instr_
in
let skip_call ?(is_objc_instance_method= false) ~reason prop path callee_pname ret_annots loc
ret_id_typ ret_typ actual_args =
let skip_call ?(is_objc_instance_method= false) ?(callee_attributes= None) ~reason prop path
callee_pname ret_annots loc ret_id_typ ret_typ actual_args =
let skip_res () =
let exn = Exceptions.Skip_function (Localise.desc_skip_function callee_pname) in
Reporting.log_info_deprecated current_pname exn ;
@ -1097,8 +1097,9 @@ let rec sym_exec exe_env tenv current_pdesc instr_ (prop_: Prop.normal Prop.t) p
| None ->
()
| Some summary ->
let proc_name = Summary.get_proc_name summary in
Tabulation.log_call_trace proc_name callee_pname ~reason loc Tabulation.CR_skip ) ;
let caller_name = Summary.get_proc_name summary in
Tabulation.log_call_trace ~caller_name ~callee_name:callee_pname ?callee_attributes
~reason loc Tabulation.CR_skip ) ;
unknown_or_scan_call ~is_scan:false ~reason ret_typ ret_annots
Builtin.
{ pdesc= current_pdesc
@ -1311,8 +1312,9 @@ let rec sym_exec exe_env tenv current_pdesc instr_ (prop_: Prop.normal Prop.t) p
ProcAttributes.equal_clang_method_kind
attrs.ProcAttributes.clang_method_kind ProcAttributes.OBJC_INSTANCE
in
skip_call ~is_objc_instance_method ~reason prop path resolved_pname
ret_annots loc ret_id_typ ret_type n_actual_params )
skip_call ~is_objc_instance_method ~callee_attributes:(Some attrs)
~reason prop path resolved_pname ret_annots loc ret_id_typ ret_type
n_actual_params )
| None ->
skip_call ~reason prop path resolved_pname ret_annots loc ret_id_typ
(snd ret_id_typ) n_actual_params )

@ -83,11 +83,30 @@ let print_results tenv actual_pre results =
L.d_strln "***** END RESULTS FUNCTION CALL *******"
let log_call_trace caller_name callee_name ?reason loc res =
let log_call_trace ~caller_name ~callee_name ?callee_attributes ?reason loc res =
let get_valid_source_file loc =
let file = loc.Location.file in
if SourceFile.is_invalid file then None else Some file
in
let callee_clang_method_kind, callee_source_file =
match callee_attributes with
| Some attributes when Language.curr_language_is Language.Clang ->
let callee_clang_method_kind =
ProcAttributes.string_of_clang_method_kind attributes.ProcAttributes.clang_method_kind
in
let callee_source_file = get_valid_source_file attributes.ProcAttributes.loc in
(Some callee_clang_method_kind, callee_source_file)
| Some attributes ->
(None, get_valid_source_file attributes.ProcAttributes.loc)
| None ->
(None, None)
in
let call_trace =
EventLogger.CallTrace
{ call_location= loc
; call_result= string_of_call_result res
; callee_clang_method_kind
; callee_source_file
; callee_name= Typ.Procname.to_string callee_name
; caller_name= Typ.Procname.to_string caller_name
; lang= Typ.Procname.get_language caller_name |> Language.to_explicit_string
@ -1428,9 +1447,9 @@ let exe_call_postprocess tenv ret_id trace_call callee_pname callee_attrs loc re
(** Execute the function call and return the list of results with return value *)
let exe_function_call exe_env callee_summary tenv ret_id caller_pdesc callee_pname loc
actual_params prop path =
let callee_attrs = Summary.get_attributes callee_summary in
let caller_pname = Procdesc.get_proc_name caller_pdesc in
let trace_call = log_call_trace caller_pname callee_pname loc in
let callee_attributes = Summary.get_attributes callee_summary in
let caller_name = Procdesc.get_proc_name caller_pdesc in
let trace_call = log_call_trace ~caller_name ~callee_name:callee_pname ~callee_attributes loc in
let spec_list, formal_params = spec_find_rename trace_call callee_summary in
let nspecs = List.length spec_list in
L.d_strln
@ -1444,4 +1463,4 @@ let exe_function_call exe_env callee_summary tenv ret_id caller_pdesc callee_pna
actual_params formal_params
in
let results = List.map ~f:exe_one_spec spec_list in
exe_call_postprocess tenv ret_id trace_call callee_pname callee_attrs loc results
exe_call_postprocess tenv ret_id trace_call callee_pname callee_attributes loc results

@ -18,7 +18,8 @@ type call_result =
| CR_skip (** the callee was skipped *)
val log_call_trace :
Typ.Procname.t -> Typ.Procname.t -> ?reason:string -> Location.t -> call_result -> unit
caller_name:Typ.Procname.t -> callee_name:Typ.Procname.t -> ?callee_attributes:ProcAttributes.t
-> ?reason:string -> Location.t -> call_result -> unit
(** Interprocedural footprint analysis *)

Loading…
Cancel
Save