Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file EVA.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155(**************************************************************************)(* *)(* This file is part of the Frama-C's Luncov plug-in. *)(* *)(* Copyright (C) 2012-2025 *)(* CEA (Commissariat à l'énergie atomique et aux énergies *)(* alternatives) *)(* *)(* you can redistribute it and/or modify it under the terms of the GNU *)(* Lesser General Public License as published by the Free Software *)(* Foundation, version 2.1. *)(* *)(* It is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)(* GNU Lesser General Public License for more details. *)(* *)(* See the GNU Lesser General Public License version 2.1 *)(* for more details (enclosed in the file LICENSE) *)(* *)(**************************************************************************)openCommonsopenInstrumentletuncov_binds=ref[]leteval_statuscondstmt=ifEva.Results.is_reachablestmtthenletva_res=Eva.Results.(beforestmt|>eval_expcond|>as_ival)inmatchva_reswith|Okva_int->ifIval.is_zerova_intthen(Options.debug"-> uncoverable @[%a@]\n"Ival.prettyva_int;Data_labels.Uncoverable)else(Options.debug"-> unknown @[%a@]\n"Ival.prettyva_int;Data_labels.Unknown)|Errorerr->Options.warning"condition %a cannot be evaluated as int: %a"Printer.pp_expcondEva.Results.pretty_errorerr;Data_labels.Unknownelse(Options.debug"-> unreachable\n";Data_labels.Uncoverable)leteval_bind_expcondstmt=ifEva.Results.is_reachablestmtthenletva_res=Eva.Results.(beforestmt|>eval_expcond|>as_ival)inmatchva_reswith|Okva_int->ifIval.is_zerova_intthenSome(false)elseifnot(Ival.contains_zerova_int)thenSome(true)elseNone|Errorerr->Options.warning"condition %a cannot be evaluated as int: %a"Printer.pp_expcondEva.Results.pretty_errorerr;NoneelseOptions.fatal"trying to evaluate binder on a non-reachable statement"letcompute_label_aux?(force=false)dataidloctagcondstmt=letcurrent_loc=location_stringlocinData_labels.updatedata~tag~current_locid;Options.debug~level:2"label #%d cond: @[%a@], tag: %s, loc: @[%a@]\n"idPrinter.pp_expcondtagPrinter.pp_locationloc;letstatus=eval_statuscondstmtin(* eval the condition at the given statement *)Options.result"label #%d found '%a' by EVA\n"idData_labels.pp_statusstatus;Data_labels.updatedata~force~status~emitter:"EVA"id(* update the status in data *)letcompute_label_with_info?(force=false)dataidinfo=letloc=info.li_locandtag=info.li_tagandcond=info.li_predicateandstmt=info.li_annotableincompute_label_aux~forcedataidloctagcondstmtletcompute_bindings_with_info?(force=false)dataidinfos=letcurrent_binding=Instrument_binding.get_ids_stringidinOptions.feedback"checking labels/bindings %s"current_binding;letuncov=reffalseinletcompute_labelsl=compute_label_aux~forcedatal.bi_idl.bi_locl.bi_tagl.bi_predicatel.bi_annotable;ifData_labels.is_uncoverabledatal.bi_idthenuncov:=trueinList.itercompute_labelsinfos;ifnot!uncov||forcethenbeginmatchinfos,(List.hdinfos).bi_tagwith|[b1;b2],"CACC"->ifList.lengthb1.bi_bindings=1&&List.lengthb2.bi_bindings=1thenbeginlet_,var_p_1=List.hdb1.bi_bindingsinlet_,var_p_2=List.hdb2.bi_bindingsinletstatus_1=eval_bind_expvar_p_1b1.bi_annotableinletstatus_2=eval_bind_expvar_p_2b2.bi_annotableinbeginmatchstatus_1,status_2with|Somefalse,Somefalse|Sometrue,Sometrue->Options.result"bindings %s found uncoverable by EVA"current_binding;uncov_binds:=b1.bi_id::b2.bi_id::!uncov_binds|_->Options.result"bindings %s found unknown by EVA"current_bindingendendelseOptions.warning"Skip binding annot for %s : Too many bindings [CACC]"current_binding|[b1;b2],"RACC"->ifList.lengthb1.bi_bindings=List.lengthb2.bi_bindingsthenbeginlet_,var_p_1=List.hdb1.bi_bindingsinlet_,var_p_2=List.hdb2.bi_bindingsinletstatus_1=eval_bind_expvar_p_1b1.bi_annotableinletstatus_2=eval_bind_expvar_p_2b2.bi_annotableinbeginmatchstatus_1,status_2with|Somefalse,Somefalse|Sometrue,Sometrue->Options.result"bindings %s found uncoverable by EVA"current_binding;uncov_binds:=b1.bi_id::b2.bi_id::!uncov_binds|_->Options.result"bindings %s found unknown by EVA"current_bindingendendelseOptions.warning"Skip binding annot for %s : Too many bindings [CACC]"current_binding|_,"CACC"|_,"RACC"->Options.warning"Skip binding annot for %s: Too many labels [CACC,RACC]"current_binding|_->Options.warning"Not supported yet"endelseOptions.feedback"skip bindings %s"current_bindingletcompute_aux?(force=false)data=letfidinfo=matchinfowith|Instrument.Labelinfo->compute_label_with_info~forcedataidinfo|Instrument.Bindinginfos->compute_bindings_with_info~forcedataidinfosinInstrument.iterfletset_eva_precisionn=ifnot(Dynamic.Parameter.Int.is_set"-eva-precision"())thenDynamic.Parameter.Int.set"-eva-precision"nletcompute?(force=false)datahdata=set_eva_precision1;lett0=Unix.gettimeofday()inEva.Analysis.compute();lett1=Unix.gettimeofday()inifOptions.Time.get()thenOptions.feedback"Value compute time: %f s"(t1-.t0);compute_aux~forcedata;Data_hyperlabels.compute_coverage~force(data,!uncov_binds)hdata