-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathmustlockHistory.ml
More file actions
47 lines (37 loc) · 1.32 KB
/
mustlockHistory.ml
File metadata and controls
47 lines (37 loc) · 1.32 KB
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
43
44
45
46
47
(** must-lock history analysis [mustlockHistory]
collects for locks, in which threads a lock operation must have happened
before reaching the current program point.
@see https://github.com/goblint/analyzer/pull/1923
*)
open Analyses
module TIDs = SetDomain.Reverse (ConcDomain.ThreadSet)
module Lock = LockDomain.MustLock
module Spec = struct
include IdentityUnitContextsSpec
(** [{ l |-> T }]
[l] must have been in all members of [T].
*)
module D = Queries.LH
let name () = "mustlockHistory"
let startstate _ = D.empty ()
let exitstate _ = D.empty ()
let lock man tid lock =
let old_threadset = D.find lock man.local in
let new_threadset = TIDs.add tid old_threadset in
D.add lock new_threadset man.local
let event man e _ =
match e with
(* we only handle exclusive locks here *)
| Events.Lock (addr, true) ->
let tid_lifted = man.ask Queries.CurrentThreadId in
let lock_opt = Lock.of_addr addr in
(match tid_lifted, lock_opt with
| `Lifted tid, Some l -> lock man tid l
| _ -> man.local)
| _ -> man.local
let query man (type a) (x : a Queries.t) : a Queries.result =
match x with
| Queries.MustlockHistory -> (man.local : D.t)
| _ -> Queries.Result.top x
end
let _ = MCP.register_analysis ~dep:[ "threadid" ] (module Spec : MCPSpec)