[clang] Added logging of attempted and completed procedure translations to clang frontend

Summary:
- After completing program translation, infer logs # of attempted procedure translations and # of completed procedure translations
- New global state in cFrontend_config.ml to represent # of attempted procedure translations and # of failed procedure translations
- Will be integrated with logging framework

Reviewed By: dulmarod

Differential Revision: D6703248

fbshipit-source-id: 10c916a
master
Varun Arora 7 years ago committed by Facebook Github Bot
parent d62b046f52
commit cd02014209

@ -31,7 +31,7 @@ let compute_icfg trans_unit_ctx tenv ast =
assert false assert false
(* NOTE: Assumes that an AST alsways starts with a TranslationUnitDecl *) (* NOTE: Assumes that an AST always starts with a TranslationUnitDecl *)
let init_global_state_capture () = let init_global_state_capture () =
Ident.NameGenerator.reset () ; Ident.NameGenerator.reset () ;
@ -66,5 +66,9 @@ let do_source_file translation_unit_context ast =
Dotty.print_icfg_dotty source_file cfg ; Dotty.print_icfg_dotty source_file cfg ;
Cg.save_call_graph_dotty source_file call_graph ) ; Cg.save_call_graph_dotty source_file call_graph ) ;
L.(debug Capture Verbose) "%a" Cfg.pp_proc_signatures cfg ; L.(debug Capture Verbose) "%a" Cfg.pp_proc_signatures cfg ;
L.(debug Capture Verbose)
"# Procedures started: %d@\n# Procedures completed: %d@\n@\n"
!CFrontend_config.procedures_attempted
(!CFrontend_config.procedures_attempted - !CFrontend_config.procedures_failed) ;
(* NOTE: nothing should be written to source_dir after this *) (* NOTE: nothing should be written to source_dir after this *)
DB.mark_file_updated (DB.source_dir_to_string source_dir) DB.mark_file_updated (DB.source_dir_to_string source_dir)

@ -173,11 +173,17 @@ let log_out = ref Format.std_formatter
let sil_types_map = ref Clang_ast_extend.TypePointerMap.empty let sil_types_map = ref Clang_ast_extend.TypePointerMap.empty
let procedures_attempted = ref 0
let procedures_failed = ref 0
let reset_global_state () = let reset_global_state () =
enum_map := ClangPointers.Map.empty ; enum_map := ClangPointers.Map.empty ;
global_translation_unit_decls := [] ; global_translation_unit_decls := [] ;
log_out := Format.std_formatter ; log_out := Format.std_formatter ;
sil_types_map := Clang_ast_extend.TypePointerMap.empty sil_types_map := Clang_ast_extend.TypePointerMap.empty ;
procedures_attempted := 0 ;
procedures_failed := 0
let tableaux_evaluation = false let tableaux_evaluation = false

@ -173,6 +173,10 @@ val sil_types_map : Typ.desc Clang_ast_extend.TypePointerMap.t ref
(** Map from type pointers (clang pointers and types created later by frontend) to sil types (** Map from type pointers (clang pointers and types created later by frontend) to sil types
Populated during frontend execution when new type is found *) Populated during frontend execution when new type is found *)
val procedures_attempted : int ref
val procedures_failed : int ref
val reset_global_state : unit -> unit val reset_global_state : unit -> unit
val tableaux_evaluation : bool val tableaux_evaluation : bool

@ -17,6 +17,7 @@ module L = Logging
let protect ~f ~recover ~pp_context = let protect ~f ~recover ~pp_context =
let log_and_recover ~print fmt = let log_and_recover ~print fmt =
recover () ; recover () ;
incr CFrontend_config.procedures_failed ;
(if print then L.internal_error else L.(debug Capture Quiet)) ("%a@\n" ^^ fmt) pp_context () (if print then L.internal_error else L.(debug Capture Quiet)) ("%a@\n" ^^ fmt) pp_context ()
in in
try f () with try f () with
@ -48,6 +49,7 @@ module CFrontend_decl_funct (T : CModule_type.CTranslation) : CModule_type.CFron
body has_return_param is_objc_method outer_context_opt extra_instrs = body has_return_param is_objc_method outer_context_opt extra_instrs =
L.(debug Capture Verbose) L.(debug Capture Verbose)
"@\n@\n>>---------- ADDING METHOD: '%a' ---------<<@\n@\n" Typ.Procname.pp procname ; "@\n@\n>>---------- ADDING METHOD: '%a' ---------<<@\n@\n" Typ.Procname.pp procname ;
incr CFrontend_config.procedures_attempted ;
let recover () = let recover () =
Cfg.remove_proc_desc cfg procname ; Cfg.remove_proc_desc cfg procname ;
CMethod_trans.create_external_procdesc cfg procname is_objc_method None CMethod_trans.create_external_procdesc cfg procname is_objc_method None

Loading…
Cancel
Save