@ -39,7 +39,7 @@ let read_dirs_to_analyze () =
let dirs_to_analyze =
let dirs_to_analyze =
lazy ( read_dirs_to_analyze () )
lazy ( read_dirs_to_analyze () )
type analyze_ondemand = Procname . t -> unit
type analyze_ondemand = Cfg. Procdesc . t -> unit
type get_cfg = Procname . t -> Cfg . cfg option
type get_cfg = Procname . t -> Cfg . cfg option
@ -62,21 +62,24 @@ let unset_callbacks () =
let nesting = ref 0
let nesting = ref 0
let procedure_should_be_analyzed proc_name =
let should_be_analyzed proc_attributes proc_name =
match AttributesTable . load_attributes proc_name with
let currently_analyzed () =
| Some proc_attributes ->
let currently_analyzed =
Specs . summary_exists proc_name &&
Specs . summary_exists proc_name &&
Specs . is_active proc_name in
Specs . is_active proc_name in
let already_analyzed = match Specs . get_summary proc_name with
let already_analyzed () =
match Specs . get_summary proc_name with
| Some summary ->
| Some summary ->
Specs . get_timestamp summary > 0
Specs . get_timestamp summary > 0
| None ->
| None ->
false in
false in
proc_attributes . ProcAttributes . is_defined && (* we have the implementation *)
proc_attributes . ProcAttributes . is_defined && (* we have the implementation *)
not currently_analyzed && (* avoid infinite loops *)
not ( currently_analyzed () ) && (* avoid infinite loops *)
not already_analyzed (* avoid re-analysis of the same procedure *)
not ( already_analyzed () ) (* avoid re-analysis of the same procedure *)
let procedure_should_be_analyzed proc_name =
match AttributesTable . load_attributes proc_name with
| Some proc_attributes ->
should_be_analyzed proc_attributes proc_name
| None ->
| None ->
false
false
@ -117,16 +120,14 @@ let restore_global_state st =
State . restore_state st . symexec_state ;
State . restore_state st . symexec_state ;
Timeout . resume_previous_timeout ()
Timeout . resume_previous_timeout ()
(* * do_analysis curr_pdesc proc_name
performs an on - demand analysis of proc_name
let run_proc_analysis ~ propagate_exceptions analyze_proc curr_pdesc callee_pdesc =
triggered during the analysis of curr_pname . * )
let do_analysis ~ propagate_exceptions curr_pdesc callee_pname =
let curr_pname = Cfg . Procdesc . get_proc_name curr_pdesc in
let curr_pname = Cfg . Procdesc . get_proc_name curr_pdesc in
let callee_pname = Cfg . Procdesc . get_proc_name callee_pdesc in
let really_do_analysis callee_pdesc analyze_proc =
(* * Dot means start of a procedure *)
(* * Dot means start of a procedure *)
L . log_progress_procedure () ;
L . log_progress_procedure () ;
if trace () then L . stderr " [%d] r eally_do _analysis %a -> %a@."
if trace () then L . stderr " [%d] r un_proc _analysis %a -> %a@."
! nesting
! nesting
Procname . pp curr_pname
Procname . pp curr_pname
Procname . pp callee_pname ;
Procname . pp callee_pname ;
@ -175,7 +176,7 @@ let do_analysis ~propagate_exceptions curr_pdesc callee_pname =
let old_state = save_global_state () in
let old_state = save_global_state () in
preprocess () ;
preprocess () ;
try
try
analyze_proc callee_pname ;
analyze_proc callee_pdesc ;
postprocess () ;
postprocess () ;
restore_global_state old_state ;
restore_global_state old_state ;
with exn ->
with exn ->
@ -196,7 +197,25 @@ let do_analysis ~propagate_exceptions curr_pdesc callee_pname =
log_error_and_continue exn kind
log_error_and_continue exn kind
| _ ->
| _ ->
(* this happens with assert false or some other unrecognized exception *)
(* this happens with assert false or some other unrecognized exception *)
log_error_and_continue exn ( FKcrash ( Printexc . to_string exn ) ) in
log_error_and_continue exn ( FKcrash ( Printexc . to_string exn ) )
let analyze_proc_desc ~ propagate_exceptions curr_pdesc callee_pdesc =
let callee_pname = Cfg . Procdesc . get_proc_name callee_pdesc in
let proc_attributes = Cfg . Procdesc . get_attributes callee_pdesc in
match ! callbacks_ref with
| Some callbacks
when should_be_analyzed proc_attributes callee_pname ->
run_proc_analysis
~ propagate_exceptions callbacks . analyze_ondemand curr_pdesc callee_pdesc
| _ -> ()
(* * analyze_proc_name curr_pdesc proc_name
performs an on - demand analysis of proc_name
triggered during the analysis of curr_pname . * )
let analyze_proc_name ~ propagate_exceptions curr_pdesc callee_pname =
match ! callbacks_ref with
match ! callbacks_ref with
| Some callbacks
| Some callbacks
@ -204,7 +223,7 @@ let do_analysis ~propagate_exceptions curr_pdesc callee_pname =
begin
begin
match callbacks . get_proc_desc callee_pname with
match callbacks . get_proc_desc callee_pname with
| Some callee_pdesc ->
| Some callee_pdesc ->
really_do_analysis callee_pdesc callbacks . analyze_ondemand
analyze_proc_desc ~ propagate_exceptions curr_pdesc callee_pdesc
| None ->
| None ->
()
()
end
end