GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "target.h"
#include "dwarf2out.h"
#include "dwarf2ctf.h"
#include "ctfc.h"
#include "gt-dwarf2ctf.h"
Variables | |
static dw_die_ref | ctf_void_die |
static dw_die_ref | ctf_array_index_die |
static dw_die_ref | ctf_unknown_die |
void ctf_debug_early_finish | ( | const char * | filename | ) |
Early finish CTF/BTF debug info.
References btf_debuginfo_p(), btf_early_finish(), btf_finish(), ctf_finalize(), ctf_output(), CTFINFO_LEVEL_NONE, and dwarf_file_data::filename.
void ctf_debug_finish | ( | void | ) |
Finish CTF/BTF debug info emission.
References btf_debuginfo_p(), and btf_finish().
void ctf_debug_init | ( | void | ) |
Initialize CTF subsystem for CTF debug info generation.
References add_name_attribute(), base_type_die(), ctf_array_index_die, ctf_init(), ctf_unknown_die, ctf_void_die, integer_type_node, and new_die_raw().
|
static |
Sizes of entities can be given in bytes or bits. This function abstracts this by returning the size in bits of the given entity. If no DW_AT_byte_size nor DW_AT_bit_size are defined, this function returns 0.
References AT_unsigned(), and get_AT().
Referenced by gen_ctf_base_type(), gen_ctf_enumeration_type(), and gen_ctf_sou_type().
bool ctf_do_die | ( | dw_die_ref | die | ) |
References ctf_get_tu_ctfc(), dw_get_die_tag(), gen_ctf_function(), gen_ctf_type(), gen_ctf_variable(), NULL, and tu_ctfc.
|
static |
Some data member DIEs have location specified as a DWARF expression (specifically in DWARF2). Luckily, the expression is a simple DW_OP_plus_uconst with one operand set to zero. Sometimes the data member location may also be negative. In yet some other cases (specifically union data members), the data member location is non-existent. Handle all these scenarios here to abstract this.
References AT_class(), AT_int(), AT_loc(), dw_loc_descr_node::dw_loc_oprnd1, dw_loc_descr_node::dw_loc_oprnd2, dw_val_class_const, dw_val_class_loc, dw_val_class_unsigned_const, gcc_assert, get_AT(), get_AT_unsigned(), dw_val_node::v, dw_val_node::val_class, and dw_val_node::dw_val_struct_union::val_unsigned.
Referenced by gen_ctf_sou_type().
|
static |
Some DIEs have a type description attribute, stored in a DW_AT_type attribute. However, GCC generates no attribute to signify a `void' type. This can happen in many contexts (return type of a function, pointed or qualified type, etc) so we use the `ctf_get_AT_type' function below abstracts this.
References ctf_void_die, and get_AT_ref().
Referenced by gen_ctf_array_type(), gen_ctf_enumeration_type(), gen_ctf_function_type(), gen_ctf_modifier_type(), gen_ctf_pointer_type(), gen_ctf_sou_type(), gen_ctf_subrange_type(), gen_ctf_typedef(), and gen_ctf_variable().
unsigned int ctf_get_die_loc_col | ( | dw_die_ref | die | ) |
References get_AT_unsigned().
Referenced by ctfc_get_dtd_srcloc(), and ctfc_get_dvd_srcloc().
const char * ctf_get_die_loc_file | ( | dw_die_ref | die | ) |
CTF Types' and CTF Variables' Location Information. CTF section does not emit location information, this is provided for BTF CO-RE use-cases. These functions fetch information from DWARF Die directly, as such the location information is not buffered in the CTF container.
References dwarf_file_data::filename, get_AT_file(), and NULL.
Referenced by ctfc_get_dtd_srcloc(), and ctfc_get_dvd_srcloc().
unsigned int ctf_get_die_loc_line | ( | dw_die_ref | die | ) |
References get_AT_unsigned().
Referenced by ctfc_get_dtd_srcloc(), and ctfc_get_dvd_srcloc().
|
static |
Generate CTF for an ARRAY_TYPE.
References ctf_get_AT_type(), ctf_type_exists(), dw_get_die_child(), dw_get_die_sib(), gen_ctf_subrange_type(), gen_ctf_type(), get_AT_flag(), last, and NULL.
Referenced by gen_ctf_type().
|
static |
Generate CTF for base type (integer, boolean, real, fixed point and complex). Important: the caller of this API must make sure that duplicate types are not added.
References ctf_encoding::cte_bits, ctf_encoding::cte_format, ctf_add_float(), ctf_add_integer(), CTF_ADD_ROOT, ctf_die_bitsize(), double_type_node, float_type_node, gcc_assert, get_AT_string(), get_AT_unsigned(), long_double_type_node, NULL, tree_to_uhwi(), and TYPE_SIZE.
Referenced by gen_ctf_type().
|
static |
Generate CTF for an enumeration type.
References AT_class(), AT_int(), AT_unsigned(), ctf_add_enum(), ctf_add_enumerator(), ctf_add_forward(), CTF_ADD_ROOT, ctf_die_bitsize(), ctf_get_AT_type(), dw_get_die_child(), dw_get_die_sib(), dw_val_class_unsigned_const, dw_val_class_unsigned_const_implicit, gcc_assert, get_AT(), get_AT_flag(), get_AT_string(), and get_AT_unsigned().
Referenced by gen_ctf_type().
|
static |
Add a CTF function record for the given input DWARF DIE.
References ctf_type_exists(), ctf_container::ctfc_num_global_funcs, and gen_ctf_function_type().
Referenced by ctf_do_die().
|
static |
Generate CTF for a function type.
References arg_type, ctf_funcinfo::ctc_argc, ctf_funcinfo::ctc_flags, ctf_funcinfo::ctc_return, ctf_add_function(), ctf_add_function_arg(), CTF_ADD_ROOT, CTF_FUNC_VARARG, ctf_get_AT_type(), ctf_type_exists(), dw_get_die_child(), dw_get_die_sib(), dw_get_die_tag(), function_name(), gcc_assert, gen_ctf_type(), get_AT_flag(), get_AT_string(), i, and NULL.
Referenced by gen_ctf_function(), and gen_ctf_type().
|
static |
Generate CTF for a type modifier. If the given DIE contains a valid C modifier (like _Atomic), which is not supported by CTF, then this function skips the modifier die and continues with the underlying type. If the modifier is supported by CTF, then this function constructs and returns an appropate CTF type representing the modifier. For all other cases, this function returns NULL.
References ctf_add_reftype(), CTF_ADD_ROOT, ctf_get_AT_type(), ctf_type_exists(), dw_get_die_tag(), gcc_assert, gen_ctf_type(), and NULL.
Referenced by gen_ctf_type().
|
static |
Generate CTF for a pointer type.
References ctf_add_pointer(), CTF_ADD_ROOT, ctf_get_AT_type(), ctf_type_exists(), and gen_ctf_type().
Referenced by gen_ctf_type().
|
static |
Generate CTF for a struct type.
References AT_class(), AT_int(), AT_unsigned(), ctf_add_forward(), ctf_add_member_offset(), CTF_ADD_NONROOT, CTF_ADD_ROOT, ctf_add_slice(), ctf_add_sou(), ctf_die_bitsize(), ctf_get_AT_data_member_location(), ctf_get_AT_type(), ctf_type_exists(), dw_get_die_child(), dw_get_die_sib(), dw_val_class_unsigned_const, field_type(), gen_ctf_type(), gen_ctf_unknown_type(), get_AT(), get_AT_flag(), and get_AT_string().
Referenced by gen_ctf_type().
|
static |
Recursively generate CTF for array dimensions starting at DIE C (of type DW_TAG_subrange_type) until DIE LAST (of type DW_TAG_subrange_type) is reached. ARRAY_ELEMS_TYPE is the CTF type object for the type of the array elements.
References AT_class(), ctf_add_array(), CTF_ADD_ROOT, ctf_get_AT_type(), ctf_type_exists(), ctf_arinfo::ctr_contents, ctf_arinfo::ctr_index, ctf_arinfo::ctr_nelems, dw_get_die_sib(), dw_get_die_tag(), dw_val_class_unsigned_const, gcc_unreachable, gen_ctf_subrange_type(), gen_ctf_type(), get_AT(), get_AT_unsigned(), and last.
Referenced by gen_ctf_array_type(), and gen_ctf_subrange_type().
|
static |
Generate CTF types and objects from the GCC DWARF. Copyright (C) 2021-2025 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>.
Forward declarations for some routines defined in this file.
Add CTF type record(s) for the given input DWARF DIE and return its type id. If there is already a CTF type corresponding to the given DIE, then this function returns the type id of the existing type. If the given DIE is not recognized as a type, then this function returns NULL.
References ctf_type_exists(), dw_get_die_tag(), gen_ctf_array_type(), gen_ctf_base_type(), gen_ctf_enumeration_type(), gen_ctf_function_type(), gen_ctf_modifier_type(), gen_ctf_pointer_type(), gen_ctf_sou_type(), gen_ctf_typedef(), gen_ctf_unknown_type(), gen_ctf_void_type(), get_AT_string(), and NULL.
Referenced by ctf_do_die(), gen_ctf_array_type(), gen_ctf_function_type(), gen_ctf_modifier_type(), gen_ctf_pointer_type(), gen_ctf_sou_type(), gen_ctf_subrange_type(), gen_ctf_typedef(), and gen_ctf_variable().
|
static |
Generate CTF for a typedef.
References CTF_ADD_ROOT, ctf_add_typedef(), ctf_get_AT_type(), ctf_type_exists(), gen_ctf_type(), and get_AT_string().
Referenced by gen_ctf_type().
|
static |
Generate CTF type of unknown kind.
References CTF_ADD_ROOT, ctf_add_unknown(), ctf_type_exists(), ctf_unknown_die, gcc_assert, and NULL.
Referenced by gen_ctf_sou_type(), and gen_ctf_type().
|
static |
Add a CTF variable record for the given input DWARF DIE.
References ctf_add_variable(), ctf_dvd_ignore_lookup(), ctf_dvd_lookup(), ctf_get_AT_type(), gen_ctf_type(), get_AT_flag(), get_AT_ref(), and get_AT_string().
Referenced by ctf_do_die().
|
static |
Generate CTF for the void type.
References ctf_encoding::cte_bits, ctf_encoding::cte_format, ctf_add_integer(), CTF_ADD_ROOT, ctf_void_die, gcc_assert, and NULL.
Referenced by gen_ctf_type().
|
static |
Referenced by ctf_debug_init().
|
static |
Referenced by ctf_debug_init(), and gen_ctf_unknown_type().
|
static |
All the DIE structures we handle come from the DWARF information generated by GCC. However, there are three situations where we need to create our own created DIE structures because GCC doesn't provide them. The DWARF spec suggests using a DIE with DW_TAG_unspecified_type and name "void" in order to denote the void type. But GCC doesn't follow this advice. Still we need a DIE to act as a key for void types, we use ctf_void_die. Also, if a subrange type corresponding to an array index does not specify a type then we assume it is `int'. Finally, for types unrepresentable in CTF, we need a DIE to anchor them to a CTF type of kind unknown. The variables below are initialized in ctf_debug_init and hold references to the proper DIEs.
Referenced by ctf_debug_init(), ctf_get_AT_type(), and gen_ctf_void_type().