Reporting cleanup 12: node_id_key -> node

Reviewed By: jvillard

Differential Revision: D9360943

fbshipit-source-id: 6f2c5720c
master
Mehdi Bouaziz 6 years ago committed by Facebook Github Bot
parent 3986a823f8
commit 9dad4c3648

@ -60,9 +60,9 @@ let compute_local_exception_line loc_trace =
List.fold_until ~init:(None, None) ~f:compute_local_exception_line ~finish:snd loc_trace List.fold_until ~init:(None, None) ~f:compute_local_exception_line ~finish:snd loc_trace
type node_id_key = type node =
| FrontendNode of {node_key: Procdesc.NodeKey.t} | FrontendNode of {node_key: Procdesc.NodeKey.t}
| BackendNode of {node_id: Procdesc.Node.id; node_key: Procdesc.NodeKey.t} | BackendNode of {node: Procdesc.Node.t}
type err_key = type err_key =
{ severity: Exceptions.severity { severity: Exceptions.severity
@ -73,7 +73,8 @@ type err_key =
(** Data associated to a specific error *) (** Data associated to a specific error *)
type err_data = type err_data =
{ node_id_key: node_id_key { node_id: int
; node_key: Procdesc.NodeKey.t
; session: int ; session: int
; loc: Location.t ; loc: Location.t
; loc_in_ml_source: L.ocaml_pos option ; loc_in_ml_source: L.ocaml_pos option
@ -173,15 +174,8 @@ let pp_warnings fmt (errlog: t) =
let pp_html source path_to_root fmt (errlog: t) = let pp_html source path_to_root fmt (errlog: t) =
let pp_eds fmt err_datas = let pp_eds fmt err_datas =
let pp_nodeid_session_loc fmt err_data = let pp_nodeid_session_loc fmt err_data =
let node_id =
match err_data.node_id_key with
| FrontendNode _ ->
0
| BackendNode {node_id} ->
(node_id :> int)
in
Io_infer.Html.pp_session_link source path_to_root fmt Io_infer.Html.pp_session_link source path_to_root fmt
(node_id, err_data.session, err_data.loc.Location.line) (err_data.node_id, err_data.session, err_data.loc.Location.line)
in in
ErrDataSet.iter (pp_nodeid_session_loc fmt) err_datas ErrDataSet.iter (pp_nodeid_session_loc fmt) err_datas
in in
@ -220,7 +214,7 @@ let update errlog_old errlog_new =
ErrLogHash.iter (fun err_key l -> ignore (add_issue errlog_old err_key l)) errlog_new ErrLogHash.iter (fun err_key l -> ignore (add_issue errlog_old err_key l)) errlog_new
let log_issue procname ~clang_method_kind severity err_log ~loc ~node_id_key ~session ~ltr let log_issue procname ~clang_method_kind severity err_log ~loc ~node ~session ~ltr
~linters_def_file ~doc_url ~access ~extras exn = ~linters_def_file ~doc_url ~access ~extras exn =
let error = Exceptions.recognize_exception exn in let error = Exceptions.recognize_exception exn in
let severity = Option.value error.severity ~default:severity in let severity = Option.value error.severity ~default:severity in
@ -268,8 +262,16 @@ let log_issue procname ~clang_method_kind severity err_log ~loc ~node_id_key ~se
EventLogger.log issue ) ; EventLogger.log issue ) ;
if should_report && not hide_java_loc_zero && not hide_memory_error then if should_report && not hide_java_loc_zero && not hide_memory_error then
let added = let added =
let node_id, node_key =
match node with
| FrontendNode {node_key} ->
(0, node_key)
| BackendNode {node} ->
((Procdesc.Node.get_id node :> int), Procdesc.Node.compute_key node)
in
let err_data = let err_data =
{ node_id_key { node_id
; node_key
; session ; session
; loc ; loc
; loc_in_ml_source= error.ocaml_pos ; loc_in_ml_source= error.ocaml_pos

@ -34,9 +34,9 @@ val compute_local_exception_line : loc_trace -> int option
This extra information adds value to the report itself, and may avoid This extra information adds value to the report itself, and may avoid
digging into the trace to understand the cause of the report. *) digging into the trace to understand the cause of the report. *)
type node_id_key = type node =
| FrontendNode of {node_key: Procdesc.NodeKey.t} | FrontendNode of {node_key: Procdesc.NodeKey.t}
| BackendNode of {node_id: Procdesc.Node.id; node_key: Procdesc.NodeKey.t} | BackendNode of {node: Procdesc.Node.t}
type err_key = private type err_key = private
{ severity: Exceptions.severity { severity: Exceptions.severity
@ -47,7 +47,8 @@ type err_key = private
(** Data associated to a specific error *) (** Data associated to a specific error *)
type err_data = private type err_data = private
{ node_id_key: node_id_key { node_id: int
; node_key: Procdesc.NodeKey.t
; session: int ; session: int
; loc: Location.t ; loc: Location.t
; loc_in_ml_source: Logging.ocaml_pos option ; loc_in_ml_source: Logging.ocaml_pos option
@ -94,6 +95,5 @@ val update : t -> t -> unit
val log_issue : val log_issue :
Typ.Procname.t -> clang_method_kind:ClangMethodKind.t option -> Exceptions.severity -> t Typ.Procname.t -> clang_method_kind:ClangMethodKind.t option -> Exceptions.severity -> t
-> loc:Location.t -> node_id_key:node_id_key -> session:int -> ltr:loc_trace -> loc:Location.t -> node:node -> session:int -> ltr:loc_trace -> linters_def_file:string option
-> linters_def_file:string option -> doc_url:string option -> access:string option -> doc_url:string option -> access:string option -> extras:Jsonbug_t.extra option -> exn -> unit
-> extras:Jsonbug_t.extra option -> exn -> unit

@ -301,11 +301,6 @@ module JsonIssuePrinter = MakeJsonListPrinter (struct
| _ -> | _ ->
Typ.Procname.to_string proc_name Typ.Procname.to_string proc_name
in in
let node_key =
match err_data.node_id_key with
| FrontendNode {node_key} | BackendNode {node_key} ->
Procdesc.NodeKey.to_string node_key
in
let bug = let bug =
{ Jsonbug_j.bug_class= Exceptions.err_class_string err_data.err_class { Jsonbug_j.bug_class= Exceptions.err_class_string err_data.err_class
; kind= severity ; kind= severity
@ -320,7 +315,7 @@ module JsonIssuePrinter = MakeJsonListPrinter (struct
; procedure_start_line ; procedure_start_line
; file ; file
; bug_trace= loc_trace_to_jsonbug_record err_data.loc_trace err_key.severity ; bug_trace= loc_trace_to_jsonbug_record err_data.loc_trace err_key.severity
; node_key ; node_key= Procdesc.NodeKey.to_string err_data.node_key
; key= compute_key bug_type proc_name file ; key= compute_key bug_type proc_name file
; hash= compute_hash severity bug_type proc_name file qualifier ; hash= compute_hash severity bug_type proc_name file qualifier
; dotty= error_desc_to_dotty_string err_key.err_desc ; dotty= error_desc_to_dotty_string err_key.err_desc

@ -12,23 +12,23 @@ type log_t =
?ltr:Errlog.loc_trace -> ?linters_def_file:string -> ?doc_url:string -> ?access:string ?ltr:Errlog.loc_trace -> ?linters_def_file:string -> ?doc_url:string -> ?access:string
-> ?extras:Jsonbug_t.extra -> exn -> unit -> ?extras:Jsonbug_t.extra -> exn -> unit
let log_issue_from_errlog procname ~clang_method_kind severity err_log ~loc ~node_id_key ~ltr let log_issue_from_errlog procname ~clang_method_kind severity err_log ~loc ~node ~ltr
~linters_def_file ~doc_url ~access ~extras exn = ~linters_def_file ~doc_url ~access ~extras exn =
let issue_type = (Exceptions.recognize_exception exn).name in let issue_type = (Exceptions.recognize_exception exn).name in
if not Config.filtering (* no-filtering takes priority *) || issue_type.IssueType.enabled then if not Config.filtering (* no-filtering takes priority *) || issue_type.IssueType.enabled then
let session = (State.get_session () :> int) in let session = (State.get_session () :> int) in
Errlog.log_issue procname ~clang_method_kind severity err_log ~loc ~node_id_key ~session ~ltr Errlog.log_issue procname ~clang_method_kind severity err_log ~loc ~node ~session ~ltr
~linters_def_file ~doc_url ~access ~extras exn ~linters_def_file ~doc_url ~access ~extras exn
let log_frontend_issue procname severity errlog ~loc ~node_key ~ltr ~linters_def_file ~doc_url exn = let log_frontend_issue procname severity errlog ~loc ~node_key ~ltr ~linters_def_file ~doc_url exn =
let node_id_key = Errlog.FrontendNode {node_key} in let node = Errlog.FrontendNode {node_key} in
log_issue_from_errlog procname ~clang_method_kind:None severity errlog ~loc ~node_id_key ~ltr log_issue_from_errlog procname ~clang_method_kind:None severity errlog ~loc ~node ~ltr
~linters_def_file ~doc_url ~access:None ~extras:None exn ~linters_def_file ~doc_url ~access:None ~extras:None exn
let log_issue_from_summary severity summary ~node_id_key ~loc ?ltr ?linters_def_file ?doc_url let log_issue_from_summary severity summary ~node ~loc ?ltr ?linters_def_file ?doc_url ?access
?access ?extras exn = ?extras exn =
let attrs = Summary.get_attributes summary in let attrs = Summary.get_attributes summary in
let procname = attrs.proc_name in let procname = attrs.proc_name in
let is_java_generated_method = let is_java_generated_method =
@ -48,20 +48,19 @@ let log_issue_from_summary severity summary ~node_id_key ~loc ?ltr ?linters_def_
let err_log = Summary.get_err_log summary in let err_log = Summary.get_err_log summary in
let clang_method_kind = Some attrs.clang_method_kind in let clang_method_kind = Some attrs.clang_method_kind in
let ltr = match ltr with None -> State.get_loc_trace () | Some ltr -> ltr in let ltr = match ltr with None -> State.get_loc_trace () | Some ltr -> ltr in
log_issue_from_errlog procname ~clang_method_kind severity err_log ~loc ~node_id_key ~ltr let node = Errlog.BackendNode {node} in
log_issue_from_errlog procname ~clang_method_kind severity err_log ~loc ~node ~ltr
~linters_def_file ~doc_url ~access ~extras exn ~linters_def_file ~doc_url ~access ~extras exn
let log_issue_deprecated severity proc_name ?node_id_key ?loc ?ltr ?linters_def_file ?doc_url let log_issue_deprecated severity proc_name ?node ?loc ?ltr ?linters_def_file ?doc_url ?access
?access ?extras:_ exn = ?extras:_ exn =
match Summary.get proc_name with match Summary.get proc_name with
| Some summary -> | Some summary ->
let node_id_key = let node = match node with None -> State.get_node () | Some node -> node in
match node_id_key with None -> State.get_node_id_key () | Some node_id_key -> node_id_key
in
let loc = match loc with None -> State.get_loc () | Some loc -> loc in let loc = match loc with None -> State.get_loc () | Some loc -> loc in
log_issue_from_summary severity summary ~node_id_key ~loc ?ltr ?linters_def_file ?doc_url log_issue_from_summary severity summary ~node ~loc ?ltr ?linters_def_file ?doc_url ?access
?access exn exn
| None -> | None ->
L.(die InternalError) L.(die InternalError)
"Trying to report error on procedure %a, but cannot because no summary exists for this \ "Trying to report error on procedure %a, but cannot because no summary exists for this \
@ -71,8 +70,8 @@ let log_issue_deprecated severity proc_name ?node_id_key ?loc ?ltr ?linters_def_
let log_issue_from_summary_simplified severity summary ~loc ?ltr ?linters_def_file ?doc_url ?access let log_issue_from_summary_simplified severity summary ~loc ?ltr ?linters_def_file ?doc_url ?access
?extras exn = ?extras exn =
let node_id_key = State.get_node_id_key () in let node = State.get_node () in
log_issue_from_summary severity summary ~node_id_key ~loc ?ltr ?linters_def_file ?doc_url ?access log_issue_from_summary severity summary ~node ~loc ?ltr ?linters_def_file ?doc_url ?access
?extras exn ?extras exn
@ -82,8 +81,8 @@ let log_warning = log_issue_from_summary_simplified Exceptions.Warning
let log_issue_external procname severity ~loc ~ltr ?access exn = let log_issue_external procname severity ~loc ~ltr ?access exn =
let errlog = IssueLog.get_errlog procname in let errlog = IssueLog.get_errlog procname in
let node_id_key = State.get_node_id_key () in let node = Errlog.BackendNode {node= State.get_node ()} in
log_issue_from_errlog procname ~clang_method_kind:None severity errlog ~loc ~node_id_key ~ltr log_issue_from_errlog procname ~clang_method_kind:None severity errlog ~loc ~node ~ltr
~linters_def_file:None ~doc_url:None ~access ~extras:None exn ~linters_def_file:None ~doc_url:None ~access ~extras:None exn

@ -14,8 +14,7 @@ type log_t =
-> ?extras:Jsonbug_t.extra -> exn -> unit -> ?extras:Jsonbug_t.extra -> exn -> unit
val log_issue_deprecated : val log_issue_deprecated :
Exceptions.severity -> Typ.Procname.t -> ?node_id_key:Errlog.node_id_key -> ?loc:Location.t Exceptions.severity -> Typ.Procname.t -> ?node:Procdesc.Node.t -> ?loc:Location.t -> log_t
-> log_t
(** Report an issue in the given procedure. (** Report an issue in the given procedure.
DEPRECATED as it can create race conditions between checkers. DEPRECATED as it can create race conditions between checkers.
Use log_error/warning instead *) Use log_error/warning instead *)

@ -20,7 +20,7 @@ type failure_stats =
; (* number of node failures (i.e. at least one instruction failure) *) ; (* number of node failures (i.e. at least one instruction failure) *)
mutable node_ok: int mutable node_ok: int
; (* number of node successes (i.e. no instruction failures) *) ; (* number of node successes (i.e. no instruction failures) *)
mutable first_failure: (Location.t * Errlog.node_id_key * int * Errlog.loc_trace * exn) option mutable first_failure: (Location.t * Procdesc.Node.t * int * Errlog.loc_trace * exn) option
(* exception at the first failure *) } (* exception at the first failure *) }
module NodeHash = Procdesc.NodeHash module NodeHash = Procdesc.NodeHash
@ -164,11 +164,6 @@ let mk_find_duplicate_nodes : Procdesc.t -> Procdesc.Node.t -> Procdesc.NodeSet.
let get_node_id () = Procdesc.Node.get_id !gs.last_node let get_node_id () = Procdesc.Node.get_id !gs.last_node
let get_node_id_key () =
Errlog.BackendNode
{node_id= Procdesc.Node.get_id !gs.last_node; node_key= Procdesc.Node.compute_key !gs.last_node}
let get_inst_update pos = let get_inst_update pos =
let loc = get_loc () in let loc = get_loc () in
Sil.inst_update loc pos Sil.inst_update loc pos
@ -251,17 +246,17 @@ let mark_instr_ok () =
let mark_instr_fail exn = let mark_instr_fail exn =
let loc = get_loc () in let loc = get_loc () in
let node_id_key = get_node_id_key () in let node = get_node () in
let session = get_session () in let session = get_session () in
let loc_trace = get_loc_trace () in let loc_trace = get_loc_trace () in
let fs = get_failure_stats (get_node ()) in let fs = get_failure_stats node in
if is_none fs.first_failure then if is_none fs.first_failure then
fs.first_failure <- Some (loc, node_id_key, (session :> int), loc_trace, exn) ; fs.first_failure <- Some (loc, node, (session :> int), loc_trace, exn) ;
fs.instr_fail <- fs.instr_fail + 1 fs.instr_fail <- fs.instr_fail + 1
type log_issue = type log_issue =
Typ.Procname.t -> ?node_id_key:Errlog.node_id_key -> ?loc:Location.t -> ?ltr:Errlog.loc_trace Typ.Procname.t -> ?node:Procdesc.Node.t -> ?loc:Location.t -> ?ltr:Errlog.loc_trace
-> ?linters_def_file:string -> ?doc_url:string -> ?access:string -> ?extras:Jsonbug_t.extra -> ?linters_def_file:string -> ?doc_url:string -> ?access:string -> ?extras:Jsonbug_t.extra
-> exn -> unit -> exn -> unit
@ -269,11 +264,11 @@ let process_execution_failures (log_issue: log_issue) pname =
let do_failure _ fs = let do_failure _ fs =
(* L.out "Node:%a node_ok:%d node_fail:%d@." Procdesc.Node.pp node fs.node_ok fs.node_fail; *) (* L.out "Node:%a node_ok:%d node_fail:%d@." Procdesc.Node.pp node fs.node_ok fs.node_fail; *)
match (fs.node_ok, fs.first_failure) with match (fs.node_ok, fs.first_failure) with
| 0, Some (loc, node_id_key, _, loc_trace, exn) when not Config.debug_exceptions -> | 0, Some (loc, node, _, loc_trace, exn) when not Config.debug_exceptions ->
let error = Exceptions.recognize_exception exn in let error = Exceptions.recognize_exception exn in
let desc' = Localise.verbatim_desc ("exception: " ^ error.name.IssueType.unique_id) in let desc' = Localise.verbatim_desc ("exception: " ^ error.name.IssueType.unique_id) in
let exn' = Exceptions.Analysis_stops (desc', error.ocaml_pos) in let exn' = Exceptions.Analysis_stops (desc', error.ocaml_pos) in
log_issue pname ~loc ~node_id_key ~ltr:loc_trace exn' log_issue pname ~loc ~node ~ltr:loc_trace exn'
| _ -> | _ ->
() ()
in in

@ -37,9 +37,6 @@ val get_loc_trace : unit -> Errlog.loc_trace
val get_node : unit -> Procdesc.Node.t val get_node : unit -> Procdesc.Node.t
(** Get last node seen in symbolic execution *) (** Get last node seen in symbolic execution *)
val get_node_id_key : unit -> Errlog.node_id_key
(** Get id and key of last node seen in symbolic execution *)
val get_normalized_pre : val get_normalized_pre :
(Tenv.t -> Prop.normal Prop.t -> Prop.normal Prop.t) -> Prop.normal Prop.t option (Tenv.t -> Prop.normal Prop.t -> Prop.normal Prop.t) -> Prop.normal Prop.t option
(** return the normalized precondition extracted form the last prop seen, if any (** return the normalized precondition extracted form the last prop seen, if any
@ -75,7 +72,7 @@ val mk_find_duplicate_nodes : Procdesc.t -> Procdesc.Node.t -> Procdesc.NodeSet.
and normalized (w.r.t. renaming of let - bound ids) list of instructions. *) and normalized (w.r.t. renaming of let - bound ids) list of instructions. *)
type log_issue = type log_issue =
Typ.Procname.t -> ?node_id_key:Errlog.node_id_key -> ?loc:Location.t -> ?ltr:Errlog.loc_trace Typ.Procname.t -> ?node:Procdesc.Node.t -> ?loc:Location.t -> ?ltr:Errlog.loc_trace
-> ?linters_def_file:string -> ?doc_url:string -> ?access:string -> ?extras:Jsonbug_t.extra -> ?linters_def_file:string -> ?doc_url:string -> ?access:string -> ?extras:Jsonbug_t.extra
-> exn -> unit -> exn -> unit

Loading…
Cancel
Save