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

[eva/server] merging callstacks

parent f1592187
No related branches found
No related tags found
No related merge requests found
...@@ -39,13 +39,9 @@ let package = ...@@ -39,13 +39,9 @@ let package =
() ()
type callstack = Value_types.callstack type callstack = Value_types.callstack
type truth = Abstract_interp.truth type truth = Abstract_interp.truth
type step = [ `Here | `After | `Then of exp | `Else of exp ] type step = [ `Here | `After | `Then of exp | `Else of exp ]
type probe = Pexpr of exp * stmt | Plval of lval
type probe =
| Expr of exp * stmt
| Lval of lval * stmt
type domain = { type domain = {
values: ( step * string ) list ; values: ( step * string ) list ;
...@@ -65,6 +61,18 @@ let next_steps s : step list = ...@@ -65,6 +61,18 @@ let next_steps s : step list =
-> [ `After ] -> [ `After ]
| Instr (Skip _) | Return _ | Break _ | Continue _ | Goto _ | Throw _ -> [] | Instr (Skip _) | Return _ | Break _ | Continue _ | Goto _ | Throw _ -> []
module CS = Value_types.Callstack
module CSmap = CS.Hashtbl
module CSlist =
struct
type t = callstack list
let rec hash = function [] -> 1 | a::q -> CS.hash a + 31 * hash q
let rec equal ca cb = match ca , cb with
| [] , [] -> true
| a::p , b::q -> Callstack.equal a b && equal p q
| _ -> false
end
(* -------------------------------------------------------------------------- *) (* -------------------------------------------------------------------------- *)
(* --- EVA Proxy --- *) (* --- EVA Proxy --- *)
(* -------------------------------------------------------------------------- *) (* -------------------------------------------------------------------------- *)
...@@ -72,7 +80,7 @@ let next_steps s : step list = ...@@ -72,7 +80,7 @@ let next_steps s : step list =
module type EvaProxy = module type EvaProxy =
sig sig
val callstacks : stmt -> callstack list val callstacks : stmt -> callstack list
val domain : probe -> callstack option -> domain val domain : Printer_tag.localizable -> callstack list -> domain
end end
module Proxy(A : Analysis.S) : EvaProxy = module Proxy(A : Analysis.S) : EvaProxy =
...@@ -81,6 +89,17 @@ struct ...@@ -81,6 +89,17 @@ struct
open Eval open Eval
type dstate = A.Dom.state or_top_or_bottom type dstate = A.Dom.state or_top_or_bottom
module CSSmap = Hashtbl.Make
(struct
type t = bool * stmt * callstack list
let hash (after,stmt,cs) =
Hashtbl.hash (after,Cil_datatype.Stmt.hash stmt,CSlist.hash cs)
let equal (a1,s1,cs1) (a2,s2,cs2) =
a1 = a2 && Cil_datatype.Stmt.equal s1 s2 && CSlist.equal cs1 cs2
end)
let stackcache = CSSmap.create 0
let callstacks stmt = let callstacks stmt =
match A.get_stmt_state_by_callstack ~after:false stmt with match A.get_stmt_state_by_callstack ~after:false stmt with
| `Top | `Bottom -> [] | `Top | `Bottom -> []
...@@ -89,24 +108,47 @@ struct ...@@ -89,24 +108,47 @@ struct
let dstate ~after stmt callstack = let dstate ~after stmt callstack =
match callstack with match callstack with
| None -> (A.get_stmt_state ~after stmt :> dstate) | [] -> (A.get_stmt_state ~after stmt :> dstate)
| Some cs -> | css ->
begin match A.get_stmt_state_by_callstack ~after stmt with begin match A.get_stmt_state_by_callstack ~after stmt with
| `Top -> `Top | `Top -> `Top
| `Bottom -> `Bottom | `Bottom -> `Bottom
| `Value cmap -> | `Value cmap ->
try `Value (CSmap.find cmap cs) match css with
with Not_found -> `Bottom | [cs] ->
begin
try `Value (CSmap.find cmap cs)
with Not_found -> `Bottom
end
| css ->
begin
try CSSmap.find stackcache (after,stmt,css)
with Not_found ->
(List.fold_left
(fun d cs ->
try
let s = CSmap.find cmap cs in
match d with
| `Bottom -> d
| `Value s0 -> `Value (A.Dom.join s0 s)
with Not_found -> d
) `Bottom css :> dstate)
end
end end
let dbottom = { let dnone = {
alarms = [] ; alarms = [] ;
values = [`Here , "Unreachable (bottom)"] ; values = [] ;
} }
let dtop = { let dtop = {
alarms = [] ; alarms = [] ;
values = [`Here , "Not available (top)"] ; values = [`Here , "Not available."] ;
}
let dbottom = {
alarms = [] ;
values = [`Here , "Unreachable."] ;
} }
let dalarms alarms = let dalarms alarms =
...@@ -157,10 +199,13 @@ struct ...@@ -157,10 +199,13 @@ struct
alarms alarms
end end
let domain probe callstack = let dexpr e s css = deval (e_expr e) s css
match probe with let dlval l s css = deval (e_lval l) s css
| Expr(expr,stmt) -> deval (e_expr expr) stmt callstack
| Lval(lval,stmt) -> deval (e_lval lval) stmt callstack let domain marker _callstacks =
let open Printer_tag in
match marker with
| _ -> dnone
end end
......
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