1 (*===-- llvm_debuginfo.ml - LLVM OCaml Interface --------------*- OCaml -*-===*
3 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 * See https://llvm.org/LICENSE.txt for license information.
5 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 *===----------------------------------------------------------------------===*)
11 (** Source languages known by DWARF. *)
12 module DWARFSourceLanguageKind
= struct
24 (* New in DWARF v3: *)
34 (* New in DWARF v4: *)
36 (* New in DWARF v5: *)
54 (* Vendor extensions: *)
60 module DIFlag
= struct
101 external diflags_get
: DIFlag.t
-> lldiflags
= "llvm_diflags_get"
103 external diflags_set
: lldiflags
-> DIFlag.t
-> lldiflags
= "llvm_diflags_set"
105 external diflags_test
: lldiflags
-> DIFlag.t
-> bool = "llvm_diflags_test"
107 (** The kind of metadata nodes. *)
108 module MetadataKind
= struct
110 | MDStringMetadataKind
111 | ConstantAsMetadataMetadataKind
112 | LocalAsMetadataMetadataKind
113 | DistinctMDOperandPlaceholderMetadataKind
114 | MDTupleMetadataKind
115 | DILocationMetadataKind
116 | DIExpressionMetadataKind
117 | DIGlobalVariableExpressionMetadataKind
118 | GenericDINodeMetadataKind
119 | DISubrangeMetadataKind
120 | DIEnumeratorMetadataKind
121 | DIBasicTypeMetadataKind
122 | DIDerivedTypeMetadataKind
123 | DICompositeTypeMetadataKind
124 | DISubroutineTypeMetadataKind
126 | DICompileUnitMetadataKind
127 | DISubprogramMetadataKind
128 | DILexicalBlockMetadataKind
129 | DILexicalBlockFileMetadataKind
130 | DINamespaceMetadataKind
131 | DIModuleMetadataKind
132 | DITemplateTypeParameterMetadataKind
133 | DITemplateValueParameterMetadataKind
134 | DIGlobalVariableMetadataKind
135 | DILocalVariableMetadataKind
136 | DILabelMetadataKind
137 | DIObjCPropertyMetadataKind
138 | DIImportedEntityMetadataKind
139 | DIMacroMetadataKind
140 | DIMacroFileMetadataKind
141 | DICommonBlockMetadataKind
144 (** The amount of debug information to emit. *)
145 module DWARFEmissionKind
= struct
146 type t
= None
| Full
| LineTablesOnly
149 external debug_metadata_version
: unit -> int = "llvm_debug_metadata_version"
151 external get_module_debug_metadata_version
: Llvm.llmodule
-> int
152 = "llvm_get_module_debug_metadata_version"
154 external dibuilder
: Llvm.llmodule
-> lldibuilder
= "llvm_dibuilder"
156 external dibuild_finalize
: lldibuilder
-> unit = "llvm_dibuild_finalize"
158 (* See LLVMDIBuilderCreateCompileUnit for argument details. *)
159 external dibuild_create_compile_unit
:
161 DWARFSourceLanguageKind.t
->
162 file_ref
:Llvm.llmetadata
->
168 DWARFEmissionKind.t
->
175 = "llvm_dibuild_create_compile_unit_bytecode" "llvm_dibuild_create_compile_unit_native"
177 external dibuild_create_file
:
178 lldibuilder
-> filename
:string -> directory
:string -> Llvm.llmetadata
179 = "llvm_dibuild_create_file"
181 external dibuild_create_module
:
183 parent_ref
:Llvm.llmetadata
->
185 config_macros
:string ->
186 include_path
:string ->
189 = "llvm_dibuild_create_module_bytecode" "llvm_dibuild_create_module_native"
191 external dibuild_create_namespace
:
193 parent_ref
:Llvm.llmetadata
->
195 export_symbols
:bool ->
196 Llvm.llmetadata
= "llvm_dibuild_create_namespace"
198 external dibuild_create_function
:
200 scope
:Llvm.llmetadata
->
202 linkage_name
:string ->
203 file
:Llvm.llmetadata
->
205 ty
:Llvm.llmetadata
->
206 is_local_to_unit
:bool ->
207 is_definition
:bool ->
212 = "llvm_dibuild_create_function_bytecode" "llvm_dibuild_create_function_native"
214 external dibuild_create_lexical_block
:
216 scope
:Llvm.llmetadata
->
217 file
:Llvm.llmetadata
->
220 Llvm.llmetadata
= "llvm_dibuild_create_lexical_block"
222 external dibuild_create_debug_location_helper
:
226 scope
:Llvm.llmetadata
->
227 inlined_at
:Llvm.llmetadata
->
228 Llvm.llmetadata
= "llvm_dibuild_create_debug_location"
230 external llmetadata_null
: unit -> Llvm.llmetadata
= "llvm_metadata_null"
232 let dibuild_create_debug_location ?
(inlined_at
= llmetadata_null
()) llctx ~line
234 dibuild_create_debug_location_helper llctx ~line ~column ~scope ~inlined_at
236 external di_location_get_line
: location
:Llvm.llmetadata
-> int
237 = "llvm_di_location_get_line"
239 external di_location_get_column
: location
:Llvm.llmetadata
-> int
240 = "llvm_di_location_get_column"
242 external di_location_get_scope
: location
:Llvm.llmetadata
-> Llvm.llmetadata
243 = "llvm_di_location_get_scope"
245 external di_location_get_inlined_at
:
246 location
:Llvm.llmetadata
-> Llvm.llmetadata
option
247 = "llvm_di_location_get_inlined_at"
249 external di_scope_get_file
: scope
:Llvm.llmetadata
-> Llvm.llmetadata
option
250 = "llvm_di_scope_get_file"
252 external di_file_get_directory
: file
:Llvm.llmetadata
-> string
253 = "llvm_di_file_get_directory"
255 external di_file_get_filename
: file
:Llvm.llmetadata
-> string
256 = "llvm_di_file_get_filename"
258 external di_file_get_source
: file
:Llvm.llmetadata
-> string
259 = "llvm_di_file_get_source"
261 external dibuild_get_or_create_type_array
:
262 lldibuilder
-> data
:Llvm.llmetadata array
-> Llvm.llmetadata
263 = "llvm_dibuild_get_or_create_type_array"
265 external dibuild_get_or_create_array
:
266 lldibuilder
-> data
:Llvm.llmetadata array
-> Llvm.llmetadata
267 = "llvm_dibuild_get_or_create_array"
269 external dibuild_create_subroutine_type
:
271 file
:Llvm.llmetadata
->
272 param_types
:Llvm.llmetadata array
->
274 Llvm.llmetadata
= "llvm_dibuild_create_subroutine_type"
276 external dibuild_create_enumerator
:
277 lldibuilder
-> name
:string -> value:int -> is_unsigned
:bool -> Llvm.llmetadata
278 = "llvm_dibuild_create_enumerator"
280 external dibuild_create_enumeration_type
:
282 scope
:Llvm.llmetadata
->
284 file
:Llvm.llmetadata
->
288 elements
:Llvm.llmetadata array
->
289 class_ty
:Llvm.llmetadata
->
291 = "llvm_dibuild_create_enumeration_type_bytecode" "llvm_dibuild_create_enumeration_type_native"
293 external dibuild_create_union_type
:
295 scope
:Llvm.llmetadata
->
297 file
:Llvm.llmetadata
->
302 elements
:Llvm.llmetadata array
->
303 run_time_language
:int ->
306 = "llvm_dibuild_create_union_type_bytecode" "llvm_dibuild_create_union_type_native"
308 external dibuild_create_array_type
:
312 ty
:Llvm.llmetadata
->
313 subscripts
:Llvm.llmetadata array
->
314 Llvm.llmetadata
= "llvm_dibuild_create_array_type"
316 external dibuild_create_vector_type
:
320 ty
:Llvm.llmetadata
->
321 subscripts
:Llvm.llmetadata array
->
322 Llvm.llmetadata
= "llvm_dibuild_create_array_type"
324 external dibuild_create_unspecified_type
:
325 lldibuilder
-> name
:string -> Llvm.llmetadata
326 = "llvm_dibuild_create_unspecified_type"
328 external dibuild_create_basic_type
:
334 Llvm.llmetadata
= "llvm_dibuild_create_basic_type"
336 external dibuild_create_pointer_type
:
338 pointee_ty
:Llvm.llmetadata
->
344 = "llvm_dibuild_create_pointer_type_bytecode" "llvm_dibuild_create_pointer_type_native"
346 external dibuild_create_struct_type
:
348 scope
:Llvm.llmetadata
->
350 file
:Llvm.llmetadata
->
355 derived_from
:Llvm.llmetadata
->
356 elements
:Llvm.llmetadata array
->
357 DWARFSourceLanguageKind.t
->
358 vtable_holder
:Llvm.llmetadata
->
361 = "llvm_dibuild_create_struct_type_bytecode" "llvm_dibuild_create_struct_type_native"
363 external dibuild_create_member_type
:
365 scope
:Llvm.llmetadata
->
367 file
:Llvm.llmetadata
->
371 offset_in_bits
:int ->
373 ty
:Llvm.llmetadata
->
375 = "llvm_dibuild_create_member_type_bytecode" "llvm_dibuild_create_member_type_native"
377 external dibuild_create_static_member_type
:
379 scope
:Llvm.llmetadata
->
381 file
:Llvm.llmetadata
->
383 ty
:Llvm.llmetadata
->
385 const_val
:Llvm.llvalue
->
388 = "llvm_dibuild_create_static_member_type_bytecode" "llvm_dibuild_create_static_member_type_native"
390 external dibuild_create_member_pointer_type
:
392 pointee_type
:Llvm.llmetadata
->
393 class_type
:Llvm.llmetadata
->
398 = "llvm_dibuild_create_member_pointer_type_bytecode" "llvm_dibuild_create_member_pointer_type_native"
400 external dibuild_create_object_pointer_type
:
401 lldibuilder
-> Llvm.llmetadata
-> Llvm.llmetadata
402 = "llvm_dibuild_create_object_pointer_type"
404 external dibuild_create_qualified_type
:
405 lldibuilder
-> tag
:int -> Llvm.llmetadata
-> Llvm.llmetadata
406 = "llvm_dibuild_create_qualified_type"
408 external dibuild_create_reference_type
:
409 lldibuilder
-> tag
:int -> Llvm.llmetadata
-> Llvm.llmetadata
410 = "llvm_dibuild_create_reference_type"
412 external dibuild_create_null_ptr_type
: lldibuilder
-> Llvm.llmetadata
413 = "llvm_dibuild_create_null_ptr_type"
415 external dibuild_create_typedef
:
417 ty
:Llvm.llmetadata
->
419 file
:Llvm.llmetadata
->
421 scope
:Llvm.llmetadata
->
424 = "llvm_dibuild_create_typedef_bytecode" "llvm_dibuild_create_typedef_native"
426 external dibuild_create_inheritance
:
428 ty
:Llvm.llmetadata
->
429 base_ty
:Llvm.llmetadata
->
434 = "llvm_dibuild_create_inheritance_bytecode" "llvm_dibuild_create_inheritance_native"
436 external dibuild_create_forward_decl
:
440 scope
:Llvm.llmetadata
->
441 file
:Llvm.llmetadata
->
446 unique_identifier
:string ->
448 = "llvm_dibuild_create_forward_decl_bytecode" "llvm_dibuild_create_forward_decl_native"
450 external dibuild_create_replaceable_composite_type
:
454 scope
:Llvm.llmetadata
->
455 file
:Llvm.llmetadata
->
461 unique_identifier
:string ->
463 = "llvm_dibuild_create_replaceable_composite_type_bytecode" "llvm_dibuild_create_replaceable_composite_type_native"
465 external dibuild_create_bit_field_member_type
:
467 scope
:Llvm.llmetadata
->
469 file
:Llvm.llmetadata
->
472 offset_in_bits
:int ->
473 storage_offset_in_bits
:int ->
475 ty
:Llvm.llmetadata
->
477 = "llvm_dibuild_create_bit_field_member_type_bytecode" "llvm_dibuild_create_bit_field_member_type_native"
479 external dibuild_create_class_type
:
481 scope
:Llvm.llmetadata
->
483 file
:Llvm.llmetadata
->
487 offset_in_bits
:int ->
489 derived_from
:Llvm.llmetadata
->
490 elements
:Llvm.llmetadata array
->
491 vtable_holder
:Llvm.llmetadata
->
492 template_params_node
:Llvm.llmetadata
->
493 unique_identifier
:string ->
495 = "llvm_dibuild_create_class_type_bytecode" "llvm_dibuild_create_class_type_native"
497 external dibuild_create_artificial_type
:
498 lldibuilder
-> ty
:Llvm.llmetadata
-> Llvm.llmetadata
499 = "llvm_dibuild_create_artificial_type"
501 external di_type_get_name
: Llvm.llmetadata
-> string = "llvm_di_type_get_name"
503 external di_type_get_size_in_bits
: Llvm.llmetadata
-> int
504 = "llvm_di_type_get_size_in_bits"
506 external di_type_get_offset_in_bits
: Llvm.llmetadata
-> int
507 = "llvm_di_type_get_offset_in_bits"
509 external di_type_get_align_in_bits
: Llvm.llmetadata
-> int
510 = "llvm_di_type_get_align_in_bits"
512 external di_type_get_line
: Llvm.llmetadata
-> int = "llvm_di_type_get_line"
514 external di_type_get_flags
: Llvm.llmetadata
-> lldiflags
515 = "llvm_di_type_get_flags"
517 external get_subprogram
: Llvm.llvalue
-> Llvm.llmetadata
option
518 = "llvm_get_subprogram"
520 external set_subprogram
: Llvm.llvalue
-> Llvm.llmetadata
-> unit
521 = "llvm_set_subprogram"
523 external di_subprogram_get_line
: Llvm.llmetadata
-> int
524 = "llvm_di_subprogram_get_line"
526 external instr_get_debug_loc
: Llvm.llvalue
-> Llvm.llmetadata
option
527 = "llvm_instr_get_debug_loc"
529 external instr_set_debug_loc_helper
: Llvm.llvalue
-> Llvm.llmetadata
-> unit
530 = "llvm_instr_set_debug_loc"
532 let instr_set_debug_loc i mopt
=
534 | None
-> instr_set_debug_loc_helper i
(llmetadata_null
())
535 | Some m
-> instr_set_debug_loc_helper i m
537 external dibuild_create_constant_value_expression
:
538 lldibuilder
-> int -> Llvm.llmetadata
539 = "llvm_dibuild_create_constant_value_expression"
541 external dibuild_create_global_variable_expression
:
543 scope
:Llvm.llmetadata
->
546 file
:Llvm.llmetadata
->
548 ty
:Llvm.llmetadata
->
549 is_local_to_unit
:bool ->
550 expr
:Llvm.llmetadata
->
551 decl
:Llvm.llmetadata
->
554 = "llvm_dibuild_create_global_variable_expression_bytecode" "llvm_dibuild_create_global_variable_expression_native"
556 external di_global_variable_expression_get_variable
:
557 Llvm.llmetadata
-> Llvm.llmetadata
option
558 = "llvm_di_global_variable_expression_get_variable"
560 external di_variable_get_line
: Llvm.llmetadata
-> int
561 = "llvm_di_variable_get_line"
563 external di_variable_get_file
: Llvm.llmetadata
-> Llvm.llmetadata
option
564 = "llvm_di_variable_get_file"
566 external get_metadata_kind
: Llvm.llmetadata
-> MetadataKind.t
567 = "llvm_get_metadata_kind"
569 external dibuild_create_auto_variable
:
571 scope
:Llvm.llmetadata
->
573 file
:Llvm.llmetadata
->
575 ty
:Llvm.llmetadata
->
576 always_preserve
:bool ->
580 = "llvm_dibuild_create_auto_variable_bytecode" "llvm_dibuild_create_auto_variable_native"
582 external dibuild_create_parameter_variable
:
584 scope
:Llvm.llmetadata
->
587 file
:Llvm.llmetadata
->
589 ty
:Llvm.llmetadata
->
590 always_preserve
:bool ->
593 = "llvm_dibuild_create_parameter_variable_bytecode" "llvm_dibuild_create_parameter_variable_native"
595 external dibuild_insert_declare_before
:
597 storage
:Llvm.llvalue
->
598 var_info
:Llvm.llmetadata
->
599 expr
:Llvm.llmetadata
->
600 location
:Llvm.llmetadata
->
601 instr
:Llvm.llvalue
->
603 = "llvm_dibuild_insert_declare_before_bytecode" "llvm_dibuild_insert_declare_before_native"
605 external dibuild_insert_declare_at_end
:
607 storage
:Llvm.llvalue
->
608 var_info
:Llvm.llmetadata
->
609 expr
:Llvm.llmetadata
->
610 location
:Llvm.llmetadata
->
611 block
:Llvm.llbasicblock
->
613 = "llvm_dibuild_insert_declare_at_end_bytecode" "llvm_dibuild_insert_declare_at_end_native"
615 external dibuild_expression
:
619 = "llvm_dibuild_expression"