GCC Middle and Back End API Reference
ctfout.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 "gt-ctfout.h"
Include dependency graph for ctfout.cc:

Data Structures

struct  ctf_dtd_preprocess_arg
 
struct  ctf_dvd_preprocess_arg
 

Macros

#define CTF_INFO_SECTION_NAME   ".ctf"
 
#define CTF_INFO_SECTION_FLAGS   (SECTION_DEBUG)
 
#define MAX_CTF_LABEL_BYTES   40
 
#define CTF_INFO_SECTION_LABEL   "Lctf"
 

Typedefs

typedef struct ctf_dtd_preprocess_arg ctf_dtd_preprocess_arg_t
 
typedef struct ctf_dvd_preprocess_arg ctf_dvd_preprocess_arg_t
 

Functions

static int ctf_varent_compare (const void *entry1, const void *entry2)
 
static uint64_t ctf_calc_num_vbytes (ctf_dtdef_ref ctftype)
 
static void ctf_list_add_ctf_vars (ctf_container_ref ctfc, ctf_dvdef_ref var)
 
void init_ctf_sections (void)
 
static void ctf_preprocess_var (ctf_container_ref ctfc, ctf_dvdef_ref var)
 
int ctf_dvd_preprocess_cb (ctf_dvdef_ref *slot, void *arg)
 
int ctf_dtd_preprocess_cb (ctf_dtdef_ref *slot, void *arg)
 
static void ctf_preprocess (ctf_container_ref ctfc)
 
static void ctf_asm_preamble (ctf_container_ref ctfc)
 
static void ctf_asm_stype (ctf_dtdef_ref type)
 
static void ctf_asm_type (ctf_dtdef_ref type)
 
static void ctf_asm_slice (ctf_dtdef_ref type)
 
static void ctf_asm_array (ctf_dtdef_ref dtd)
 
static void ctf_asm_varent (ctf_dvdef_ref var)
 
static void ctf_asm_sou_lmember (ctf_dmdef_t *dmd)
 
static void ctf_asm_sou_member (ctf_dmdef_t *dmd)
 
static void ctf_asm_enum_const (ctf_dmdef_t *dmd)
 
static void ctf_asm_func_arg (ctf_func_arg_t *farg)
 
static void output_ctf_header (ctf_container_ref ctfc)
 
static void output_ctf_obj_info (ctf_container_ref ctfc)
 
static void output_ctf_func_info (ctf_container_ref ctfc)
 
static void output_ctf_objtidx (ctf_container_ref ctfc)
 
static void output_ctf_funcidx (ctf_container_ref ctfc)
 
static void output_ctf_vars (ctf_container_ref ctfc)
 
static void output_ctf_strs (ctf_container_ref ctfc)
 
static void output_asm_ctf_sou_fields (ctf_container_ref ARG_UNUSED(ctfc), ctf_dtdef_ref dtd)
 
static void output_asm_ctf_enum_list (ctf_container_ref ARG_UNUSED(ctfc), ctf_dtdef_ref dtd)
 
static void output_asm_func_args_list (ctf_container_ref ARG_UNUSED(ctfc), ctf_dtdef_ref dtd)
 
static void output_asm_ctf_vlen_bytes (ctf_container_ref ctfc, ctf_dtdef_ref ctftype)
 
static void output_asm_ctf_type (ctf_container_ref ctfc, ctf_dtdef_ref type)
 
static void output_ctf_types (ctf_container_ref ctfc)
 
void ctf_output (const char *filename)
 
void ctf_finalize (void)
 

Variables

static int ctf_label_num
 
static sectionctf_info_section
 
static char ctf_info_section_label [MAX_CTF_LABEL_BYTES]
 

Macro Definition Documentation

◆ CTF_INFO_SECTION_FLAGS

#define CTF_INFO_SECTION_FLAGS   (SECTION_DEBUG)
Section flags for the CTF debug info section.   

Referenced by init_ctf_sections().

◆ CTF_INFO_SECTION_LABEL

#define CTF_INFO_SECTION_LABEL   "Lctf"

Referenced by init_ctf_sections().

◆ CTF_INFO_SECTION_NAME

#define CTF_INFO_SECTION_NAME   ".ctf"
Section names used to hold CTF debugging information.   
CTF debug info section.   

Referenced by init_ctf_sections().

◆ MAX_CTF_LABEL_BYTES

#define MAX_CTF_LABEL_BYTES   40
Maximum size (in bytes) of an artificially generated CTF label.   

Typedef Documentation

◆ ctf_dtd_preprocess_arg_t

CTF preprocess callback arguments.   

◆ ctf_dvd_preprocess_arg_t

Function Documentation

◆ ctf_asm_array()

static void ctf_asm_array ( ctf_dtdef_ref dtd)
static

◆ ctf_asm_enum_const()

static void ctf_asm_enum_const ( ctf_dmdef_t * dmd)
static
Asm'out an enumerator constant.   

References ctf_dmdef::dmd_name_offset, ctf_dmdef::dmd_value, and dw2_asm_output_data().

