[inferbo] Use Logging for logging

Summary:
- Use Logging for logging
- Add a few extra debug (not ON by default)
- No space before colon

Depends on D4961957

Reviewed By: KihongHeo

Differential Revision: D4961989

fbshipit-source-id: 7c8697d
master
Mehdi Bouaziz 8 years ago committed by Facebook Github Bot
parent 7d70310691
commit 2dbde13335

@ -87,11 +87,10 @@ struct
= fun params mem loc -> = fun params mem loc ->
match params with match params with
| (e, _) :: _ -> | (e, _) :: _ ->
(* TODO: only print when debug mode? *) if Config.bo_debug >= 1 then
F.fprintf F.err_formatter "@[<v>=== Infer Print === at %a@," L.err "@[<v>=== Infer Print === at %a@,%a@]%!"
Location.pp loc; Location.pp loc
Dom.Val.pp F.err_formatter (Sem.eval e mem loc); Dom.Val.pp (Sem.eval e mem loc);
F.fprintf F.err_formatter "@]";
mem mem
| _ -> mem | _ -> mem
@ -164,7 +163,10 @@ struct
Sem.eval_array_alloc pname node typ offset size inst_num dimension Sem.eval_array_alloc pname node typ offset size inst_num dimension
in in
(Dom.Mem.add_heap field v mem, sym_num + 4) (Dom.Mem.add_heap field v mem, sym_num + 4)
| _ -> (mem, sym_num) | _ ->
if Config.bo_debug >= 3 then
L.err "decl_fld of unhandled type: %a@." (Typ.pp Pp.text) typ;
(mem, sym_num)
in in
match typ.Typ.desc with match typ.Typ.desc with
| Typ.Tstruct typename -> | Typ.Tstruct typename ->
@ -190,7 +192,10 @@ struct
~inst_num ~sym_num ~dimension:1 mem ~inst_num ~sym_num ~dimension:1 mem
in in
(mem, inst_num + 1, sym_num) (mem, inst_num + 1, sym_num)
| _ -> (mem, inst_num, sym_num) (* TODO: add other cases if necessary *) | _ ->
if Config.bo_debug >= 3 then
L.err "declare_symbolic_parameter of unhandled type: %a@." (Typ.pp Pp.text) typ;
(mem, inst_num, sym_num) (* TODO: add other cases if necessary *)
in in
List.fold ~f:add_formal ~init:(mem, inst_num, 0) (Sem.get_formals pdesc) List.fold ~f:add_formal ~init:(mem, inst_num, 0) (Sem.get_formals pdesc)
|> fst3 |> fst3
@ -216,16 +221,13 @@ struct
= fun instr pre post -> = fun instr pre post ->
if Config.bo_debug >= 2 then if Config.bo_debug >= 2 then
begin begin
F.fprintf F.err_formatter "@.@.================================@."; L.err "@\n@\n================================@\n";
F.fprintf F.err_formatter "@[<v 2>Pre-state : @,"; L.err "@[<v 2>Pre-state : @,%a" Dom.Mem.pp pre;
Dom.Mem.pp F.err_formatter pre; L.err "@]@\n@\n%a" (Sil.pp_instr Pp.text) instr;
F.fprintf F.err_formatter "@]@.@."; L.err "@\n@\n";
Sil.pp_instr Pp.text F.err_formatter instr; L.err "@[<v 2>Post-state : @,%a" Dom.Mem.pp post;
F.fprintf F.err_formatter "@.@."; L.err "@]@\n";
F.fprintf F.err_formatter "@[<v 2>Post-state : @,"; L.err "================================@\n@."
Dom.Mem.pp F.err_formatter post;
F.fprintf F.err_formatter "@]@.";
F.fprintf F.err_formatter "================================@.@."
end end
let exec_instr let exec_instr
@ -317,10 +319,10 @@ struct
let offset = ArrayBlk.offsetof arr in let offset = ArrayBlk.offsetof arr in
let idx = (if is_plus then Itv.plus else Itv.minus) offset idx in let idx = (if is_plus then Itv.plus else Itv.minus) offset idx in
(if Config.bo_debug >= 2 then (if Config.bo_debug >= 2 then
(F.fprintf F.err_formatter "@[<v 2>Add condition :@,"; (L.err "@[<v 2>Add condition :@,";
F.fprintf F.err_formatter "array: %a@," ArrayBlk.pp arr; L.err "array: %a@," ArrayBlk.pp arr;
F.fprintf F.err_formatter " idx: %a@," Itv.pp idx; L.err " idx: %a@," Itv.pp idx;
F.fprintf F.err_formatter "@]@.")); L.err "@]@."));
if size <> Itv.bot && idx <> Itv.bot then if size <> Itv.bot && idx <> Itv.bot then
Dom.ConditionSet.add_bo_safety pname loc site ~size ~idx cond_set Dom.ConditionSet.add_bo_safety pname loc site ~size ~idx cond_set
else cond_set else cond_set
@ -344,15 +346,12 @@ struct
let print_debug_info : Sil.instr -> Dom.Mem.astate -> Dom.ConditionSet.t -> unit let print_debug_info : Sil.instr -> Dom.Mem.astate -> Dom.ConditionSet.t -> unit
= fun instr pre cond_set -> = fun instr pre cond_set ->
if Config.bo_debug >= 2 then if Config.bo_debug >= 2 then
(F.fprintf F.err_formatter "@.@.================================@."; (L.err "@\n@\n================================@\n";
F.fprintf F.err_formatter "@[<v 2>Pre-state : @,"; L.err "@[<v 2>Pre-state : @,%a" Dom.Mem.pp pre;
Dom.Mem.pp F.err_formatter pre; L.err "@]@\n@\n%a" (Sil.pp_instr Pp.text) instr;
F.fprintf F.err_formatter "@]@.@."; L.err "@[<v 2>@\n@\n%a" Dom.ConditionSet.pp cond_set;
Sil.pp_instr Pp.text F.err_formatter instr; L.err "@]@\n";
F.fprintf F.err_formatter "@[<v 2>@.@."; L.err "================================@\n@.")
Dom.ConditionSet.pp F.err_formatter cond_set;
F.fprintf F.err_formatter "@]@.";
F.fprintf F.err_formatter "================================@.@.")
let collect_instr let collect_instr
: extras ProcData.t -> CFG.node -> Dom.ConditionSet.t * Dom.Mem.astate : extras ProcData.t -> CFG.node -> Dom.ConditionSet.t * Dom.Mem.astate
@ -446,10 +445,9 @@ let compute_post
let print_summary : Typ.Procname.t -> Dom.Summary.t -> unit let print_summary : Typ.Procname.t -> Dom.Summary.t -> unit
= fun proc_name s -> = fun proc_name s ->
F.fprintf F.err_formatter "@.@[<v 2>Summary of %a :@," L.err "@\n@[<v 2>Summary of %a :@,%a@]@."
Typ.Procname.pp proc_name; Typ.Procname.pp proc_name
Dom.Summary.pp_summary F.err_formatter s; Dom.Summary.pp_summary s
F.fprintf F.err_formatter "@]@."
let checker : Callbacks.proc_callback_args -> Specs.summary let checker : Callbacks.proc_callback_args -> Specs.summary
= fun ({ summary } as callback) -> = fun ({ summary } as callback) ->

