-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy paththreadAccess.ml
More file actions
42 lines (35 loc) · 944 Bytes
/
threadAccess.ml
File metadata and controls
42 lines (35 loc) · 944 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
open Analyses
module Spec =
struct
include UnitAnalysis.Spec
let name () = "threadAccess"
module V =
struct
include CilType.Varinfo
let is_write_only _ = false
end
module G = ConcDomain.ThreadSet
let query man (type a) (q: a Queries.t): a Queries.result =
match q with
| MayBePublic {global; _} ->
if G.cardinal (man.global global) = 1 then
false
else
Queries.Result.top q
| _ -> Queries.Result.top q
let event man e oman =
match e with
| Events.Access {ad; _} ->
Queries.AD.iter (function
| Queries.AD.Addr.Addr (v, _) when v.vglob ->
begin match man.ask CurrentThreadId with
| `Lifted tid -> man.sideg v (G.singleton tid)
| _ -> () (* TODO: what here? *)
end
| _ -> ()
) ad
| _ ->
man.local
end
let _ =
MCP.register_analysis ~dep:["access"] (module Spec : MCPSpec)