text stringlengths 12 786k |
|---|
let optional_value opt = try Some ( Opt . get opt ) with Opt . No_value -> None |
let string_to_tc str = match String . lowercase str with | " zzuf " -> ZzufMutational | " random " | " rand " | " r " -> RandomWithReplacement | " randomwithoutreplacement " | " rwr " -> RandomWithoutReplacement | " ball " | " b " -> BallMutational | " surface " | " ... |
let string_to_sch str = match String . lowercase str with | " round - robin " | " roundrobin " | " round " | " rr " -> RoundRobin | " weighted - rr " | " weightedrr " | " wrr " -> WeightedRoundRobin | " uniform - time " | " uniformtime " | " unitime " | _ -> ... |
let string_to_seed_range str = let regexp = Str . regexp_string " " : in match Str . split regexp str with | sbegin :: send [ ] :: -> string_to_seed sbegin , string_to_seed send | _ -> raise ( Opt . Option_error ( " seed - range " , " invalid seed range format " ) ) |
let string_to_verbo str = match String . lowercase str with | " quiet " | " q " -> Logger . quiet | " verbose " | " v " -> Logger . verbose | " normal " | " n " | _ -> Logger . normal |
let string_to_repropair str = let comma = Str . regexp_string " , " in match Str . split comma str with | rseed :: confid [ ] :: -> string_to_seed rseed , int_of_string confid | _ -> raise ( Opt . Option_error ( " reproduce " , " invalid format for reproduce " ) ) |
let opt_verbosity = StdOpt . any_option ~ default ( : Some Logger . normal ) ~ metavar " :< VERBOSITY " > string_to_verbo |
let get_verbosity ( ) = Opt . get opt_verbosity |
let opt_output_dir = StdOpt . str_option ~ default " : ofuzz - output " ~ metavar " :< DIRNAME " > ( ) |
let get_output_dir ( ) = Opt . get opt_output_dir |
let opt_timeout = StdOpt . int_option ~ default : 3600 ~ metavar " :< SEC " > ( ) |
let get_timeout ( ) = Opt . get opt_timeout |
let opt_gui = StdOpt . store_true ( ) |
let get_gui ( ) = Opt . get opt_gui |
let opt_debugflag = StdOpt . store_true ( ) |
let get_debugflag ( ) = Opt . get opt_debugflag |
let opt_testgen_alg = StdOpt . any_option ~ default ( : Some SurfaceMutational ) ~ metavar " :< ALG " > string_to_tc |
let get_testgen_alg ( ) = Opt . get opt_testgen_alg |
let opt_seedrange = StdOpt . any_option ~ default ( : Some default_seed_range ) ~ metavar " :< BEGIN : END " > string_to_seed_range |
let get_seedrange ( ) = Opt . get opt_seedrange |
let opt_reproduce = StdOpt . any_option ~ metavar " :< RSEED , CONF_ID " > string_to_repropair |
let get_reproduce ( ) = optional_value opt_reproduce |
let opt_genall_tcs = StdOpt . store_true ( ) |
let get_genall_tcs ( ) = Opt . get opt_genall_tcs |
let opt_gencrash_tcs = StdOpt . store_true ( ) |
let get_gencrash_tcs ( ) = Opt . get opt_gencrash_tcs |
let opt_triage = StdOpt . store_true ( ) |
let get_triage ( ) = Opt . get opt_triage |
let opt_exec_timeout = StdOpt . int_option ~ default : 5 ~ metavar " :< SEC " > ( ) |
let get_exec_timeout ( ) = Opt . get opt_exec_timeout |
let opt_scheduling = StdOpt . any_option ~ default ( : Some UniformTime ) ~ metavar " :< ALG " > string_to_sch |
let get_scheduling ( ) = Opt . get opt_scheduling |
let opt_round_timeout = StdOpt . int_option ~ default : 5 ~ metavar " :< SEC " > ( ) |
let get_round_timeout ( ) = Opt . get opt_round_timeout |
let opt_dbhost = StdOpt . str_option ~ default " " : ~ metavar " :< HOSTNAME " > ( ) |
let get_dbhost ( ) = let dbhost = Opt . get opt_dbhost in if dbhost = " " then None else Some dbhost |
let opt_dbport = StdOpt . int_option ~ default : 3306 ~ metavar " :< PORT " > ( ) |
let get_dbport ( ) = Opt . get opt_dbport |
let opt_dbuser = StdOpt . str_option ~ default " : fuzzer " ~ metavar " :< USERNAME " > ( ) |
let get_dbuser ( ) = Opt . get opt_dbuser |
let opt_dbpassword = StdOpt . str_option ~ default " " : ~ metavar " :< PASSWORD " > ( ) |
let get_dbpassword ( ) = let get_password_from_cmdline ( ) = let ( ) = output_string stdout " password for the db : " in let ( ) = flush stdout in let open Unix in let attr = tcgetattr stdin in let ( ) = attr . c_echo <- false in let ( ) = tcsetattr stdin TCSAFLUSH attr in let pas... |
let opt_dbname = StdOpt . str_option ~ default " : fuzzing " ~ metavar " :< DBNAME " > ( ) |
let get_dbname ( ) = Opt . get opt_dbname |
let opt_dbexpid = StdOpt . int_option ~ default : 0 ~ metavar " :< EID " > ( ) |
let get_dbexpid ( ) = Opt . get opt_dbexpid |
let read_conf_files p files = if List . length files = 0 then begin OptParser . usage p ( ) ; Misc . error_exit " \ nError : a conf file is required to start ofuzz " end else try begin List . fold_left ( fun acc file -> let lst = Conf . parse file in List . rev_append lst acc ) [ ] ... |
let usage = " % prog [ options ] < ofuzz config file ( s ) " > |
let opt_init ( ) = let myformatter = Formatter . indented_formatter ~ max_help_position : 50 ~ width : 100 ~ short_first : false ( ) in let p = OptParser . make ~ usage : usage ~ formatter : myformatter ( ) in let grp_testgen = OptParser . add_group p " Options related to Test - Gen... |
let dir_quit ( ) = raise ( Compenv . Exit_with_status 0 ) |
let _ = Hashtbl . add directive_table " quit " ( Directive_none dir_quit ) |
let dir_directory s = let d = expand_directory Config . standard_library s in let dir = Load_path . Dir . create d in Load_path . add dir ; toplevel_env := Stdlib . String . Set . fold ( fun name env -> Env . add_persistent_structure ( Ident . create_persistent name ) env ) ( Env . ... |
let _ = Hashtbl . add directive_table " directory " ( Directive_string dir_directory ) |
let dir_remove_directory s = let d = expand_directory Config . standard_library s in let keep id = match Load_path . find_uncap ( Ident . name id ^ " . cmi " ) with | exception Not_found -> true | fn -> Filename . dirname fn <> d in toplevel_env := Env . filter_non_loaded_persistent keep ... |
let _ = Hashtbl . add directive_table " remove_directory " ( Directive_string dir_remove_directory ) |
let _ = Hashtbl . add directive_table " show_dirs " ( Directive_none ( fun ( ) -> List . iter print_endline ( Load_path . get_paths ( ) ) ) ) |
let dir_cd s = Sys . chdir s |
let _ = Hashtbl . add directive_table " cd " ( Directive_string dir_cd ) |
let load_file ppf name0 = let name = try Some ( Load_path . find name0 ) with Not_found -> None in match name with | None -> fprintf ppf " File not found : % s . " @ name0 ; false | Some name -> let fn , tmp = if Filename . check_suffix name " . cmx " || Filename . check_suffix nam... |
let dir_load ppf name = ignore ( load_file ppf name ) |
let _ = Hashtbl . add directive_table " load " ( Directive_string ( dir_load std_out ) ) |
let dir_use ppf name = ignore ( Opttoploop . use_file ppf name ) |
let dir_use_output ppf name = ignore ( Opttoploop . use_output ppf name ) |
let _ = Hashtbl . add directive_table " use " ( Directive_string ( dir_use std_out ) ) |
let _ = Hashtbl . add directive_table " use_output " ( Directive_string ( dir_use_output std_out ) ) |
type ' a printer_type_new = Format . formatter -> ' a -> unit |
type ' a printer_type_old = ' a -> unit |
let match_printer_type ppf desc typename = let printer_type = match Env . find_type_by_name ( Ldot ( Lident " Opttopdirs " , typename ) ) ! toplevel_env with | ( path , _ ) -> path | exception Not_found -> fprintf ppf " Cannot find type Topdirs . % s . . " @ typename ; raise ... |
let find_printer_type ppf lid = match Env . find_value_by_name lid ! toplevel_env with | ( path , desc ) -> begin match match_printer_type ppf desc " printer_type_new " with | ty_arg -> ( ty_arg , path , false ) | exception Ctype . Unify _ -> begin match match_printer_type ppf desc " pr... |
let dir_install_printer ppf lid = try let ( ty_arg , path , is_old_style ) = find_printer_type ppf lid in let v = eval_value_path ! toplevel_env path in let print_function = if is_old_style then ( fun _formatter repr -> Obj . obj v ( Obj . obj repr ) ) else ( fun formatter repr -> Obj . ... |
let dir_remove_printer ppf lid = try let ( _ty_arg , path , _is_old_style ) = find_printer_type ppf lid in begin try remove_printer path with Not_found -> fprintf ppf " No printer named % a . . " @ Printtyp . longident lid end with Exit -> ( ) |
let _ = Hashtbl . add directive_table " install_printer " ( Directive_ident ( dir_install_printer std_out ) ) |
let _ = Hashtbl . add directive_table " remove_printer " ( Directive_ident ( dir_remove_printer std_out ) ) |
let parse_warnings ppf iserr s = try Warnings . parse_options iserr s with Arg . Bad err -> fprintf ppf " % s . . " @ err |
let _ = Hashtbl . add directive_table " print_depth " ( Directive_int ( fun n -> max_printer_depth := n ) ) ; Hashtbl . add directive_table " print_length " ( Directive_int ( fun n -> max_printer_steps := n ) ) ; Hashtbl . add directive_table " labels " ( Directive_bool ( ... |
let section_options = " Compiler options " |
let _ = add_directive " ppx " ( Directive_string ( fun s -> Clflags . all_ppx := s :: ! Clflags . all_ppx ) ) { section = section_options ; doc = " After parsing , pipe the abstract \ syntax tree through the preprocessor command . " ; } |
let any_flambda = Config . flambda || Config . flambda2 |
type res = Ok of Obj . t | Err of string |
type evaluation_outcome = Result of Obj . t | Exception of exn |
let _dummy = ( Ok ( Obj . magic 0 ) , Err " " ) |
module Jit = struct type t = { load : Format . formatter -> Lambda . program -> evaluation_outcome ; lookup_symbol : string -> Obj . t option ; } end |
let jit = ref None |
let register_jit j = jit := Some j = " caml_natdynlink_run_toplevel " |
let default_lookup sym = Dynlink . unsafe_get_global_value ~ bytecode_or_asm_symbol : sym |
let global_symbol id = let sym = Compilenv . symbol_for_global id in let lookup = match ! jit with | None -> default_lookup | Some { Jit . lookup_symbol ; _ } -> lookup_symbol in match lookup sym with | None -> fatal_error ( " Opttoploop . global_symbol " ^ ( Ident . unique_name id ) ... |
let need_symbol sym = Option . is_none ( Dynlink . unsafe_get_global_value ~ bytecode_or_asm_symbol : sym ) |
let dll_run dll entry = match ( try Result ( Obj . magic ( ndl_run_toplevel dll entry ) ) with exn -> Exception exn ) with | Exception _ as r -> r | Result r -> match Obj . magic r with | Ok x -> Result x | Err s -> fatal_error ( " Opttoploop . dll_run " ^ s ) |
type directive_fun = | Directive_none of ( unit -> unit ) | Directive_string of ( string -> unit ) | Directive_int of ( int -> unit ) | Directive_ident of ( Longident . t -> unit ) | Directive_bool of ( bool -> unit ) |
type directive_info = { section : string ; doc : string ; } |
let remembered = ref Ident . empty |
let rec remember phrase_name i = function | [ ] -> ( ) | Sig_module ( _ , _ , { md_type = Mty_alias _ ; _ } , _ , _ ) :: rest -> remember phrase_name i rest | Sig_value ( id , _ , _ ) :: rest | Sig_module ( id , _ , _ , _ , _ ) :: rest | Sig_typext (... |
let toplevel_value id = try Ident . find_same id ! remembered with _ -> failwith ( " Unknown ident : " ^ Ident . unique_name id ) |
let close_phrase lam = let open Lambda in Ident . Set . fold ( fun id l -> let glb , pos = toplevel_value id in let glob = Lprim ( mod_field pos , [ Lprim ( Pgetglobal glb , [ ] , Loc_unknown ) ] , Loc_unknown ) in Llet ( Strict , Pgenval , id , glob , l ) ) ( free_va... |
let toplevel_value id = let glob , pos = if any_flambda then toplevel_value id else Translmod . nat_toplevel_name id in ( Obj . magic ( global_symbol glob ) ) . ( pos ) |
let rec eval_address = function | Env . Aident id -> if Ident . persistent id || Ident . global id then global_symbol id else toplevel_value id | Env . Adot ( a , pos ) -> Obj . field ( eval_address a ) pos |
let eval_path find env path = match find path env with | addr -> eval_address addr | exception Not_found -> fatal_error ( " Cannot find address for : " ^ ( Path . name path ) ) |
let eval_module_path env path = eval_path Env . find_module_address env path |
let eval_value_path env path = eval_path Env . find_value_address env path |
let eval_extension_path env path = eval_path Env . find_constructor_address env path |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.