annotate include/gcc-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 /* Generic interface between GCC 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_INTERFACE_H
kono
parents:
diff changeset
21 #define GCC_INTERFACE_H
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23 /* This header defines the interface to the GCC API. It must be both
kono
parents:
diff changeset
24 valid C and valid C++, because it is included by both programs. */
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 #ifdef __cplusplus
kono
parents:
diff changeset
27 extern "C" {
kono
parents:
diff changeset
28 #endif
kono
parents:
diff changeset
29
kono
parents:
diff changeset
30 /* Opaque typedefs for objects passed through the interface. */
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 typedef unsigned long long gcc_type;
kono
parents:
diff changeset
33 typedef unsigned long long gcc_decl;
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 /* An address in the inferior. */
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 typedef unsigned long long gcc_address;
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 /* Forward declaration. */
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 struct gcc_base_context;
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 /* Defined versions of the generic API. */
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 enum gcc_base_api_version
kono
parents:
diff changeset
46 {
kono
parents:
diff changeset
47 GCC_FE_VERSION_0 = 0,
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 /* Deprecated methods set_arguments_v0 and compile_v0. Added methods
kono
parents:
diff changeset
50 set_arguments, set_triplet_regexp, set_driver_filename, set_verbose and
kono
parents:
diff changeset
51 compile. */
kono
parents:
diff changeset
52 GCC_FE_VERSION_1 = 1,
kono
parents:
diff changeset
53 };
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 /* The operations defined by the GCC base API. This is the vtable for
kono
parents:
diff changeset
56 the real context structure which is passed around.
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 The "base" API is concerned with basics shared by all compiler
kono
parents:
diff changeset
59 front ends: setting command-line arguments, the file names, etc.
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 Front-end-specific interfaces inherit from this one. */
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63 struct gcc_base_vtable
kono
parents:
diff changeset
64 {
kono
parents:
diff changeset
65 /* The actual version implemented in this interface. This field can
kono
parents:
diff changeset
66 be relied on not to move, so users can always check it if they
kono
parents:
diff changeset
67 desire. The value is one of the gcc_base_api_version constants.
kono
parents:
diff changeset
68 */
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 unsigned int version;
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 /* Deprecated GCC_FE_VERSION_0 variant of the GCC_FE_VERSION_1
kono
parents:
diff changeset
73 methods set_triplet_regexp and set_arguments. */
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 char *(*set_arguments_v0) (struct gcc_base_context *self,
kono
parents:
diff changeset
76 const char *triplet_regexp,
kono
parents:
diff changeset
77 int argc, char **argv);
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 /* Set the file name of the program to compile. The string is
kono
parents:
diff changeset
80 copied by the method implementation, but the caller must
kono
parents:
diff changeset
81 guarantee that the file exists through the compilation. */
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 void (*set_source_file) (struct gcc_base_context *self, const char *file);
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 /* Set a callback to use for printing error messages. DATUM is
kono
parents:
diff changeset
86 passed through to the callback unchanged. */
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 void (*set_print_callback) (struct gcc_base_context *self,
kono
parents:
diff changeset
89 void (*print_function) (void *datum,
kono
parents:
diff changeset
90 const char *message),
kono
parents:
diff changeset
91 void *datum);
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 /* Deprecated GCC_FE_VERSION_0 variant of the GCC_FE_VERSION_1
kono
parents:
diff changeset
94 compile method. GCC_FE_VERSION_0 version verbose parameter has
kono
parents:
diff changeset
95 been replaced by the set_verbose method. */
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 int /* bool */ (*compile_v0) (struct gcc_base_context *self,
kono
parents:
diff changeset
98 const char *filename,
kono
parents:
diff changeset
99 int /* bool */ verbose);
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 /* Destroy this object. */
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 void (*destroy) (struct gcc_base_context *self);
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105 /* VERBOSE can be set to non-zero to cause GCC to print some
kono
parents:
diff changeset
106 information as it works. Calling this method overrides its
kono
parents:
diff changeset
107 possible previous calls.
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 This method is only available since GCC_FE_VERSION_1. */
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111 void (*set_verbose) (struct gcc_base_context *self,
kono
parents:
diff changeset
112 int /* bool */ verbose);
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 /* Perform the compilation. FILENAME is the name of the resulting
kono
parents:
diff changeset
115 object file. Either set_triplet_regexp or set_driver_filename must
kono
parents:
diff changeset
116 be called before. Returns true on success, false on error.
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 This method is only available since GCC_FE_VERSION_1. */
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 int /* bool */ (*compile) (struct gcc_base_context *self,
kono
parents:
diff changeset
121 const char *filename);
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 /* Set the compiler's command-line options for the next compilation.
kono
parents:
diff changeset
124 The arguments are copied by GCC. ARGV need not be
kono
parents:
diff changeset
125 NULL-terminated. The arguments must be set separately for each
kono
parents:
diff changeset
126 compilation; that is, after a compile is requested, the
kono
parents:
diff changeset
127 previously-set arguments cannot be reused.
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129 This returns NULL on success. On failure, returns a malloc()d
kono
parents:
diff changeset
130 error message. The caller is responsible for freeing it.
kono
parents:
diff changeset
131
kono
parents:
diff changeset
132 This method is only available since GCC_FE_VERSION_1. */
kono
parents:
diff changeset
133
kono
parents:
diff changeset
134 char *(*set_arguments) (struct gcc_base_context *self,
kono
parents:
diff changeset
135 int argc, char **argv);
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137 /* Set TRIPLET_REGEXP as a regular expression that is used to match
kono
parents:
diff changeset
138 the configury triplet prefix to the compiler. Calling this method
kono
parents:
diff changeset
139 overrides possible previous call of itself or set_driver_filename.
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 This returns NULL on success. On failure, returns a malloc()d
kono
parents:
diff changeset
142 error message. The caller is responsible for freeing it.
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144 This method is only available since GCC_FE_VERSION_1. */
kono
parents:
diff changeset
145
kono
parents:
diff changeset
146 char *(*set_triplet_regexp) (struct gcc_base_context *self,
kono
parents:
diff changeset
147 const char *triplet_regexp);
kono
parents:
diff changeset
148
kono
parents:
diff changeset
149 /* DRIVER_FILENAME should be filename of the gcc compiler driver
kono
parents:
diff changeset
150 program. It will be searched in PATH components like
kono
parents:
diff changeset
151 TRIPLET_REGEXP. Calling this method overrides possible previous
kono
parents:
diff changeset
152 call of itself or set_triplet_regexp.
kono
parents:
diff changeset
153
kono
parents:
diff changeset
154 This returns NULL on success. On failure, returns a malloc()d
kono
parents:
diff changeset
155 error message. The caller is responsible for freeing it.
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 This method is only available since GCC_FE_VERSION_1. */
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 char *(*set_driver_filename) (struct gcc_base_context *self,
kono
parents:
diff changeset
160 const char *driver_filename);
kono
parents:
diff changeset
161 };
kono
parents:
diff changeset
162
kono
parents:
diff changeset
163 /* The GCC object. */
kono
parents:
diff changeset
164
kono
parents:
diff changeset
165 struct gcc_base_context
kono
parents:
diff changeset
166 {
kono
parents:
diff changeset
167 /* The virtual table. */
kono
parents:
diff changeset
168
kono
parents:
diff changeset
169 const struct gcc_base_vtable *ops;
kono
parents:
diff changeset
170 };
kono
parents:
diff changeset
171
kono
parents:
diff changeset
172 /* An array of types used for creating function types in multiple
kono
parents:
diff changeset
173 languages. */
kono
parents:
diff changeset
174
kono
parents:
diff changeset
175 struct gcc_type_array
kono
parents:
diff changeset
176 {
kono
parents:
diff changeset
177 /* Number of elements. */
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179 int n_elements;
kono
parents:
diff changeset
180
kono
parents:
diff changeset
181 /* The elements. */
kono
parents:
diff changeset
182
kono
parents:
diff changeset
183 gcc_type *elements;
kono
parents:
diff changeset
184 };
kono
parents:
diff changeset
185
kono
parents:
diff changeset
186 /* The name of the dummy wrapper function generated by gdb. */
kono
parents:
diff changeset
187
kono
parents:
diff changeset
188 #define GCC_FE_WRAPPER_FUNCTION "_gdb_expr"
kono
parents:
diff changeset
189
kono
parents:
diff changeset
190 #ifdef __cplusplus
kono
parents:
diff changeset
191 }
kono
parents:
diff changeset
192 #endif
kono
parents:
diff changeset
193
kono
parents:
diff changeset
194 #endif /* GCC_INTERFACE_H */