]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - include/gcc-c-interface.h
[PATCH] fix windmc typedef bug
[thirdparty/binutils-gdb.git] / include / gcc-c-interface.h
CommitLineData
a92a2e34
TT
1/* Interface between GCC C FE and GDB
2
b3adc24a 3 Copyright (C) 2014-2020 Free Software Foundation, Inc.
a92a2e34
TT
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#ifndef GCC_C_INTERFACE_H
21#define GCC_C_INTERFACE_H
22
23#include "gcc-interface.h"
24
25/* This header defines the interface to the GCC API. It must be both
26 valid C and valid C++, because it is included by both programs. */
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32/* Forward declaration. */
33
34struct gcc_c_context;
35
36/*
37 * Definitions and declarations for the C front end.
38 */
39
40/* Defined versions of the C front-end API. */
41
42enum gcc_c_api_version
43{
26a67918
PA
44 GCC_C_FE_VERSION_0 = 0,
45
46 /* Added char_type. Added new version of int_type and float_type,
47 deprecated int_type_v0 and float_type_v0. */
48 GCC_C_FE_VERSION_1 = 1
a92a2e34
TT
49};
50
51/* Qualifiers. */
52
53enum gcc_qualifiers
54{
55 GCC_QUALIFIER_CONST = 1,
56 GCC_QUALIFIER_VOLATILE = 2,
57 GCC_QUALIFIER_RESTRICT = 4
58};
59
60/* This enumerates the kinds of decls that GDB can create. */
61
62enum gcc_c_symbol_kind
63{
64 /* A function. */
65
66 GCC_C_SYMBOL_FUNCTION,
67
68 /* A variable. */
69
70 GCC_C_SYMBOL_VARIABLE,
71
72 /* A typedef. */
73
74 GCC_C_SYMBOL_TYPEDEF,
75
76 /* A label. */
77
78 GCC_C_SYMBOL_LABEL
79};
80
81/* This enumerates the types of symbols that GCC might request from
82 GDB. */
83
84enum gcc_c_oracle_request
85{
86 /* An ordinary symbol -- a variable, function, typedef, or enum
87 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
a92a2e34
TT
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
26a67918 140 to the callbacks in requests. */
a92a2e34
TT
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 */