Skip to content
Snippets Groups Projects
Commit e7e4ae71 authored by Loïc Correnson's avatar Loïc Correnson
Browse files

[wp] fix havoc tactical

parent 1d58bf41
No related branches found
No related tags found
No related merge requests found
...@@ -35,7 +35,7 @@ val contrapose : ?priority:float -> selection -> strategy ...@@ -35,7 +35,7 @@ val contrapose : ?priority:float -> selection -> strategy
val compound : ?priority:float -> selection -> strategy val compound : ?priority:float -> selection -> strategy
val cut : ?priority:float -> ?modus:bool -> selection -> strategy val cut : ?priority:float -> ?modus:bool -> selection -> strategy
val filter : ?priority:float -> ?anti:bool -> unit -> strategy val filter : ?priority:float -> ?anti:bool -> unit -> strategy
val havoc : ?priority:float -> havoc:selection -> addr:selection -> strategy val havoc : ?priority:float -> havoc:selection -> strategy
val separated : ?priority:float -> selection -> strategy val separated : ?priority:float -> selection -> strategy
val instance : ?priority:float -> selection -> selection list -> strategy val instance : ?priority:float -> selection -> selection list -> strategy
val lemma : ?priority:float -> ?at:selection -> string -> selection list -> strategy val lemma : ?priority:float -> ?at:selection -> string -> selection list -> strategy
......
...@@ -30,62 +30,38 @@ module L = Qed.Logic ...@@ -30,62 +30,38 @@ module L = Qed.Logic
(* --- Havoc --- *) (* --- Havoc --- *)
(* -------------------------------------------------------------------------- *) (* -------------------------------------------------------------------------- *)
let field,parameter = let lookup_havoc e =
Tactical.composer match F.repr e with
~id:"address" | L.Aget( m , p ) ->
~title:"Address" begin
~descr:"Access Outside the Assigned Range" match F.repr m with
() | L.Fun( f , [mr;m0;a;n] ) when f == MemTyped.f_havoc ->
Some( mr , m0 , a , n , p )
let has_type t e = | _ -> None
try F.Tau.equal t (F.typeof e) end
with Not_found -> false | _ -> None
let match_havoc =
let havoc m1 = function
| L.Fun( f , [m_undef;m0;a;n] ) when f == MemTyped.f_havoc -> m1,(m_undef,m0,a,n)
| _ -> raise Not_found
in function
| L.Eq (m,m') -> (try havoc m' (F.repr m) with | Not_found -> havoc m (F.repr m'))
| _ -> raise Not_found
class havoc = class havoc =
object(self) object
inherit Tactical.make ~id:"Wp.havoc" inherit Tactical.make ~id:"Wp.havoc"
~title:"Havoc" ~title:"Havoc"
~descr:"Go Through Assigns" ~descr:"Go Through Assigns"
~params:[parameter] ~params:[]
method select feedback sel = method select _feedback sel =
match sel with let at = Tactical.at sel in
| Clause(Step s) -> let e = Tactical.selected sel in
begin match lookup_havoc e with
match s.condition with | None -> Not_applicable
| Have p | When p -> | Some(mr,m0,a,n,p) ->
let m1,(m_undef,m0,a,n) = match_havoc (F.e_expr p) in let separated =
let tp = F.typeof a in F.p_call MemTyped.p_separated
feedback#update_field ~filter:(has_type tp) field ; [ p ; F.e_int 1 ; a ; n ] in
let sel = self#get_field field in let process = Tactical.rewrite ?at [
if not (Tactical.is_empty sel) then "Unassigned" , separated , e , F.e_get m0 p ;
let ptr = Tactical.selected sel in "Assigned" , F.p_not separated , e , F.e_get mr p ;
if has_type tp ptr then ] in
let separated = Applicable process
F.p_call MemTyped.p_separated
[ ptr ; F.e_int 1 ; a ; n ] in
let equal_unassigned =
F.p_equal (F.e_get m1 ptr) (F.e_get m0 ptr) in
let equal_assigned =
F.p_equal (F.e_get m1 ptr) (F.e_get m_undef ptr) in
let process = Tactical.insert ~at:s.id
[ "Havoc",F.p_if separated equal_unassigned equal_assigned ] in
Applicable process
else
( feedback#set_error "Not a pointer type" ;
Not_configured )
else Not_configured
| _ -> Not_applicable
end
| _ -> Not_applicable
end end
(* -------------------------------------------------------------------------- *) (* -------------------------------------------------------------------------- *)
...@@ -219,14 +195,13 @@ class validity = ...@@ -219,14 +195,13 @@ class validity =
module Havoc = module Havoc =
struct struct
let field = field
let tactical = Tactical.export (new havoc) let tactical = Tactical.export (new havoc)
let strategy ?(priority=1.0) ~havoc ~addr = let strategy ?(priority=1.0) ~havoc =
Strategy.{ Strategy.{
priority ; priority ;
tactical ; tactical ;
selection = havoc ; selection = havoc ;
arguments = [ arg field addr ] ; arguments = [] ;
} }
end end
......
...@@ -27,10 +27,9 @@ open Strategy ...@@ -27,10 +27,9 @@ open Strategy
module Havoc : module Havoc :
sig sig
val field : selection field
val tactical : tactical val tactical : tactical
val strategy : val strategy :
?priority:float -> havoc:selection -> addr:selection -> strategy ?priority:float -> havoc:selection -> strategy
end end
module Separated : module Separated :
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment