123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596(****************************************************************************)(* *)(* This file is part of MOPSA, a Modular Open Platform for Static Analysis. *)(* *)(* Copyright (C) 2017-2023 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/>. *)(* *)(****************************************************************************)openCore.AllopenMopsa_utilsopenActionopenFormatopenLocationtypetrace_element_kind=BEGIN|ENDtypetrace_element={id:int;action:action;kind:trace_element_kind;time:float;}typetrace={elements:trace_elementlist;last_id:int;}letempty_trace={elements=[];last_id=-1;}letbegin_trace_elementactiontrace=letid=trace.last_id+1in{elements={id;kind=BEGIN;action;time=Sys.time()}::trace.elements;last_id=id}letend_trace_elementidactiontrace={elements={id;kind=END;action;time=Sys.time()}::trace.elements;last_id=trace.last_id}letget_last_trace_element_idtrace=trace.last_idletcoloredlevels=letcode=(levelmod16)*16+10inif!Debug.print_colorthenPrintf.sprintf"\027[1;38;5;%dm%s\027[0m"codeselsesletpp_tracefmttrace=letreciterindentfmt=function|[]->()|hd::tl->letmargin=List.initindent(funi->coloredi"│ ")|>String.concat""infprintffmt"%s%a %a [#%d, %.4f, %a]"margin(funfmt->function|BEGIN->pp_print_stringfmt(coloredindent"┌")|END->pp_print_stringfmt(coloredindent"└"))hd.kind(pp_action~truncate:true~indent:0)hd.actionhd.idhd.timepp_relative_range(action_rangehd.action);matchtlwith|[]->()|next::_->letindent'=matchhd.kind,next.kindwith|BEGIN,BEGIN->indent+1|BEGIN,END->indent|END,BEGIN->indent|END,END->indent-1infprintffmt"@,%a"(iterindent')tlinletrelements=List.revtrace.elementsinfprintffmt"@[<v>%a@]"(iter0)relements