Summary: Currently all alarms are reported as "Invalid memory access", which is not accurate for `abort` and hence assertion violations. This diff adds an explicit type for alarms which distinguishes these two cases. Further refinement is left for later. Reviewed By: jvillard Differential Revision: D27828754 fbshipit-source-id: 9c33f3c86master
parent
cd7b11889e
commit
631eacd71f
@ -0,0 +1,25 @@
|
|||||||
|
(*
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*)
|
||||||
|
|
||||||
|
type kind = Abort | Invalid_memory_access
|
||||||
|
|
||||||
|
let pp_kind fs = function
|
||||||
|
| Abort -> Format.fprintf fs "Abort"
|
||||||
|
| Invalid_memory_access -> Format.fprintf fs "Invalid memory access"
|
||||||
|
|
||||||
|
type t =
|
||||||
|
{ kind: kind
|
||||||
|
; loc: Llair.Loc.t
|
||||||
|
; pp_action: Format.formatter -> unit
|
||||||
|
; pp_state: Format.formatter -> unit }
|
||||||
|
|
||||||
|
let pp fs {kind; loc; pp_action} =
|
||||||
|
Format.fprintf fs "%a %a@;<1 2>@[%t@]" Llair.Loc.pp loc pp_kind kind
|
||||||
|
pp_action
|
||||||
|
|
||||||
|
let pp_trace fs alarm =
|
||||||
|
Format.fprintf fs "%a@;<1 2>@[{ %t@ }@]" pp alarm alarm.pp_state
|
@ -0,0 +1,20 @@
|
|||||||
|
(*
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*)
|
||||||
|
|
||||||
|
type kind = Abort | Invalid_memory_access
|
||||||
|
|
||||||
|
type t =
|
||||||
|
{ kind: kind
|
||||||
|
; loc: Llair.Loc.t
|
||||||
|
; pp_action: Format.formatter -> unit
|
||||||
|
; pp_state: Format.formatter -> unit }
|
||||||
|
|
||||||
|
val pp : t pp
|
||||||
|
(** print an alarm for the user report *)
|
||||||
|
|
||||||
|
val pp_trace : t pp
|
||||||
|
(** print an error for the debug trace *)
|
@ -0,0 +1,21 @@
|
|||||||
|
(*
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*)
|
||||||
|
|
||||||
|
module T = struct
|
||||||
|
type 'a t = ('a, Alarm.t) result
|
||||||
|
end
|
||||||
|
|
||||||
|
include Stdlib.Result
|
||||||
|
|
||||||
|
include Monad.Make (struct
|
||||||
|
include T
|
||||||
|
|
||||||
|
let return = Result.ok
|
||||||
|
let bind = Result.bind
|
||||||
|
end)
|
||||||
|
|
||||||
|
let iter x ~f = iter f x
|
@ -0,0 +1,12 @@
|
|||||||
|
(*
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*)
|
||||||
|
|
||||||
|
type 'a t = ('a, Alarm.t) result
|
||||||
|
|
||||||
|
include Monad.S with type 'a t := 'a t
|
||||||
|
|
||||||
|
val iter : 'a t -> f:('a -> unit) -> unit
|
Loading…
Reference in new issue