annotate include/gcc-c-interface.h @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Interface between GCC C FE and GDB
kono
parents:
diff changeset
2
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3 Copyright (C) 2014-2018 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 This file is part of GCC.
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 This program is free software; you can redistribute it and/or modify
kono
parents:
diff changeset
8 it under the terms of the GNU General Public License as published by
kono
parents:
diff changeset
9 the Free Software Foundation; either version 3 of the License, or
kono
parents:
diff changeset
10 (at your option) any later version.
kono
parents:
diff changeset
11
kono
parents:
diff changeset
12 This program is distributed in the hope that it will be useful,
kono
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
kono
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
kono
parents:
diff changeset
15 GNU General Public License for more details.
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 #ifndef GCC_C_INTERFACE_H
kono
parents:
diff changeset
21 #define GCC_C_INTERFACE_H
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23 #include "gcc-interface.h"
kono
parents:
diff changeset
24
kono
parents:
diff changeset
25 /* This header defines the interface to the GCC API. It must be both
kono
parents:
diff changeset
26 valid C and valid C++, because it is included by both programs. */
kono
parents:
diff changeset
27
kono
parents:
diff changeset
28 #ifdef __cplusplus
kono
parents:
diff changeset
29 extern "C" {
kono
parents:
diff changeset
30 #endif
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 /* Forward declaration. */
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 struct gcc_c_context;
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 /*
kono
parents:
diff changeset
37 * Definitions and declarations for the C front end.
kono
parents:
diff changeset
38 */
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 /* Defined versions of the C front-end API. */
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 enum gcc_c_api_version
kono
parents:
diff changeset
43 {
kono
parents:
diff changeset
44 GCC_C_FE_VERSION_0 = 0,
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 /* Added char_type. Added new version of int_type and float_type,
kono
parents:
diff changeset
47 deprecated int_type_v0 and float_type_v0. */
kono
parents:
diff changeset
48 GCC_C_FE_VERSION_1 = 1
kono
parents:
diff changeset
49 };
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 /* Qualifiers. */
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 enum gcc_qualifiers
kono
parents:
diff changeset
54 {
kono
parents:
diff changeset
55 GCC_QUALIFIER_CONST = 1,
kono
parents:
diff changeset
56 GCC_QUALIFIER_VOLATILE = 2,
kono
parents:
diff changeset
57 GCC_QUALIFIER_RESTRICT = 4
kono
parents:
diff changeset
58 };
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 /* This enumerates the kinds of decls that GDB can create. */
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 enum gcc_c_symbol_kind
kono
parents:
diff changeset
63 {
kono
parents:
diff changeset
64 /* A function. */
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 GCC_C_SYMBOL_FUNCTION,
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 /* A variable. */
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 GCC_C_SYMBOL_VARIABLE,
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 /* A typedef. */
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 GCC_C_SYMBOL_TYPEDEF,
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 /* A label. */
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 GCC_C_SYMBOL_LABEL
kono
parents:
diff changeset
79 };
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 /* This enumerates the types of symbols that GCC might request from
kono
parents:
diff changeset
82 GDB. */
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 enum gcc_c_oracle_request
kono
parents:
diff changeset
85 {
kono
parents:
diff changeset
86 /* An ordinary symbol -- a variable, function, typedef, or enum
kono
parents:
diff changeset
87 constant. */
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 GCC_C_ORACLE_SYMBOL,
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 /* A struct, union, or enum tag. */
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 GCC_C_ORACLE_TAG,
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 /* A label. */
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 GCC_C_ORACLE_LABEL
kono
parents:
diff changeset
98 };
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 /* The type of the function called by GCC to ask GDB for a symbol's
kono
parents:
diff changeset
101 definition. DATUM is an arbitrary value supplied when the oracle
kono
parents:
diff changeset
102 function is registered. CONTEXT is the GCC context in which the
kono
parents:
diff changeset
103 request is being made. REQUEST specifies what sort of symbol is
kono
parents:
diff changeset
104 being requested, and IDENTIFIER is the name of the symbol. */
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 typedef void gcc_c_oracle_function (void *datum,
kono
parents:
diff changeset
107 struct gcc_c_context *context,
kono
parents:
diff changeset
108 enum gcc_c_oracle_request request,
kono
parents:
diff changeset
109 const char *identifier);
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111 /* The type of the function called by GCC to ask GDB for a symbol's
kono
parents:
diff changeset
112 address. This should return 0 if the address is not known. */
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 typedef gcc_address gcc_c_symbol_address_function (void *datum,
kono
parents:
diff changeset
115 struct gcc_c_context *ctxt,
kono
parents:
diff changeset
116 const char *identifier);
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 /* The vtable used by the C front end. */
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 struct gcc_c_fe_vtable
kono
parents:
diff changeset
121 {
kono
parents:
diff changeset
122 /* The version of the C interface. The value is one of the
kono
parents:
diff changeset
123 gcc_c_api_version constants. */
kono
parents:
diff changeset
124
kono
parents:
diff changeset
125 unsigned int c_version;
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127 /* Set the callbacks for this context.
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129 The binding oracle is called whenever the C parser needs to look
kono
parents:
diff changeset
130 up a symbol. This gives the caller a chance to lazily
kono
parents:
diff changeset
131 instantiate symbols using other parts of the gcc_c_fe_interface
kono
parents:
diff changeset
132 API.
kono
parents:
diff changeset
133
kono
parents:
diff changeset
134 The address oracle is called whenever the C parser needs to look
kono
parents:
diff changeset
135 up a symbol. This is only called for symbols not provided by the
kono
parents:
diff changeset
136 symbol oracle -- that is, just built-in functions where GCC
kono
parents:
diff changeset
137 provides the declaration.
kono
parents:
diff changeset
138
kono
parents:
diff changeset
139 DATUM is an arbitrary piece of data that is passed back verbatim
kono
parents:
diff changeset
140 to the callbacks in requests. */
kono
parents:
diff changeset
141
kono
parents:
diff changeset
142 void (*set_callbacks) (struct gcc_c_context *self,
kono
parents:
diff changeset
143 gcc_c_oracle_function *binding_oracle,
kono
parents:
diff changeset
144 gcc_c_symbol_address_function *address_oracle,
kono
parents:
diff changeset
145 void *datum);
kono
parents:
diff changeset
146
kono
parents:
diff changeset
147 #define GCC_METHOD0(R, N) \
kono
parents:
diff changeset
148 R (*N) (struct gcc_c_context *);
kono
parents:
diff changeset
149 #define GCC_METHOD1(R, N, A) \
kono
parents:
diff changeset
150 R (*N) (struct gcc_c_context *, A);
kono
parents:
diff changeset
151 #define GCC_METHOD2(R, N, A, B) \
kono
parents:
diff changeset
152 R (*N) (struct gcc_c_context *, A, B);
kono
parents:
diff changeset
153 #define GCC_METHOD3(R, N, A, B, C) \
kono
parents:
diff changeset
154 R (*N) (struct gcc_c_context *, A, B, C);
kono
parents:
diff changeset
155 #define GCC_METHOD4(R, N, A, B, C, D) \
kono
parents:
diff changeset
156 R (*N) (struct gcc_c_context *, A, B, C, D);
kono
parents:
diff changeset
157 #define GCC_METHOD5(R, N, A, B, C, D, E) \
kono
parents:
diff changeset
158 R (*N) (struct gcc_c_context *, A, B, C, D, E);
kono
parents:
diff changeset
159 #define GCC_METHOD7(R, N, A, B, C, D, E, F, G) \
kono
parents:
diff changeset
160 R (*N) (struct gcc_c_context *, A, B, C, D, E, F, G);
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 #include "gcc-c-fe.def"
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164 #undef GCC_METHOD0
kono
parents:
diff changeset
165 #undef GCC_METHOD1
kono
parents:
diff changeset
166 #undef GCC_METHOD2
kono
parents:
diff changeset
167 #undef GCC_METHOD3
kono
parents:
diff changeset
168 #undef GCC_METHOD4
kono
parents:
diff changeset
169 #undef GCC_METHOD5
kono
parents:
diff changeset
170 #undef GCC_METHOD7
kono
parents:
diff changeset
171
kono
parents:
diff changeset
172 };
kono
parents:
diff changeset
173
kono
parents:
diff changeset
174 /* The C front end object. */
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 struct gcc_c_context
kono
parents:
diff changeset
177 {
kono
parents:
diff changeset
178 /* Base class. */
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 struct gcc_base_context base;
kono
parents:
diff changeset
181
kono
parents:
diff changeset
182 /* Our vtable. This is a separate field because this is simpler
kono
parents:
diff changeset
183 than implementing a vtable inheritance scheme in C. */
kono
parents:
diff changeset
184
kono
parents:
diff changeset
185 const struct gcc_c_fe_vtable *c_ops;
kono
parents:
diff changeset
186 };
kono
parents:
diff changeset
187
kono
parents:
diff changeset
188 /* The name of the .so that the compiler builds. We dlopen this
kono
parents:
diff changeset
189 later. */
kono
parents:
diff changeset
190
kono
parents:
diff changeset
191 #define GCC_C_FE_LIBCC libcc1.so
kono
parents:
diff changeset
192
kono
parents:
diff changeset
193 /* The compiler exports a single initialization function. This macro
kono
parents:
diff changeset
194 holds its name as a symbol. */
kono
parents:
diff changeset
195
kono
parents:
diff changeset
196 #define GCC_C_FE_CONTEXT gcc_c_fe_context
kono
parents:
diff changeset
197
kono
parents:
diff changeset
198 /* The type of the initialization function. The caller passes in the
kono
parents:
diff changeset
199 desired base version and desired C-specific version. If the
kono
parents:
diff changeset
200 request can be satisfied, a compatible gcc_context object will be
kono
parents:
diff changeset
201 returned. Otherwise, the function returns NULL. */
kono
parents:
diff changeset
202
kono
parents:
diff changeset
203 typedef struct gcc_c_context *gcc_c_fe_context_function
kono
parents:
diff changeset
204 (enum gcc_base_api_version,
kono
parents:
diff changeset
205 enum gcc_c_api_version);
kono
parents:
diff changeset
206
kono
parents:
diff changeset
207 #ifdef __cplusplus
kono
parents:
diff changeset
208 }
kono
parents:
diff changeset
209 #endif
kono
parents:
diff changeset
210
kono
parents:
diff changeset
211 #endif /* GCC_C_INTERFACE_H */