123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123(****************************************************************************)(* *)(* This file is part of MOPSA, a Modular Open Platform for Static Analysis. *)(* *)(* Copyright (C) 2017-2019 The MOPSA Project. *)(* *)(* This program is free software: 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, either version 3 of the License, or *)(* (at your option) any later version. *)(* *)(* This program 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. *)(* *)(* You should have received a copy of the GNU Lesser General Public License *)(* along with this program. If not, see <http://www.gnu.org/licenses/>. *)(* *)(****************************************************************************)(** Signature of interactive engine interfaces *)openCore.AllopenMopsa_utilsopenLocationopenCallstackopenBreakpointopenToplevelopenActionopenEnvdbopenTracetypecommand=|Continue|Next|Step|Finish|NextI|StepI|Backwardtypestate={mutabledepth:int;(** Current depth of the interpretation tree *)mutablecommand:command;(** Last entered command *)mutablecommand_depth:int;(** Depth of the interpretation tree when the command was issued *)mutablecommand_callstack:callstack;(** Callstack when the command was issued *)mutablecallstack:callstack;(** Current call-stack *)mutableloc:rangeoption;(** Last analyzed line of code *)mutablelocstack:rangeoptionlist;(** Stack of lines of codes *)mutabletrace:trace;(** Analysis trace *)mutablecall_preamble:bool;(** Flag set when calling a function and reset when reaching its first loc *)mutablealarms:AlarmSet.t;(** Set of discovered alarms *)}(* Initialize a state *)letinit_states=s.command<-StepI;s.depth<-0;s.command_depth<-0;s.command_callstack<-empty_callstack;s.callstack<-empty_callstack;s.loc<-None;s.locstack<-[];s.trace<-empty_trace;s.call_preamble<-false;s.alarms<-AlarmSet.empty(* Copy a state *)letcopy_states={command=s.command;depth=s.depth;command_depth=s.command_depth;command_callstack=s.command_callstack;callstack=s.callstack;loc=s.loc;locstack=s.locstack;trace=s.trace;call_preamble=s.call_preamble;alarms=s.alarms;}(** Global state *)letstate={command=StepI;depth=0;command_depth=0;command_callstack=empty_callstack;callstack=empty_callstack;loc=None;locstack=[];trace=empty_trace;call_preamble=false;alarms=AlarmSet.empty;}moduletypeINTERFACE=functor(Toplevel:TOPLEVEL)->sigvalinit:unit->unitvalreach:action->(Toplevel.t,Toplevel.t)man->Toplevel.tflow->unitvalalarm:alarmlist->action->(Toplevel.t,Toplevel.t)man->Toplevel.tflow->unitvalread_command:action->Toplevel.tenvdb->(Toplevel.t,Toplevel.t)man->Toplevel.tflow->commandvalfinish:(Toplevel.t,Toplevel.t)man->Toplevel.tflow->unitvalerror:exn->unitend