1 /* Generic interface between GCC and GDB
3 Copyright (C) 2014-2017 Free Software Foundation, Inc.
5 This file is part of GCC.
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.
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.
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/>. */
20 #ifndef GCC_INTERFACE_H
21 #define GCC_INTERFACE_H
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. */
30 /* Opaque typedefs for objects passed through the interface. */
32 typedef unsigned long long gcc_type
;
33 typedef unsigned long long gcc_decl
;
35 /* An address in the inferior. */
37 typedef unsigned long long gcc_address
;
39 /* Forward declaration. */
41 struct gcc_base_context
;
43 /* Defined versions of the generic API. */
45 enum gcc_base_api_version
50 /* The operations defined by the GCC base API. This is the vtable for
51 the real context structure which is passed around.
53 The "base" API is concerned with basics shared by all compiler
54 front ends: setting command-line arguments, the file names, etc.
56 Front-end-specific interfaces inherit from this one. */
58 struct gcc_base_vtable
60 /* The actual version implemented in this interface. This field can
61 be relied on not to move, so users can always check it if they
62 desire. The value is one of the gcc_base_api_version constants.
67 /* Set the compiler's command-line options for the next compilation.
68 TRIPLET_REGEXP is a regular expression that is used to match the
69 configury triplet prefix to the compiler.
70 The arguments are copied by GCC. ARGV need not be
71 NULL-terminated. The arguments must be set separately for each
72 compilation; that is, after a compile is requested, the
73 previously-set arguments cannot be reused.
75 This returns NULL on success. On failure, returns a malloc()d
76 error message. The caller is responsible for freeing it. */
78 char *(*set_arguments
) (struct gcc_base_context
*self
,
79 const char *triplet_regexp
,
80 int argc
, char **argv
);
82 /* Set the file name of the program to compile. The string is
83 copied by the method implementation, but the caller must
84 guarantee that the file exists through the compilation. */
86 void (*set_source_file
) (struct gcc_base_context
*self
, const char *file
);
88 /* Set a callback to use for printing error messages. DATUM is
89 passed through to the callback unchanged. */
91 void (*set_print_callback
) (struct gcc_base_context
*self
,
92 void (*print_function
) (void *datum
,
96 /* Perform the compilation. FILENAME is the name of the resulting
97 object file. VERBOSE can be set to cause GCC to print some
98 information as it works. Returns true on success, false on
101 int /* bool */ (*compile
) (struct gcc_base_context
*self
,
102 const char *filename
,
103 int /* bool */ verbose
);
105 /* Destroy this object. */
107 void (*destroy
) (struct gcc_base_context
*self
);
110 /* The GCC object. */
112 struct gcc_base_context
114 /* The virtual table. */
116 const struct gcc_base_vtable
*ops
;
119 /* The name of the dummy wrapper function generated by gdb. */
121 #define GCC_FE_WRAPPER_FUNCTION "_gdb_expr"
127 #endif /* GCC_INTERFACE_H */