-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
85 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
(* SPDX-License-Identifier: AGPL-3.0-or-later *) | ||
(* Copyright © 2021-2024 OCamlPro *) | ||
(* Written by the Owi programmers *) | ||
|
||
[@@@warning "-69"] | ||
|
||
module Memsight_backend = struct | ||
open Smtml | ||
open Symbolic_choice_without_memory | ||
|
||
type address = Symbolic_value.int32 | ||
|
||
type record = | ||
{ address : address | ||
; value : Symbolic_value.int32 | ||
; condition : Symbolic_value.vbool | ||
; time : int | ||
} | ||
|
||
type t = | ||
{ mutable records : record list | ||
; mutable time : int | ||
} | ||
|
||
let make () = { records = []; time = 0 } | ||
|
||
let clone { records; time } = { records; time } | ||
|
||
let address a = return a | ||
|
||
let address_i32 i = Symbolic_value.const_i32 i | ||
|
||
let loadn mem addr _n = | ||
let open Symbolic_value in | ||
let v = const_i32 0l in | ||
List.fold_right | ||
(fun r acc -> | ||
Bool.select_expr | ||
(Bool.and_ (I32.eq addr r.address) r.condition) | ||
~if_true:r.value ~if_false:acc ) | ||
mem.records v | ||
|
||
let storen mem addr v _n = | ||
mem.time <- succ mem.time; | ||
let record = | ||
{ address = addr | ||
; value = v | ||
; condition = Smtml.Expr.Bool.true_ | ||
; time = mem.time | ||
} | ||
in | ||
mem.records <- record :: mem.records | ||
|
||
let validate_address _m a = return (Ok a) | ||
|
||
let free _ _ = | ||
Fmt.epr "TODO: Symbolic_memory.free@."; | ||
return () | ||
|
||
let realloc _m ~ptr ~size:_ = | ||
Fmt.epr "TODO: Symbolic_memory.replace_size@."; | ||
let+ base = select_i32 ptr in | ||
Expr.ptr base (Symbolic_value.const_i32 0l) | ||
|
||
let pp_record fmt { address; value; condition; time } = | ||
Fmt.pf fmt "%a, %a, %a, %d" Expr.pp address Expr.pp value Expr.pp condition | ||
time | ||
|
||
let pp fmt { time; records; _ } = | ||
Fmt.pf fmt "Time: %d@;" time; | ||
Fmt.pf fmt "Records:@; @[<v 2>%a@]" | ||
(Fmt.list (Fmt.parens pp_record)) | ||
records | ||
end | ||
|
||
module Memsight_backend' : Symbolic_memory_intf.M = Memsight_backend | ||
|
||
include Symbolic_memory_make.Make (Memsight_backend) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters