Home | History | Annotate | Line # | Download | only in include
      1 /* Interface between GCC C FE and GDB  -*- c -*-
      2 
      3    Copyright (C) 2014-2024 Free Software Foundation, Inc.
      4 
      5    This file is part of GCC.
      6 
      7    This program is free software; you can redistribute it and/or modify
      8    it under the terms of the GNU General Public License as published by
      9    the Free Software Foundation; either version 3 of the License, or
     10    (at your option) any later version.
     11 
     12    This program is distributed in the hope that it will be useful,
     13    but WITHOUT ANY WARRANTY; without even the implied warranty of
     14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15    GNU General Public License for more details.
     16 
     17    You should have received a copy of the GNU General Public License
     18    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
     19 
     20 
     21 
     22 /* Create a new "decl" in GCC.  A decl is a declaration, basically a
     23    kind of symbol.
     24 
     25    NAME is the name of the new symbol.  SYM_KIND is the kind of
     26    symbol being requested.  SYM_TYPE is the new symbol's C type;
     27    except for labels, where this is not meaningful and should be
     28    zero.  If SUBSTITUTION_NAME is not NULL, then a reference to this
     29    decl in the source will later be substituted with a dereference
     30    of a variable of the given name.  Otherwise, for symbols having
     31    an address (e.g., functions), ADDRESS is the address.  FILENAME
     32    and LINE_NUMBER refer to the symbol's source location.  If this
     33    is not known, FILENAME can be NULL and LINE_NUMBER can be 0.
     34    This function returns the new decl.  */
     35 
     36 GCC_METHOD7 (gcc_decl, build_decl,
     37 	     const char *,	      /* Argument NAME.  */
     38 	     enum gcc_c_symbol_kind,  /* Argument SYM_KIND.  */
     39 	     gcc_type,		      /* Argument SYM_TYPE.  */
     40 	     const char *,	      /* Argument SUBSTITUTION_NAME.  */
     41 	     gcc_address,	      /* Argument ADDRESS.  */
     42 	     const char *,	      /* Argument FILENAME.  */
     43 	     unsigned int)	      /* Argument LINE_NUMBER.  */
     44 
     45 /* Insert a GCC decl into the symbol table.  DECL is the decl to
     46    insert.  IS_GLOBAL is true if this is an outermost binding, and
     47    false if it is a possibly-shadowing binding.  */
     48 
     49 GCC_METHOD2 (int /* bool */, bind,
     50 	     gcc_decl,		   /* Argument DECL.  */
     51 	     int /* bool */)       /* Argument IS_GLOBAL.  */
     52 
     53 /* Insert a tagged type into the symbol table.  NAME is the tag name
     54    of the type and TAGGED_TYPE is the type itself.  TAGGED_TYPE must
     55    be either a struct, union, or enum type, as these are the only
     56    types that have tags.  FILENAME and LINE_NUMBER refer to the type's
     57    source location.  If this is not known, FILENAME can be NULL and
     58    LINE_NUMBER can be 0.  */
     59 
     60 GCC_METHOD4 (int /* bool */, tagbind,
     61 	     const char *,	      /* Argument NAME.  */
     62 	     gcc_type,		      /* Argument TAGGED_TYPE.  */
     63 	     const char *,	      /* Argument FILENAME.  */
     64 	     unsigned int)	      /* Argument LINE_NUMBER.  */
     65 
     66 /* Return the type of a pointer to a given base type.  */
     67 
     68 GCC_METHOD1 (gcc_type, build_pointer_type,
     69 	     gcc_type)			/* Argument BASE_TYPE.  */
     70 
     71 /* Create a new 'struct' type.  Initially it has no fields.  */
     72 
     73 GCC_METHOD0 (gcc_type, build_record_type)
     74 
     75 /* Create a new 'union' type.  Initially it has no fields.  */
     76 
     77 GCC_METHOD0 (gcc_type, build_union_type)
     78 
     79 /* Add a field to a struct or union type.  FIELD_NAME is the field's
     80    name.  FIELD_TYPE is the type of the field.  BITSIZE and BITPOS
     81    indicate where in the struct the field occurs.  */
     82 
     83 GCC_METHOD5 (int /* bool */, build_add_field,
     84 	     gcc_type,			   /* Argument RECORD_OR_UNION_TYPE. */
     85 	     const char *,		   /* Argument FIELD_NAME.  */
     86 	     gcc_type,			   /* Argument FIELD_TYPE.  */
     87 	     unsigned long,		   /* Argument BITSIZE.  */
     88 	     unsigned long)		   /* Argument BITPOS.  */
     89 
     90 /* After all the fields have been added to a struct or union, the
     91    struct or union type must be "finished".  This does some final
     92    cleanups in GCC.
     93 
     94    Note that when using GCC_C_FE_VERSION_2, it is preferable to call
     95    finish_record_with_alignment instead.  */
     96 
     97 GCC_METHOD2 (int /* bool */, finish_record_or_union,
     98 	     gcc_type,			   /* Argument RECORD_OR_UNION_TYPE. */
     99 	     unsigned long)		   /* Argument SIZE_IN_BYTES.  */
    100 
    101 /* Create a new 'enum' type.  The new type initially has no
    102    associated constants.  */
    103 
    104 GCC_METHOD1 (gcc_type, build_enum_type,
    105 	     gcc_type)			    /* Argument UNDERLYING_INT_TYPE. */
    106 
    107 /* Add a new constant to an enum type.  NAME is the constant's
    108    name and VALUE is its value.  */
    109 
    110 GCC_METHOD3 (int /* bool */, build_add_enum_constant,
    111 	     gcc_type,		       /* Argument ENUM_TYPE.  */
    112 	     const char *,	       /* Argument NAME.  */
    113 	     unsigned long)	       /* Argument VALUE.  */
    114 
    115 /* After all the constants have been added to an enum, the type must
    116    be "finished".  This does some final cleanups in GCC.  */
    117 
    118 GCC_METHOD1 (int /* bool */, finish_enum_type,
    119 	     gcc_type)		       /* Argument ENUM_TYPE.  */
    120 
    121 /* Create a new function type.  RETURN_TYPE is the type returned by
    122    the function, and ARGUMENT_TYPES is a vector, of length NARGS, of
    123    the argument types.  IS_VARARGS is true if the function is
    124    varargs.  */
    125 
    126 GCC_METHOD3 (gcc_type, build_function_type,
    127 	     gcc_type,			   /* Argument RETURN_TYPE.  */
    128 	     const struct gcc_type_array *, /* Argument ARGUMENT_TYPES.  */
    129 	     int /* bool */)               /* Argument IS_VARARGS.  */
    130 
    131 /* Return an integer type with the given properties.
    132    Deprecated in v1, use int_type instead.  */
    133 
    134 GCC_METHOD2 (gcc_type, int_type_v0,
    135 	     int /* bool */,               /* Argument IS_UNSIGNED.  */
    136 	     unsigned long)                /* Argument SIZE_IN_BYTES.  */
    137 
    138 /* Return a floating point type with the given properties.
    139    Deprecated in v1, use float_type instead.  */
    140 
    141 GCC_METHOD1 (gcc_type, float_type_v0,
    142 	     unsigned long)                /* Argument SIZE_IN_BYTES.  */
    143 
    144 /* Return the 'void' type.  */
    145 
    146 GCC_METHOD0 (gcc_type, void_type)
    147 
    148 /* Return the 'bool' type.  */
    149 
    150 GCC_METHOD0 (gcc_type, bool_type)
    151 
    152 /* Create a new array type.  If NUM_ELEMENTS is -1, then the array
    153    is assumed to have an unknown length.  */
    154 
    155 GCC_METHOD2 (gcc_type, build_array_type,
    156 	     gcc_type,			  /* Argument ELEMENT_TYPE.  */
    157 	     int)			  /* Argument NUM_ELEMENTS.  */
    158 
    159 /* Create a new variably-sized array type.  UPPER_BOUND_NAME is the
    160    name of a local variable that holds the upper bound of the array;
    161    it is one less than the array size.  */
    162 
    163 GCC_METHOD2 (gcc_type, build_vla_array_type,
    164 	     gcc_type,			  /* Argument ELEMENT_TYPE.  */
    165 	     const char *)		  /* Argument UPPER_BOUND_NAME.  */
    166 
    167 /* Return a qualified variant of a given base type.  QUALIFIERS says
    168    which qualifiers to use; it is composed of or'd together
    169    constants from 'enum gcc_qualifiers'.  */
    170 
    171 GCC_METHOD2 (gcc_type, build_qualified_type,
    172 	     gcc_type,			      /* Argument UNQUALIFIED_TYPE.  */
    173 	     enum gcc_qualifiers)	      /* Argument QUALIFIERS.  */
    174 
    175 /* Build a complex type given its element type.  */
    176 
    177 GCC_METHOD1 (gcc_type, build_complex_type,
    178 	     gcc_type)			  /* Argument ELEMENT_TYPE.  */
    179 
    180 /* Build a vector type given its element type and number of
    181    elements.  */
    182 
    183 GCC_METHOD2 (gcc_type, build_vector_type,
    184 	     gcc_type,			  /* Argument ELEMENT_TYPE.  */
    185 	     int)			  /* Argument NUM_ELEMENTS.  */
    186 
    187 /* Build a constant.  NAME is the constant's name and VALUE is its
    188    value.  FILENAME and LINE_NUMBER refer to the type's source
    189    location.  If this is not known, FILENAME can be NULL and
    190    LINE_NUMBER can be 0.  */
    191 
    192 GCC_METHOD5 (int /* bool */, build_constant,
    193 	     gcc_type,		  /* Argument TYPE.  */
    194 	     const char *,	  /* Argument NAME.  */
    195 	     unsigned long,	  /* Argument VALUE.  */
    196 	     const char *,	  /* Argument FILENAME.  */
    197 	     unsigned int)	  /* Argument LINE_NUMBER.  */
    198 
    199 /* Emit an error and return an error type object.  */
    200 
    201 GCC_METHOD1 (gcc_type, error,
    202 	     const char *)		 /* Argument MESSAGE.  */
    203 
    204 /* Return an integer type with the given properties.  If BUILTIN_NAME
    205    is non-NULL, it must name a builtin integral type with the given
    206    signedness and size, and that is the type that will be returned.  */
    207 
    208 GCC_METHOD3 (gcc_type, int_type,
    209 	     int /* bool */,               /* Argument IS_UNSIGNED.  */
    210 	     unsigned long,                /* Argument SIZE_IN_BYTES.  */
    211 	     const char *)		   /* Argument BUILTIN_NAME.  */
    212 
    213 /* Return the 'char' type, a distinct type from both 'signed char' and
    214    'unsigned char' returned by int_type.  */
    215 
    216 GCC_METHOD0 (gcc_type, char_type)
    217 
    218 /* Return a floating point type with the given properties.  If BUILTIN_NAME
    219    is non-NULL, it must name a builtin integral type with the given
    220    signedness and size, and that is the type that will be returned.  */
    221 
    222 GCC_METHOD2 (gcc_type, float_type,
    223 	     unsigned long,                /* Argument SIZE_IN_BYTES.  */
    224 	     const char *)		   /* Argument BUILTIN_NAME.  */
    225 
    226 /* New in GCC_FE_VERSION_2.  Like finish_record_or_union but the caller also
    227    supplies the alignment.  If the alignment is 0, this acts identically to
    228    finish_record_or_union.  */
    229 
    230 GCC_METHOD3 (int /* bool */, finish_record_with_alignment,
    231 	     gcc_type,			   /* Argument RECORD_OR_UNION_TYPE. */
    232 	     unsigned long,		   /* Argument SIZE_IN_BYTES.  */
    233 	     unsigned long)		   /* Argument ALIGNMENT.  */
    234