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
Asm'out a CTF type of kind CTF_K_ARRAY.   

References dw2_asm_output_data(), and ggc_alloc().

Referenced by output_asm_ctf_vlen_bytes().

◆ ctf_asm_enum_const()

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

References dw2_asm_output_data(), and ggc_alloc().

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 dw2_asm_output_data(), and ggc_alloc().

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 dw2_asm_output_data(), and ggc_alloc().

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 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 dw2_asm_output_data(), and ggc_alloc().

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 dw2_asm_output_data(), and ggc_alloc().

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_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, gcc_assert, ggc_alloc(), and NULL.

Referenced by ctf_dtd_preprocess_cb().

◆ ctf_dtd_preprocess_cb()

int ctf_dtd_preprocess_cb ( ctf_dtdef_ref * slot,
void * arg )
CTF preprocess callback routine for CTF types.   

References ctf_calc_num_vbytes(), gcc_assert, and ggc_alloc().

Referenced by ctf_preprocess().

◆ ctf_dvd_preprocess_cb()

int ctf_dvd_preprocess_cb ( ctf_dvdef_ref * slot,
void * arg )
CTF preprocess callback routine for CTF variables.   

References ctf_dvd_ignore_lookup(), ctf_preprocess_var(), ctf_dvdef::dvd_key, and ggc_alloc().

Referenced by ctf_preprocess().

◆ 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_finalize().

◆ 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 ggc_alloc().

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(), gcc_assert, ggc_alloc(), and qsort.

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(), and ggc_alloc().

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, and ggc_alloc().

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(), ggc_alloc(), 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, ggc_alloc(), 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 the members of the CTF struct or union.   

References ctf_asm_sou_lmember(), ctf_asm_sou_member(), ctf_dmd_list_next, CTF_NULL_TYPEID, gcc_assert, ggc_alloc(), and NULL.

Referenced by output_asm_ctf_vlen_bytes().

◆ output_asm_ctf_type()

static void output_asm_ctf_type ( ctf_container_ref ctfc,
ctf_dtdef_ref type )
static

◆ output_asm_ctf_vlen_bytes()

static void output_asm_ctf_vlen_bytes ( ctf_container_ref ctfc,
ctf_dtdef_ref ctftype )
static

◆ 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, ggc_alloc(), 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 dw2_asm_output_data(), ggc_alloc(), and i.

Referenced by ctf_output().

◆ output_ctf_funcidx()

static void output_ctf_funcidx ( ctf_container_ref ctfc)
static
Output the CTF function index section.   

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

Referenced by ctf_output().

◆ output_ctf_header()

◆ output_ctf_obj_info()

static void output_ctf_obj_info ( ctf_container_ref ctfc)
static
Output the CTF object info section.   

References ctf_dvdef::dvd_type, dw2_asm_output_data(), ggc_alloc(), and i.

Referenced by ctf_output().

◆ output_ctf_objtidx()

static void output_ctf_objtidx ( ctf_container_ref ctfc)
static
Output the CTF object index section.   

References ctf_dvdef::dvd_name_offset, dw2_asm_output_data(), ggc_alloc(), and i.

Referenced by ctf_output().

◆ output_ctf_strs()

static void output_ctf_strs ( ctf_container_ref ctfc)
static
Output the CTF string records.   

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

Referenced by ctf_output().

◆ output_ctf_types()

static void output_ctf_types ( ctf_container_ref ctfc)
static
Output all CTF type records.   

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

Referenced by ctf_output().

◆ 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, gcc_assert, ggc_alloc(), 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().