Add stacktrace extras to BoundedCallTree checker.

Reviewed By: sblackshear

Differential Revision: D3589871

fbshipit-source-id: 93c3df9
master
Lázaro Clapp Jiménez Labora 8 years ago committed by Facebook Github Bot 1
parent 0ca19da3cf
commit 9f7cb87bb0

@ -25,11 +25,18 @@ module Domain = AbstractDomain.FiniteSet(ProcnameSet)
module TransferFunctions (CFG : ProcCfg.S) = struct
module CFG = CFG
module Domain = Domain
type extras = ProcData.no_extras
type extras = Stacktrace.t
let exec_instr astate _ _ = function
let exec_instr astate proc_data _ = function
| Sil.Call (_, Const (Const.Cfun pn), _, _, _) ->
Domain.add pn astate
(** TODO: Match class. *)
let caller = Cfg.Procdesc.get_proc_name proc_data.ProcData.pdesc in
let matches_proc frame =
frame.Stacktrace.method_str = (Procname.get_method caller) in
let proc_in_trace = IList.exists
matches_proc
proc_data.ProcData.extras.Stacktrace.frames in
if proc_in_trace then Domain.add pn astate else astate
| Sil.Call _ ->
(** We currently ignore calls through function pointers in C and
* other potential special kinds of procedure calls to be added later,
@ -46,5 +53,5 @@ module Analyzer =
(Scheduler.ReversePostorder)
(TransferFunctions)
let checker { Callbacks.proc_desc; tenv; } =
ignore(Analyzer.exec_pdesc (ProcData.make_default proc_desc tenv))
let checker { Callbacks.proc_desc; tenv; } trace =
ignore(Analyzer.exec_pdesc (ProcData.make proc_desc tenv trace))

@ -39,7 +39,6 @@ let active_procedure_checkers () =
PrintfArgs.callback_printf_args, checkers_enabled;
AnnotationReachability.Interprocedural.check_and_report, checkers_enabled;
Checkers.callback_print_access_to_globals, false;
BoundedCallTree.checker, false;
] in
IList.map (fun (x, y) -> (x, y, Some Config.Java)) l in
let c_cpp_checkers =

@ -23,7 +23,15 @@ let tests =
let g_proc_name = Procname.from_string_c_fun "g" in
let g_args = [((Sil.Const (Const.Cint (IntLit.one))), (Typ.Tint IInt))] in
let g_ret_ids = [(ident_of_str "r")] in
let test_list = [
let class_name = "com.example.SomeClass" in
let file_name = "SomeClass.java" in
let trace = Stacktrace.make "java.lang.NullPointerException"
[Stacktrace.make_frame class_name "foo" file_name 16;
Stacktrace.make_frame class_name "bar" file_name 20] in
let caller_foo_name = Procname.from_string_c_fun "foo" in
let caller_bar_name = Procname.from_string_c_fun "bar" in
let caller_baz_name = Procname.from_string_c_fun "baz" in
let test_list_from_foo = [
"on_call_add_proc_name",
[
make_call ~procname:f_proc_name [] []; (* means f() *)
@ -48,5 +56,22 @@ let tests =
make_call ~procname:f_proc_name [] [];
invariant "{ f }"
];
] |> TestInterpreter.create_tests ProcData.empty_extras in
] |> TestInterpreter.create_tests ~test_pname:caller_foo_name trace in
let test_list_from_bar = [
"on_call_anywhere_on_stack_add_proc_name",
[
make_call ~procname:f_proc_name [] []; (* means f() *)
invariant "{ f }"
];
] |> TestInterpreter.create_tests ~test_pname:caller_bar_name trace in
let test_list_from_baz = [
"ignore_procs_unrelated_to_trace",
[
make_call ~procname:f_proc_name [] []; (* means f() *)
invariant "{ }"
];
] |> TestInterpreter.create_tests ~test_pname:caller_baz_name trace in
let test_list = test_list_from_foo @
test_list_from_bar @
test_list_from_baz in
"bounded_calltree_test_suite">:::test_list

Loading…
Cancel
Save