182900Sjake/* Interface between GCC C FE and GDB 282900Sjake 382900Sjake Copyright (C) 2014-2022 Free Software Foundation, Inc. 482900Sjake 582900Sjake This file is part of GCC. 682900Sjake 782900Sjake This program is free software; you can redistribute it and/or modify 882900Sjake it under the terms of the GNU General Public License as published by 982900Sjake the Free Software Foundation; either version 3 of the License, or 1082900Sjake (at your option) any later version. 1182900Sjake 1282900Sjake This program is distributed in the hope that it will be useful, 1382900Sjake but WITHOUT ANY WARRANTY; without even the implied warranty of 1482900Sjake MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1582900Sjake GNU General Public License for more details. 1682900Sjake 1782900Sjake You should have received a copy of the GNU General Public License 1882900Sjake along with this program. If not, see <http://www.gnu.org/licenses/>. */ 1982900Sjake 2082900Sjake#ifndef GCC_C_INTERFACE_H 2182900Sjake#define GCC_C_INTERFACE_H 2282900Sjake 2382900Sjake#include "gcc-interface.h" 2482900Sjake 2582900Sjake/* This header defines the interface to the GCC API. It must be both 2682900Sjake valid C and valid C++, because it is included by both programs. */ 2782900Sjake 2882900Sjake#ifdef __cplusplus 2982900Sjakeextern "C" { 3082900Sjake#endif 3182900Sjake 3282900Sjake/* Forward declaration. */ 3382900Sjake 3482900Sjakestruct gcc_c_context; 3582900Sjake 3682900Sjake/* 3782900Sjake * Definitions and declarations for the C front end. 3882900Sjake */ 3982900Sjake 4082900Sjake/* Defined versions of the C front-end API. */ 4182900Sjake 4282900Sjakeenum gcc_c_api_version 4382900Sjake{ 4482900Sjake GCC_C_FE_VERSION_0 = 0, 4582900Sjake 4682900Sjake /* Added char_type. Added new version of int_type and float_type, 4782900Sjake deprecated int_type_v0 and float_type_v0. */ 4882900Sjake GCC_C_FE_VERSION_1 = 1 4982900Sjake}; 5082900Sjake 5182900Sjake/* Qualifiers. */ 5282900Sjake 5382900Sjakeenum gcc_qualifiers 5482900Sjake{ 5582900Sjake GCC_QUALIFIER_CONST = 1, 5682900Sjake GCC_QUALIFIER_VOLATILE = 2, 5782900Sjake GCC_QUALIFIER_RESTRICT = 4 5882900Sjake}; 5982900Sjake 6082900Sjake/* This enumerates the kinds of decls that GDB can create. */ 6182900Sjake 6282900Sjakeenum gcc_c_symbol_kind 6382900Sjake{ 6482900Sjake /* A function. */ 6582900Sjake 6682900Sjake GCC_C_SYMBOL_FUNCTION, 6782900Sjake 6882900Sjake /* A variable. */ 6982900Sjake 7082900Sjake GCC_C_SYMBOL_VARIABLE, 7182900Sjake 7282900Sjake /* A typedef. */ 7382900Sjake 7482900Sjake GCC_C_SYMBOL_TYPEDEF, 7582900Sjake 7682900Sjake /* A label. */ 7782900Sjake 7882900Sjake GCC_C_SYMBOL_LABEL 7982900Sjake}; 8082900Sjake 8182900Sjake/* This enumerates the types of symbols that GCC might request from 8282900Sjake GDB. */ 8382900Sjake 8482900Sjakeenum gcc_c_oracle_request 8582900Sjake{ 8682900Sjake /* An ordinary symbol -- a variable, function, typedef, or enum 8782900Sjake constant. */ 88 89 GCC_C_ORACLE_SYMBOL, 90 91 /* A struct, union, or enum tag. */ 92 93 GCC_C_ORACLE_TAG, 94 95 /* A label. */ 96 97 GCC_C_ORACLE_LABEL 98}; 99 100/* The type of the function called by GCC to ask GDB for a symbol's 101 definition. DATUM is an arbitrary value supplied when the oracle 102 function is registered. CONTEXT is the GCC context in which the 103 request is being made. REQUEST specifies what sort of symbol is 104 being requested, and IDENTIFIER is the name of the symbol. */ 105 106typedef void gcc_c_oracle_function (void *datum, 107 struct gcc_c_context *context, 108 enum gcc_c_oracle_request request, 109 const char *identifier); 110 111/* The type of the function called by GCC to ask GDB for a symbol's 112 address. This should return 0 if the address is not known. */ 113 114typedef gcc_address gcc_c_symbol_address_function (void *datum, 115 struct gcc_c_context *ctxt, 116 const char *identifier); 117 118/* The vtable used by the C front end. */ 119 120struct gcc_c_fe_vtable 121{ 122 /* The version of the C interface. The value is one of the 123 gcc_c_api_version constants. */ 124 125 unsigned int c_version; 126 127 /* Set the callbacks for this context. 128 129 The binding oracle is called whenever the C parser needs to look 130 up a symbol. This gives the caller a chance to lazily 131 instantiate symbols using other parts of the gcc_c_fe_interface 132 API. 133 134 The address oracle is called whenever the C parser needs to look 135 up a symbol. This is only called for symbols not provided by the 136 symbol oracle -- that is, just built-in functions where GCC 137 provides the declaration. 138 139 DATUM is an arbitrary piece of data that is passed back verbatim 140 to the callbacks in requests. */ 141 142 void (*set_callbacks) (struct gcc_c_context *self, 143 gcc_c_oracle_function *binding_oracle, 144 gcc_c_symbol_address_function *address_oracle, 145 void *datum); 146 147#define GCC_METHOD0(R, N) \ 148 R (*N) (struct gcc_c_context *); 149#define GCC_METHOD1(R, N, A) \ 150 R (*N) (struct gcc_c_context *, A); 151#define GCC_METHOD2(R, N, A, B) \ 152 R (*N) (struct gcc_c_context *, A, B); 153#define GCC_METHOD3(R, N, A, B, C) \ 154 R (*N) (struct gcc_c_context *, A, B, C); 155#define GCC_METHOD4(R, N, A, B, C, D) \ 156 R (*N) (struct gcc_c_context *, A, B, C, D); 157#define GCC_METHOD5(R, N, A, B, C, D, E) \ 158 R (*N) (struct gcc_c_context *, A, B, C, D, E); 159#define GCC_METHOD7(R, N, A, B, C, D, E, F, G) \ 160 R (*N) (struct gcc_c_context *, A, B, C, D, E, F, G); 161 162#include "gcc-c-fe.def" 163 164#undef GCC_METHOD0 165#undef GCC_METHOD1 166#undef GCC_METHOD2 167#undef GCC_METHOD3 168#undef GCC_METHOD4 169#undef GCC_METHOD5 170#undef GCC_METHOD7 171 172}; 173 174/* The C front end object. */ 175 176struct gcc_c_context 177{ 178 /* Base class. */ 179 180 struct gcc_base_context base; 181 182 /* Our vtable. This is a separate field because this is simpler 183 than implementing a vtable inheritance scheme in C. */ 184 185 const struct gcc_c_fe_vtable *c_ops; 186}; 187 188/* The name of the .so that the compiler builds. We dlopen this 189 later. */ 190 191#define GCC_C_FE_LIBCC libcc1.so 192 193/* The compiler exports a single initialization function. This macro 194 holds its name as a symbol. */ 195 196#define GCC_C_FE_CONTEXT gcc_c_fe_context 197 198/* The type of the initialization function. The caller passes in the 199 desired base version and desired C-specific version. If the 200 request can be satisfied, a compatible gcc_context object will be 201 returned. Otherwise, the function returns NULL. */ 202 203typedef struct gcc_c_context *gcc_c_fe_context_function 204 (enum gcc_base_api_version, 205 enum gcc_c_api_version); 206 207#ifdef __cplusplus 208} 209#endif 210 211#endif /* GCC_C_INTERFACE_H */ 212