Referenced by output_asm_ctf_enum_list().

◆ ctf_asm_func_arg()

static void ctf_asm_func_arg ( ctf_func_arg_t * farg)
static
Asm'out a function argument.   

References ctf_type_id, dw2_asm_output_data(), and ctf_func_arg::farg_type.

Referenced by output_asm_func_args_list().

◆ ctf_asm_preamble()

static void ctf_asm_preamble ( ctf_container_ref ctfc)
static
CTF asm helper routines.   
Asm'out the CTF preamble.   

References ctf_container::ctfc_flags, ctf_container::ctfc_magic, ctf_container::ctfc_version, and dw2_asm_output_data().

Referenced by output_ctf_header().

◆ ctf_asm_slice()

static void ctf_asm_slice ( ctf_dtdef_ref type)
static
Asm'out a CTF type of kind CTF_K_SLICE.   

References ctf_type_id, and dw2_asm_output_data().

Referenced by output_asm_ctf_vlen_bytes().

◆ ctf_asm_sou_lmember()

static void ctf_asm_sou_lmember ( ctf_dmdef_t * dmd)
static
Asm'out a member of CTF struct or union, represented by ctf_lmember_t.   

References ctf_type_id, ctf_dmdef::dmd_name_offset, ctf_dmdef::dmd_offset, ctf_dmdef::dmd_type, and dw2_asm_output_data().

Referenced by output_asm_ctf_sou_fields().

◆ ctf_asm_sou_member()

static void ctf_asm_sou_member ( ctf_dmdef_t * dmd)
static
Asm'out a member of a CTF sruct or union, represented by ctf_member_t.   

References ctf_type_id, ctf_dmdef::dmd_name_offset, ctf_dmdef::dmd_offset, ctf_dmdef::dmd_type, and dw2_asm_output_data().

Referenced by output_asm_ctf_sou_fields().

◆ ctf_asm_stype()

static void ctf_asm_stype ( ctf_dtdef_ref type)
static
Asm'out a CTF type which is represented by ctf_stype_t.   

References dw2_asm_output_data().

Referenced by output_asm_ctf_type().

◆ ctf_asm_type()

static void ctf_asm_type ( ctf_dtdef_ref type)
static
Asm'out a CTF type which is represented by ctf_type_t.   

References dw2_asm_output_data().

Referenced by output_asm_ctf_type().

◆ ctf_asm_varent()

static void ctf_asm_varent ( ctf_dvdef_ref var)
static
Asm'out a CTF variable.   

References ctf_type_id, ctf_dvdef::dvd_name_offset, ctf_dvdef::dvd_type, and dw2_asm_output_data().

Referenced by output_ctf_vars().

◆ ctf_calc_num_vbytes()

static uint64_t ctf_calc_num_vbytes ( ctf_dtdef_ref ctftype)
static
A CTF type record may be followed by variable-length of bytes to encode the
CTF type completely.  This routine calculates the number of bytes, in the
final binary CTF format, which are used to encode information about the type
completely.

This function must always be in sync with the CTF header.   

References ctf_dmd_list_next, ctf_farg_list_next, ctf_itype::ctti_info, ctf_dtdef::dtd_data, ctf_dtdef::dtd_u, ctf_dtdef::dtu_argv, ctf_dtdef::dtu_members, gcc_assert, and NULL.

Referenced by ctf_dtd_preprocess_cb().

◆ ctf_dtd_preprocess_cb()

◆ ctf_dvd_preprocess_cb()

int ctf_dvd_preprocess_cb ( ctf_dvdef_ref * slot,
void * arg )

◆ ctf_finalize()

void ctf_finalize ( void )
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().

◆ ctf_list_add_ctf_vars()

static void ctf_list_add_ctf_vars ( ctf_container_ref ctfc,
ctf_dvdef_ref var )
static
Add a CTF variable to the end of the list.   

References ctf_container::ctfc_vars_list, and ctf_container::ctfc_vars_list_count.

Referenced by ctf_preprocess_var().

◆ ctf_output()

◆ ctf_preprocess()

static void ctf_preprocess ( ctf_container_ref ctfc)
static
CTF preprocessing.
After the CTF types for the compilation unit have been generated fully, the
compiler writes out the asm for the CTF types.

CTF writeout in the compiler requires two passes over the CTF types.  In the
first pass, the CTF preprocess pass:
  1.  CTF types are sorted in the order of their type IDs.
  2.  The variable number of bytes after each CTF type record are calculated.
      This is used to calculate the offsets in the ctf_header_t.
  3.  If the CTF type is of CTF_K_FUNCTION, the number of bytes in the
      funcinfo sub-section are calculated.  This is used to calculate the
      offsets in the ctf_header_t.
  4.  Keep the list of CTF variables in ASCIIbetical order of their names.

In the second pass, the CTF writeout pass, asm tags are written out using
the compiler's afore-generated internal pre-processed CTF types.   

References ctf_dtd_preprocess_cb(), ctf_dvd_preprocess_cb(), ctf_varent_compare(), ctfc_get_num_ctf_vars(), ctf_container::ctfc_gfuncs_list, ctf_container::ctfc_gobjts_list, ctf_container::ctfc_num_global_funcs, ctf_container::ctfc_num_global_objts, ctf_container::ctfc_types, ctf_container::ctfc_types_list, ctf_container::ctfc_vars, ctf_container::ctfc_vars_list, ctf_container::ctfc_vars_list_count, ctf_dtd_preprocess_arg::dtd_arg_ctfc, ctf_dtd_preprocess_arg::dtd_global_func_idx, ctf_dvd_preprocess_arg::dvd_arg_ctfc, ctf_dvd_preprocess_arg::dvd_global_obj_idx, hash_table< Descriptor, Lazy, Allocator >::elements(), gcc_assert, ggc_vec_alloc(), qsort, and hash_table< Descriptor, Lazy, Allocator >::traverse().

Referenced by ctf_output().

◆ ctf_preprocess_var()

static void ctf_preprocess_var ( ctf_container_ref ctfc,
ctf_dvdef_ref var )
static
Routines for CTF pre-processing.   

References ctf_list_add_ctf_vars().

Referenced by ctf_dvd_preprocess_cb().

◆ ctf_varent_compare()

static int ctf_varent_compare ( const void * entry1,
const void * entry2 )
static
Compare two CTF variable definition entries.  Currently used for sorting
by name.   

References ctf_dvdef::dvd_name.

Referenced by ctf_preprocess().

◆ init_ctf_sections()

void init_ctf_sections ( void )
Initialize the various sections and labels for CTF output.   

References ctf_info_section, CTF_INFO_SECTION_FLAGS, CTF_INFO_SECTION_LABEL, ctf_info_section_label, CTF_INFO_SECTION_NAME, ctf_label_num, get_section(), and NULL.

Referenced by ctf_output().

◆ output_asm_ctf_enum_list()

static void output_asm_ctf_enum_list ( ctf_container_ref ARG_UNUSEDctfc,
ctf_dtdef_ref dtd )
static
Output the list of enumerator constants of the CTF enum type.   

References ctf_asm_enum_const(), ctf_dmd_list_next, ctf_dtdef::dtd_u, ctf_dtdef::dtu_members, and NULL.

Referenced by output_asm_ctf_vlen_bytes().

◆ output_asm_ctf_sou_fields()

static void output_asm_ctf_sou_fields ( ctf_container_ref ARG_UNUSEDctfc,
ctf_dtdef_ref dtd )
static

◆ output_asm_ctf_type()

static void output_asm_ctf_type ( ctf_container_ref ctfc,
ctf_dtdef_ref type )
static

◆ output_asm_ctf_vlen_bytes()

◆ output_asm_func_args_list()

static void output_asm_func_args_list ( ctf_container_ref ARG_UNUSEDctfc,
ctf_dtdef_ref dtd )
static
Output the list of function arguments of the CTF function type.   

References ctf_asm_func_arg(), ctf_farg_list_next, ctf_dtdef::dtd_u, ctf_dtdef::dtu_argv, and NULL.

Referenced by output_asm_ctf_vlen_bytes().

◆ output_ctf_func_info()

static void output_ctf_func_info ( ctf_container_ref ctfc)
static
Output the CTF function info section.   

References ctf_container::ctfc_gfuncs_list, ctf_container::ctfc_num_global_funcs, ctf_dtdef::dtd_type, dw2_asm_output_data(), and i.

Referenced by ctf_output().

◆ output_ctf_funcidx()

static void output_ctf_funcidx ( ctf_container_ref ctfc)
static

◆ output_ctf_header()

◆ output_ctf_obj_info()

static void output_ctf_obj_info ( ctf_container_ref ctfc)
static

◆ output_ctf_objtidx()

static void output_ctf_objtidx ( ctf_container_ref ctfc)
static

◆ output_ctf_strs()

static void output_ctf_strs ( ctf_container_ref ctfc)
static

◆ output_ctf_types()

static void output_ctf_types ( ctf_container_ref ctfc)
static

◆ output_ctf_vars()

static void output_ctf_vars ( ctf_container_ref ctfc)
static
Output the CTF variables.  Variables appear in the sorted ASCIIbetical
order of their names.  This permits binary searching in the CTF reader.   

References ctf_asm_varent(), CTF_NULL_TYPEID, ctf_container::ctfc_vars_list, ctf_container::ctfc_vars_list_count, ctf_dvdef::dvd_type, gcc_assert, and i.

Referenced by ctf_output().

Variable Documentation

◆ ctf_info_section

section* ctf_info_section
static
Pointers to various CTF sections.   

Referenced by ctf_finalize(), init_ctf_sections(), and output_ctf_header().

◆ ctf_info_section_label

char ctf_info_section_label[MAX_CTF_LABEL_BYTES]
static

◆ ctf_label_num

int ctf_label_num
static
Output CTF format from GCC.
   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/>.   

Referenced by init_ctf_sections().