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