text stringlengths 0 601k |
|---|
let set_current_connection io_chan = conn := io_chan ; update_follow_fork_mode ( ) |
type pc = { frag : int ; pos : int ; } |
let set_event { frag ; pos } = output_char ! conn . io_out ' e ' ; output_binary_int ! conn . io_out frag ; output_binary_int ! conn . io_out pos |
let set_breakpoint { frag ; pos } = output_char ! conn . io_out ' B ' ; output_binary_int ! conn . io_out frag ; output_binary_int ! conn . io_out pos |
let reset_instr { frag ; pos } = output_char ! conn . io_out ' i ' ; output_binary_int ! conn . io_out frag ; output_binary_int ! conn . io_out pos |
type execution_summary = Event | Breakpoint | Exited | Trap_barrier | Uncaught_exc | Debug_info of Instruct . debug_event list array | Code_loaded of int | Code_unloaded of int |
type report = { rep_type : execution_summary ; rep_event_count : int64 ; rep_stack_pointer : int ; rep_program_pointer : pc } |
type checkpoint_report = Checkpoint_done of int | Checkpoint_failed |
let do_go_smallint n = output_char ! conn . io_out ' g ' ; output_binary_int ! conn . io_out n ; flush ! conn . io_out ; Input_handling . execute_with_other_controller Input_handling . exit_main_loop ! conn ( function ( ) -> Input_handling . main_loop ( ) ; let summary = match input_char ! conn . io_in with ' e ' -> Ev... |
let rec do_go n = assert ( n >= _0 ) ; if n > max_small_int then begin match do_go_smallint max_int with | { rep_type = Event } -> do_go ( n -- max_small_int ) | report -> { report with rep_event_count = report . rep_event_count ++ ( n -- max_small_int ) } end else do_go_smallint ( Int64 . to_int n ) |
let do_checkpoint ( ) = match Sys . os_type with " Win32 " -> failwith " do_checkpoint " | _ -> output_char ! conn . io_out ' c ' ; flush ! conn . io_out ; let pid = input_binary_int ! conn . io_in in if pid = - 1 then Checkpoint_failed else Checkpoint_done pid |
let stop chan = try output_char chan . io_out ' s ' ; flush chan . io_out with Sys_error _ | End_of_file -> ( ) |
let wait_child chan = try output_char chan . io_out ' w ' with Sys_error _ | End_of_file -> ( ) |
let initial_frame ( ) = output_char ! conn . io_out ' 0 ' ; flush ! conn . io_out ; let stack_pos = input_binary_int ! conn . io_in in let frag = input_binary_int ! conn . io_in in let pos = input_binary_int ! conn . io_in in ( stack_pos , { frag ; pos } ) |
let set_initial_frame ( ) = ignore ( initial_frame ( ) ) |
let up_frame stacksize = output_char ! conn . io_out ' U ' ; output_binary_int ! conn . io_out stacksize ; flush ! conn . io_out ; let stack_pos = input_binary_int ! conn . io_in in let frag , pos = if stack_pos = - 1 then 0 , 0 else let frag = input_binary_int ! conn . io_in in let pos = input_binary_int ! conn . io_i... |
let get_frame ( ) = output_char ! conn . io_out ' f ' ; flush ! conn . io_out ; let stack_pos = input_binary_int ! conn . io_in in let frag = input_binary_int ! conn . io_in in let pos = input_binary_int ! conn . io_in in ( stack_pos , { frag ; pos } ) |
let set_frame stack_pos = output_char ! conn . io_out ' S ' ; output_binary_int ! conn . io_out stack_pos |
let set_trap_barrier pos = output_char ! conn . io_out ' b ' ; output_binary_int ! conn . io_out pos |
let value_size = if 1 lsl 31 = 0 then 4 else 8 |
let input_remote_value ic = really_input_string ic value_size |
let output_remote_value ic v = output_substring ic v 0 value_size |
module Remote_value = struct type t = Remote of string | Local of Obj . t let repr x = Local ( Obj . repr x ) let obj = function | Local obj -> Obj . obj obj | Remote v -> output_char ! conn . io_out ' M ' ; output_remote_value ! conn . io_out v ; flush ! conn . io_out ; try input_value ! conn . io_in with End_of_file ... |
let debugger_prompt = " ( ocd ) " |
let shell = match Sys . os_type with " Win32 " -> " cmd " | _ -> " / bin / sh " |
let history_size = ref 30 |
let load_path_for = Hashtbl . create 7 |
let checkpoint_big_step = ref ( ~~ " 10000 " ) |
let checkpoint_small_step = ref ( ~~ " 1000 " ) |
let checkpoint_max_count = ref 15 |
let make_checkpoints = ref ( match Sys . os_type with " Win32 " -> false | _ -> true ) |
let break_on_load = ref true |
let environment = ref [ ] |
type t = { label : Asm_label . t ; name : Asm_symbol . t option ; abbreviation_code : Abbreviation_code . t ; attribute_values : AV . t ASS . Map . t } |
let create ~ label ~ name ~ abbreviation_code ~ attribute_values = { label ; name ; abbreviation_code ; attribute_values } |
let null = lazy { label = Asm_label . create ( DWARF Debug_info ) ; name = None ; abbreviation_code = Abbreviation_code . null ; attribute_values = ASS . Map . empty } |
let create_null ( ) = Lazy . force null |
let emit ~ asm_directives t = let module A = ( val asm_directives : Asm_directives . S ) in if not ( Abbreviation_code . is_null t . abbreviation_code ) then begin begin match t . name with | None -> ( ) | Some symbol -> A . define_data_symbol symbol end ; A . define_label t . label end ; Abbreviation_code . emit ~ asm... |
let size t = ASS . Map . fold ( fun _attribute_spec attribute_value size -> Dwarf_int . add size ( AV . size attribute_value ) ) t . attribute_values ( Abbreviation_code . size t . abbreviation_code ) |
let label t = t . label |
let abbreviation_code t = t . abbreviation_code |
let attribute_values t = t . attribute_values |
let is_null t = t == Lazy . force null |
let symbol t = t . name |
module Scoped_location = struct type scope_item = | Sc_anonymous_function | Sc_value_definition | Sc_module_definition | Sc_class_definition | Sc_method_definition | Sc_partial_or_eta_wrapper | Sc_lazy type scopes = | Empty | Cons of { item : scope_item ; str : string ; str_fun : string ; name : string ; prev : scopes ... |
type item = { dinfo_file : string ; dinfo_line : int ; dinfo_char_start : int ; dinfo_char_end : int ; dinfo_start_bol : int ; dinfo_end_bol : int ; dinfo_end_line : int ; dinfo_scopes : Scoped_location . scopes ; } |
type t = item list |
type alloc_dbginfo_item = { alloc_words : int ; alloc_dbg : t } |
type alloc_dbginfo = alloc_dbginfo_item list |
let is_none = function | [ ] -> true | _ :: _ -> false |
let to_string dbg = match dbg with | [ ] -> " " | ds -> let items = List . map ( fun d -> Printf . sprintf " % s :% d , % d -% d " d . dinfo_file d . dinfo_line d . dinfo_char_start d . dinfo_char_end ) ds in " { " ^ String . concat " ; " items ^ " } " |
let item_from_location ~ scopes loc = let valid_endpos = String . equal loc . loc_end . pos_fname loc . loc_start . pos_fname in { dinfo_file = loc . loc_start . pos_fname ; dinfo_line = loc . loc_start . pos_lnum ; dinfo_char_start = loc . loc_start . pos_cnum - loc . loc_start . pos_bol ; dinfo_char_end = if valid_en... |
let from_location = function | Scoped_location . Loc_unknown -> [ ] | Scoped_location . Loc_known { scopes ; loc } -> assert ( not ( Location . is_none loc ) ) ; [ item_from_location ~ scopes loc ] |
let to_location = function | [ ] -> Location . none | d :: _ -> let loc_start = { pos_fname = d . dinfo_file ; pos_lnum = d . dinfo_line ; pos_bol = d . dinfo_start_bol ; pos_cnum = d . dinfo_start_bol + d . dinfo_char_start ; } in let loc_end = { pos_fname = d . dinfo_file ; pos_lnum = d . dinfo_end_line ; pos_bol = d... |
let inline dbg1 dbg2 = dbg1 @ dbg2 |
let compare dbg1 dbg2 = let rec loop ds1 ds2 = match ds1 , ds2 with | [ ] , [ ] -> 0 | _ :: _ , [ ] -> 1 | [ ] , _ :: _ -> - 1 | d1 :: ds1 , d2 :: ds2 -> let c = String . compare d1 . dinfo_file d2 . dinfo_file in if c <> 0 then c else let c = compare d1 . dinfo_line d2 . dinfo_line in if c <> 0 then c else let c = com... |
let hash t = List . fold_left ( fun hash item -> Hashtbl . hash ( hash , item ) ) 0 t |
let rec print_compact ppf t = let print_item item = Format . fprintf ppf " % a :% i " Location . print_filename item . dinfo_file item . dinfo_line ; if item . dinfo_char_start >= 0 then begin Format . fprintf ppf " , % i --% i " item . dinfo_char_start item . dinfo_char_end end in match t with | [ ] -> ( ) | [ item ] ... |
type t = { dies : DIE . t list ; debug_abbrev_label : Asm_label . t ; compilation_unit_header_label : Asm_label . t } |
let create ~ dies ~ debug_abbrev_label ~ compilation_unit_header_label = { dies ; debug_abbrev_label ; compilation_unit_header_label } |
let dwarf_version ( ) = match ! Dwarf_flags . gdwarf_version with | Four -> Dwarf_version . four | Five -> Dwarf_version . five |
let debug_abbrev_offset t = Dwarf_value . offset_into_debug_abbrev ~ comment " : abbrevs . for this comp . unit " t . debug_abbrev_label |
let address_width_in_bytes_on_target = Dwarf_value . int8 ~ comment " : Dwarf_arch_sizes . size_addr " ( Numbers . Int8 . of_int_exn Dwarf_arch_sizes . size_addr ) |
let size_without_first_word t = let ( + ) = Dwarf_int . add in let total_die_size = List . fold_left ( fun size die -> size + DIE . size die ) ( Dwarf_int . zero ( ) ) t . dies in match ! Dwarf_flags . gdwarf_version with | Four -> Dwarf_version . size ( dwarf_version ( ) ) + Dwarf_value . size ( debug_abbrev_offset t ... |
let size t = let size_without_first_word = size_without_first_word t in let initial_length = Initial_length . create size_without_first_word in Dwarf_int . add ( Initial_length . size initial_length ) size_without_first_word |
let emit ~ asm_directives t = let module A = ( val asm_directives : Asm_directives . S ) in let size_without_first_word = size_without_first_word t in let initial_length = Initial_length . create size_without_first_word in A . define_label t . compilation_unit_header_label ; Initial_length . emit ~ asm_directives initi... |
module Bits = struct include Bits let hash_fold_t state t = Bits . to_string t |> String . hash_fold_t state end |
module Structure_kind = struct type t = | Empty | Const of Bits . t | Op of Signal . signal_op | Mux | Cat | Not | Wire of string list | Select of int * int | Mem_read_port | Dont_dedup of Signal . Uid . t [ @@ deriving sexp_of , compare , hash ] let equal a b = compare a b = 0 end |
let structure_kind ( signal : Signal . t ) = match signal with | Signal . Empty -> Structure_kind . Empty | Signal . Const { constant ; _ } -> Structure_kind . Const constant | Signal . Op2 { op ; _ } -> Structure_kind . Op op | Signal . Mux _ -> Structure_kind . Mux | Signal . Cat _ -> Structure_kind . Cat | Signal . ... |
let children ( signal : Signal . t ) = match structure_kind signal with | Structure_kind . Dont_dedup _ -> [ ] | _ -> ( match signal with | Wire { driver ; _ } -> [ ! driver ] | Mem_read_port { memory ; read_address ; _ } -> [ memory ; read_address ] | _ -> Signal . deps signal ) ; ; |
let signal_id_map_children s ~ f = { s with Signal . s_id = Signal . new_id ( ) ; s_deps = List . map s . Signal . s_deps ~ f } ; ; |
let map_children signal ~ f = match signal with | Signal . Empty -> signal | Signal . Const _ -> signal | Signal . Op2 { signal_id ; op ; arg_a ; arg_b } -> let arg_a = f arg_a in let arg_b = f arg_b in Signal . Op2 { signal_id = { signal_id with s_id = Signal . new_id ( ) ; s_deps = [ arg_a ; arg_b ] } ; op ; arg_a ; ... |
let find_by_signal_uid memo s = Hashtbl . find_exn memo ( Signal . uid s ) |
let signal_hash memo signal = Hashtbl . find_or_add memo ( Signal . uid signal ) ~ default ( : fun ( ) -> let children_hashes = List . map ( children signal ) ~ f ( : find_by_signal_uid memo ) in [ % hash : Structure_kind . t * int list ] ( structure_kind signal , children_hashes ) ) ; ; |
let make_canonical_signal canonical sequential_wires signal = match structure_kind signal with | Structure_kind . Dont_dedup _ -> let wire = Signal . wire ( Signal . width signal ) in Hashtbl . add_exn sequential_wires ~ key ( : Signal . uid signal ) ~ data ( : signal , wire ) ; wire | Structure_kind . Mem_read_port ->... |
let is_anonymous signal = Signal . is_empty signal || List . is_empty ( Signal . names signal ) |
let rec shallow_equal a b = is_anonymous a && is_anonymous b && Structure_kind . equal ( structure_kind a ) ( structure_kind b ) && match a , b with | Wire { driver = r_a ; _ } , Wire { driver = r_b ; _ } -> shallow_equal ! r_a ! r_b | _ -> [ % equal : Signal . Uid . t list ] ( children a |> List . map ~ f : Signal . u... |
let transform_sequential_signal canonical signal = let get_canonical signal = Hashtbl . find_exn canonical ( Signal . uid signal ) in let rewrite_instantiation ( instantiation : Signal . instantiation ) = let inst_inputs = List . map instantiation . inst_inputs ~ f ( : fun ( name , s ) -> name , get_canonical s ) in { ... |
let rec unwrap_wire s = match s with | Signal . Wire { driver ; _ } when List . is_empty ( Signal . names s ) -> unwrap_wire ! driver | _ -> s ; ; |
let fix_mem_read_ports signals = List . iter signals ~ f ( : function | Signal . Wire { driver ; _ } -> ( match ! driver with | Signal . Mem_read_port { signal_id ; memory = Wire { driver = mem_ref ; _ } ; read_address } -> let memory = match unwrap_wire ! mem_ref with | Signal . Multiport_mem _ as unwrapped -> unwrapp... |
let compress_wires signals = Signal_graph . create signals |> Signal_graph . iter ~ f ( : function | Signal . Wire { driver ; _ } -> driver := unwrap_wire ! driver | _ -> ( ) ) ; ; |
let canonicalize signals = let hash_memo = Hashtbl . create ( module Signal . Uid ) in let canonical = Hashtbl . create ( module Signal . Uid ) in let canonical_by_hash = Hashtbl . create ( module Int ) in let sequential_wires = Hashtbl . create ( module Signal . Uid ) in List . iter ( Signal_graph . topological_sort ~... |
let deduplicate circuit = let all_original_signals = Circuit . signal_graph circuit |> Signal_graph . filter ~ f ( : Fn . const true ) in let canonical = canonicalize ( all_original_signals @ Map . data ( Circuit . assertions circuit ) ) in let outputs = Circuit . outputs circuit in let assertions = Map . map ( Circuit... |
module Make ( Structure : Structure . S ) = struct module Tools = Tools . Make Structure ; module Parser = Parser . Make Structure ; open Structure ; let rec delete_in_tree symbols tree = match ( symbols , tree ) with [ ( [ s :: sl ] , Node n ) -> if Tools . logically_eq_symbols entry s n . node then delete_son sl n el... |
let db = quick_connect ~ database " : test " ( ) |
let table = [ ( " one " , 1 , 1 . 0 ) ; ( " two " , 2 , 2 . 0 ) ; ( " three " , 3 , 3 . 0 ) ; ( " , ' " :- , 4 , 4 . 0 ) ] |
let mk_table ( ) = let _r = exec db " create table caml ( a char ( 64 ) , b int , c float ) " in db |
let fill_table c = let ml2values ( a , b , c ) = values [ ml2str a ; ml2int b ; ml2float c ] in let insert values = " insert into caml values " ^ values in let rec loop = function | [ ] -> ( ) | x :: xs -> ( ignore ( exec c ( insert ( ml2values x ) ) ) ; loop xs ) in loop table |
let read_table c = let r = exec c " select * from caml " in let col = column r in let row x = ( not_null str2ml ( col ~ key " : a " ~ row : x ) , not_null int2ml ( col ~ key " : b " ~ row : x ) , not_null float2ml ( col ~ key " : c " ~ row : x ) ) in let rec loop = function | None -> [ ] | Some x -> row x :: loop ( fet... |
let main ( ) = let c = mk_table ( ) in ( fill_table c ; ignore ( read_table c ) ; ignore ( exec c " drop table caml " ) ; disconnect c ) |
let _ = Printexc . print main ( ) |
let ( _ : Thread . t ) = Thread . create ( fun ( ) -> let i = ref 0 in while true do Gc . compact ( ) ; incr i ; if ! i mod 100 = 0 then ( print_char ' . ' ; flush stdout ) done ) ( ) |
let db = Mysql . quick_connect ~ database ( : s " test " ) ~ user ( : s " root " ) ( ) |
let ( _ : Mysql . result ) = Mysql . exec db ( s " CREATE TABLE test ( id INT , v VARCHAR ( 10 ) ) ENGINE = MEMORY " ) |
let ( ) = let insert = P . create db ( s " INSERT INTO test VALUES ( , ) " ) ?? in for i = 10 to 15 do ignore ( P . execute insert [ | string_of_int i ; sprintf " value % d " i ] ) | done ; for i = 16 to 20 do ignore ( P . execute_null insert [ | Some ( string_of_int i ) ; None ] ) | done ; P . close insert |
let ( ) = let rec loop t = match P . fetch t with | Some arr -> Array . iter ( function Some s -> printf " % s " s | None -> print_string " < NULL > " ) arr ; print_endline " " ; loop t | None -> ( ) in let select = P . create db ( s " SELECT * FROM test WHERE id > " ) ? in print_endline " > 13 " ; loop ( P . execute s... |
let ( _ : Mysql . result ) = Mysql . exec db ( s " DROP TABLE test " ) |
let ( ) = Mysql . disconnect db |
let pp_deps = ref [ ] |
type map_tree = Node of String . Set . t * bound_map |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.