Skip to content

Commit 852297b

Browse files
committed
Add value and format to ghost_instrumentation
1 parent 12dadf4 commit 852297b

File tree

3 files changed

+54
-17
lines changed

3 files changed

+54
-17
lines changed

src/witness/yamlWitness.ml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,16 @@ struct
165165
name = variable;
166166
scope = "global";
167167
type_;
168-
initial;
168+
initial = {
169+
value = initial;
170+
format = "c_expression";
171+
};
169172
}
170173

171174
let ghost_update' ~variable ~(expression): GhostInstrumentation.Update.t = {
172175
variable;
173-
expression;
176+
value = expression;
177+
format = "c_expression";
174178
}
175179

176180
let ghost_location_update' ~location ~(updates): GhostInstrumentation.LocationUpdate.t = {

src/witness/yamlWitnessType.ml

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -488,13 +488,34 @@ end
488488
module GhostInstrumentation =
489489
struct
490490

491+
module Initial =
492+
struct
493+
type t = {
494+
value: string;
495+
format: string;
496+
}
497+
[@@deriving eq, ord, hash]
498+
499+
let to_yaml {value; format} =
500+
`O [
501+
("value", `String value);
502+
("format", `String format);
503+
]
504+
505+
let of_yaml y =
506+
let open GobYaml in
507+
let+ value = y |> find "value" >>= to_string
508+
and+ format = y |> find "format" >>= to_string in
509+
{value; format}
510+
end
511+
491512
module Variable =
492513
struct
493514
type t = {
494515
name: string;
495516
scope: string;
496517
type_: string;
497-
initial: string;
518+
initial: Initial.t;
498519
}
499520
[@@deriving eq, ord, hash]
500521

@@ -503,37 +524,40 @@ struct
503524
("name", `String name);
504525
("scope", `String scope);
505526
("type", `String type_);
506-
("initial", `String initial);
527+
("initial", Initial.to_yaml initial);
507528
]
508529

509530
let of_yaml y =
510531
let open GobYaml in
511532
let+ name = y |> find "name" >>= to_string
512533
and+ scope = y |> find "scope" >>= to_string
513534
and+ type_ = y |> find "type" >>= to_string
514-
and+ initial = y |> find "initial" >>= to_string in
535+
and+ initial = y |> find "initial" >>= Initial.of_yaml in
515536
{name; scope; type_; initial}
516537
end
517538

518539
module Update =
519540
struct
520541
type t = {
521542
variable: string;
522-
expression: string;
543+
value: string;
544+
format: string;
523545
}
524546
[@@deriving eq, ord, hash]
525547

526-
let to_yaml {variable; expression} =
548+
let to_yaml {variable; value; format} =
527549
`O [
528550
("variable", `String variable);
529-
("expression", `String expression);
551+
("value", `String value);
552+
("format", `String format);
530553
]
531554

532555
let of_yaml y =
533556
let open GobYaml in
534557
let+ variable = y |> find "variable" >>= to_string
535-
and+ expression = y |> find "expression" >>= to_string in
536-
{variable; expression}
558+
and+ value = y |> find "value" >>= to_string
559+
and+ format = y |> find "format" >>= to_string in
560+
{variable; value; format}
537561
end
538562

539563
module LocationUpdate =

tests/regression/13-privatized/74-mutex.t

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,15 @@ Same with ghost_instrumentation and invariant_set entries.
174174
- name: m_locked
175175
scope: global
176176
type: int
177-
initial: "0"
177+
initial:
178+
value: "0"
179+
format: c_expression
178180
- name: multithreaded
179181
scope: global
180182
type: int
181-
initial: "0"
183+
initial:
184+
value: "0"
185+
format: c_expression
182186
ghost_updates:
183187
- location:
184188
file_name: 74-mutex.c
@@ -188,7 +192,8 @@ Same with ghost_instrumentation and invariant_set entries.
188192
function: producer
189193
updates:
190194
- variable: m_locked
191-
expression: "1"
195+
value: "1"
196+
format: c_expression
192197
- location:
193198
file_name: 74-mutex.c
194199
file_hash: $FILE_HASH
@@ -197,7 +202,8 @@ Same with ghost_instrumentation and invariant_set entries.
197202
function: producer
198203
updates:
199204
- variable: m_locked
200-
expression: "0"
205+
value: "0"
206+
format: c_expression
201207
- location:
202208
file_name: 74-mutex.c
203209
file_hash: $FILE_HASH
@@ -206,7 +212,8 @@ Same with ghost_instrumentation and invariant_set entries.
206212
function: main
207213
updates:
208214
- variable: multithreaded
209-
expression: "1"
215+
value: "1"
216+
format: c_expression
210217
- location:
211218
file_name: 74-mutex.c
212219
file_hash: $FILE_HASH
@@ -215,7 +222,8 @@ Same with ghost_instrumentation and invariant_set entries.
215222
function: main
216223
updates:
217224
- variable: m_locked
218-
expression: "1"
225+
value: "1"
226+
format: c_expression
219227
- location:
220228
file_name: 74-mutex.c
221229
file_hash: $FILE_HASH
@@ -224,7 +232,8 @@ Same with ghost_instrumentation and invariant_set entries.
224232
function: main
225233
updates:
226234
- variable: m_locked
227-
expression: "0"
235+
value: "0"
236+
format: c_expression
228237
- entry_type: invariant_set
229238
content:
230239
- invariant:

0 commit comments

Comments
 (0)