Commit | Line | Data |
---|---|---|
a92a2e34 TT |
1 | /* Generic interface between GCC and GDB |
2 | ||
2571583a | 3 | Copyright (C) 2014-2017 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 | ||
49 | /* Deprecated method compile_v0. Added method set_verbose and compile. */ | |
50 | GCC_FE_VERSION_1 = 1, | |
a92a2e34 TT |
51 | }; |
52 | ||
53 | /* The operations defined by the GCC base API. This is the vtable for | |
54 | the real context structure which is passed around. | |
55 | ||
56 | The "base" API is concerned with basics shared by all compiler | |
57 | front ends: setting command-line arguments, the file names, etc. | |
58 | ||
59 | Front-end-specific interfaces inherit from this one. */ | |
60 | ||
61 | struct gcc_base_vtable | |
62 | { | |
63 | /* The actual version implemented in this interface. This field can | |
64 | be relied on not to move, so users can always check it if they | |
65 | desire. The value is one of the gcc_base_api_version constants. | |
66 | */ | |
67 | ||
68 | unsigned int version; | |
69 | ||
70 | /* Set the compiler's command-line options for the next compilation. | |
71 | TRIPLET_REGEXP is a regular expression that is used to match the | |
72 | configury triplet prefix to the compiler. | |
73 | The arguments are copied by GCC. ARGV need not be | |
74 | NULL-terminated. The arguments must be set separately for each | |
75 | compilation; that is, after a compile is requested, the | |
76 | previously-set arguments cannot be reused. | |
77 | ||
78 | This returns NULL on success. On failure, returns a malloc()d | |
79 | error message. The caller is responsible for freeing it. */ | |
80 | ||
81 | char *(*set_arguments) (struct gcc_base_context *self, | |
82 | const char *triplet_regexp, | |
83 | int argc, char **argv); | |
84 | ||
85 | /* Set the file name of the program to compile. The string is | |
86 | copied by the method implementation, but the caller must | |
87 | guarantee that the file exists through the compilation. */ | |
88 | ||
89 | void (*set_source_file) (struct gcc_base_context *self, const char *file); | |
90 | ||
91 | /* Set a callback to use for printing error messages. DATUM is | |
92 | passed through to the callback unchanged. */ | |
93 | ||
94 | void (*set_print_callback) (struct gcc_base_context *self, | |
95 | void (*print_function) (void *datum, | |
96 | const char *message), | |
97 | void *datum); | |
98 | ||
e68c32d5 JK |
99 | /* Deprecated GCC_FE_VERSION_0 variant of the GCC_FE_VERSION_1 |
100 | compile method. GCC_FE_VERSION_0 version verbose parameter has | |
101 | been replaced by the set_verbose method. */ | |
a92a2e34 | 102 | |
e68c32d5 JK |
103 | int /* bool */ (*compile_v0) (struct gcc_base_context *self, |
104 | const char *filename, | |
105 | int /* bool */ verbose); | |
a92a2e34 TT |
106 | |
107 | /* Destroy this object. */ | |
108 | ||
109 | void (*destroy) (struct gcc_base_context *self); | |
e68c32d5 JK |
110 | |
111 | /* VERBOSE can be set to non-zero to cause GCC to print some | |
112 | information as it works. Calling this method overrides its | |
113 | possible previous calls. | |
114 | ||
115 | This method is only available since GCC_FE_VERSION_1. */ | |
116 | ||
117 | void (*set_verbose) (struct gcc_base_context *self, | |
118 | int /* bool */ verbose); | |
119 | ||
120 | /* Perform the compilation. FILENAME is the name of the resulting | |
121 | object file. Either set_triplet_regexp or set_driver_filename must | |
122 | be called before. Returns true on success, false on error. | |
123 | ||
124 | This method is only available since GCC_FE_VERSION_1. */ | |
125 | ||
126 | int /* bool */ (*compile) (struct gcc_base_context *self, | |
127 | const char *filename); | |
a92a2e34 TT |
128 | }; |
129 | ||
130 | /* The GCC object. */ | |
131 | ||
132 | struct gcc_base_context | |
133 | { | |
134 | /* The virtual table. */ | |
135 | ||
136 | const struct gcc_base_vtable *ops; | |
137 | }; | |
138 | ||
139 | /* The name of the dummy wrapper function generated by gdb. */ | |
140 | ||
141 | #define GCC_FE_WRAPPER_FUNCTION "_gdb_expr" | |
142 | ||
143 | #ifdef __cplusplus | |
144 | } | |
145 | #endif | |
146 | ||
147 | #endif /* GCC_INTERFACE_H */ |