delete ondemand capture

Summary:
Good night, sweet prince. This was never used and hasn't seen progress
in a while.

Reviewed By: jberdine

Differential Revision: D21201932

fbshipit-source-id: e6f537b30
master
Jules Villard 5 years ago committed by Facebook GitHub Bot
parent 16859e0961
commit 44108c2392

@ -1615,10 +1615,6 @@ INTERNAL OPTIONS
Activates: [Purity]Consider unknown functions to be pure by Activates: [Purity]Consider unknown functions to be pure by
default (Conversely: --no-pure-by-default) default (Conversely: --no-pure-by-default)
--reactive-capture
Activates: Compile source files only when required by analyzer
(clang only) (Conversely: --no-reactive-capture)
--reanalyze --reanalyze
Activates: Rerun the analysis. Not compatible with Activates: Rerun the analysis. Not compatible with
--incremental-analysis and --continue-analysis. (Conversely: --incremental-analysis and --continue-analysis. (Conversely:

@ -66,23 +66,15 @@ let select_statement =
ResultsDatabase.register_statement "SELECT proc_attributes FROM procedures WHERE proc_name = :k" ResultsDatabase.register_statement "SELECT proc_attributes FROM procedures WHERE proc_name = :k"
let select_defined_statement = let find pname_blob =
ResultsDatabase.register_statement ResultsDatabase.with_registered_statement select_statement ~f:(fun db select_stmt ->
"SELECT proc_attributes FROM procedures WHERE proc_name = :k AND attr_kind = %Ld"
(int64_of_attributes_kind ProcDefined)
let find ~defined pname_blob =
(if defined then select_defined_statement else select_statement)
|> ResultsDatabase.with_registered_statement ~f:(fun db select_stmt ->
Sqlite3.bind select_stmt 1 pname_blob Sqlite3.bind select_stmt 1 pname_blob
|> SqliteUtils.check_result_code db ~log:"find bind proc name" ; |> SqliteUtils.check_result_code db ~log:"find bind proc name" ;
SqliteUtils.result_single_column_option ~finalize:false ~log:"Attributes.find" db SqliteUtils.result_single_column_option ~finalize:false ~log:"Attributes.find" db select_stmt
select_stmt
|> Option.map ~f:ProcAttributes.SQLite.deserialize ) |> Option.map ~f:ProcAttributes.SQLite.deserialize )
let load pname = Procname.SQLite.serialize pname |> find ~defined:false let load pname = find (Procname.SQLite.serialize pname)
let store ~proc_desc (attr : ProcAttributes.t) = let store ~proc_desc (attr : ProcAttributes.t) =
let pkind = proc_kind_of_attr attr in let pkind = proc_kind_of_attr attr in
@ -95,8 +87,6 @@ let store ~proc_desc (attr : ProcAttributes.t) =
(Option.map proc_desc ~f:Procdesc.get_static_callees |> Option.value ~default:[]) (Option.map proc_desc ~f:Procdesc.get_static_callees |> Option.value ~default:[])
let load_defined pname = Procname.SQLite.serialize pname |> find ~defined:true
let find_file_capturing_procedure pname = let find_file_capturing_procedure pname =
Option.map (load pname) ~f:(fun proc_attributes -> Option.map (load pname) ~f:(fun proc_attributes ->
let source_file = proc_attributes.ProcAttributes.translation_unit in let source_file = proc_attributes.ProcAttributes.translation_unit in

@ -19,9 +19,6 @@ val store : proc_desc:Procdesc.t option -> ProcAttributes.t -> unit
val load : Procname.t -> ProcAttributes.t option val load : Procname.t -> ProcAttributes.t option
(** Load the attributes for the procedure from the attributes database. *) (** Load the attributes for the procedure from the attributes database. *)
val load_defined : Procname.t -> ProcAttributes.t option
(** Load attributes for the procedure but only if is_defined is true *)
val find_file_capturing_procedure : Procname.t -> (SourceFile.t * [`Include | `Source]) option val find_file_capturing_procedure : Procname.t -> (SourceFile.t * [`Include | `Source]) option
(** Find the file where the procedure was captured, if a cfg for that file exists. Return also a (** Find the file where the procedure was captured, if a cfg for that file exists. Return also a
boolean indicating whether the procedure is defined in an include file. *) boolean indicating whether the procedure is defined in an include file. *)

@ -93,21 +93,6 @@ let proc_names_of_source source =
|> Option.value_map ~default:[] ~f:Procname.SQLiteList.deserialize ) |> Option.value_map ~default:[] ~f:Procname.SQLiteList.deserialize )
let exists_source_statement =
ResultsDatabase.register_statement "SELECT 1 FROM source_files WHERE source_file = :k"
let is_captured source =
ResultsDatabase.with_registered_statement exists_source_statement ~f:(fun db exists_stmt ->
SourceFile.SQLite.serialize source
|> Sqlite3.bind exists_stmt 1
(* :k *)
|> SqliteUtils.check_result_code db ~log:"load captured source file" ;
SqliteUtils.result_single_column_option ~finalize:false ~log:"SourceFiles.is_captured" db
exists_stmt
|> Option.is_some )
let is_non_empty_statement = ResultsDatabase.register_statement "SELECT 1 FROM source_files LIMIT 1" let is_non_empty_statement = ResultsDatabase.register_statement "SELECT 1 FROM source_files LIMIT 1"
let is_empty () = let is_empty () =

@ -16,9 +16,6 @@ val get_all : filter:Filtering.source_files_filter -> unit -> SourceFile.t list
val proc_names_of_source : SourceFile.t -> Procname.t list val proc_names_of_source : SourceFile.t -> Procname.t list
(** list of all the proc names (declared and defined) found in a source file *) (** list of all the proc names (declared and defined) found in a source file *)
val is_captured : SourceFile.t -> bool
(** has the source file been captured? *)
val is_empty : unit -> bool val is_empty : unit -> bool
(** whether there exists at least one captured source file *) (** whether there exists at least one captured source file *)

@ -1,58 +0,0 @@
(*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
open! IStd
module L = Logging
let compilation_db = lazy (CompilationDatabase.from_json_files !Config.clang_compilation_dbs)
(** Given proc_attributes try to produce proc_attributes' where proc_attributes'.is_defined = true
It may trigger capture of extra files to do so and when it does, it waits for frontend to finish
before returning *)
let try_capture (attributes : ProcAttributes.t) : ProcAttributes.t option =
let (lazy cdb) = compilation_db in
( if Option.is_none (Attributes.load_defined attributes.proc_name) then
let decl_file = attributes.loc.file in
let definition_file_opt = SourceFile.of_header decl_file in
let try_compile definition_file =
(* Use the cfg as a proxy to find out whether definition_file was already captured. If it
was, there is no point in trying to capture it again. Treat existance of the cfg as a
barrier - if it exists it means that all attributes files have been created - write logic
is defined in Cfg.store *)
if not (SourceFiles.is_captured decl_file) then (
L.(debug Capture Verbose) "Started capture of %a...@\n" SourceFile.pp definition_file ;
Timeout.suspend_existing_timeout ~keep_symop_total:true ;
protect
~f:(fun () -> CaptureCompilationDatabase.capture_file_in_database cdb definition_file)
~finally:Timeout.resume_previous_timeout ;
if Config.debug_mode && Option.is_none (Attributes.load_defined attributes.proc_name) then
(* peek at the results to know if capture succeeded, but only in debug mode *)
L.(debug Capture Verbose)
"Captured file %a to get procedure %a but it wasn't found there@\n" SourceFile.pp
definition_file Procname.pp attributes.proc_name )
else
L.(debug Capture Verbose)
"Wanted to capture file %a to get procedure %a but file was already captured@\n"
SourceFile.pp definition_file Procname.pp attributes.proc_name
in
match definition_file_opt with
| None ->
L.(debug Capture Medium)
"Couldn't find source file for %a (declared in %a)@\n" Procname.pp attributes.proc_name
SourceFile.pp decl_file
| Some file ->
try_compile file ) ;
(* It's important to call load_defined_attributes again in all cases to make sure we try
reading from disk again no matter which condition happened. If previous call to
load_defined_attributes is None, it may mean couple of things:
- proc_name hasn't been captured yet, so it needs to get captured (most likely scenario)
- there was a race and proc_name got captured by the time we checked whether
cfg_filename exists. In this case it's important to refetch attributes from disk because
contents may have changed (attributes file for proc_name may be there now)
Caveat: it's possible that procedure will be captured in some other unrelated file
later - infer may ignore it then. *)
Attributes.load_defined attributes.proc_name

@ -49,9 +49,6 @@ let get_file_data exe_env pname =
| None -> | None ->
L.debug Analysis Medium "can't find attributes for %a@." Procname.pp pname ; L.debug Analysis Medium "can't find attributes for %a@." Procname.pp pname ;
None None
| Some proc_attributes when Config.reactive_capture ->
let get_captured_file {ProcAttributes.translation_unit} = translation_unit in
OndemandCapture.try_capture proc_attributes |> Option.map ~f:get_captured_file
| Some proc_attributes -> | Some proc_attributes ->
Some proc_attributes.ProcAttributes.translation_unit Some proc_attributes.ProcAttributes.translation_unit
in in

@ -81,10 +81,6 @@ let get_proc_attr proc_name =
let procedure_should_be_analyzed proc_name = let procedure_should_be_analyzed proc_name =
match get_proc_attr proc_name with match get_proc_attr proc_name with
| Some proc_attributes when Config.reactive_capture && not proc_attributes.is_defined ->
(* try to capture procedure first *)
let defined_proc_attributes = OndemandCapture.try_capture proc_attributes in
Option.value_map ~f:should_be_analyzed ~default:false defined_proc_attributes
| Some proc_attributes -> | Some proc_attributes ->
should_be_analyzed proc_attributes should_be_analyzed proc_attributes
| None -> | None ->

@ -1843,11 +1843,6 @@ and reactive =
started" started"
and reactive_capture =
CLOpt.mk_bool ~long:"reactive-capture"
"Compile source files only when required by analyzer (clang only)"
and reanalyze = and reanalyze =
CLOpt.mk_bool ~long:"reanalyze" CLOpt.mk_bool ~long:"reanalyze"
"Rerun the analysis. Not compatible with $(b,--incremental-analysis) and \ "Rerun the analysis. Not compatible with $(b,--incremental-analysis) and \
@ -2882,8 +2877,6 @@ and racerd_guardedby = !racerd_guardedby
and reactive_mode = !reactive and reactive_mode = !reactive
and reactive_capture = !reactive_capture
and reanalyze = !reanalyze and reanalyze = !reanalyze
and relative_path_backtrack = !relative_path_backtrack and relative_path_backtrack = !relative_path_backtrack

@ -469,8 +469,6 @@ val quiet : bool
val racerd_guardedby : bool val racerd_guardedby : bool
val reactive_capture : bool
val reactive_mode : bool val reactive_mode : bool
val reanalyze : bool val reanalyze : bool

@ -155,7 +155,3 @@ let capture_files_in_database ~changed_files compilation_database =
fun source_file -> SourceFile.Set.mem source_file changed_files_set fun source_file -> SourceFile.Set.mem source_file changed_files_set
in in
run_compilation_database compilation_database filter_changed run_compilation_database compilation_database filter_changed
let capture_file_in_database compilation_database source_file =
run_compilation_database compilation_database (SourceFile.equal source_file)

@ -12,8 +12,6 @@ val capture_files_in_database :
(** Run the capture of the files for which we have compilation commands in the database and in (** Run the capture of the files for which we have compilation commands in the database and in
[changed_files], if specified. *) [changed_files], if specified. *)
val capture_file_in_database : CompilationDatabase.t -> SourceFile.t -> unit
val get_compilation_database_files_buck : val get_compilation_database_files_buck :
BuckMode.clang_compilation_db_deps -> prog:string -> args:string list -> [> `Raw of string] list BuckMode.clang_compilation_db_deps -> prog:string -> args:string list -> [> `Raw of string] list
(** Get the compilation database files that contain the compilation given by the buck command. It (** Get the compilation database files that contain the compilation given by the buck command. It

@ -36,16 +36,9 @@ infer-out-no-index/report.json: $(CMAKE_BUILD_DIR)/compile_commands.json $(CLANG
$(QUIET)$(call silent_on_success,Testing Clang compilation database integration,\ $(QUIET)$(call silent_on_success,Testing Clang compilation database integration,\
$(INFER_BIN) $(INFER_OPTIONS) -o $(@D) --compilation-database $<) $(INFER_BIN) $(INFER_OPTIONS) -o $(@D) --compilation-database $<)
infer-out-reactive-capture/report.json: $(CMAKE_BUILD_DIR)/compile_commands.json $(CLANG_DEPS) $(SOURCES) issues.exp.test: infer-out-with-index/report.json infer-out-no-index/report.json
$(QUIET)$(call silent_on_success,Testing Clang compilation database reactive capture integration,\
$(INFER_BIN) $(INFER_OPTIONS) -o $(@D) --reactive-capture \
--changed-files-index $(CMAKE_DIR)/index.txt --compilation-database $<)
issues.exp.test: infer-out-with-index/report.json infer-out-no-index/report.json infer-out-reactive-capture/report.json
$(QUIET)$(INFER_BIN) report -q $(INFERPRINT_OPTIONS) $@.with-index \ $(QUIET)$(INFER_BIN) report -q $(INFERPRINT_OPTIONS) $@.with-index \
-o infer-out-with-index -o infer-out-with-index
$(QUIET)$(INFER_BIN) report -q $(INFERPRINT_OPTIONS) $@.no-index \ $(QUIET)$(INFER_BIN) report -q $(INFERPRINT_OPTIONS) $@.no-index \
-o infer-out-no-index -o infer-out-no-index
$(QUIET)$(INFER_BIN) report -q $(INFERPRINT_OPTIONS) $@.reactive-capture \ $(QUIET)cat $@.with-index $@.no-index > $@
-o infer-out-reactive-capture
$(QUIET)cat $@.with-index $@.no-index $@.reactive-capture > $@

@ -5,7 +5,3 @@ hello.cpp, test0, 2, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure tes
hello.cpp, test1, 2, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure test1(),start of procedure deref1()] hello.cpp, test1, 2, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure test1(),start of procedure deref1()]
hello.cpp, test2, 2, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure test2(),start of procedure deref2()] hello.cpp, test2, 2, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure test2(),start of procedure deref2()]
lib3.h, test, 0, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure test(),start of procedure deref3()] lib3.h, test, 0, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure test(),start of procedure deref3()]
hello.cpp, test0, 2, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure test0()]
hello.cpp, test1, 2, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure test1(),start of procedure deref1()]
hello.cpp, test2, 2, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure test2(),start of procedure deref2()]
lib3.h, test, 0, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure test(),start of procedure deref3()]

Loading…
Cancel
Save