11debfc3dSmrg /* Generic interface between GCC and GDB 21debfc3dSmrg 3*8feb0f0bSmrg Copyright (C) 2014-2020 Free Software Foundation, Inc. 41debfc3dSmrg 51debfc3dSmrg This file is part of GCC. 61debfc3dSmrg 71debfc3dSmrg This program is free software; you can redistribute it and/or modify 81debfc3dSmrg it under the terms of the GNU General Public License as published by 91debfc3dSmrg the Free Software Foundation; either version 3 of the License, or 101debfc3dSmrg (at your option) any later version. 111debfc3dSmrg 121debfc3dSmrg This program is distributed in the hope that it will be useful, 131debfc3dSmrg but WITHOUT ANY WARRANTY; without even the implied warranty of 141debfc3dSmrg MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 151debfc3dSmrg GNU General Public License for more details. 161debfc3dSmrg 171debfc3dSmrg You should have received a copy of the GNU General Public License 181debfc3dSmrg along with this program. If not, see <http://www.gnu.org/licenses/>. */ 191debfc3dSmrg 201debfc3dSmrg #ifndef GCC_INTERFACE_H 211debfc3dSmrg #define GCC_INTERFACE_H 221debfc3dSmrg 231debfc3dSmrg /* This header defines the interface to the GCC API. It must be both 241debfc3dSmrg valid C and valid C++, because it is included by both programs. */ 251debfc3dSmrg 261debfc3dSmrg #ifdef __cplusplus 271debfc3dSmrg extern "C" { 281debfc3dSmrg #endif 291debfc3dSmrg 301debfc3dSmrg /* Opaque typedefs for objects passed through the interface. */ 311debfc3dSmrg 321debfc3dSmrg typedef unsigned long long gcc_type; 331debfc3dSmrg typedef unsigned long long gcc_decl; 341debfc3dSmrg 351debfc3dSmrg /* An address in the inferior. */ 361debfc3dSmrg 371debfc3dSmrg typedef unsigned long long gcc_address; 381debfc3dSmrg 391debfc3dSmrg /* Forward declaration. */ 401debfc3dSmrg 411debfc3dSmrg struct gcc_base_context; 421debfc3dSmrg 431debfc3dSmrg /* Defined versions of the generic API. */ 441debfc3dSmrg 451debfc3dSmrg enum gcc_base_api_version 461debfc3dSmrg { 471debfc3dSmrg GCC_FE_VERSION_0 = 0, 481debfc3dSmrg 491debfc3dSmrg /* Deprecated methods set_arguments_v0 and compile_v0. Added methods 501debfc3dSmrg set_arguments, set_triplet_regexp, set_driver_filename, set_verbose and 511debfc3dSmrg compile. */ 521debfc3dSmrg GCC_FE_VERSION_1 = 1, 531debfc3dSmrg }; 541debfc3dSmrg 551debfc3dSmrg /* The operations defined by the GCC base API. This is the vtable for 561debfc3dSmrg the real context structure which is passed around. 571debfc3dSmrg 581debfc3dSmrg The "base" API is concerned with basics shared by all compiler 591debfc3dSmrg front ends: setting command-line arguments, the file names, etc. 601debfc3dSmrg 611debfc3dSmrg Front-end-specific interfaces inherit from this one. */ 621debfc3dSmrg 631debfc3dSmrg struct gcc_base_vtable 641debfc3dSmrg { 651debfc3dSmrg /* The actual version implemented in this interface. This field can 661debfc3dSmrg be relied on not to move, so users can always check it if they 671debfc3dSmrg desire. The value is one of the gcc_base_api_version constants. 681debfc3dSmrg */ 691debfc3dSmrg 701debfc3dSmrg unsigned int version; 711debfc3dSmrg 721debfc3dSmrg /* Deprecated GCC_FE_VERSION_0 variant of the GCC_FE_VERSION_1 731debfc3dSmrg methods set_triplet_regexp and set_arguments. */ 741debfc3dSmrg 751debfc3dSmrg char *(*set_arguments_v0) (struct gcc_base_context *self, 761debfc3dSmrg const char *triplet_regexp, 771debfc3dSmrg int argc, char **argv); 781debfc3dSmrg 791debfc3dSmrg /* Set the file name of the program to compile. The string is 801debfc3dSmrg copied by the method implementation, but the caller must 811debfc3dSmrg guarantee that the file exists through the compilation. */ 821debfc3dSmrg 831debfc3dSmrg void (*set_source_file) (struct gcc_base_context *self, const char *file); 841debfc3dSmrg 851debfc3dSmrg /* Set a callback to use for printing error messages. DATUM is 861debfc3dSmrg passed through to the callback unchanged. */ 871debfc3dSmrg 881debfc3dSmrg void (*set_print_callback) (struct gcc_base_context *self, 891debfc3dSmrg void (*print_function) (void *datum, 901debfc3dSmrg const char *message), 911debfc3dSmrg void *datum); 921debfc3dSmrg 931debfc3dSmrg /* Deprecated GCC_FE_VERSION_0 variant of the GCC_FE_VERSION_1 941debfc3dSmrg compile method. GCC_FE_VERSION_0 version verbose parameter has 951debfc3dSmrg been replaced by the set_verbose method. */ 961debfc3dSmrg 971debfc3dSmrg int /* bool */ (*compile_v0) (struct gcc_base_context *self, 981debfc3dSmrg const char *filename, 991debfc3dSmrg int /* bool */ verbose); 1001debfc3dSmrg 1011debfc3dSmrg /* Destroy this object. */ 1021debfc3dSmrg 1031debfc3dSmrg void (*destroy) (struct gcc_base_context *self); 1041debfc3dSmrg 1051debfc3dSmrg /* VERBOSE can be set to non-zero to cause GCC to print some 1061debfc3dSmrg information as it works. Calling this method overrides its 1071debfc3dSmrg possible previous calls. 1081debfc3dSmrg 1091debfc3dSmrg This method is only available since GCC_FE_VERSION_1. */ 1101debfc3dSmrg 1111debfc3dSmrg void (*set_verbose) (struct gcc_base_context *self, 1121debfc3dSmrg int /* bool */ verbose); 1131debfc3dSmrg 1141debfc3dSmrg /* Perform the compilation. FILENAME is the name of the resulting 1151debfc3dSmrg object file. Either set_triplet_regexp or set_driver_filename must 1161debfc3dSmrg be called before. Returns true on success, false on error. 1171debfc3dSmrg 1181debfc3dSmrg This method is only available since GCC_FE_VERSION_1. */ 1191debfc3dSmrg 1201debfc3dSmrg int /* bool */ (*compile) (struct gcc_base_context *self, 1211debfc3dSmrg const char *filename); 1221debfc3dSmrg 1231debfc3dSmrg /* Set the compiler's command-line options for the next compilation. 1241debfc3dSmrg The arguments are copied by GCC. ARGV need not be 1251debfc3dSmrg NULL-terminated. The arguments must be set separately for each 1261debfc3dSmrg compilation; that is, after a compile is requested, the 1271debfc3dSmrg previously-set arguments cannot be reused. 1281debfc3dSmrg 1291debfc3dSmrg This returns NULL on success. On failure, returns a malloc()d 1301debfc3dSmrg error message. The caller is responsible for freeing it. 1311debfc3dSmrg 1321debfc3dSmrg This method is only available since GCC_FE_VERSION_1. */ 1331debfc3dSmrg 1341debfc3dSmrg char *(*set_arguments) (struct gcc_base_context *self, 1351debfc3dSmrg int argc, char **argv); 1361debfc3dSmrg 1371debfc3dSmrg /* Set TRIPLET_REGEXP as a regular expression that is used to match 1381debfc3dSmrg the configury triplet prefix to the compiler. Calling this method 1391debfc3dSmrg overrides possible previous call of itself or set_driver_filename. 1401debfc3dSmrg 1411debfc3dSmrg This returns NULL on success. On failure, returns a malloc()d 1421debfc3dSmrg error message. The caller is responsible for freeing it. 1431debfc3dSmrg 1441debfc3dSmrg This method is only available since GCC_FE_VERSION_1. */ 1451debfc3dSmrg 1461debfc3dSmrg char *(*set_triplet_regexp) (struct gcc_base_context *self, 1471debfc3dSmrg const char *triplet_regexp); 1481debfc3dSmrg 1491debfc3dSmrg /* DRIVER_FILENAME should be filename of the gcc compiler driver 1501debfc3dSmrg program. It will be searched in PATH components like 1511debfc3dSmrg TRIPLET_REGEXP. Calling this method overrides possible previous 1521debfc3dSmrg call of itself or set_triplet_regexp. 1531debfc3dSmrg 1541debfc3dSmrg This returns NULL on success. On failure, returns a malloc()d 1551debfc3dSmrg error message. The caller is responsible for freeing it. 1561debfc3dSmrg 1571debfc3dSmrg This method is only available since GCC_FE_VERSION_1. */ 1581debfc3dSmrg 1591debfc3dSmrg char *(*set_driver_filename) (struct gcc_base_context *self, 1601debfc3dSmrg const char *driver_filename); 1611debfc3dSmrg }; 1621debfc3dSmrg 1631debfc3dSmrg /* The GCC object. */ 1641debfc3dSmrg 1651debfc3dSmrg struct gcc_base_context 1661debfc3dSmrg { 1671debfc3dSmrg /* The virtual table. */ 1681debfc3dSmrg 1691debfc3dSmrg const struct gcc_base_vtable *ops; 1701debfc3dSmrg }; 1711debfc3dSmrg 1721debfc3dSmrg /* An array of types used for creating function types in multiple 1731debfc3dSmrg languages. */ 1741debfc3dSmrg 1751debfc3dSmrg struct gcc_type_array 1761debfc3dSmrg { 1771debfc3dSmrg /* Number of elements. */ 1781debfc3dSmrg 1791debfc3dSmrg int n_elements; 1801debfc3dSmrg 1811debfc3dSmrg /* The elements. */ 1821debfc3dSmrg 1831debfc3dSmrg gcc_type *elements; 1841debfc3dSmrg }; 1851debfc3dSmrg 1861debfc3dSmrg /* The name of the dummy wrapper function generated by gdb. */ 1871debfc3dSmrg 1881debfc3dSmrg #define GCC_FE_WRAPPER_FUNCTION "_gdb_expr" 1891debfc3dSmrg 1901debfc3dSmrg #ifdef __cplusplus 1911debfc3dSmrg } 1921debfc3dSmrg #endif 1931debfc3dSmrg 1941debfc3dSmrg #endif /* GCC_INTERFACE_H */ 195