let get_init_funcs main_name cg =
match main_name with
| None -> InitFunc.get ()
| Some s ->
(* the entry point is always a root *)
let init_funcs = Datatype.String.Set.add s (InitFunc.get ()) in
(* Add the callees of entry point as roots *)
Datatype.String.Set.union
(try
let callees = (Hashtbl.find cg s).Callgraph.cnCallees in
Inthash.fold
(fun _ v acc -> match v.Callgraph.cnInfo with
| Callgraph.NIVar ({vname=n},_) -> Datatype.String.Set.add n acc
| _ -> acc)
callees
Datatype.String.Set.empty
with Not_found ->
Datatype.String.Set.empty)
init_funcs