[infer][java] Java frontendonly print information when the debug mode is on

Summary: The logging should only happen when the debug mode is used.

Reviewed By: jberdine

Differential Revision: D4076960

fbshipit-source-id: da41932
master
Jeremy Dubreil 8 years ago committed by Facebook Github Bot
parent 53de1b7f53
commit e90f67abd6

@ -274,7 +274,7 @@ let collect_classes classmap jar_filename =
let load_program classpath classes =
L.stdout "loading program ... %!";
L.out_debug "loading program ... %!";
let models =
if !models_jar = "" then JBasics.ClassMap.empty
else collect_classes JBasics.ClassMap.empty !models_jar in
@ -286,5 +286,5 @@ let load_program classpath classes =
JBasics.ClassSet.iter
(fun cn -> ignore (lookup_node cn program))
classes;
L.stdout "done@.";
L.out_debug "done@.";
program

@ -147,7 +147,7 @@ let is_classname_cached cn =
In init - mode, finds out whether this class contains initializers at all,
in this case translates it. In standard mode, all methods are translated *)
let create_icfg source_file linereader program icfg cn node =
L.stdout "\tclassname: %s@." (JBasics.cn_name cn);
L.out_debug "\tclassname: %s@." (JBasics.cn_name cn);
if Config.dependency_mode && not (is_classname_cached cn) then
cache_classname cn;
let translate m =

@ -66,7 +66,7 @@ let store_icfg source_file tenv cg cfg =
let do_source_file
linereader classes program tenv
source_basename package_opt source_file =
L.stdout "\nfilename: %s (%s)@."
L.out_debug "\nfilename: %s (%s)@."
(DB.source_file_to_string source_file) source_basename;
let call_graph, cfg =
JFrontend.compute_source_icfg
@ -111,13 +111,13 @@ let save_tenv tenv =
if not Config.models_mode then JTransType.add_models_types tenv;
(* TODO: this prevents per compilation step incremental analysis at this stage *)
if DB.file_exists DB.global_tenv_fname then DB.file_remove DB.global_tenv_fname;
L.stdout "writing new tenv %s@." (DB.filename_to_string DB.global_tenv_fname);
L.out_debug "writing new tenv %s@." (DB.filename_to_string DB.global_tenv_fname);
Tenv.store_to_file DB.global_tenv_fname tenv
(* The program is loaded and translated *)
let do_all_files classpath sources classes =
L.stdout "Translating %d source files (%d classes)@."
L.do_out "Translating %d source files (%d classes)@."
(StringMap.cardinal sources)
(JBasics.ClassSet.cardinal classes);
let program = JClasspath.load_program classpath classes in
@ -149,7 +149,7 @@ let do_all_files classpath sources classes =
capture_libs linereader program tenv;
save_tenv tenv;
JClasspath.cleanup program;
L.stdout "done @."
L.out_debug "done @."
(* loads the source files and translates them *)

@ -112,7 +112,7 @@ let get_field_name program static tenv cn fs =
fieldname
| exception Not_found ->
(* TODO: understand why fields cannot be found here *)
L.stdout "cannot find %s.%s@." (JBasics.cn_name cn) (JBasics.fs_name fs);
L.do_err "cannot find %s.%s@." (JBasics.cn_name cn) (JBasics.fs_name fs);
raise (Frontend_error "Cannot find fieldname")
@ -213,8 +213,7 @@ let get_implementation cm =
| Javalib.Native ->
let cms = cm.Javalib.cm_class_method_signature in
let cn, ms = JBasics.cms_split cms in
L.stdout "native method %s found in %s@." (JBasics.ms_name ms) (JBasics.cn_name cn);
assert false
failwithf "native method %s found in %s@." (JBasics.ms_name ms) (JBasics.cn_name cn)
| Javalib.Java t ->
JBir.transform ~bcv: false ~ch_link: false ~formula: false ~formula_cmd:[] cm (Lazy.force t)
@ -238,7 +237,7 @@ let create_procdesc source_file program linereader icfg m : Cfg.Procdesc.t optio
if JClasspath.is_model proc_name then
begin
(* do not translate the method if there is a model for it *)
L.stdout "Skipping method with a model: %s@." (Procname.to_string proc_name);
L.out_debug "Skipping method with a model: %s@." (Procname.to_string proc_name);
None
end
else
@ -334,7 +333,7 @@ let create_procdesc source_file program linereader icfg m : Cfg.Procdesc.t optio
procdesc in
Some procdesc
with JBir.Subroutine | JBasics.Class_structure_error _ ->
L.stderr
L.do_err
"create_procdesc raised JBir.Subroutine or JBasics.Class_structure_error on %a@."
Procname.pp proc_name;
None
@ -351,7 +350,6 @@ let create_sil_deref exp typ loc =
(** translate an expression used as an r-value *)
let rec expression (context : JContext.t) pc expr =
(* L.stdout "\t\t\t\texpr: %s@." (JBir.print_expr expr); *)
let program = context.program in
let loc = get_location context.source_file context.impl pc in
let file = loc.Location.file in
@ -666,7 +664,7 @@ let instruction_array_call ms obj_type obj args var_opt =
let instruction_thread_start (context : JContext.t) cn ms obj args var_opt =
match JClasspath.lookup_node cn context.program with
| None ->
let () = L.stderr "\t\t\tWARNING: %s should normally be found@." (JBasics.cn_name cn) in
let () = L.do_err "\t\t\tWARNING: %s should normally be found@." (JBasics.cn_name cn) in
None
| Some node ->
begin
@ -1061,5 +1059,5 @@ let rec instruction (context : JContext.t) pc instr : translation =
| _ -> Skip
with Frontend_error s ->
L.stderr "Skipping because of: %s@." s;
L.do_err "Skipping because of: %s@." s;
Skip

Loading…
Cancel
Save