Created
March 1, 2019 06:08
-
-
Save aaronjeline/f6349d9b531bc91be6d582ef7e23ea08 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open Core_kernel.Std | |
open Bap.Std | |
open Graphlib.Std | |
open Format | |
include Self() | |
module CG = Graphs.Callgraph | |
(* Every node reaches itself, need to check children *) | |
let find_recursion prog sub = | |
let cg = Program.to_graph prog in | |
let tid = Term.tid sub in | |
Graphlib.shortest_path (module CG) cg tid tid | |
(* Collect all subroutines in the program*) | |
let find_subs prog = Term.enum sub_t prog | |
let print_subs subs = | |
let print_sub s = printf "%s\n" (Sub.name s) in | |
Seq.iter subs print_sub | |
let main proj = | |
let prog = Project.program proj in | |
let recs = | |
Seq.filter | |
(find_subs prog) | |
(fun sub -> Option.is_some (find_recursion prog sub)) in | |
printf "Recursive Functions\n"; | |
print_subs recs | |
module Cmdline = struct | |
open Config | |
let () = when_ready (fun{get=(!!)} -> | |
Project.register_pass' (main)) | |
let () = manpage [ | |
`S "Description"; | |
`P | |
"Checks" | |
] | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment