GCC Middle and Back End API Reference
btfout.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "target.h"
#include "memmodel.h"
#include "tm_p.h"
#include "output.h"
#include "dwarf2asm.h"
#include "debug.h"
#include "ctfc.h"
#include "diagnostic-core.h"
#include "cgraph.h"
#include "varasm.h"
#include "stringpool.h"
#include "attribs.h"
#include "dwarf2out.h"
#include "gt-btfout.h"
Include dependency graph for btfout.cc:

Data Structures

struct  btf_datasec


#define MAX_BTF_LABEL_BYTES   40
#define BTF_VOID_TYPEID   0
#define BTF_INIT_TYPEID   1


typedef struct btf_datasec btf_datasec_t


static const charbtf_kind_name (uint32_t btf_kind)
static uint32_t get_btf_kind (uint32_t ctf_kind)
static const charget_btf_type_name (ctf_dtdef_ref dtd)
static ctf_id_t btf_absolute_var_id (ctf_id_t rel)
static ctf_id_t btf_relative_var_id (ctf_id_t abs)
static ctf_id_t btf_absolute_func_id (ctf_id_t rel)
static ctf_id_t btf_relative_func_id (ctf_id_t abs)
static ctf_id_t btf_absolute_datasec_id (ctf_id_t rel)
static void init_btf_id_map (size_t len)
ctf_id_t get_btf_id (ctf_id_t key)
static void set_btf_id (ctf_id_t key, ctf_id_t val)
static bool btf_emit_id_p (ctf_id_t id)
static bool btf_fwd_to_enum_p (ctf_dtdef_ref dtd)
static uint64_t btf_calc_num_vbytes (ctf_dtdef_ref dtd)
void init_btf_sections (void)
static void btf_datasec_push_entry (ctf_container_ref ctfc, const char *secname, struct btf_var_secinfo info)
static const charget_section_name (symtab_node *node)
static void btf_collect_datasec (ctf_container_ref ctfc)
static bool btf_removed_type_p (ctf_id_t id)
static ctf_id_t btf_adjust_type_id (ctf_id_t id)
int btf_dtd_postprocess_cb (ctf_dtdef_ref *slot, ctf_container_ref arg_ctfc)
int btf_dvd_emit_preprocess_cb (ctf_dvdef_ref *slot, ctf_container_ref arg_ctfc)
static void btf_dtd_emit_preprocess_cb (ctf_container_ref ctfc, ctf_dtdef_ref dtd)
static void btf_emit_preprocess (ctf_container_ref ctfc)
static bool btf_dmd_representable_bitfield_p (ctf_container_ref ctfc, ctf_dmdef_t *dmd)
static void btf_asm_type_ref (const char *prefix, ctf_container_ref ctfc, ctf_id_t ctf_id)
static void btf_asm_datasec_type_ref (const char *prefix, ctf_container_ref ctfc, ctf_id_t btf_id)
static void btf_asm_type (ctf_container_ref ctfc, ctf_dtdef_ref dtd)
static void btf_asm_array (ctf_container_ref ctfc, ctf_arinfo_t arr)
static void btf_asm_varent (ctf_container_ref ctfc, ctf_dvdef_ref var)
static void btf_asm_sou_member (ctf_container_ref ctfc, ctf_dmdef_t *dmd, unsigned int idx)
static void btf_asm_enum_const (unsigned int size, ctf_dmdef_t *dmd, unsigned int idx)
static void btf_asm_func_arg (ctf_container_ref ctfc, ctf_func_arg_t *farg, size_t stroffset)
static void btf_asm_func_type (ctf_container_ref ctfc, ctf_dtdef_ref dtd, ctf_id_t id)
static const charget_name_for_datasec_entry (ctf_container_ref ctfc, ctf_id_t ref_id)
static void btf_asm_datasec_entry (ctf_container_ref ctfc, struct btf_var_secinfo info)
static void btf_asm_datasec_type (ctf_container_ref ctfc, btf_datasec_t ds, ctf_id_t id, size_t stroffset)
static void output_btf_header (ctf_container_ref ctfc)
static void output_btf_vars (ctf_container_ref ctfc)
static void output_btf_strs (ctf_container_ref ctfc)
static void output_asm_btf_sou_fields (ctf_container_ref ctfc, ctf_dtdef_ref dtd)
static void output_asm_btf_enum_list (ctf_container_ref ARG_UNUSED(ctfc), ctf_dtdef_ref dtd)
static void output_asm_btf_func_args_list (ctf_container_ref ctfc, ctf_dtdef_ref dtd)
static void output_asm_btf_vlen_bytes (ctf_container_ref ctfc, ctf_dtdef_ref dtd)
static void output_asm_btf_type (ctf_container_ref ctfc, ctf_dtdef_ref type)
static void output_btf_types (ctf_container_ref ctfc)
static void output_btf_func_types (ctf_container_ref ctfc)
static void output_btf_datasec_types (ctf_container_ref ctfc)
void btf_init_postprocess (void)
void btf_output (const char *filename)
void btf_finalize (void)
bool traverse_btf_func_types (funcs_traverse_callback callback, void *data)


static int btf_label_num
static sectionbtf_info_section
static char btf_info_section_label [MAX_BTF_LABEL_BYTES]
static hash_map< ctf_dvdef_ref, unsigned > * btf_var_ids
static ctf_id_tbtf_id_map = NULL
static vec< btf_datasec_tdatasecs
static vec< ctf_id_tholes
static vec< ctf_id_tvoids
static vec< ctf_dtdef_ref, va_gc > * funcs
static unsigned int num_vars_added = 0
static unsigned int num_types_added = 0
static unsigned int num_types_created = 0
static const char *const btf_kind_names []

Macro Definition Documentation



Referenced by init_btf_sections().



Referenced by init_btf_sections().


BTF debug info section.   

Referenced by init_btf_sections().


#define BTF_INIT_TYPEID   1




#define BTF_VOID_TYPEID   0


#define MAX_BTF_LABEL_BYTES   40
Maximum size (in bytes) for an artifically generated BTF label.   

Typedef Documentation

◆ btf_datasec_t

Information for creating the BTF_KIND_DATASEC records.   

Function Documentation

◆ btf_absolute_datasec_id()

static ctf_id_t btf_absolute_datasec_id ( ctf_id_t rel)
Return the final BTF ID of the datasec record at relative index REL.   

References funcs, ggc_alloc(), num_types_added, and num_vars_added.

Referenced by btf_asm_datasec_type().

◆ btf_absolute_func_id()

static ctf_id_t btf_absolute_func_id ( ctf_id_t rel)
Return the final BTF ID of the func record at relative index REL.   

References ggc_alloc(), num_types_added, and num_vars_added.

Referenced by btf_asm_func_type().

◆ btf_absolute_var_id()

static ctf_id_t btf_absolute_var_id ( ctf_id_t rel)
Helper routines to map between 'relative' and 'absolute' IDs.

In BTF all records (including variables) are output in one long list, and all
inter-type references are via index into that list.  But internally since we
a) translate from CTF, which separates variable records from regular types
and b) create some additional types after the fact, things like VAR and FUNC
records are stored in separate vectors with their own indices.  These
functions map between the 'relative' IDs (i.e.  indices in their respective
containers) and 'absolute' IDs (i.e.  indices in the final contiguous
output list), which goes in order:
  all normal type records translated from CTF
  all BTF_KIND_VAR records
  all BTF_KIND_FUNC records (synthesized split function records)
  all BTF_KIND_DATASEC records (synthesized)

The extra '+ 1's below are to account for the implicit "void" record, which
has index 0 but isn't actually contained in the type list.   
Return the final BTF ID of the variable at relative index REL.   

References ggc_alloc(), and num_types_added.

Referenced by btf_collect_datasec().

◆ btf_adjust_type_id()

static ctf_id_t btf_adjust_type_id ( ctf_id_t id)
Adjust the given type ID to account for holes and duplicate definitions of

References BTF_INVALID_TYPEID, BTF_VOID_TYPEID, holes, i, and voids.

Referenced by btf_init_postprocess().

◆ btf_asm_array()

static void btf_asm_array ( ctf_container_ref ctfc,
ctf_arinfo_t arr )
Asm'out the variable information following a BTF_KIND_ARRAY.   

References btf_asm_type_ref(), dw2_asm_output_data(), and ggc_alloc().

Referenced by output_asm_btf_vlen_bytes().

◆ btf_asm_datasec_entry()

static void btf_asm_datasec_entry ( ctf_container_ref ctfc,
struct btf_var_secinfo info )

◆ btf_asm_datasec_type()

static void btf_asm_datasec_type ( ctf_container_ref ctfc,
btf_datasec_t ds,
ctf_id_t id,
size_t stroffset )
Asm'out a whole BTF_KIND_DATASEC, including its variable entries.   

References btf_absolute_datasec_id(), btf_asm_datasec_entry(), dw2_asm_output_data(), btf_datasec::entries, ggc_alloc(), i, btf_datasec::name, btf_datasec::name_offset, and PRIu64.

Referenced by output_btf_datasec_types().

◆ btf_asm_datasec_type_ref()

static void btf_asm_datasec_type_ref ( const char * prefix,
ctf_container_ref ctfc,
ctf_id_t btf_id )
Asm'out a reference to a BTF_KIND_VAR or BTF_KIND_FUNC type.  These type
kinds are BTF-specific, and should only be referred to by entries in
BTF_KIND_DATASEC records.   

References btf_relative_func_id(), btf_relative_var_id(), dw2_asm_output_data(), gcc_unreachable, get_btf_type_name(), ggc_alloc(), num_types_added, and num_vars_added.

Referenced by btf_asm_datasec_entry().

◆ btf_asm_enum_const()

static void btf_asm_enum_const ( unsigned int size,
ctf_dmdef_t * dmd,
unsigned int idx )
Asm'out an enum constant following a BTF_KIND_ENUM{,64}.   

References dw2_asm_output_data(), and ggc_alloc().

Referenced by output_asm_btf_enum_list().

◆ btf_asm_func_arg()

static void btf_asm_func_arg ( ctf_container_ref ctfc,
ctf_func_arg_t * farg,
size_t stroffset )
Asm'out a function parameter description following a BTF_KIND_FUNC_PROTO.   

References btf_asm_type_ref(), btf_removed_type_p(), BTF_VOID_TYPEID, dw2_asm_output_data(), ggc_alloc(), and NULL.

Referenced by output_asm_btf_func_args_list().

◆ btf_asm_func_type()

static void btf_asm_func_type ( ctf_container_ref ctfc,
ctf_dtdef_ref dtd,
ctf_id_t id )

◆ btf_asm_sou_member()

static void btf_asm_sou_member ( ctf_container_ref ctfc,
ctf_dmdef_t * dmd,
unsigned int idx )
Asm'out a member description following a BTF_KIND_STRUCT or

References btf_asm_type_ref(), btf_dmd_representable_bitfield_p(), BTF_VOID_TYPEID, dw2_asm_output_data(), and ggc_alloc().

Referenced by output_asm_btf_sou_fields().

◆ btf_asm_type()

static void btf_asm_type ( ctf_container_ref ctfc,
ctf_dtdef_ref dtd )
Asm'out a BTF type. This routine is responsible for the bulk of the task
of converting CTF types to their BTF representation.   

References btf_asm_type_ref(), btf_dmd_representable_bitfield_p(), btf_kind_name(), ctf_dmd_list_next, dw2_asm_output_data(), gcc_assert, get_btf_id(), get_btf_kind(), get_btf_type_name(), ggc_alloc(), NULL, and PRIu64.

Referenced by output_asm_btf_type().

◆ btf_asm_type_ref()

◆ btf_asm_varent()

◆ btf_calc_num_vbytes()

static uint64_t btf_calc_num_vbytes ( ctf_dtdef_ref dtd)
Each BTF type can be followed additional, variable-length information
completing the description of the type. Calculate the number of bytes
of variable information required to encode a given type.   

References get_btf_kind(), and ggc_alloc().

Referenced by btf_dtd_emit_preprocess_cb().

◆ btf_collect_datasec()

static void btf_collect_datasec ( ctf_container_ref ctfc)
Construct all BTF_KIND_DATASEC records for CTFC. One such record is created
for each non-empty data-containing section in the output. Each record is
followed by a variable number of entries describing the variables stored
in that section.   

References btf_absolute_var_id(), btf_datasec_push_entry(), btf_var_ids, ctf_dtd_lookup(), ctf_dvd_lookup(), datasecs, symtab_node::decl, DECL_ATTRIBUTES, DECL_EXTERNAL, DECL_SIZE_UNIT, FOR_EACH_FUNCTION, FOR_EACH_VARIABLE, funcs, symtab_node::get_section(), get_section_name(), ggc_alloc(), lookup_attribute(), lookup_decl_die(), NULL, NULL_TREE, num_types_added, num_types_created, tree_fits_uhwi_p(), tree_to_uhwi(), TREE_TYPE, vec_safe_push(), and VOID_TYPE_P.

Referenced by btf_emit_preprocess().

◆ btf_datasec_push_entry()

static void btf_datasec_push_entry ( ctf_container_ref ctfc,
const char * secname,
struct btf_var_secinfo info )
Push a BTF datasec variable entry INFO into the datasec named SECNAME,
creating the datasec if it does not already exist.   

References ctf_add_string(), CTF_AUX_STRTAB, datasecs, btf_datasec::entries, ggc_alloc(), i, btf_datasec::name, btf_datasec::name_offset, and NULL.

Referenced by btf_collect_datasec().

◆ btf_dmd_representable_bitfield_p()

static bool btf_dmd_representable_bitfield_p ( ctf_container_ref ctfc,
ctf_dmdef_t * dmd )
Return true iff DMD is a member description of a bit-field which can be
validly represented in BTF.   

References ggc_alloc().

Referenced by btf_asm_sou_member(), and btf_asm_type().

◆ btf_dtd_emit_preprocess_cb()

static void btf_dtd_emit_preprocess_cb ( ctf_container_ref ctfc,
ctf_dtdef_ref dtd )
Preprocessing callback routine for types.   

References btf_calc_num_vbytes(), btf_emit_id_p(), and ggc_alloc().

Referenced by btf_emit_preprocess().

◆ btf_dtd_postprocess_cb()

int btf_dtd_postprocess_cb ( ctf_dtdef_ref * slot,
ctf_container_ref arg_ctfc )
Postprocessing callback routine for types.   

References gcc_assert, get_btf_kind(), ggc_alloc(), holes, and voids.

Referenced by btf_init_postprocess().

◆ btf_dvd_emit_preprocess_cb()

int btf_dvd_emit_preprocess_cb ( ctf_dvdef_ref * slot,
ctf_container_ref arg_ctfc )

◆ btf_emit_id_p()

static bool btf_emit_id_p ( ctf_id_t id)
Return TRUE iff the given CTF type ID maps to a BTF type which will
be emitted.   

References btf_id_map, BTF_VOID_TYPEID, and ggc_alloc().

Referenced by btf_dtd_emit_preprocess_cb(), and output_asm_btf_type().

◆ btf_emit_preprocess()

static void btf_emit_preprocess ( ctf_container_ref ctfc)
Preprocess the CTF information to prepare for BTF output.  BTF is almost a
subset of CTF, with many small differences in encoding, and lacking support
for some types (notably floating point formats).

During the preprocessing pass:
- Ascertain that the sorted list of types has been prepared.  For the BTF
  generation process, this is taken care of by the btf_init_postprocess ().

- BTF_KIND_FUNC and BTF_KIND_DATASEC records are constructed. These types do
  not have analogues in CTF (the analogous type to CTF_K_FUNCTION is
  BTF_KIND_FUNC_PROTO), but can be relatively easily deduced from CTF

- Construct BTF_KIND_VAR records, representing variables.

- Calculate the total size in bytes of variable-length information following
  BTF type records. This is used for outputting the BTF header.

After preprocessing, all BTF information is ready to be output:
- ctfc->ctfc_types_list holdstypes converted from CTF types. This does not
  include KIND_VAR, KIND_FUNC, nor KIND_DATASEC types. These types have been
  re-encoded to the appropriate representation in BTF.
- ctfc->ctfc_vars_list holds all variables which should be output.
  Variables of unsupported types are not present in this list.
- Vector 'funcs' holds all BTF_KIND_FUNC types, one to match each
- Vector 'datasecs' holds all BTF_KIND_DATASEC types.   

References btf_collect_datasec(), btf_dtd_emit_preprocess_cb(), btf_dvd_emit_preprocess_cb(), btf_var_ids, hash_map< KeyId, Value, Traits >::create_ggc(), gcc_assert, ggc_alloc(), i, and num_vars_added.

Referenced by btf_output().

◆ btf_finalize()

void btf_finalize ( void )
Reset all state for BTF generation so that we can rerun the compiler within
the same process.   

References btf_id_map, btf_info_section, btf_var_ids, ctf_get_tu_ctfc(), ctfc_delete_container(), datasecs, free(), funcs, holes, i, NULL, num_types_added, num_types_created, num_vars_added, tu_ctfc, and voids.

Referenced by ctf_debug_finalize().

◆ btf_fwd_to_enum_p()

static bool btf_fwd_to_enum_p ( ctf_dtdef_ref dtd)
Return true if DTD is a forward-declared enum.  The BTF representation
of forward declared enums is not formally defined.   

References get_btf_kind(), and ggc_alloc().

Referenced by btf_asm_type_ref().

◆ btf_init_postprocess()

void btf_init_postprocess ( void )
Postprocess the CTF debug data post initialization.

During the postprocess pass:

- Prepare the sorted list of BTF types.

  The sorted list of BTF types is, firstly, used for lookup (during the BTF
  generation process) of CTF/BTF types given a typeID.

  Secondly, in the emitted BTF section, BTF Types need to be in the sorted
  order of their type IDs.  The BTF types section is viewed as an array,
  with type IDs used to index into that array.  It is essential that every
  type be placed at the exact index corresponding to its ID, or else
  references to that type from other types will no longer be correct.

- References to void types are converted to reference BTF_VOID_TYPEID. In
  CTF, a distinct type is used to encode void.

- Bitfield struct/union members are converted to BTF encoding. CTF uses
  slices to encode bitfields, but BTF does not have slices and encodes
  bitfield information directly in the variable-length btf_member
  descriptions following the struct or union type.

- Unrepresentable types are removed. We cannot have any invalid BTF types
  appearing in the output so they must be removed, and type ids of other
  types and references adjust accordingly. This also involves ensuring that
  BTF descriptions of struct members referring to unrepresentable types are
  not emitted, as they would be nonsensical.

- Adjust inner- and inter-type references-by-ID to account for removed
  types, and construct the types list.   

References btf_adjust_type_id(), btf_dtd_postprocess_cb(), BTF_VOID_TYPEID, ctf_add_reftype(), CTF_ADD_ROOT, ctf_dvd_lookup(), ctf_get_tu_ctfc(), CTF_NULL_TYPEID, ctf_container::ctfc_types, ctf_container::ctfc_types_list, symtab_node::decl, hash_table< Descriptor, Lazy, Allocator >::elements(), FOR_EACH_VARIABLE, ggc_alloc(), holes, i, init_btf_id_map(), lookup_decl_die(), NULL, num_types_added, num_types_created, set_btf_id(), hash_table< Descriptor, Lazy, Allocator >::traverse(), TREE_TYPE, tu_ctfc, TYPE_READONLY, VOID_TYPE_P, and voids.

Referenced by ctf_debug_init_postprocess().

◆ btf_kind_name()

static const char * btf_kind_name ( uint32_t btf_kind)
Return a name string for the given BTF_KIND.   

References btf_kind_names, and ggc_alloc().

Referenced by btf_asm_type(), and btf_asm_type_ref().

◆ btf_output()

◆ btf_relative_func_id()

static ctf_id_t btf_relative_func_id ( ctf_id_t abs)
Return the relative index of the func record with final BTF ID ABS.   

References num_types_added, and num_vars_added.

Referenced by btf_asm_datasec_type_ref(), and get_name_for_datasec_entry().

◆ btf_relative_var_id()

static ctf_id_t btf_relative_var_id ( ctf_id_t abs)
Return the relative index of the variable with final BTF ID ABS.   

References num_types_added.

Referenced by btf_asm_datasec_type_ref(), and get_name_for_datasec_entry().

◆ btf_removed_type_p()

static bool btf_removed_type_p ( ctf_id_t id)
Return true if the type ID is that of a type which will not be emitted (for
example, if it is not representable in BTF).   

References holes.

Referenced by btf_asm_func_arg(), and btf_dvd_emit_preprocess_cb().

◆ get_btf_id()

ctf_id_t get_btf_id ( ctf_id_t key)
Return the BTF type ID of CTF type ID KEY, or BTF_INVALID_TYPEID if the CTF
type with ID KEY does not map to a BTF type.   

References btf_id_map.

Referenced by btf_asm_type(), and btf_asm_type_ref().

◆ get_btf_kind()

static uint32_t get_btf_kind ( uint32_t ctf_kind)
Map a CTF type kind to the corresponding BTF type kind.   

References ggc_alloc().

Referenced by btf_asm_type(), btf_asm_type_ref(), btf_calc_num_vbytes(), btf_dtd_postprocess_cb(), btf_fwd_to_enum_p(), and output_asm_btf_vlen_bytes().

◆ get_btf_type_name()

static const char * get_btf_type_name ( ctf_dtdef_ref dtd)
Some BTF types, like BTF_KIND_FUNC_PROTO, are anonymous.  The machinery
in btfout to emit BTF, may reset dtd_data->ctti_name, but does not update
the name in the ctf_dtdef_ref type object (deliberate choice).  This
interface helps abstract out that state of affairs, while giving access to
the name of the type as intended.   

References ggc_alloc().

Referenced by btf_asm_datasec_type_ref(), btf_asm_func_type(), btf_asm_type(), btf_asm_type_ref(), and get_name_for_datasec_entry().

◆ get_name_for_datasec_entry()

static const char * get_name_for_datasec_entry ( ctf_container_ref ctfc,
ctf_id_t ref_id )
Collect the name for the DATASEC reference required to be output as a

References btf_relative_func_id(), btf_relative_var_id(), get_btf_type_name(), ggc_alloc(), NULL, num_types_added, and num_vars_added.

Referenced by btf_asm_datasec_entry().

◆ get_section_name()

static const char * get_section_name ( symtab_node * node)
Return the section name, as of interest to btf_collect_datasec, for the
given symtab node.  Note that this deliberately returns NULL for objects
which do not go in a section btf_collect_datasec cares about.   

References categorize_decl_for_section(), symtab_node::decl, symtab_node::get_section(), ggc_alloc(), NULL, SECCAT_BSS, SECCAT_DATA, and SECCAT_RODATA.

Referenced by btf_collect_datasec().

◆ init_btf_id_map()

static void init_btf_id_map ( size_t len)
Allocate the btf_id_map, and initialize elements to BTF_INVALID_TYPEID.   

References btf_id_map, BTF_INVALID_TYPEID, BTF_VOID_TYPEID, ggc_alloc(), and i.

Referenced by btf_init_postprocess().

◆ init_btf_sections()

void init_btf_sections ( void )

◆ output_asm_btf_enum_list()

static void output_asm_btf_enum_list ( ctf_container_ref ARG_UNUSEDctfc,
ctf_dtdef_ref dtd )
Output all enumerator constants following a BTF_KIND_ENUM{,64}.   

References btf_asm_enum_const(), ctf_dmd_list_next, ggc_alloc(), and NULL.

Referenced by output_asm_btf_vlen_bytes().

◆ output_asm_btf_func_args_list()

static void output_asm_btf_func_args_list ( ctf_container_ref ctfc,
ctf_dtdef_ref dtd )
Output all function arguments following a BTF_KIND_FUNC_PROTO.   

References btf_asm_func_arg(), ctf_farg_list_next, CTF_STRTAB, ctfc_get_strtab_len(), ggc_alloc(), and NULL.

Referenced by output_asm_btf_vlen_bytes().

◆ output_asm_btf_sou_fields()

static void output_asm_btf_sou_fields ( ctf_container_ref ctfc,
ctf_dtdef_ref dtd )
Output all (representable) members of a BTF_KIND_STRUCT or

References btf_asm_sou_member(), ctf_dmd_list_next, ggc_alloc(), and NULL.

Referenced by output_asm_btf_vlen_bytes().

◆ output_asm_btf_type()

static void output_asm_btf_type ( ctf_container_ref ctfc,
ctf_dtdef_ref type )
Output a whole BTF type record for TYPE, including the fixed and variable
data portions.   

References btf_asm_type(), btf_emit_id_p(), ggc_alloc(), and output_asm_btf_vlen_bytes().

Referenced by output_btf_types().

◆ output_asm_btf_vlen_bytes()

static void output_asm_btf_vlen_bytes ( ctf_container_ref ctfc,
ctf_dtdef_ref dtd )
Output the variable portion of a BTF type record. The information depends
on the kind of the type.   

References btf_asm_array(), dw2_asm_output_data(), gcc_unreachable, get_btf_kind(), ggc_alloc(), output_asm_btf_enum_list(), output_asm_btf_func_args_list(), and output_asm_btf_sou_fields().

Referenced by output_asm_btf_type().

◆ output_btf_datasec_types()

static void output_btf_datasec_types ( ctf_container_ref ctfc)
Output all BTF_KIND_DATASEC records.   

References btf_asm_datasec_type(), CTF_STRTAB, ctfc_get_strtab_len(), datasecs, ggc_alloc(), and i.

Referenced by btf_output().

◆ output_btf_func_types()

static void output_btf_func_types ( ctf_container_ref ctfc)
Output all BTF_KIND_FUNC type records.   

References btf_asm_func_type(), FOR_EACH_VEC_ELT, funcs, ggc_alloc(), and i.

Referenced by btf_output().

◆ output_btf_header()

static void output_btf_header ( ctf_container_ref ctfc)

◆ output_btf_strs()

static void output_btf_strs ( ctf_container_ref ctfc)
Output BTF string records. The BTF strings section is a concatenation
of the standard and auxilliary string tables in the ctf container.   

References ctf_string::cts_next, ctf_string::cts_str, dw2_asm_output_nstring(), and ggc_alloc().

Referenced by btf_output().

◆ output_btf_types()

static void output_btf_types ( ctf_container_ref ctfc)
Output all BTF types in the container. This does not include synthesized

References ggc_alloc(), i, and output_asm_btf_type().

Referenced by btf_output().

