[debug/explore] add possibility to select "all"

Summary: Can be useful, especially to dump all the summaries as json.

Reviewed By: skcho

Differential Revision: D24504253

fbshipit-source-id: 845e7d657
master
Jules Villard 4 years ago committed by Facebook GitHub Bot
parent 46838a45a4
commit 8f94d39ce1

@ -34,8 +34,9 @@ OPTIONS
Show this manual with all internal options in the INTERNAL OPTIONS Show this manual with all internal options in the INTERNAL OPTIONS
section section
--select N --select (N|all)
Select option number N. If omitted, prompt for input. Select option number N or all of them. If omitted, prompt for
input.
DEBUG GLOBAL TYPE ENVIRONMENT DEBUG GLOBAL TYPE ENVIRONMENT
--global-tenv --global-tenv
Activates: Print the global type environment. (Conversely: Activates: Print the global type environment. (Conversely:

@ -36,8 +36,9 @@ EXPLORE BUGS
maximum nesting level are skipped. If omitted, all levels are maximum nesting level are skipped. If omitted, all levels are
shown. shown.
--select N --select (N|all)
Select option number N. If omitted, prompt for input. Select option number N or all of them. If omitted, prompt for
input.
--no-source-preview --no-source-preview
Deactivates: print code excerpts around trace elements Deactivates: print code excerpts around trace elements

@ -1048,9 +1048,9 @@ OPTIONS
performs better in some circumstances performs better in some circumstances
See also infer-analyze(1). See also infer-analyze(1).
--select N --select (N|all)
Select option number N. If omitted, prompt for input. Select option number N or all of them. If omitted, prompt for
See also infer-debug(1) and infer-explore(1). input. See also infer-debug(1) and infer-explore(1).
--no-self-in-block --no-self-in-block
Deactivates: checker self-in-block: An Objective-C-specific Deactivates: checker self-in-block: An Objective-C-specific

@ -1048,9 +1048,9 @@ OPTIONS
performs better in some circumstances performs better in some circumstances
See also infer-analyze(1). See also infer-analyze(1).
--select N --select (N|all)
Select option number N. If omitted, prompt for input. Select option number N or all of them. If omitted, prompt for
See also infer-debug(1) and infer-explore(1). input. See also infer-debug(1) and infer-explore(1).
--no-self-in-block --no-self-in-block
Deactivates: checker self-in-block: An Objective-C-specific Deactivates: checker self-in-block: An Objective-C-specific

@ -26,12 +26,14 @@ let select_proc_names_interactive ~filter =
| [], _ -> | [], _ ->
F.eprintf "No procedures found" ; F.eprintf "No procedures found" ;
None None
| _, Some n when n >= proc_names_len -> | _, Some (`Select n) when n >= proc_names_len ->
L.die UserError "Cannot select result #%d out of only %d procedures" n proc_names_len L.die UserError "Cannot select result #%d out of only %d procedures" n proc_names_len
| [proc_name], _ -> | [proc_name], _ ->
F.eprintf "Selected proc name: %a@." Procname.pp proc_name ; F.eprintf "Selected proc name: %a@." Procname.pp proc_name ;
Some proc_names Some proc_names
| _, Some n -> | _, Some `All ->
Some proc_names
| _, Some (`Select n) ->
let proc_names_array = List.to_array proc_names in let proc_names_array = List.to_array proc_names in
Some [proc_names_array.(n)] Some [proc_names_array.(n)]
| _, None -> | _, None ->

@ -2070,9 +2070,9 @@ and seconds_per_iteration =
and select = and select =
CLOpt.mk_int_opt ~long:"select" ~meta:"N" CLOpt.mk_string_opt ~long:"select" ~meta:"(N|all)"
~in_help:InferCommand.[(Debug, manual_generic); (Explore, manual_explore_bugs)] ~in_help:InferCommand.[(Debug, manual_generic); (Explore, manual_explore_bugs)]
"Select option number $(i,N). If omitted, prompt for input." "Select option number $(i,N) or $(i,all) of them. If omitted, prompt for input."
and scuba_logging, cost_scuba_logging = and scuba_logging, cost_scuba_logging =
@ -3123,7 +3123,17 @@ and scuba_tags = String.Map.map !scuba_tags ~f:(fun v -> String.split v ~on:',')
and seconds_per_iteration = !seconds_per_iteration and seconds_per_iteration = !seconds_per_iteration
and select = !select and select =
match !select with
| None ->
None
| Some "all" ->
Some `All
| Some n -> (
try Some (`Select (Int.of_string n))
with _ ->
L.die UserError "Wrong argument for --select: expected an integer or \"all\" but got '%s'" n )
and show_buckets = !print_buckets and show_buckets = !print_buckets

@ -527,7 +527,7 @@ val scuba_tags : string list String.Map.t
val seconds_per_iteration : float option val seconds_per_iteration : float option
val select : int option val select : [`All | `Select of int] option
val show_buckets : bool val show_buckets : bool

@ -76,30 +76,30 @@ let read_report report_json = Atdgen_runtime.Util.Json.from_file Jsonbug_j.read_
let explore ~selector_limit ~report_txt:_ ~report_json ~show_source_context ~selected let explore ~selector_limit ~report_txt:_ ~report_json ~show_source_context ~selected
~max_nested_level = ~max_nested_level =
let report = read_report report_json in let report = read_report report_json in
let issue_to_display = let display_issue issue =
match (selected, report) with L.result "@\n%a" (pp_issue_with_trace ~show_source_context ~max_nested_level) issue
| Some n, _ -> (
(* an issue number has been pre-selected, use that *)
match List.nth report n with
| None ->
L.die UserError "Cannot select issues #%d: only %d issues in '%s'" n (List.length report)
report_json
| Some issue ->
Some (n, issue) )
| None, [] ->
(* empty report, can't print anything *)
L.progress "No issues found in '%s', exiting.@\n" report_json ;
None
| None, [issue] ->
(* single-issue report: no need to prompt the user to select which issue to display *)
L.progress "Auto-selecting the only issue in '%s'@\n%!" report_json ;
Some (0, issue)
| None, _ :: _ :: _ ->
(* user prompt *)
Some (user_select_issue ~selector_limit report)
in in
Option.iter issue_to_display ~f:(fun issue -> match (selected, report) with
L.result "@\n%a" (pp_issue_with_trace ~show_source_context ~max_nested_level) issue ) | Some `All, _ ->
List.iteri report ~f:(fun n issue -> display_issue (n, issue))
| Some (`Select n), _ -> (
(* an issue number has been pre-selected, use that *)
match List.nth report n with
| None ->
L.die UserError "Cannot select issues #%d: only %d issues in '%s'" n (List.length report)
report_json
| Some issue ->
display_issue (n, issue) )
| None, [] ->
(* empty report, can't print anything *)
L.progress "No issues found in '%s', exiting.@\n" report_json
| None, [issue] ->
(* single-issue report: no need to prompt the user to select which issue to display *)
L.progress "Auto-selecting the only issue in '%s'@\n%!" report_json ;
display_issue (0, issue)
| None, _ :: _ :: _ ->
(* user prompt *)
display_issue (user_select_issue ~selector_limit report)
module GitHub = struct module GitHub = struct

@ -11,7 +11,7 @@ val explore :
-> report_txt:string -> report_txt:string
-> report_json:string -> report_json:string
-> show_source_context:bool -> show_source_context:bool
-> selected:int option -> selected:[`All | `Select of int] option
-> max_nested_level:int option -> max_nested_level:int option
-> unit -> unit

Loading…
Cancel
Save