text stringlengths 12 786k |
|---|
let same_custom x y = Obj . field x 0 = Obj . field ( Obj . repr y ) 0 |
let rec print_obj x = if Obj . is_block x then begin let tag = Obj . tag x in if tag = Obj . string_tag then printf " % S " ( Obj . magic x : string ) else if tag = Obj . double_tag then printf " . % 12g " ( Obj . magic x : float ) else if tag = Obj . double_array_tag then begi... |
let currpos ic = pos_in ic - ! start |
let rec rassoc key = function [ ] -> raise Not_found | ( a , b ) :: l -> if b = key then a else rassoc key l |
let find_reloc ic = rassoc ( pos_in ic - ! start ) ! reloc |
let print_getglobal_name ic = if ! objfile then begin begin try match find_reloc ic with Reloc_getglobal id -> print_string ( Ident . name id ) | Reloc_literal sc -> print_struct_const sc | _ -> print_string " < wrong reloc " > with Not_found -> print_string " < no reloc " > end ; ignore ( ... |
let print_setglobal_name ic = if ! objfile then begin begin try match find_reloc ic with Reloc_setglobal id -> print_string ( Ident . name id ) | _ -> print_string " < wrong reloc " > with Not_found -> print_string " < no reloc " > end ; ignore ( inputu ic ) ; end else begin let n = in... |
let print_primitive ic = if ! objfile then begin begin try match find_reloc ic with Reloc_primitive s -> print_string s | _ -> print_string " < wrong reloc " > with Not_found -> print_string " < no reloc " > end ; ignore ( inputu ic ) ; end else begin let n = inputu ic in if n >= Array . ... |
let currpc ic = currpos ic / 4 |
type shape = | Nothing | Uint | Sint | Uint_Uint | Disp | Uint_Disp | Sint_Disp | Getglobal | Getglobal_Uint | Setglobal | Primitive | Uint_Primitive | Switch | Closurerec | Pubmet ; ; |
let op_shapes = [ opACC0 , Nothing ; opACC1 , Nothing ; opACC2 , Nothing ; opACC3 , Nothing ; opACC4 , Nothing ; opACC5 , Nothing ; opACC6 , Nothing ; opACC7 , Nothing ; opACC , Uint ; opPUSH , Nothing ; opPUSHACC0 , Nothing ; opPUSHACC1 , Nothing ; opPUSHACC2 , Noth... |
let print_event ev = let ls = ev . ev_loc . loc_start in let le = ev . ev_loc . loc_end in printf " File " \% s " , \ line % d , characters % d -% d :\ n " ls . Lexing . pos_fname ls . Lexing . pos_lnum ( ls . Lexing . pos_cnum - ls . Lexing . pos_bol ) ( le . Lexin... |
let print_instr ic = let pos = currpos ic in List . iter print_event ( Hashtbl . find_all event_table pos ) ; printf " % 8d " ( pos / 4 ) ; let op = inputu ic in if op >= Array . length names_of_instructions || op < 0 then ( print_string " *** unknown opcode : " ; print_int op... |
let print_code ic len = start := pos_in ic ; let stop = ! start + len in while pos_in ic < stop do print_instr ic done |
let print_reloc ( info , pos ) = printf " % d ( % d ) " pos ( pos / 4 ) ; match info with Reloc_literal sc -> print_struct_const sc ; printf " \ n " | Reloc_getglobal id -> printf " require % s \ n " ( Ident . name id ) | Reloc_setglobal id -> printf " provide % s \ ... |
let dump_obj filename ic = let buffer = String . create ( String . length cmo_magic_number ) in really_input ic buffer 0 ( String . length cmo_magic_number ) ; if buffer <> cmo_magic_number then begin prerr_endline " Not an object file " ; exit 2 end ; let cu_pos = input_binary_int ic in s... |
let read_primitive_table ic len = let p = String . create len in really_input ic p 0 len ; let rec split beg cur = if cur >= len then [ ] else if p . [ cur ] = ' \ 000 ' then String . sub p beg ( cur - beg ) :: split ( cur + 1 ) ( cur + 1 ) else split beg ( cur + 1 ) ... |
let dump_exe ic = Bytesections . read_toc ic ; let prim_size = Bytesections . seek_section ic " PRIM " in primitives := read_primitive_table ic prim_size ; ignore ( Bytesections . seek_section ic " DATA " ) ; let init_data = ( input_value ic : Obj . t array ) in globals := Array . ... |
let main ( ) = for i = 1 to Array . length Sys . argv - 1 do let filnam = Sys . argv . ( i ) in let ic = open_in_bin filnam in if i > 1 then print_newline ( ) ; printf " ## start of ocaml dump of % S \ n " %! filnam ; begin try objfile := false ; dump_exe ic with Bytesections... |
let _ = main ( ) |
module Id : Sig . Id = struct value name = " Camlp4Printers . DumpOCamlAst " ; value version = Sys . ocaml_version ; end ; |
module Make ( Syntax : Sig . Camlp4Syntax ) include Syntax ; module Ast2pt = Struct . Camlp4Ast2OCamlAst . Make Ast ; value with_open_out_file x f = match x with [ Some file -> do { let oc = open_out_bin file ; f oc ; flush oc ; close_out oc } | None -> do { set_binary_mode_out stdout... |
let ( ** ) = Int64 . mul |
type nonrec t = t |
let compare_zero ( f : int -> int -> _ ) a b = f ( compare a b ) 0 [ @@ inlined ] |
let ( + ) = Mtime . Span . add |
let ( < ) = compare_zero ( < ) |
let ( <= ) = compare_zero ( <= ) |
let ( = ) = compare_zero ( = ) |
let ( >= ) = compare_zero ( >= ) |
let ( > ) = compare_zero ( > ) |
let zero = v 0L |
let nanosecond = v 1L |
let microsecond = v 1_000L |
let millisecond = v 1_000_000L |
let second = v 1_000_000_000L |
let minute = v ( 60L ** 1_000_000_000L ) |
let hour = v ( 60L ** 60L ** 1_000_000_000_000L ) |
let day = v ( 24L ** 60L ** 60L ** 1_000_000_000_000L ) |
let of_ns x = v ( Int64 . of_float x ) |
let of_us x = v ( Int64 . of_float ( x . * 1e3 ) ) |
let of_ms x = v ( Int64 . of_float ( x . * 1e6 ) ) |
let of_sec x = v ( Int64 . of_float ( x . * 1e9 ) ) |
let of_int64_ms x = v ( x ** 1_000_000L ) |
let of_int_ms x = of_int64_ms ( Int64 . of_int x ) |
let of_int64_sec x = v ( x ** 1_000_000_000L ) |
let of_int_sec x = of_int64_sec ( Int64 . of_int x ) |
let of_min = let f = 60 . . * 1e9 in fun x -> v ( Int64 . of_float ( x . * f ) ) |
let of_int64_min = let f = 60L ** 1_000_000_000L in fun x -> v ( x ** f ) |
let of_int_min x = of_int64_min ( Int64 . of_int x ) |
let of_hour = let f = 60 . . * 60 . . * 1e9 in fun x -> v ( Int64 . of_float ( x . * f ) ) |
let of_int64_hour = let f = 60L ** 60L ** 1_000_000_000L in fun x -> v ( x ** f ) |
let of_int_hour x = of_int64_hour ( Int64 . of_int x ) |
let of_day = let f = 24 . . * 60 . . * 60 . . * 1e9 in fun x -> v ( Int64 . of_float ( x . * f ) ) |
module Of_int = struct let ms = of_int_ms let sec = of_int_sec let min = of_int_min let hour = of_int_hour let ( + ) = ( + ) end |
type t = { state : DS . t ; asm_directives : ( module Asm_directives . S ) ; get_file_id : string -> int ; mutable emitted : bool } |
let create ~ sourcefile ~ unit_name ~ asm_directives ~ get_file_id = begin match ! Dwarf_flags . gdwarf_format with | Thirty_two -> Dwarf_format . set Thirty_two | Sixty_four -> Dwarf_format . set Sixty_four end ; let compilation_unit_proto_die = Dwarf_compilation_unit . compile_unit_proto_die ~ s... |
let dwarf_for_fundecl t fundecl = Dwarf_concrete_instances . for_fundecl ~ get_file_id : t . get_file_id t . state fundecl |
let emit t = if t . emitted then Misc . fatal_error " Cannot call [ Dwarf . emit ] more than once on a given value of type \ [ Dwarf . t ] " ; t . emitted <- true ; Dwarf_world . emit ~ asm_directives : t . asm_directives ~ compilation_unit_proto_die ( : DS . compilation_unit_pr... |
let emit t = Profile . record " emit_dwarf " emit t |
type t = { name : Asm_label . t ; entries : Dwarf_4_location_list_entry . t list } |
let sort entries = List . sort Dwarf_4_location_list_entry . compare_ascending_vma entries |
let create ~ location_list_entries = { name = Asm_label . create ( DWARF Debug_loc ) ; entries = sort location_list_entries } |
let label t = t . name |
let end_marker ( ) = Dwarf_value . absolute_address ~ comment " : end marker " Targetint . zero |
let size t = let ( + ) = Dwarf_int . add in let body_size = List . fold_left ( fun size entry -> size + Dwarf_4_location_list_entry . size entry ) ( Dwarf_int . zero ( ) ) t . entries in let end_marker = end_marker ( ) in body_size + Dwarf_value . size end_marker + Dwarf_value .... |
let compare_increasing_vma t1 t2 = match t1 . entries , t2 . entries with | t1_entry :: _ , t2_entry :: _ -> Dwarf_4_location_list_entry . compare_ascending_vma t1_entry t2_entry | _ -> failwith " Location_list . compare on empty location list ( s ) " |
let emit ~ asm_directives t = let module A = ( val asm_directives : Asm_directives . S ) in A . new_line ( ) ; A . comment " Location list " ; : A . define_label t . name ; List . iter ( fun entry -> Dwarf_4_location_list_entry . emit ~ asm_directives entry ) t . entries ; ... |
module Location_list_entry = struct type t = { start_of_code_symbol : Asm_symbol . t ; beginning_address_label : Asm_label . t ; beginning_address_offset : int option ; ending_address_label : Asm_label . t ; ending_address_offset : int option ; expr : Single_location_description . t } let ... |
module Base_address_selection_entry = struct type t = Asm_symbol . t let create ~ base_address_symbol = base_address_symbol let to_dwarf_values t = [ Dwarf_value . absolute_address ~ comment " : largest representable addr . offset " Targetint . minus_one ; Dwarf_value . code_address_from_symbol... |
type t = | Location_list_entry of Location_list_entry . t | Base_address_selection_entry of Base_address_selection_entry . t |
let create_location_list_entry ~ start_of_code_symbol ~ first_address_when_in_scope ~ first_address_when_in_scope_offset ~ first_address_when_not_in_scope ~ first_address_when_not_in_scope_offset ~ single_location_description = Location_list_entry ( Location_list_entry . create ~ start_of_code_symbol ~ fir... |
let create_base_address_selection_entry ~ base_address_symbol = Base_address_selection_entry ( Base_address_selection_entry . create ~ base_address_symbol ) |
let size = function | Location_list_entry entry -> Location_list_entry . size entry | Base_address_selection_entry entry -> Base_address_selection_entry . size entry |
let emit ~ asm_directives t = let module A = ( val asm_directives : Asm_directives . S ) in match t with | Location_list_entry entry -> A . new_line ( ) ; A . comment " Location list entry " ; : Location_list_entry . emit ~ asm_directives entry | Base_address_selection_entry entry -> A... |
let compare_ascending_vma t1 t2 = match t1 , t2 with | Base_address_selection_entry _ , Base_address_selection_entry _ -> failwith " Location_list_entry . compare_ascending_vma : unsupported " | Base_address_selection_entry _ , Location_list_entry _ -> - 1 | Location_list_entry _ , Base_addr... |
type t = { name : Asm_label . t ; entries : Dwarf_4_range_list_entry . t list } |
let sort entries = List . sort Dwarf_4_range_list_entry . compare_ascending_vma entries |
let create ~ range_list_entries = { name = Asm_label . create ( DWARF Debug_ranges ) ; entries = sort range_list_entries } |
let label t = t . name |
let end_marker ( ) = Dwarf_value . absolute_address ~ comment " : end marker " Targetint . zero |
let size t = let ( + ) = Dwarf_int . add in let body_size = List . fold_left ( fun size entry -> size + Dwarf_4_range_list_entry . size entry ) ( Dwarf_int . zero ( ) ) t . entries in let end_marker = end_marker ( ) in body_size + Dwarf_value . size end_marker + Dwarf_value . ... |
let compare_increasing_vma t1 t2 = match t1 . entries , t2 . entries with | t1_entry :: _ , t2_entry :: _ -> Dwarf_4_range_list_entry . compare_ascending_vma t1_entry t2_entry | _ -> failwith " Range_list . compare on empty range list ( s ) " |
let emit ~ asm_directives t = let module A = ( val asm_directives : Asm_directives . S ) in A . new_line ( ) ; A . comment " Range list " ; : A . define_label t . name ; List . iter ( fun entry -> Dwarf_4_range_list_entry . emit ~ asm_directives entry ) t . entries ; let e... |
module Range_list_entry = struct type t = { start_of_code_symbol : Asm_symbol . t ; beginning_address_label : Asm_label . t ; ending_address_label : Asm_label . t ; ending_address_offset : int option } let create ~ start_of_code_symbol ~ first_address_when_in_scope ~ first_address_when_not_in_s... |
module Base_address_selection_entry = struct type t = Asm_symbol . t let create ~ base_address_symbol = base_address_symbol let to_dwarf_values t = [ Dwarf_value . absolute_address ~ comment " : largest representable addr . offset " Targetint . minus_one ; Dwarf_value . code_address_from_symbol... |
type t = | Range_list_entry of Range_list_entry . t | Base_address_selection_entry of Base_address_selection_entry . t |
let create_range_list_entry ~ start_of_code_symbol ~ first_address_when_in_scope ~ first_address_when_not_in_scope ~ first_address_when_not_in_scope_offset = Range_list_entry ( Range_list_entry . create ~ start_of_code_symbol ~ first_address_when_in_scope ~ first_address_when_not_in_scope ~ first_address_w... |
let create_base_address_selection_entry ~ base_address_symbol = Base_address_selection_entry ( Base_address_selection_entry . create ~ base_address_symbol ) |
let size = function | Range_list_entry entry -> Range_list_entry . size entry | Base_address_selection_entry entry -> Base_address_selection_entry . size entry |
let emit ~ asm_directives t = let module A = ( val asm_directives : Asm_directives . S ) in match t with | Range_list_entry entry -> A . new_line ( ) ; A . comment " Range list entry " ; : Range_list_entry . emit ~ asm_directives entry | Base_address_selection_entry entry -> A . comm... |
let compare_ascending_vma t1 t2 = match t1 , t2 with | Base_address_selection_entry _ , Base_address_selection_entry _ -> failwith " Range_list_entry . compare_ascending_vma : unsupported " | Base_address_selection_entry _ , Range_list_entry _ -> - 1 | Range_list_entry _ , Base_address_selec... |
module Class = struct type address = [ ` address ] type addrptr = [ ` addrptr ] type block = [ ` block ] type constant = [ ` constant ] type exprloc = [ ` exprloc ] type flag = [ ` flag ] type lineptr = [ ` lineptr ] type loclist = [ ` loclist ] type loclistsptr ... |
module Form = struct type addr = [ ` addr ] type block = [ ` block ] type block1 = [ ` block1 ] type block2 = [ ` block2 ] type block4 = [ ` block4 ] type data1 = [ ` data1 ] type data2 = [ ` data2 ] type data4 = [ ` data4 ] type data8 = [ ` data8 ] type s... |
module Attribute = struct module Dwarf_4 = struct type ' dwarf_classes t = | Location : [ < Class . exprloc | Class . Dwarf_4 . loclistptr ] t | String_length : [ < Class . exprloc | Class . Dwarf_4 . loclistptr ] t | Return_addr : [ < Class . exprloc | Class . Dwarf_4 . loc... |
module Attribute_specification = struct type ' form t = | T : ' dwarf_classes Attribute . t * ( ' dwarf_classes , ' form ) Form . t -> ' form t type ' form spec = ' form t let create attribute form = T ( attribute , form ) module Sealed = struct type t = T1 : ' form spec -> t... |
let needs_dwarf_five ( ) = match ! Dwarf_flags . gdwarf_version with | Four -> Misc . fatal_error " Attribute not supported for DWARF - 4 " | Five -> ( ) |
let create_entry_pc address_label = let spec = AS . create Entry_pc Addr in AV . create spec ( V . code_address_from_label ~ comment " : entry PC value " address_label ) |
let create_low_pc address_label = let spec = AS . create Low_pc Addr in AV . create spec ( V . code_address_from_label ~ comment " : low PC value " address_label ) |
let create_high_pc_offset offset = match Targetint . repr offset with | Int32 offset -> let spec = AS . create High_pc Data4 in AV . create spec ( V . int32 ~ comment " : high PC value as offset " offset ) | Int64 offset -> let spec = AS . create High_pc Data8 in AV . create spec ( V . ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.