text
stringlengths
12
786k
let create_high_pc ~ low_pc high_pc = match Dwarf_arch_sizes . size_addr with | 4 -> let spec = AS . create High_pc Data4 in AV . create spec ( V . distance_between_label_and_symbol_32_bit ~ comment " : high PC value " ~ upper : high_pc ~ lower : low_pc ( ) ) | 8 -> let spec = AS . ...
let create_entry_pc_from_symbol symbol = let spec = AS . create Entry_pc Addr in AV . create spec ( V . code_address_from_symbol ~ comment " : entry PC value " symbol )
let create_low_pc_from_symbol symbol = let spec = AS . create Low_pc Addr in AV . create spec ( V . code_address_from_symbol ~ comment " : low PC value " symbol )
let create_high_pc_from_symbol ~ low_pc high_pc = match Dwarf_arch_sizes . size_addr with | 4 -> let spec = AS . create High_pc Data4 in AV . create spec ( V . distance_between_symbols_32_bit ~ comment " : high PC value " ~ upper : high_pc ~ lower : low_pc ( ) ) | 8 -> let spec = AS ...
let create_producer producer_name = let spec = AS . create Producer Strp in AV . create spec ( V . indirect_string ~ comment " : producer name " producer_name )
let create_name name = let spec = AS . create Name Strp in AV . create spec ( V . indirect_string ~ comment " : name " name )
let create_comp_dir directory = let spec = AS . create Comp_dir Strp in AV . create spec ( V . indirect_string ~ comment " : compilation directory " directory )
let create_stmt_list ~ debug_line_label = let spec = AS . create Stmt_list Sec_offset_lineptr in AV . create spec ( V . offset_into_debug_line debug_line_label )
let create_external ~ is_visible_externally = if is_visible_externally then let spec = AS . create External Flag_present in AV . create spec ( V . flag_true ~ comment " : visible externally " ( ) ) else let spec = AS . create External Flag in AV . create spec ( V . bool ~ comment " :...
let create_artificial ( ) = let spec = AS . create Artificial Flag_present in AV . create spec ( V . flag_true ~ comment " : artificial " ( ) )
let create_decl_file file = let spec = AS . create Decl_file Udata in let file = Uint64 . of_nonnegative_int_exn file in AV . create spec ( V . uleb128 ~ comment " : file number " file )
let create_decl_line line = let spec = AS . create Decl_line Udata in let line = Uint64 . of_nonnegative_int_exn line in AV . create spec ( V . uleb128 ~ comment " : line number " line )
let create_decl_column column = let spec = AS . create Decl_column Udata in let column = Uint64 . of_nonnegative_int_exn column in AV . create spec ( V . uleb128 ~ comment " : column number " column )
let create_call_pc label = let spec = AS . create Call_pc Addr in needs_dwarf_five ( ) ; AV . create spec ( V . code_address_from_label ~ comment " : PC of call site " label )
let create_call_return_pc label = needs_dwarf_five ( ) ; let spec = AS . create Call_return_pc Addr in AV . create spec ( V . code_address_from_label ~ comment " : PC immediately after call site " label )
let create_call_tail_call ~ is_tail = if is_tail then let spec = match ! Dwarf_flags . gdwarf_version with | Four -> AS . create ( Dwarf_4 GNU_tail_call ) Flag_present | Five -> AS . create Call_tail_call Flag_present in AV . create spec ( V . flag_true ~ comment " : is a tail call " ( )...
let create_call_all_calls ( ) = let spec = match ! Dwarf_flags . gdwarf_version with | Four -> AS . create ( Dwarf_4 GNU_all_call_sites ) Flag_present | Five -> AS . create Call_all_calls Flag_present in AV . create spec ( V . flag_true ~ comment " : DW_AT_call_all_calls is set " ( ) ...
let create_call_target loc_desc = let spec = match ! Dwarf_flags . gdwarf_version with | Four -> AS . create ( Dwarf_4 GNU_call_site_target ) Exprloc | Five -> AS . create Call_target Exprloc in AV . create spec ( V . single_location_description loc_desc )
let create_call_target_clobbered loc_desc = let spec = match ! Dwarf_flags . gdwarf_version with | Four -> AS . create ( Dwarf_4 GNU_call_site_target_clobbered ) Exprloc | Five -> AS . create Call_target_clobbered Exprloc in AV . create spec ( V . single_location_description loc_desc )
let create_location index = needs_dwarf_five ( ) ; let location_list_label = Location_list_table . Index . to_label index in let location_list_index = Location_list_table . Index . to_uint64 index in if not ! Dwarf_flags . gdwarf_offsets then let spec = AS . create Location Sec_offset_loclist in ...
let create_ranges index = needs_dwarf_five ( ) ; let range_list_label = Range_list_table . Index . to_label index in let range_list_index = Range_list_table . Index . to_uint64 index in if not ! Dwarf_flags . gdwarf_offsets then let spec = AS . create Ranges Sec_offset_rnglist in AV . create sp...
let create_single_location_description loc_desc = let spec = AS . create Location Exprloc in AV . create spec ( V . single_location_description loc_desc )
let create_composite_location_description loc_desc = let spec = AS . create Location Exprloc in AV . create spec ( V . composite_location_description loc_desc )
let create_single_call_value_location_description loc_desc = let spec = match ! Dwarf_flags . gdwarf_version with | Four -> AS . create ( Dwarf_4 GNU_call_site_value ) Exprloc | Five -> AS . create Call_value Exprloc in AV . create spec ( V . single_location_description loc_desc )
let create_composite_call_value_location_description loc_desc = let spec = match ! Dwarf_flags . gdwarf_version with | Four -> AS . create ( Dwarf_4 GNU_call_site_value ) Exprloc | Five -> AS . create Call_value Exprloc in AV . create spec ( V . composite_location_description loc_desc )
let create_single_call_data_location_description loc_desc = needs_dwarf_five ( ) ; let spec = AS . create Call_data_location Exprloc in AV . create spec ( V . single_location_description loc_desc )
let create_single_call_data_value_location_description loc_desc = let spec = match ! Dwarf_flags . gdwarf_version with | Four -> AS . create ( Dwarf_4 GNU_call_site_data_value ) Exprloc | Five -> AS . create Call_data_value Exprloc in AV . create spec ( V . single_location_description loc_desc ) ...
let create_encoding ~ encoding = let spec = AS . create Encoding Data1 in AV . create spec ( V . encoding_attribute encoding )
let reference_proto_die attribute proto_die = let spec = AS . create attribute Ref_addr in let label = Proto_die . reference proto_die in AV . create spec ( V . offset_into_debug_info ~ comment " : ref . to DIE " label )
let create_type ~ proto_die = reference_proto_die Type proto_die
let create_sibling ~ proto_die = reference_proto_die Sibling proto_die
let create_import ~ proto_die = reference_proto_die Import proto_die
let create_type_from_reference ~ proto_die_reference : label = let spec = AS . create Type Ref_addr in AV . create spec ( V . offset_into_debug_info ~ comment " : reference to type DIE " label )
let create_byte_size_exn ~ byte_size = let spec = AS . create Byte_size Data8 in AV . create spec ( V . int64 ~ comment " : byte size " ( Int64 . of_int byte_size ) )
let create_bit_size bit_size = let spec = AS . create Bit_size Data8 in AV . create spec ( V . int64 ~ comment " : bit size " bit_size )
let create_data_member_location ~ byte_offset = let spec = AS . create Data_member_location Data8 in AV . create spec ( V . int64 ~ comment " : data member location " byte_offset )
let create_linkage_name ~ linkage_name = let spec = AS . create Linkage_name Strp in AV . create spec ( V . indirect_string ~ comment " : linkage name " linkage_name )
let create_const_value_from_symbol ~ symbol = match Targetint . size with | 32 -> let spec = AS . create Const_value Data4 in AV . create spec ( V . symbol_32 symbol ) | 64 -> let spec = AS . create Const_value Data8 in AV . create spec ( V . symbol_64 symbol ) | size -> Misc . fatal...
let create_addr_base label = let spec = AS . create Addr_base Sec_offset_addrptr in AV . create spec ( V . offset_into_debug_addr label )
let create_loclists_base label = let spec = AS . create Loclists_base Sec_offset_loclistsptr in AV . create spec ( V . offset_into_debug_loclists label )
let create_rnglists_base label = let spec = AS . create Rnglists_base Sec_offset_rnglistsptr in AV . create spec ( V . offset_into_debug_rnglists label )
let create_inline inline_code = let spec = AS . create Inline Data1 in AV . create spec ( V . inline_code inline_code )
let create_call_origin ~ die_symbol = let comment = " reference to call origin DIE " in let spec = match ! Dwarf_flags . gdwarf_version with | Four -> AS . create Abstract_origin Ref_addr | Five -> AS . create Call_origin Ref_addr in AV . create spec ( V . offset_into_debug_info_from_symbol ~ ...
let create_abstract_origin ~ die_symbol = let spec = AS . create Abstract_origin Ref_addr in AV . create spec ( V . offset_into_debug_info_from_symbol ~ comment " : reference to abstract origin DIE " die_symbol )
let create_language lang = let spec = AS . create Language Data1 in AV . create spec ( V . language lang )
let create_declaration ( ) = let spec = AS . create Declaration Flag_present in AV . create spec ( V . flag_true ~ comment " : incomplete / non - defining declaration " ( ) )
let create_ocaml_compiler_version version = let spec = AS . create ( Ocaml_specific Compiler_version ) Strp in AV . create spec ( V . indirect_string ~ comment " : OCaml compiler version " version )
let create_ocaml_unit_name unit_name = let spec = AS . create ( Ocaml_specific Unit_name ) Strp in AV . create spec ( V . indirect_string ~ comment " : unit name " ( Ident . name unit_name ) )
let create_ocaml_config_digest digest = let hex = Digest . to_hex digest in let spec = AS . create ( Ocaml_specific Config_digest ) Strp in AV . create spec ( V . indirect_string ~ comment " : static config value digest " hex )
let create_ocaml_prefix_name name = let spec = AS . create ( Ocaml_specific Prefix_name ) Strp in AV . create spec ( V . indirect_string ~ comment " : prefix name " name )
let create_ocaml_linker_dirs dirs = let dirs = Dwarf_name_laundry . mangle_linker_dirs ( Misc . Stdlib . String . Set . elements dirs ) in let spec = AS . create ( Ocaml_specific Linker_dirs ) Strp in AV . create spec ( V . indirect_string ~ comment " : linker dirs " dirs )
let create_ocaml_cmt_file_digest digest = let hex = Digest . to_hex digest in let spec = AS . create ( Ocaml_specific Cmt_file_digest ) Strp in AV . create spec ( V . indirect_string ~ comment " . : cmt file digest " hex )
module Value = struct type internal_t = | Dwarf_value of Dwarf_value . t | Single_location_description of Single_location_description . t | Composite_location_description of Composite_location_description . t type _ t = internal_t module V = Dwarf_value let flag_true ? comment ( ) = Dwarf_value ( ...
module Attribute_value = struct type t = Dwarf_attributes . Attribute_specification . Sealed . t * Value . internal_t let create attr_spec value = let attr_spec = Dwarf_attributes . Attribute_specification . seal attr_spec in attr_spec , value let rec uleb128_size i = assert ( Int64 . compare i ...
type fundecl = { fun_name : string ; fun_dbg : Debuginfo . t }
let end_symbol_name ~ start_symbol = start_symbol ^ " __end "
let for_fundecl ~ get_file_id state fundecl = let parent = Dwarf_state . compilation_unit_proto_die state in let fun_name = fundecl . fun_name in let linkage_name = match fundecl . fun_dbg with | [ item ] -> Debuginfo . Scoped_location . string_of_scopes item . dinfo_scopes | [ ] | _ :: _...
type debug_thing = | Debug_ocamldebug | Debug_js_of_ocaml | Debug_subprocs | Debug_backtraces | Debug_bounds_checking | Debug_disable_bytecode_opt | Debug_dwarf_cfi | Debug_dwarf_loc | Debug_dwarf_functions | Debug_dwarf_scopes | Debug_dwarf_vars | Debug_dwarf_call_sites | Debug_dwarf_cmm
let bytecode_g = [ Debug_ocamldebug ; Debug_js_of_ocaml ; Debug_subprocs ; Debug_backtraces ; Debug_disable_bytecode_opt ]
let g1 = [ Debug_subprocs ; Debug_backtraces ; Debug_bounds_checking ; Debug_disable_bytecode_opt ; Debug_dwarf_cfi ; Debug_dwarf_loc ]
let g2 = [ Debug_subprocs ; Debug_backtraces ; Debug_bounds_checking ; Debug_disable_bytecode_opt ; Debug_dwarf_cfi ; Debug_dwarf_loc ; Debug_dwarf_functions ]
let g3 = [ Debug_subprocs ; Debug_backtraces ; Debug_bounds_checking ; Debug_disable_bytecode_opt ; Debug_dwarf_cfi ; Debug_dwarf_loc ; Debug_dwarf_functions ; Debug_dwarf_scopes ; Debug_dwarf_vars ; Debug_dwarf_call_sites ; Debug_dwarf_cmm ]
let all_g_levels = [ " g0 " , g0 ; " g1 " , g1 ; " g2 " , g2 ; " g3 " , g3 ]
let current_debug_settings = ref g0
let use_g0 ( ) = current_debug_settings := g0
let use_g1 ( ) = current_debug_settings := g1
let use_g2 ( ) = current_debug_settings := g2
let use_g3 ( ) = Clflags . binary_annotations := true ; current_debug_settings := g3
let use_g ( ) = if ! Clflags . native_code then use_g1 ( ) else current_debug_settings := bytecode_g
let restrict_to_upstream_dwarf = ref false
let debug_thing thing = List . mem thing ! current_debug_settings
let set_debug_thing thing = let new_settings = List . filter ( fun thing ' -> thing <> thing ' ) ! current_debug_settings in current_debug_settings := thing :: new_settings
let clear_debug_thing thing = let new_settings = List . filter ( fun thing ' -> thing <> thing ' ) ! current_debug_settings in current_debug_settings := new_settings
let describe_debug_default_internal ~ negate thing = let defaults = List . filter_map ( fun ( level , things_enabled_at_level ) -> let enabled_at_level = List . mem thing things_enabled_at_level in let state = if negate then not enabled_at_level else enabled_at_level in if state then Some ( " " ...
let describe_debug_default thing = describe_debug_default_internal ~ negate : false thing
let describe_debug_default_negated thing = describe_debug_default_internal ~ negate : true thing
type dwarf_version = | Four | Five
let gdwarf_version = ref default_gdwarf_version
let gdwarf_offsets = ref default_gdwarf_offsets
let ddebug_invariants = ref default_ddebug_invariants
type dwarf_format = | Thirty_two | Sixty_four
let gdwarf_format = ref default_gdwarf_format
let gdwarf_self_tail_calls = ref default_gdwarf_self_tail_calls
type t = | Thirty_two of Int32 . t | Sixty_four of Int64 . t
let print ppf t = match t with | Thirty_two i -> Format . fprintf ppf " % ld " i | Sixty_four i -> Format . fprintf ppf " % Ld " i
let num i32 = match Dwarf_format . get ( ) with | Thirty_two -> Thirty_two i32 | Sixty_four -> Sixty_four ( Int64 . of_int32 i32 )
let zero ( ) = num 0l
let one ( ) = num 1l
let two ( ) = num 2l
let four ( ) = num 4l
let eight ( ) = num 8l
let of_host_int_exn i = match Sys . int_size , Dwarf_format . get ( ) with | 31 , Thirty_two -> Thirty_two ( Int32 . of_int i ) | 63 , Sixty_four -> Sixty_four ( Int64 . of_int i ) | 31 , Sixty_four -> Sixty_four ( Int64 . of_int i ) | 63 , Thirty_two -> if i >= - 0x80...
let of_int64_exn i64 = match Dwarf_format . get ( ) with | Sixty_four -> Sixty_four i64 | Thirty_two -> if i64 >= - 0x8000_0000L && i64 <= 0x7fff_ffffL then Thirty_two ( Int64 . to_int32 i64 ) else raise Dwarf_format . Too_large_for_thirty_two_bit_dwarf
let of_targetint_exn i = match Targetint . repr i , Dwarf_format . get ( ) with | Int32 i32 , Thirty_two -> Thirty_two i32 | Int64 i64 , Sixty_four -> Sixty_four i64 | Int32 i32 , Sixty_four -> Sixty_four ( Int64 . of_int32 i32 ) | Int64 i64 , Thirty_two -> if i64 >= - 0x8000_0000L ...
let to_int64 t = match t with Thirty_two t -> Int64 . of_int32 t | Sixty_four t -> t
let to_uint64_exn t = match t with | Thirty_two t -> Uint64 . of_nonnegative_int32_exn t | Sixty_four t -> Uint64 . of_nonnegative_int64_exn t
let add t1 t2 = begin match t1 , t2 with | Thirty_two _ , Thirty_two _ | Sixty_four _ , Sixty_four _ -> ( ) | Thirty_two _ , Sixty_four _ | Sixty_four _ , Thirty_two _ -> Misc . fatal_error " Cannot intermix sizes of [ Dwarf_int ] s " end ; let t1 = to_int64 t1 in let t2 = to_...
let succ t = add t ( one ( ) )
let width_as_int64 ( ) = match zero ( ) with Thirty_two _ -> 4L | Sixty_four _ -> 8L
let size t = match t with Thirty_two _ -> Thirty_two 4l | Sixty_four _ -> Sixty_four 8L