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