Home | History | Annotate | Line # | Download | only in include
gcc-interface.h revision 1.4
      1  1.1  christos /* Generic interface between GCC and GDB
      2  1.1  christos 
      3  1.4  christos    Copyright (C) 2014-2016 Free Software Foundation, Inc.
      4  1.1  christos 
      5  1.1  christos    This file is part of GCC.
      6  1.1  christos 
      7  1.1  christos    This program is free software; you can redistribute it and/or modify
      8  1.1  christos    it under the terms of the GNU General Public License as published by
      9  1.1  christos    the Free Software Foundation; either version 3 of the License, or
     10  1.1  christos    (at your option) any later version.
     11  1.1  christos 
     12  1.1  christos    This program is distributed in the hope that it will be useful,
     13  1.1  christos    but WITHOUT ANY WARRANTY; without even the implied warranty of
     14  1.1  christos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15  1.1  christos    GNU General Public License for more details.
     16  1.1  christos 
     17  1.1  christos    You should have received a copy of the GNU General Public License
     18  1.1  christos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
     19  1.1  christos 
     20  1.1  christos #ifndef GCC_INTERFACE_H
     21  1.1  christos #define GCC_INTERFACE_H
     22  1.1  christos 
     23  1.1  christos /* This header defines the interface to the GCC API.  It must be both
     24  1.1  christos    valid C and valid C++, because it is included by both programs.  */
     25  1.1  christos 
     26  1.1  christos #ifdef __cplusplus
     27  1.1  christos extern "C" {
     28  1.1  christos #endif
     29  1.1  christos 
     30  1.1  christos /* Opaque typedefs for objects passed through the interface.  */
     31  1.1  christos 
     32  1.1  christos typedef unsigned long long gcc_type;
     33  1.1  christos typedef unsigned long long gcc_decl;
     34  1.1  christos 
     35  1.1  christos /* An address in the inferior.  */
     36  1.1  christos 
     37  1.1  christos typedef unsigned long long gcc_address;
     38  1.1  christos 
     39  1.1  christos /* Forward declaration.  */
     40  1.1  christos 
     41  1.1  christos struct gcc_base_context;
     42  1.1  christos 
     43  1.1  christos /* Defined versions of the generic API.  */
     44  1.1  christos 
     45  1.1  christos enum gcc_base_api_version
     46  1.1  christos {
     47  1.1  christos   GCC_FE_VERSION_0 = 0
     48  1.1  christos };
     49  1.1  christos 
     50  1.1  christos /* The operations defined by the GCC base API.  This is the vtable for
     51  1.1  christos    the real context structure which is passed around.
     52  1.1  christos 
     53  1.1  christos    The "base" API is concerned with basics shared by all compiler
     54  1.1  christos    front ends: setting command-line arguments, the file names, etc.
     55  1.1  christos 
     56  1.1  christos    Front-end-specific interfaces inherit from this one.  */
     57  1.1  christos 
     58  1.1  christos struct gcc_base_vtable
     59  1.1  christos {
     60  1.1  christos   /* The actual version implemented in this interface.  This field can
     61  1.1  christos      be relied on not to move, so users can always check it if they
     62  1.1  christos      desire.  The value is one of the gcc_base_api_version constants.
     63  1.1  christos   */
     64  1.1  christos 
     65  1.1  christos   unsigned int version;
     66  1.1  christos 
     67  1.1  christos   /* Set the compiler's command-line options for the next compilation.
     68  1.1  christos      TRIPLET_REGEXP is a regular expression that is used to match the
     69  1.1  christos      configury triplet prefix to the compiler.
     70  1.1  christos      The arguments are copied by GCC.  ARGV need not be
     71  1.1  christos      NULL-terminated.  The arguments must be set separately for each
     72  1.1  christos      compilation; that is, after a compile is requested, the
     73  1.1  christos      previously-set arguments cannot be reused.
     74  1.1  christos 
     75  1.1  christos      This returns NULL on success.  On failure, returns a malloc()d
     76  1.1  christos      error message.  The caller is responsible for freeing it.  */
     77  1.1  christos 
     78  1.1  christos   char *(*set_arguments) (struct gcc_base_context *self,
     79  1.1  christos 			  const char *triplet_regexp,
     80  1.1  christos 			  int argc, char **argv);
     81  1.1  christos 
     82  1.1  christos   /* Set the file name of the program to compile.  The string is
     83  1.1  christos      copied by the method implementation, but the caller must
     84  1.1  christos      guarantee that the file exists through the compilation.  */
     85  1.1  christos 
     86  1.1  christos   void (*set_source_file) (struct gcc_base_context *self, const char *file);
     87  1.1  christos 
     88  1.1  christos   /* Set a callback to use for printing error messages.  DATUM is
     89  1.1  christos      passed through to the callback unchanged.  */
     90  1.1  christos 
     91  1.1  christos   void (*set_print_callback) (struct gcc_base_context *self,
     92  1.1  christos 			      void (*print_function) (void *datum,
     93  1.1  christos 						      const char *message),
     94  1.1  christos 			      void *datum);
     95  1.1  christos 
     96  1.1  christos   /* Perform the compilation.  FILENAME is the name of the resulting
     97  1.1  christos      object file.  VERBOSE can be set to cause GCC to print some
     98  1.1  christos      information as it works.  Returns true on success, false on
     99  1.1  christos      error.  */
    100  1.1  christos 
    101  1.1  christos   int /* bool */ (*compile) (struct gcc_base_context *self,
    102  1.1  christos 			     const char *filename,
    103  1.1  christos 			     int /* bool */ verbose);
    104  1.1  christos 
    105  1.1  christos   /* Destroy this object.  */
    106  1.1  christos 
    107  1.1  christos   void (*destroy) (struct gcc_base_context *self);
    108  1.1  christos };
    109  1.1  christos 
    110  1.1  christos /* The GCC object.  */
    111  1.1  christos 
    112  1.1  christos struct gcc_base_context
    113  1.1  christos {
    114  1.1  christos   /* The virtual table.  */
    115  1.1  christos 
    116  1.1  christos   const struct gcc_base_vtable *ops;
    117  1.1  christos };
    118  1.1  christos 
    119  1.1  christos /* The name of the dummy wrapper function generated by gdb.  */
    120  1.1  christos 
    121  1.1  christos #define GCC_FE_WRAPPER_FUNCTION "_gdb_expr"
    122  1.1  christos 
    123  1.1  christos #ifdef __cplusplus
    124  1.1  christos }
    125  1.1  christos #endif
    126  1.1  christos 
    127  1.1  christos #endif /* GCC_INTERFACE_H */
    128