GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "tree.h"
#include "fold-const.h"
#include "dwarf2ctf.h"
#include "ctf.h"
#include "btf.h"
Go to the source code of this file.
Data Structures | |
struct | ctf_string |
struct | ctf_strtable |
struct | ctf_encoding |
struct | ctf_arinfo |
struct | ctf_funcinfo |
struct | ctf_sliceinfo |
struct | ctf_itype |
struct | ctf_dmdef |
struct | ctf_func_arg |
struct | ctf_dtdef |
struct | ctf_dvdef |
struct | ctf_srcloc |
struct | ctfc_dtd_hasher |
struct | ctfc_dvd_hasher |
struct | ctf_container |
Macros | |
#define | CTF_NULL_TYPEID 0 |
#define | CTF_INIT_TYPEID 1 |
#define | ctti_size _u._size |
#define | ctti_type _u._type |
#define | CTF_FUNC_VARARG 0x1 |
#define | ctf_dmd_list_next(elem) |
#define | ctf_farg_list_next(elem) |
#define | ctf_type_id(dtd) |
#define | CTF_STRTAB 0 /* CTF string table. @endverbatim */ |
#define | CTF_AUX_STRTAB 1 /* CTF auxilliary string table. @endverbatim */ |
#define | CTF_ADD_NONROOT 0 /* CTF type only visible in nested scope. @endverbatim */ |
#define | CTF_ADD_ROOT 1 /* CTF type visible at top-level scope. @endverbatim */ |
Typedefs | |
typedef uint64_t | ctf_id_t |
typedef struct ctf_dtdef | ctf_dtdef_t |
typedef ctf_dtdef_t * | ctf_dtdef_ref |
typedef struct ctf_string | ctf_string_t |
typedef struct ctf_strtable | ctf_strtable_t |
typedef struct ctf_encoding | ctf_encoding_t |
typedef struct ctf_arinfo | ctf_arinfo_t |
typedef struct ctf_funcinfo | ctf_funcinfo_t |
typedef struct ctf_sliceinfo | ctf_sliceinfo_t |
typedef struct ctf_itype | ctf_itype_t |
typedef struct ctf_dmdef | ctf_dmdef_t |
typedef struct ctf_func_arg | ctf_func_arg_t |
typedef struct ctf_dvdef | ctf_dvdef_t |
typedef ctf_dvdef_t * | ctf_dvdef_ref |
typedef struct ctf_srcloc | ctf_srcloc_t |
typedef ctf_srcloc_t * | ctf_srcloc_ref |
typedef struct ctf_container | ctf_container_t |
typedef ctf_container_t * | ctf_container_ref |
typedef bool(* | funcs_traverse_callback) (ctf_dtdef_ref, void *) |
Enumerations | |
enum | ctf_dtu_d_union_enum { CTF_DTU_D_MEMBERS , CTF_DTU_D_ARRAY , CTF_DTU_D_ENCODING , CTF_DTU_D_ARGUMENTS , CTF_DTU_D_SLICE } |
Variables | |
ctf_container_ref | tu_ctfc |
#define CTF_ADD_NONROOT 0 /* CTF type only visible in nested scope. @endverbatim */ |
The compiler demarcates whether types are visible at top-level scope or not. The only example so far of a type not visible at top-level scope is slices. CTF_ADD_NONROOT is used to indicate the latter.
Referenced by ctf_add_enum(), ctf_add_generic(), ctf_add_sou(), and gen_ctf_sou_type().
#define CTF_ADD_ROOT 1 /* CTF type visible at top-level scope. @endverbatim */ |
#define CTF_AUX_STRTAB 1 /* CTF auxilliary string table. @endverbatim */ |
Referenced by btf_datasec_push_entry(), and ctf_add_function_arg().
#define ctf_dmd_list_next | ( | elem | ) |
Referenced by btf_add_used_type(), btf_add_vars(), btf_asm_type(), ctf_calc_num_vbytes(), output_asm_btf_enum_list(), output_asm_btf_sou_fields(), output_asm_ctf_enum_list(), and output_asm_ctf_sou_fields().
#define ctf_farg_list_next | ( | elem | ) |
Referenced by btf_add_used_type(), ctf_calc_num_vbytes(), output_asm_btf_func_args_list(), and output_asm_func_args_list().
#define CTF_FUNC_VARARG 0x1 |
Function arguments end with varargs.
Referenced by gen_ctf_function_type().
#define CTF_INIT_TYPEID 1 |
Value to start generating the CTF type ID from.
Referenced by ctfc_is_empty_container(), and init_ctf_container().
#define CTF_NULL_TYPEID 0 |
ctfc.h - Declarations and definitions related to the CTF container. Copyright (C) 2019-2024 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/>.
This file defines the data structures and functions used by the compiler to generate the CTF debug info. The definitions below are compiler internal representations and closely reflect the CTF format requirements in <ctf.h>. The contents of the CTF container are used eventually for emission of both CTF (ctfout.cc) and BTF debug info (btfout.cc), as the two type debug formats are close cousins.
Invalid CTF type ID definition.
Referenced by output_asm_ctf_sou_fields(), output_asm_ctf_type(), output_asm_ctf_vlen_bytes(), and output_ctf_vars().
#define CTF_STRTAB 0 /* CTF string table. @endverbatim */ |
Markers for which string table from the CTF container to use.
Referenced by btf_add_used_type(), btf_assign_datasec_ids(), btf_collect_pruned_types(), ctf_output(), and output_asm_btf_func_args_list().
#define ctf_type_id | ( | dtd | ) |
Referenced by ctf_asm_array(), ctf_asm_func_arg(), ctf_asm_slice(), ctf_asm_sou_lmember(), ctf_asm_sou_member(), ctf_asm_varent(), and output_ctf_obj_info().
#define ctti_size _u._size |
#define ctti_type _u._type |
typedef struct ctf_arinfo ctf_arinfo_t |
Array information for CTF generation.
typedef ctf_container_t* ctf_container_ref |
typedef struct ctf_container ctf_container_t |
CTF container structure. It is the context passed around when generating ctf debug info. There is one container per translation unit.
typedef struct ctf_dmdef ctf_dmdef_t |
Struct/union/enum member definition for CTF generation.
typedef ctf_dtdef_t* ctf_dtdef_ref |
typedef struct ctf_dtdef ctf_dtdef_t |
typedef ctf_dvdef_t* ctf_dvdef_ref |
typedef struct ctf_dvdef ctf_dvdef_t |
typedef struct ctf_encoding ctf_encoding_t |
Encoding information for integers, floating-point values etc. The flags field will contain values appropriate for the type defined in <ctf.h>.
typedef struct ctf_func_arg ctf_func_arg_t |
Function Argument.
typedef struct ctf_funcinfo ctf_funcinfo_t |
Function information for CTF generation.
typedef uint64_t ctf_id_t |
CTF type ID.
typedef struct ctf_itype ctf_itype_t |
CTF type representation internal to the compiler. It closely reflects the ctf_type_t type node in <ctf.h> except the tags.
typedef struct ctf_sliceinfo ctf_sliceinfo_t |
typedef ctf_srcloc_t* ctf_srcloc_ref |
typedef struct ctf_srcloc ctf_srcloc_t |
Location information for CTF Types and CTF Variables.
typedef struct ctf_string ctf_string_t |
CTF string table element (list node).
typedef struct ctf_strtable ctf_strtable_t |
Internal representation of CTF string table.
typedef bool(* funcs_traverse_callback) (ctf_dtdef_ref, void *) |
Callback and traversal function for BTF_KIND_FUNC records. Used by BPF target for BPF CO-RE implementation.
enum ctf_dtu_d_union_enum |
|
extern |
Initial entry point of BTF generation, called at early_finish () after CTF information has possibly been output. Translate all CTF information to BTF, and do any processing that must be done early, such as creating BTF_KIND_FUNC records.
References btf_add_const_void(), btf_add_func_records(), btf_used_types, hash_map< KeyId, Value, Traits >::create_ggc(), hash_set< KeyId, Lazy, Traits >::create_ggc(), ctf_get_tu_ctfc(), ctfc_delete_strtab(), ctf_container::ctfc_nextid, ctf_container::ctfc_num_types, ctf_container::ctfc_num_vlen_bytes, ctf_container::ctfc_strlen, ctf_container::ctfc_strtable, ctf_container::ctfc_types, ctf_container::ctfc_vars_list_count, hash_table< Descriptor, Lazy, Allocator >::elements(), fixups, func_map, funcs, init_ctf_strtable(), tu_ctfc, and vec_alloc().
Referenced by ctf_debug_early_finish().
|
extern |
Reset all state for BTF generation so that we can rerun the compiler within the same process.
References btf_info_section, btf_used_types, ctf_get_tu_ctfc(), ctfc_delete_container(), datasecs, fixups, forwards, func_map, funcs, i, max_translated_id, NULL, and tu_ctfc.
Referenced by btf_finish().
|
extern |
Late entry point for BTF generation, called from dwarf2out_finish (). Complete and emit BTF information.
References btf_add_func_datasec_entries(), btf_add_vars(), btf_assign_datasec_ids(), btf_assign_func_ids(), btf_assign_var_ids(), btf_collect_pruned_types(), btf_collect_translated_types(), btf_finalize(), btf_output(), btf_with_core_debuginfo_p(), ctf_get_tu_ctfc(), datasecs, init_btf_sections(), and tu_ctfc.
Referenced by ctf_debug_early_finish(), and ctf_debug_finish().
|
extern |
Manually mark that type T is used to ensure it will not be pruned. Used by the BPF backend when generating BPF CO-RE to mark types used in CO-RE relocations.
References btf_add_used_type(), ctf_get_tu_ctfc(), ctf_lookup_tree_type(), gcc_assert, and TYPE_P.
|
extern |
References ctf_add_generic(), ctf_container::ctfc_num_stypes, ctf_itype::ctti_info, ctf_dtdef::dtd_data, ctf_dtdef::dtd_u, ctf_dtdef::dtu_arr, gcc_assert, and NULL.
Referenced by gen_ctf_subrange_type().
|
extern |
Add the compilation unit (CU) name string to the CTF string table. The CU name has a prepended pwd string if it is a relative path. Also set the CU name offset in the CTF container.
References CONST_CAST, ctf_add_string(), ctf_container::ctfc_cuname_offset, ctf_container::ctfc_strlen, DIR_SEPARATOR, get_src_pwd(), ggc_alloc_atomic(), ggc_strdup, and NULL.
Referenced by ctf_output().
|
extern |
References ctf_add_generic(), CTF_ADD_NONROOT, ctf_dtd_lookup(), ctf_container::ctfc_num_stypes, ctf_itype::ctti_info, ctf_dtdef::dtd_data, ctf_dtdef::dtd_enum_unsigned, and gcc_assert.
Referenced by gen_ctf_enumeration_type().
|
extern |
References btf_debuginfo_p(), ctf_add_string(), ctf_dmd_list_append(), ctf_dtd_lookup(), ctf_container::ctfc_strlen, ctf_itype::ctti_info, ctf_dmdef::dmd_name, ctf_dmdef::dmd_name_offset, ctf_dmdef::dmd_offset, ctf_dmdef::dmd_type, ctf_dmdef::dmd_value, ctf_dtdef::dtd_data, ctf_dtdef::dtd_u, ctf_dtdef::dtu_members, gcc_assert, ggc_cleared_alloc(), INT_MAX, INT_MIN, and NULL.
Referenced by gen_ctf_enumeration_type().
|
extern |
References ctf_add_encoded().
Referenced by gen_ctf_base_type().
|
extern |
References ctf_add_generic(), ctf_container::ctfc_num_stypes, ctf_itype::ctti_info, and ctf_dtdef::dtd_data.
Referenced by gen_ctf_enumeration_type(), and gen_ctf_sou_type().
|
extern |
References ctf_funcinfo::ctc_argc, ctf_funcinfo::ctc_return, ctf_add_generic(), ctf_container::ctfc_num_stypes, ctf_itype::ctti_info, ctf_dtdef::dtd_data, ctf_dtdef::dtd_type, ctf_dtdef::from_global_func, gcc_assert, ctf_dtdef::linkage, and ctf_dtdef::ref_type.
Referenced by gen_ctf_function_type().
|
extern |
References ctf_add_string(), CTF_AUX_STRTAB, ctf_dtd_lookup(), ctf_farg_list_append(), ctf_container::ctfc_aux_strlen, ctf_itype::ctti_info, ctf_dtdef::dtd_data, ctf_dtdef::dtd_u, ctf_dtdef::dtu_argv, ctf_func_arg::farg_name, ctf_func_arg::farg_name_offset, ctf_func_arg::farg_type, gcc_assert, ggc_cleared_alloc(), and NULL.
Referenced by gen_ctf_function_type().
|
extern |
References ctf_add_encoded().
Referenced by gen_ctf_base_type(), and gen_ctf_void_type().
|
extern |
References ctf_add_string(), ctf_dmd_list_append(), ctf_dtd_lookup(), ctf_container::ctfc_strlen, ctf_itype::ctti_info, ctf_dmdef::dmd_name, ctf_dmdef::dmd_name_offset, ctf_dmdef::dmd_offset, ctf_dmdef::dmd_type, ctf_dmdef::dmd_value, ctf_dtdef::dtd_data, ctf_dtdef::dtd_u, ctf_dtdef::dtu_members, gcc_assert, ggc_cleared_alloc(), NULL, and type().
Referenced by gen_ctf_sou_type().
|
extern |
References ctf_add_reftype().
Referenced by gen_ctf_pointer_type().
|
extern |
References ctf_add_generic(), ctf_container::ctfc_num_stypes, ctf_itype::ctti_info, ctf_dtdef::dtd_data, ctf_dtdef::dtd_type, gcc_assert, NULL, and ctf_dtdef::ref_type.
Referenced by btf_add_const_void(), ctf_add_pointer(), and gen_ctf_modifier_type().
|
extern |
References ceil_log2(), ctf_add_generic(), ctf_container::ctfc_num_stypes, ctf_sliceinfo::cts_bits, ctf_sliceinfo::cts_offset, ctf_sliceinfo::cts_type, ctf_itype::ctti_info, ctf_dtdef::dtd_data, ctf_dtdef::dtd_u, ctf_dtdef::dtu_slice, gcc_assert, NULL, and ROUND_UP.
Referenced by gen_ctf_sou_type().
|
extern |
|
extern |
Add string to the appropriate string table in the CTF container.
References ctfc_get_strtab(), and ctfc_strtable_add_str().
Referenced by btf_add_used_type(), btf_collect_pruned_types(), btf_datasec_push_entry(), ctf_add_cuname(), ctf_add_enumerator(), ctf_add_function_arg(), ctf_add_generic(), ctf_add_member_offset(), and ctf_add_variable().
|
extern |
References ctf_add_generic(), ctf_container::ctfc_num_stypes, ctf_itype::ctti_info, ctf_dtdef::dtd_data, ctf_dtdef::dtd_type, gcc_assert, NULL, and ctf_dtdef::ref_type.
Referenced by gen_ctf_typedef().
|
extern |
References ctf_add_encoded().
Referenced by gen_ctf_unknown_type().
|
extern |
|
extern |
Lookup CTF type given a DWARF die for the type.
References ctf_container::ctfc_types, ctf_dtdef::dtd_key, hash_table< Descriptor, Lazy, Allocator >::find_slot(), NULL, and type().
Referenced by btf_add_func_datasec_entries(), btf_add_func_records(), ctf_add_enum(), ctf_add_enumerator(), ctf_add_function_arg(), ctf_add_member_offset(), ctf_add_sou(), ctf_lookup_tree_type(), and ctf_type_exists().
enum ctf_dtu_d_union_enum ctf_dtu_d_union_selector | ( | ctf_dtdef_ref | ctftype | ) |
Return which member of the union is used in CTFTYPE. Used for garbage collection.
References CTF_DTU_D_ARGUMENTS, CTF_DTU_D_ARRAY, CTF_DTU_D_ENCODING, CTF_DTU_D_MEMBERS, CTF_DTU_D_SLICE, ctf_itype::ctti_info, and ctf_dtdef::dtd_data.
|
extern |
Lookup the dummy CTF variable given the DWARF die for the non-defining decl to be ignored.
References ctf_container::ctfc_ignore_vars, ctf_dvdef::dvd_key, and hash_table< Descriptor, Lazy, Allocator >::find_slot().
Referenced by btf_emit_variable_p(), ctf_dvd_preprocess_cb(), and gen_ctf_variable().
|
extern |
Lookup CTF variable given a DWARF die for the decl.
References ctf_container::ctfc_vars, ctf_dvdef::dvd_key, hash_table< Descriptor, Lazy, Allocator >::find_slot(), and NULL.
Referenced by btf_add_const_void(), btf_emit_variable_p(), and gen_ctf_variable().
|
extern |
Reset all state for CTF generation so that we can rerun the compiler within the same process.
References ctf_get_tu_ctfc(), ctf_info_section, ctfc_delete_container(), NULL, and tu_ctfc.
Referenced by ctf_debug_early_finish().
|
extern |
References tu_ctfc.
Referenced by btf_early_finish(), btf_finalize(), btf_finish(), btf_mark_type_used(), ctf_do_die(), ctf_finalize(), and ctf_output().
|
extern |
These APIs allow to initialize and finalize the CTF machinery and to add types to the CTF container associated to the current translation unit. Used in dwarf2ctf.cc.
CTF routines interfacing to the compiler.
References init_ctf_container().
Referenced by ctf_debug_init().
|
extern |
Given a TREE_TYPE node, return the CTF type object for that type.
References ctf_dtd_lookup(), lookup_type_die(), and NULL.
Referenced by btf_mark_type_used().
|
extern |
CTF routines interfacing to the compiler.
Prepare and output the CTF section.
References ctf_add_cuname(), ctf_get_tu_ctfc(), ctf_preprocess(), CTF_STRTAB, ctfc_get_strtab_len(), ctf_container::ctfc_strlen, CTFINFO_LEVEL_NONE, gcc_assert, init_ctf_sections(), output_ctf_func_info(), output_ctf_funcidx(), output_ctf_header(), output_ctf_obj_info(), output_ctf_objtidx(), output_ctf_strs(), output_ctf_types(), output_ctf_vars(), and tu_ctfc.
Referenced by ctf_debug_early_finish().
|
extern |
Check if CTF for TYPE has already been generated. Mainstay for de-duplication. If CTF type already exists, returns TRUE and updates the CTF type object DTD for the caller.
References ctf_dtd_lookup().
Referenced by gen_ctf_array_type(), gen_ctf_function(), gen_ctf_function_type(), gen_ctf_modifier_type(), gen_ctf_pointer_type(), gen_ctf_sou_type(), gen_ctf_subrange_type(), gen_ctf_type(), gen_ctf_typedef(), and gen_ctf_unknown_type().
|
extern |
Delete the CTF container's resources.
References ctf_container::ctfc_aux_strtable, ctfc_delete_strtab(), ctf_container::ctfc_gfuncs_list, ctf_container::ctfc_gobjts_list, ctf_container::ctfc_ignore_vars, ctf_container::ctfc_strtable, ctf_container::ctfc_types, ctf_container::ctfc_types_list, ctf_container::ctfc_vars, ctf_container::ctfc_vars_list, hash_table< Descriptor, Lazy, Allocator >::empty(), ggc_free(), and NULL.
Referenced by btf_finalize(), and ctf_finalize().
|
extern |
References ctf_string::cts_next, ctf_strtable::ctstab_estr, ctf_strtable::ctstab_head, ctf_strtable::ctstab_tail, ggc_free(), and NULL.
Referenced by btf_early_finish(), and ctfc_delete_container().
|
extern |
CTF section does not emit location information; at this time, location information is needed for BTF CO-RE use-cases.
Location information for CTF Types and CTF Variables. CTF section does not emit location information; at this time, location information is needed for BTF CO-RE use-cases.
References ctf_get_die_loc_col(), ctf_get_die_loc_file(), ctf_get_die_loc_line(), ctf_srcloc::ctsloc_col, ctf_srcloc::ctsloc_file, ctf_srcloc::ctsloc_line, ctf_dtdef::dtd_key, and NULL.
|
extern |
|
extern |
Get the total number of CTF types in the container.
References ctf_container::ctfc_types, and hash_table< Descriptor, Lazy, Allocator >::elements().
Referenced by output_ctf_header().
|
extern |
Get the total number of CTF variables in the container.
References ctf_container::ctfc_vars, and hash_table< Descriptor, Lazy, Allocator >::elements().
Referenced by ctf_preprocess().
|
extern |
Get the number of bytes to represent the variable length portion of all CTF types in the CTF container.
References ctf_container::ctfc_num_vlen_bytes.
Referenced by output_ctf_header().
|
extern |
Get reference to the CTF string table or the CTF auxilliary string table.
References ctf_container::ctfc_strtable.
Referenced by ctf_add_string(), and ctfc_get_strtab_len().
|
extern |
Get the length of the specified string table in the CTF container.
Get the length of the specified string table of the CTF container.
References ctfc_get_strtab(), and ctf_strtable::ctstab_len.
Referenced by btf_assign_datasec_ids(), ctf_output(), and output_asm_btf_func_args_list().
|
extern |
If the next ctf type id is still set to the init value, no ctf records to report.
References CTF_INIT_TYPEID.
Referenced by output_btf_header(), and output_ctf_header().
|
extern |
CTF container setup and teardown routines.
Initialize the CTF string table. The first entry in the CTF string table (empty string) is added.
References ctfc_strtable_add_str(), ctf_strtable::ctstab_estr, ctf_strtable::ctstab_head, ctf_strtable::ctstab_len, ctf_strtable::ctstab_num, ctf_strtable::ctstab_tail, and NULL.
Referenced by btf_early_finish(), and init_ctf_string_table().
bool traverse_btf_func_types | ( | funcs_traverse_callback | callback, |
void * | data ) |
Traversal function for all BTF_KIND_FUNC type records.
References FOR_EACH_VEC_ELT, funcs, and i.
|
extern |
Generate CTF. Copyright (C) 2019-2024 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/>.
A CTF container object - one per translation unit.
Referenced by btf_early_finish(), btf_finalize(), btf_finish(), ctf_do_die(), ctf_finalize(), ctf_get_tu_ctfc(), ctf_output(), init_ctf_container(), and new_ctf_container().