@ -125,7 +125,7 @@ let invalid : t -> bool
let to_string : t -> string let to_string : t -> string
= fun c -> = fun c ->
let c = set_size_pos c in let c = set_size_pos c in
"Offset : " ^ Itv.to_string c.idx ^ " Size : " ^ Itv.to_string c.size "Offset: " ^ Itv.to_string c.idx ^ " Size: " ^ Itv.to_string c.size
^ " @ " ^ string_of_location c.loc ^ " @ " ^ string_of_location c.loc
^ (match c.trace with ^ (match c.trace with
Inter (_, pname, _) -> Inter (_, pname, _) ->
@ -604,14 +604,14 @@ struct
let pp : F.formatter -> t -> unit let pp : F.formatter -> t -> unit
= fun fmt x -> = fun fmt x ->
F.fprintf fmt "Stack :@,"; F.fprintf fmt "Stack:@;";
F.fprintf fmt "%a@," Stack.pp x.stack; F.fprintf fmt "%a@;" Stack.pp x.stack;
F.fprintf fmt "Heap :@,"; F.fprintf fmt "Heap:@;";
F.fprintf fmt "%a" Heap.pp x.heap F.fprintf fmt "%a" Heap.pp x.heap
let pp_summary : F.formatter -> t -> unit let pp_summary : F.formatter -> t -> unit
= fun fmt x -> = fun fmt x ->
F.fprintf fmt "@[<v 0>Parameters :@,"; F.fprintf fmt "@[<v 0>Parameters:@,";
F.fprintf fmt "%a" Heap.pp_summary x.heap ; F.fprintf fmt "%a" Heap.pp_summary x.heap ;
F.fprintf fmt "@]" F.fprintf fmt "@]"
@ -668,7 +668,12 @@ struct
= fun ploc v s -> = fun ploc v s ->
if can_strong_update ploc if can_strong_update ploc
then strong_update_heap ploc v s then strong_update_heap ploc v s
else weak_update_heap ploc v s else
let () =
if Config.bo_debug >= 3 then
L.err "Weak update for %a <- %a@." PowLoc.pp ploc Val.pp v
in
weak_update_heap ploc v s
end end
module Mem = struct module Mem = struct

@ -1,12 +1,12 @@
codetoanalyze/c/bufferoverrun/break_continue_return.c, break_continue_return, 16, BUFFER_OVERRUN, [Offset : [0, 10] Size : [10, 10] @ codetoanalyze/c/bufferoverrun/break_continue_return.c:29:5] codetoanalyze/c/bufferoverrun/break_continue_return.c, break_continue_return, 16, BUFFER_OVERRUN, [Offset: [0, 10] Size: [10, 10] @ codetoanalyze/c/bufferoverrun/break_continue_return.c:29:5]
codetoanalyze/c/bufferoverrun/do_while.c, do_while, 2, BUFFER_OVERRUN, [Offset : [0, +oo] Size : [10, 10] @ codetoanalyze/c/bufferoverrun/do_while.c:18:5 by call `do_while_sub()` ] codetoanalyze/c/bufferoverrun/do_while.c, do_while, 2, BUFFER_OVERRUN, [Offset: [0, +oo] Size: [10, 10] @ codetoanalyze/c/bufferoverrun/do_while.c:18:5 by call `do_while_sub()` ]
codetoanalyze/c/bufferoverrun/do_while.c, do_while, 3, BUFFER_OVERRUN, [Offset : [0, +oo] Size : [10, 10] @ codetoanalyze/c/bufferoverrun/do_while.c:18:5 by call `do_while_sub()` ] codetoanalyze/c/bufferoverrun/do_while.c, do_while, 3, BUFFER_OVERRUN, [Offset: [0, +oo] Size: [10, 10] @ codetoanalyze/c/bufferoverrun/do_while.c:18:5 by call `do_while_sub()` ]
codetoanalyze/c/bufferoverrun/for_loop.c, for_loop, 10, BUFFER_OVERRUN, [Offset : [0, 9] Size : [5, 10] @ codetoanalyze/c/bufferoverrun/for_loop.c:38:5] codetoanalyze/c/bufferoverrun/for_loop.c, for_loop, 10, BUFFER_OVERRUN, [Offset: [0, 9] Size: [5, 10] @ codetoanalyze/c/bufferoverrun/for_loop.c:38:5]
codetoanalyze/c/bufferoverrun/function_call.c, function_call, 4, BUFFER_OVERRUN, [Offset : [20, 20] Size : [10, 10] @ codetoanalyze/c/bufferoverrun/function_call.c:18:3 by call `arr_access()` ] codetoanalyze/c/bufferoverrun/function_call.c, function_call, 4, BUFFER_OVERRUN, [Offset: [20, 20] Size: [10, 10] @ codetoanalyze/c/bufferoverrun/function_call.c:18:3 by call `arr_access()` ]
codetoanalyze/c/bufferoverrun/function_call.c, function_call, 4, BUFFER_OVERRUN, [Offset : [100, 100] Size : [10, 10] @ codetoanalyze/c/bufferoverrun/function_call.c:17:3 by call `arr_access()` ] codetoanalyze/c/bufferoverrun/function_call.c, function_call, 4, BUFFER_OVERRUN, [Offset: [100, 100] Size: [10, 10] @ codetoanalyze/c/bufferoverrun/function_call.c:17:3 by call `arr_access()` ]
codetoanalyze/c/bufferoverrun/goto_loop.c, goto_loop, 11, BUFFER_OVERRUN, [Offset : [10, +oo] Size : [10, 10] @ codetoanalyze/c/bufferoverrun/goto_loop.c:24:3] codetoanalyze/c/bufferoverrun/goto_loop.c, goto_loop, 11, BUFFER_OVERRUN, [Offset: [10, +oo] Size: [10, 10] @ codetoanalyze/c/bufferoverrun/goto_loop.c:24:3]
codetoanalyze/c/bufferoverrun/nested_loop.c, nested_loop, 7, BUFFER_OVERRUN, [Offset : [0, 10] Size : [10, 10] @ codetoanalyze/c/bufferoverrun/nested_loop.c:20:7] codetoanalyze/c/bufferoverrun/nested_loop.c, nested_loop, 7, BUFFER_OVERRUN, [Offset: [0, 10] Size: [10, 10] @ codetoanalyze/c/bufferoverrun/nested_loop.c:20:7]
codetoanalyze/c/bufferoverrun/nested_loop_with_label.c, nested_loop_with_label, 6, BUFFER_OVERRUN, [Offset : [0, +oo] Size : [10, 10] @ codetoanalyze/c/bufferoverrun/nested_loop_with_label.c:19:5] codetoanalyze/c/bufferoverrun/nested_loop_with_label.c, nested_loop_with_label, 6, BUFFER_OVERRUN, [Offset: [0, +oo] Size: [10, 10] @ codetoanalyze/c/bufferoverrun/nested_loop_with_label.c:19:5]
codetoanalyze/c/bufferoverrun/prune_alias.c, FP_prune_alias_exp_Ok, 4, BUFFER_OVERRUN, [Offset : [1, 1] Size : [1, 1] @ codetoanalyze/c/bufferoverrun/prune_alias.c:107:5] codetoanalyze/c/bufferoverrun/prune_alias.c, FP_prune_alias_exp_Ok, 4, BUFFER_OVERRUN, [Offset: [1, 1] Size: [1, 1] @ codetoanalyze/c/bufferoverrun/prune_alias.c:107:5]
codetoanalyze/c/bufferoverrun/trivial.c, trivial, 2, BUFFER_OVERRUN, [Offset : [10, 10] Size : [10, 10] @ codetoanalyze/c/bufferoverrun/trivial.c:15:3] codetoanalyze/c/bufferoverrun/trivial.c, trivial, 2, BUFFER_OVERRUN, [Offset: [10, 10] Size: [10, 10] @ codetoanalyze/c/bufferoverrun/trivial.c:15:3]
codetoanalyze/c/bufferoverrun/while_loop.c, while_loop, 3, BUFFER_OVERRUN, [Offset : [0, +oo] Size : [10, 10] @ codetoanalyze/c/bufferoverrun/while_loop.c:16:10] codetoanalyze/c/bufferoverrun/while_loop.c, while_loop, 3, BUFFER_OVERRUN, [Offset: [0, +oo] Size: [10, 10] @ codetoanalyze/c/bufferoverrun/while_loop.c:16:10]

@ -1 +1 @@
codetoanalyze/cpp/bufferoverrun/trivial.cpp, trivial, 2, BUFFER_OVERRUN, [Offset : [10, 10] Size : [10, 10] @ codetoanalyze/cpp/bufferoverrun/trivial.cpp:15:3] codetoanalyze/cpp/bufferoverrun/trivial.cpp, trivial, 2, BUFFER_OVERRUN, [Offset: [10, 10] Size: [10, 10] @ codetoanalyze/cpp/bufferoverrun/trivial.cpp:15:3]

Loading…
Cancel
Save