Summary: Add a `--procedures` option to `infer explore` to print information about the procedures captured by infer. More precisely, `infer explore --procedures` will print each row of the "procedures" table in the results database. A new `--procedures-filter` controls which procedures to print information about, and there is one flag per column in the db too to print more or less options about each procedure (in particular, we can now print attributes), with some defaults. Reviewed By: sblackshear Differential Revision: D7639062 fbshipit-source-id: 034a2b8master
parent
269a1a9b93
commit
97ac7662f8
@ -0,0 +1,68 @@
|
||||
(*
|
||||
* Copyright (c) 2018 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*)
|
||||
open! IStd
|
||||
module F = Format
|
||||
module L = Logging
|
||||
|
||||
let select_all_procedures_like_statement =
|
||||
ResultsDatabase.register_statement
|
||||
"SELECT * FROM procedures WHERE proc_name LIKE :pname_like AND source_file LIKE \
|
||||
:source_file_like"
|
||||
|
||||
|
||||
let pp_all ?filter ~proc_name ~attr_kind ~source_file ~proc_attributes fmt () =
|
||||
let source_file_like, pname_like =
|
||||
match filter with
|
||||
| None ->
|
||||
let wildcard = Sqlite3.Data.TEXT "%" in
|
||||
(wildcard, wildcard)
|
||||
| Some filter_string ->
|
||||
match String.lsplit2 ~on:':' filter_string with
|
||||
| Some (source_file_like, pname_like) ->
|
||||
(Sqlite3.Data.TEXT source_file_like, Sqlite3.Data.TEXT pname_like)
|
||||
| None ->
|
||||
L.die UserError
|
||||
"Invalid filter for procedures. Please see the documentation for --procedures-filter \
|
||||
in `infer explore --help`."
|
||||
in
|
||||
ResultsDatabase.with_registered_statement select_all_procedures_like_statement ~f:(fun db stmt ->
|
||||
Sqlite3.bind stmt 1 (* :pname_like *) pname_like
|
||||
|> SqliteUtils.check_sqlite_error db ~log:"procedures filter pname bind" ;
|
||||
Sqlite3.bind stmt 2 (* :source_file_like *) source_file_like
|
||||
|> SqliteUtils.check_sqlite_error db ~log:"procedures filter source file bind" ;
|
||||
let pp_if ?(newline= false) condition deserialize pp fmt column =
|
||||
if condition then (
|
||||
if newline then F.fprintf fmt "@\n " ;
|
||||
F.fprintf fmt "%a@ " pp (Sqlite3.column stmt column |> deserialize) )
|
||||
in
|
||||
let rec aux () =
|
||||
match Sqlite3.step stmt with
|
||||
| Sqlite3.Rc.ROW ->
|
||||
let proc_name_hum =
|
||||
(* same as proc_name for now, will change later *)
|
||||
match[@warning "-8"] Sqlite3.column stmt 0 with Sqlite3.Data.TEXT s -> s
|
||||
in
|
||||
Format.fprintf fmt "@[<h2>%s:@ %a%a%a%a@]@\n" proc_name_hum
|
||||
(pp_if source_file SourceFile.SQLite.deserialize SourceFile.pp)
|
||||
2
|
||||
(pp_if proc_name Typ.Procname.SQLite.deserialize Typ.Procname.pp)
|
||||
0
|
||||
(pp_if attr_kind Attributes.deserialize_attributes_kind Attributes.pp_attributes_kind)
|
||||
1
|
||||
(pp_if ~newline:true proc_attributes ProcAttributes.SQLite.deserialize
|
||||
ProcAttributes.pp)
|
||||
3 ;
|
||||
aux ()
|
||||
| DONE ->
|
||||
()
|
||||
| err ->
|
||||
L.die InternalError "procedures_iter: %s (%s)" (Sqlite3.Rc.to_string err)
|
||||
(Sqlite3.errmsg db)
|
||||
in
|
||||
aux () )
|
@ -0,0 +1,14 @@
|
||||
(*
|
||||
* Copyright (c) 2018 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*)
|
||||
|
||||
open! IStd
|
||||
|
||||
val pp_all :
|
||||
?filter:string -> proc_name:bool -> attr_kind:bool -> source_file:bool -> proc_attributes:bool
|
||||
-> Format.formatter -> unit -> unit
|
Loading…
Reference in new issue