1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677openBasemodulePrintexc=Caml.PrintexcmoduleMode=structtypet=|Disabled|Top_of_stack|Full_traceendletmode=ref(ifBase.Exported_for_specific_uses.am_testingthenMode.DisabledelseTop_of_stack);;letset_modem=mode:=m(* Small helper to find out who is the caller of a function *)typet=|Top_of_stackofPrintexc.location|Full_traceofPrintexc.locationoptionlistletsexp_of_location(t:Printexc.location)=letloc=Printf.sprintf"%s:%i:%i"t.filenamet.line_numbert.start_charin[%sexp(loc:string)];;letsexp_of_t(t:t)=matchtwith|Top_of_stacks->[%sexp(s:location)]|Full_traces->[%sexp(s:locationoptionlist)];;letget?(skip=[])()=letskip="list.ml"::"list0.ml"::"array.ml"::"comb.ml"::"interface.ml"::"signal.ml"::"bits.ml"::"with_valid.ml"::"scope.ml"::"parameter.ml"::"hierarchy.ml"::Caml.__FILE__::skipinletstack=Printexc.get_callstack16inletlen=Printexc.raw_backtrace_lengthstackinletrectoppos=ifpos=lenthenNoneelse(matchPrintexc.get_raw_backtrace_slotstackpos|>Printexc.convert_raw_backtrace_slot|>Printexc.Slot.locationwith|None->None|Someloc->ifList.mem~equal:String.equalskiploc.filenamethentop(pos+1)elseSomeloc)inletrecfullpos=ifpos=lenthen[]else(Printexc.get_raw_backtrace_slotstackpos|>Printexc.convert_raw_backtrace_slot|>Printexc.Slot.location)::full(pos+1)inmatch!modewith|Disabled->None|Top_of_stack->top0|>Option.map~f:(funs->Top_of_stacks)|Full_trace->Some(Full_trace(full0));;