11(* *
2- Call String analysis [call_string] and/or Call Site analysis [call_site].
3- The call string limitation for both approaches can be adjusted with the "callString_length" option.
4- By adding new implementations of the CallstringType, additional analyses can be added.
2+ Call String analysis [call_string] and/or Call Site analysis [call_site].
3+ The call string limitation for both approaches can be adjusted with the "callString_length" option.
4+ By adding new implementations of the CallstringType, additional analyses can be added.
55*)
66
77open Analyses
1818
1919(* * Analysis with infinite call string or with limited call string (k-CFA, tracks the last k call stack elements).
2020 With the CT argument it is possible to specify the type of the call string elements *)
21- module Spec (CT :CallstringType ) : MCPSpec =
21+ module Spec (CT :CallstringType ) : MCPSpec =
2222struct
23- include Analyses. IdentitySpec
23+ include UnitAnalysis. Spec
2424
2525 (* simulates a call string (with or without limitation)*)
2626 module CallString = struct
2727 include Printable. PQueue (CT )
2828
29+ let (empty:t ) = BatDeque. empty
30+
2931 (* pushes "elem" to the call string, guarantees a depth of k if limitation is specified with "ana.context.callString_length" *)
30- let push callstr elem =
32+ let push callstr elem =
3133 match elem with
3234 | None -> callstr
33- | Some e ->
34- let new_callstr = BatDeque. cons e callstr in (* pushes new element to callstr *)
35+ | Some e ->
36+ let new_callstr = BatDeque. cons e callstr in (* pushes new element to callstr *)
3537 if get_int " ana.context.callString_length" < 0
3638 then new_callstr (* infinite call string *)
3739 else (* maximum of k elements *)
@@ -41,46 +43,32 @@ struct
4143 | _ -> failwith " CallString Error: It shouldn't happen that more than one element must be deleted to maintain the correct height!"
4244 end
4345
44- module D = Lattice. Flat (CallString ) (* should be the CallString (C=D). Since a Lattice is required, Lattice.Flat is used to fulfill the type *)
4546 module C = CallString
46- module V = EmptyV
47- module G = Lattice. Unit
4847
4948 let name () = " call_" ^ CT. ana_name
50- let startstate v = `Lifted (BatDeque. empty)
51- let exitstate v = `Lifted (BatDeque. empty)
52-
53- let context fd x = match x with
54- | `Lifted x -> x
55- | _ -> failwith " CallString: Context error! The context cannot be derived from Top or Bottom!"
56-
57- let callee_state ctx f =
58- let elem = CT. new_ele f ctx in (* receive element that should be added to call string *)
59- let new_callstr = CallString. push (context f ctx.local) elem in
60- `Lifted new_callstr
61-
62- let enter ctx r f args = [ctx.local, callee_state ctx f]
6349
64- let combine_env ctx lval fexp f args fc au f_ask = ctx.local
50+ let startcontext () = CallString. empty
6551
66- let threadenter ctx ~multiple lval v args = [callee_state ctx (Cilfacade. find_varinfo_fundec v)]
52+ let context ctx fd _ =
53+ let elem = CT. new_ele fd ctx in (* receive element that should be added to call string *)
54+ CallString. push (ctx.context () ) elem
6755end
6856
6957(* implementations of CallstringTypes*)
7058module Callstring : CallstringType = struct
7159 include CilType. Fundec
7260 let ana_name = " string"
73- let new_ele f ctx =
74- let f' = Node. find_fundec ctx.node in
75- if CilType.Fundec. equal f' dummyFunDec
61+ let new_ele f ctx =
62+ let f' = Node. find_fundec ctx.node in
63+ if CilType.Fundec. equal f' dummyFunDec
7664 then None
7765 else Some f'
7866end
7967
8068module Callsite : CallstringType = struct
8169 include CilType. Stmt
8270 let ana_name = " site"
83- let new_ele f ctx =
71+ let new_ele f ctx =
8472 match ctx.prev_node with
8573 | Statement stmt -> Some stmt
8674 | _ -> None (* first statement is filtered *)
0 commit comments