123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354(**************************************************************************)(* This file is part of BINSEC. *)(* *)(* Copyright (C) 2016-2026 *)(* 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 licenses/LGPLv2.1). *)(* *)(**************************************************************************)includeCli.Options(structletname="smtlib"letshortname=nameend)moduleModel_from_file=Builder.String_option(structletname="model-from-file"letdoc="Parse model from given file."end)lettest_model_parsing()=ifModel_from_file.is_set()then(letfilename=Model_from_file.get()inLogger.debug"Parsing SMT model from %s"filename;letparser=Smtlib.Lang.Parser.modelinletlexer=Smtlib.Lang.Lexer.tokeninletpremodel=Parse_utils.read_file~parser~lexer~filenameinLogger.debug"@[Parsed model@\n%a@]"Smtlib.Lang.Printer.pp_modelpremodel;letmodel=Smtlib.Formula.Model.extractpremodelinletsection_name=matchKernel_functions.get_img()with|img->(funaddress->matchLoader_utils.find_section_by_address~addressimgwith|None->None|Somesection->Some(Loader.Section.namesection))|exceptionFailure_->fun_->NoneinLogger.result"%a"(Smtlib.Formula.Model.pp_with_sectionssection_name)model)let_=Cli.Boot.enlist~name:"SMT model parser test"~f:test_model_parsing