123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172(************************************************************************)(* * The Coq Proof Assistant / The Coq Development Team *)(* v * Copyright INRIA, CNRS and contributors *)(* <O___,, * (see version control and CREDITS file for authors & dates) *)(* \VV/ **************************************************************)(* // * This file is distributed under the terms of the *)(* * GNU Lesser General Public License Version 2.1 *)(* * (see LICENSE file for the text of the license) *)(************************************************************************)openTac2expropenProofview.Notationsletbacktrace_evd:backtraceEvd.Store.field=Evd.Store.field"ltac2_trace"letbacktrace:backtraceExninfo.t=Exninfo.make"ltac2_trace"letprint_ltac2_backtrace=reffalselet()=Goptions.declare_bool_option{Goptions.optstage=Summary.Stage.Interp;Goptions.optdepr=None;Goptions.optkey=["Ltac2";"Backtrace"];Goptions.optread=(fun()->!print_ltac2_backtrace);Goptions.optwrite=(funb->print_ltac2_backtrace:=b);}letltac2_in_ltac1_profiling=reffalselet()=Goptions.declare_bool_option{Goptions.optstage=Summary.Stage.Interp;Goptions.optdepr=None;Goptions.optkey=["Ltac2";"In";"Ltac1";"Profiling"];Goptions.optread=(fun()->!ltac2_in_ltac1_profiling);Goptions.optwrite=(funb->ltac2_in_ltac1_profiling:=b);}letget_backtrace=Proofview.tclEVARMAP>>=funsigma->matchEvd.Store.get(Evd.get_extra_datasigma)backtrace_evdwith|None->Proofview.tclUNIT[]|Somebt->Proofview.tclUNITbtletset_backtracebt=Proofview.tclEVARMAP>>=funsigma->letstore=Evd.get_extra_datasigmainletstore=Evd.Store.setstorebacktrace_evdbtinletsigma=Evd.set_extra_datastoresigmainProofview.Unsafe.tclEVARSsigmaletpr_frame,pr_frame_hook=Hook.make()letwith_frameframetac=lettac=if!print_ltac2_backtracethenget_backtrace>>=funbt->set_backtrace(frame::bt)>>=fun()->Proofview.tclORtac(fun(e,info)->(* If it's already present assume it's more precise *)letinfo=ifOption.has_some(Exninfo.getinfobacktrace)theninfoelseExninfo.addinfobacktrace(frame::bt)inProofview.tclZERO~infoe)>>=funans->set_backtracebt>>=fun()->Proofview.tclUNITanselsetacinif!ltac2_in_ltac1_profilingthenletpr_framef=Some(Hook.getpr_framef)inProfile_tactic.do_profile_genpr_frameframe~count_call:truetacelsetac