Skip to content
Snippets Groups Projects
Commit aef56052 authored by David Bühler's avatar David Bühler
Browse files

[Eva] Frama_C_show_each directives print the offsetmap on arrays.

parent ad1d991e
No related branches found
No related tags found
No related merge requests found
...@@ -224,13 +224,13 @@ let finalize_call stmt call ~pre:_ ~post:state = ...@@ -224,13 +224,13 @@ let finalize_call stmt call ~pre:_ ~post:state =
let show_expr valuation state fmt expr = let show_expr valuation state fmt expr =
match expr.enode with match expr.enode with
| Lval lval -> | Lval lval | StartOf lval ->
let record = match valuation.Abstract_domain.find_loc lval with let record = match valuation.Abstract_domain.find_loc lval with
| `Value record -> record | `Value record -> record
| `Top -> assert false | `Top -> assert false
in in
let offsm = Cvalue_offsetmap.offsetmap_of_lval state lval record.loc in let offsm = Cvalue_offsetmap.offsetmap_of_lval state lval record.loc in
let typ = Cil.typeOf expr in let typ = Cil.typeOfLval lval in
Eval_op.pretty_offsetmap typ fmt offsm Eval_op.pretty_offsetmap typ fmt offsm
| _ -> Format.fprintf fmt "%s" (Unicode.top_string ()) | _ -> Format.fprintf fmt "%s" (Unicode.top_string ())
......
...@@ -621,22 +621,17 @@ module Make (Abstract: Abstractions.Eva) = struct ...@@ -621,22 +621,17 @@ module Make (Abstract: Abstractions.Eva) = struct
| None, _ | _, None -> | None, _ | _, None ->
fun fmt _ _ _ -> Format.fprintf fmt "%s" (Unicode.top_string ()) fun fmt _ _ _ -> Format.fprintf fmt "%s" (Unicode.top_string ())
| Some get_cvalue, Some get_ploc -> | Some get_cvalue, Some get_ploc ->
fun fmt subdivnb expr state -> fun fmt subdivnb lval state ->
match expr.enode with try
| Lval lval -> let offsm =
begin fst (Eval.lvaluate ~for_writing:false ~subdivnb state lval)
try >>- fun (_, loc, _) ->
let offsm = Eval_op.offsetmap_of_loc (get_ploc loc) (get_cvalue state)
fst (Eval.lvaluate ~for_writing:false ~subdivnb state lval) in
>>- fun (_, loc, _) -> let typ = Cil.typeOfLval lval in
Eval_op.offsetmap_of_loc (get_ploc loc) (get_cvalue state) (Bottom.pretty (Eval_op.pretty_offsetmap typ)) fmt offsm
in with Abstract_interp.Error_Top ->
let typ = Cil.typeOf expr in Format.fprintf fmt "%s" (Unicode.top_string ())
(Bottom.pretty (Eval_op.pretty_offsetmap typ)) fmt offsm
with Abstract_interp.Error_Top ->
Format.fprintf fmt "%s" (Unicode.top_string ())
end
| _ -> assert false
(* For scalar expressions, prints the cvalue component of their values. *) (* For scalar expressions, prints the cvalue component of their values. *)
let show_value = let show_value =
...@@ -650,10 +645,12 @@ module Make (Abstract: Abstractions.Eva) = struct ...@@ -650,10 +645,12 @@ module Make (Abstract: Abstractions.Eva) = struct
(Bottom.pretty Cvalue.V.pretty) fmt value (Bottom.pretty Cvalue.V.pretty) fmt value
let pretty_arguments ~subdivnb state arguments = let pretty_arguments ~subdivnb state arguments =
let is_scalar lval = Cil.isArithmeticOrPointerType (Cil.typeOfLval lval) in
let pretty fmt expr = let pretty fmt expr =
if Cil.isArithmeticOrPointerType (Cil.typeOf expr) match expr.enode with
then show_value fmt subdivnb expr state | Lval lval | StartOf lval when not (is_scalar lval) ->
else show_offsm fmt subdivnb expr state show_offsm fmt subdivnb lval state
| _ -> show_value fmt subdivnb expr state
in in
Pretty_utils.pp_list ~pre:"@[<hv>" ~sep:",@ " ~suf:"@]" pretty arguments Pretty_utils.pp_list ~pre:"@[<hv>" ~sep:",@ " ~suf:"@]" pretty arguments
......
...@@ -12,6 +12,6 @@ void main (void) { ...@@ -12,6 +12,6 @@ void main (void) {
buf[0] = 42; buf[0] = 42;
TcpOption * option = buf + 10; TcpOption * option = buf + 10;
option->length = 5; option->length = 5;
Frama_C_show_each(option->value); Frama_C_show_each(&(option->value));
memcpy(option->value, value, 2); memcpy(option->value, value, 2);
} }
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