Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file runtime.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109(* This Source Code Form is subject to the terms of the Mozilla Public License,
v. 2.0. If a copy of the MPL was not distributed with this file, You can
obtain one at http://mozilla.org/MPL/2.0/. *)typemessage=|Unable_to_create_file|Unable_to_write_file|Stringofstringletstring_of_message=function|Unable_to_create_file->" *** Bisect runtime was unable to create file."|Unable_to_write_file->" *** Bisect runtime was unable to write file."|Strings->" *** "^sletfull_pathfname=ifFilename.is_implicitfnamethenFilename.concatFilename.current_dir_namefnameelsefnameletenv_to_fnameenvdefault=trySys.getenvenvwithNot_found->defaultletverbose=lazybeginletfname=env_to_fname"BISECT_SILENT""bisect.log"inmatch(String.uppercase[@ocaml.warning"-3"])fnamewith|"YES"|"ON"->fun_->()|"ERR"->funmsg->prerr_endline(string_of_messagemsg)|_uc_fname->letoc_l=lazy((* A weird race condition is caused if we use this invocation instead
let oc = open_out_gen [Open_append] 0o244 (full_path fname) in
Note that verbose is called only during [at_exit]. *)letoc=open_out_bin(full_pathfname)inat_exit(fun()->close_out_noerroc);oc)infunmsg->Printf.fprintf(Lazy.forceoc_l)"%s\n"(string_of_messagemsg)endletverbosemessage=(Lazy.forceverbose)messagelettable:(string,intarray*string)Hashtbl.tLazy.t=lazy(Hashtbl.create17)letfile_channel()=letbase_name=full_path(env_to_fname"BISECT_FILE""bisect")inletreccreate_filenumeric_suffix=letfilename=Printf.sprintf"%s%04d.%s"base_namenumeric_suffixExtension.valueintryletfd=Unix.(openfilefilename[O_WRONLY;O_CREAT;O_EXCL]0o644)inletchannel=Unix.out_channel_of_descrfdinSomechannelwith|Unix.Unix_error(Unix.EEXIST,_,_)->create_file(numeric_suffix+1)|Unix.Unix_error(code,_,_)->letdetail=Printf.sprintf"%s: %s"(Unix.error_messagecode)filenameinverboseUnable_to_create_file;verbose(Stringdetail);Noneincreate_file1letdump_counters_exnchannel=letcontent=Hashtbl.fold(funkvacc->(k,v)::acc)(Lazy.forcetable)[]inCommon.write_runtime_datachannelcontentletreset_counters()=Hashtbl.iter(fun_(point_state,_)->matchArray.lengthpoint_statewith|0->()|n->Array.(fillpoint_state0(n-1)0))(Lazy.forcetable)letdump()=matchfile_channel()with|None->()|Somechannel->(trydump_counters_exnchannelwith_->verboseUnable_to_write_file);close_out_noerrchannelletregister_dump:unitLazy.t=lazy(at_exitdump)letregister_filefile~point_count~point_definitions=let()=Lazy.forceregister_dumpinletpoint_state=Array.makepoint_count0inlettable=Lazy.forcetableinifnot(Hashtbl.memtablefile)thenHashtbl.addtablefile(point_state,point_definitions);`Staged(funpoint_index->letcurrent_count=point_state.(point_index)inpoint_state.(point_index)<-ifcurrent_count<Pervasives.max_intthenPervasives.succcurrent_countelsecurrent_count)