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