◆ output_btf_vars()

static void output_btf_vars ( ctf_container_ref ctfc)
Output all BTF_KIND_VARs in CTFC.   

References btf_asm_varent(), ggc_alloc(), i, and num_vars_added.

Referenced by btf_output().

◆ set_btf_id()

static void set_btf_id ( ctf_id_t key,
ctf_id_t val )
Set the CTF type ID KEY to map to BTF type ID VAL.   

References btf_id_map.

Referenced by btf_init_postprocess().

◆ traverse_btf_func_types()

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.

Variable Documentation

◆ btf_id_map

ctf_id_t* btf_id_map = NULL
Mapping of type IDs from original CTF ID to BTF ID. Types do not map
1-to-1 from CTF to BTF. To avoid polluting the CTF container when updating
type references-by-ID, we use this map instead.   

Referenced by btf_emit_id_p(), btf_finalize(), get_btf_id(), init_btf_id_map(), and set_btf_id().

◆ btf_info_section

section* btf_info_section

◆ btf_info_section_label

char btf_info_section_label[MAX_BTF_LABEL_BYTES]

◆ btf_kind_names

const char* const btf_kind_names[]
Initial value:
Name strings for BTF kinds.
Note: the indices here must match the type defines in btf.h.   

Referenced by btf_kind_name().

◆ btf_label_num

int btf_label_num
Output BTF format from GCC.
   Copyright (C) 2021-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

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
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
This file contains routines to output the BPF Type Format (BTF). The BTF
debug format is very similar to CTF; as a result, the structure of this file
closely resembles that of ctfout.cc, and the same CTF container objects are

Referenced by init_btf_sections().

◆ btf_var_ids

hash_map<ctf_dvdef_ref, unsigned>* btf_var_ids
Mapping of CTF variables to the IDs they will be assigned when they are
converted to BTF_KIND_VAR type records. Strictly accounts for the index
from the start of the variable type entries, does not include the number
of types emitted prior to the variable records.   

Referenced by btf_asm_varent(), btf_collect_datasec(), btf_dvd_emit_preprocess_cb(), btf_emit_preprocess(), and btf_finalize().

◆ datasecs

vec<btf_datasec_t> datasecs
One BTF_KIND_DATASEC record is created for each output data section which
will hold at least one variable.   

Referenced by btf_collect_datasec(), btf_datasec_push_entry(), btf_finalize(), btf_output(), output_btf_datasec_types(), and output_btf_header().

◆ funcs

vec<ctf_dtdef_ref, va_gc>* funcs
Functions in BTF have two separate type records - one for the prototype
map closely to BTF_KIND_FUNC_PROTO, but the BTF_KIND_FUNC records must be
created. This vector holds them.   

Referenced by btf_absolute_datasec_id(), btf_collect_datasec(), btf_finalize(), btf_output(), output_btf_func_types(), and traverse_btf_func_types().

◆ holes

vec<ctf_id_t> holes
Holes occur for types which are present in the CTF container, but are either
non-representable or redundant in BTF.   

Referenced by btf_adjust_type_id(), btf_dtd_postprocess_cb(), btf_finalize(), btf_init_postprocess(), btf_removed_type_p(), and undistribute_bitref_for_vector().

◆ num_types_added

◆ num_types_created

unsigned int num_types_created = 0
The number of types synthesized for BTF that do not correspond to
CTF types.   

Referenced by btf_collect_datasec(), btf_dvd_emit_preprocess_cb(), btf_finalize(), btf_init_postprocess(), and output_btf_header().

◆ num_vars_added

◆ voids

vec<ctf_id_t> voids
CTF definition(s) of void. Only one definition of void should be generated.
We should not encounter more than one definition of void, but use a vector
to be safe.   

Referenced by btf_adjust_type_id(), btf_dtd_postprocess_cb(), btf_dvd_emit_preprocess_cb(), btf_finalize(), and btf_init_postprocess().