From 010b57e7cc1c4b195a83225bf5cbac0f0f288d66 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Mon, 14 Mar 2016 06:14:04 -0700 Subject: [PATCH] Add --continue option for reactive analysis to continue the capture. Summary:public The reactive analysis starts from the set of changed files/procedures, and proceeds reactively to analyze their dependencies. This means that after every command, the set of changed files/procedures is reset. With the --continue option, the capture is continued: all the files/procedures marked as changed stay changed, plus any additional changes are recorded. In addition to allowing to spread capture over several commands, the option also allows to separate capture and analysis in reactive mode, or to repeat the analysis. Reviewed By: sblackshear Differential Revision: D3046361 fb-gh-sync-id: b6e3797 shipit-source-id: b6e3797 --- infer/lib/python/infer | 3 ++- infer/lib/python/inferlib/analyze.py | 11 +++++++++-- infer/src/backend/cfg.ml | 5 ++++- infer/src/backend/config.ml | 4 ++++ infer/src/backend/inferanalyze.ml | 6 ++++++ 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/infer/lib/python/infer b/infer/lib/python/infer index c226fa3a9..367b072f3 100755 --- a/infer/lib/python/infer +++ b/infer/lib/python/infer @@ -126,7 +126,8 @@ def main(): if imported_module: analyze.create_results_dir(args.infer_out) - analyze.reset_start_file(args.infer_out) + if not args.continue_capture: + analyze.reset_start_file(args.infer_out) utils.configure_logging(args) logging.info('Running command %s', ' '.join(sys.argv)) diff --git a/infer/lib/python/inferlib/analyze.py b/infer/lib/python/inferlib/analyze.py index c790bc74d..cf76ae94e 100644 --- a/infer/lib/python/inferlib/analyze.py +++ b/infer/lib/python/inferlib/analyze.py @@ -65,9 +65,13 @@ base_group.add_argument('-i', '--incremental', base_group.add_argument('-ic', '--changed-only', dest='reactive', action='store_true', help='''DEPRECATED: use --reactive.''') -base_group.add_argument('--reactive', action='store_true', +base_group.add_argument('-r', '--reactive', action='store_true', help='''Analyze in reactive propagation mode starting from changed files.''') +base_group.add_argument('-c', '--continue', action='store_true', + dest='continue_capture', + help='''Continue the capture for the reactive + analysis, increasing the changed files/procedures.''') base_group.add_argument('--debug-exceptions', action='store_true', help='''Generate lightweight debugging information: just print the internal exceptions during analysis''') @@ -108,7 +112,7 @@ infer_group.add_argument('-j', '--multicore', metavar='n', type=int, infer_group.add_argument('-x', '--project', metavar='', help='Project name, for recording purposes only') -infer_group.add_argument('-r', '--revision', metavar='', +infer_group.add_argument('--revision', metavar='', help='The githash, for recording purposes only') infer_group.add_argument('--buck', action='store_true', dest='buck', @@ -309,6 +313,9 @@ class AnalyzerWrapper(object): if self.args.reactive: infer_options.append('-reactive') + if self.args.continue_capture: + infer_options.append('-continue') + if self.args.specs_dirs: infer_options += self.args.specs_dirs diff --git a/infer/src/backend/cfg.ml b/infer/src/backend/cfg.ml index 606e926cd..615884865 100644 --- a/infer/src/backend/cfg.ml +++ b/infer/src/backend/cfg.ml @@ -133,7 +133,10 @@ module Node = struct let mark_pdesc_if_unchanged pname new_pdesc = try let old_pdesc = Procname.Hash.find old_procs pname in - let changed = not (pdescs_eq old_pdesc new_pdesc) in + let changed = + (* in continue_capture mode keep the old changed bit *) + (!Config.continue_capture && old_pdesc.pd_attributes.ProcAttributes.changed) || + not (pdescs_eq old_pdesc new_pdesc) in new_pdesc.pd_attributes.changed <- changed with Not_found -> () in Procname.Hash.iter mark_pdesc_if_unchanged new_procs diff --git a/infer/src/backend/config.ml b/infer/src/backend/config.ml index 7d7bf44e9..a3c9d8a3c 100644 --- a/infer/src/backend/config.ml +++ b/infer/src/backend/config.ml @@ -195,6 +195,10 @@ let checkers_enabled () = not !eradicate the analysis starts from the files captured since the "infer" command started *) let reactive_mode = ref false +(** Continue the capture for reactive mode: + If a procedure was changed beforehand, keep the changed marking. *) +let continue_capture = ref false + (** Flag for footprint discovery mode *) let footprint = ref true diff --git a/infer/src/backend/inferanalyze.ml b/infer/src/backend/inferanalyze.ml index 6920c51cb..ff2cac7f0 100644 --- a/infer/src/backend/inferanalyze.ml +++ b/infer/src/backend/inferanalyze.ml @@ -82,6 +82,12 @@ let arg_desc = None, "analyze in reactive propagation mode starting from changed files" ; + "-continue", + Arg.Set Config.continue_capture, + None, + "continue the capture for the reactive analysis,\ + increasing the changed files/procedures." + ; (* TODO: merge with the -project_root option *) "-java", Arg.Unit (fun () -> Config.curr_language := Config.Java),