gdb/compile/compile-internal.h - gdb

Data types defined

Macros defined

Source code

  1. /* Header file for GDB compile command and supporting functions.
  2.    Copyright (C) 2014-2015 Free Software Foundation, Inc.

  3.    This program is free software; you can redistribute it and/or modify
  4.    it under the terms of the GNU General Public License as published by
  5.    the Free Software Foundation; either version 3 of the License, or
  6.    (at your option) any later version.

  7.    This program is distributed in the hope that it will be useful,
  8.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  9.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10.    GNU General Public License for more details.

  11.    You should have received a copy of the GNU General Public License
  12.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  13. #ifndef GDB_COMPILE_INTERNAL_H
  14. #define GDB_COMPILE_INTERNAL_H

  15. #include "hashtab.h"
  16. #include "gcc-c-interface.h"

  17. /* Debugging flag for the "compile" family of commands.  */

  18. extern int compile_debug;

  19. struct block;

  20. /* An object of this type holds state associated with a given
  21.    compilation job.  */

  22. struct compile_instance
  23. {
  24.   /* The GCC front end.  */

  25.   struct gcc_base_context *fe;

  26.   /* The "scope" of this compilation.  */

  27.   enum compile_i_scope_types scope;

  28.   /* The block in which an expression is being parsed.  */

  29.   const struct block *block;

  30.   /* Specify "-std=gnu11", "-std=gnu++11" or similar.  These options are put
  31.      after CU's DW_AT_producer compilation options to override them.  */

  32.   const char *gcc_target_options;

  33.   /* How to destroy this object.  */

  34.   void (*destroy) (struct compile_instance *);
  35. };

  36. /* A subclass of compile_instance that is specific to the C front
  37.    end.  */
  38. struct compile_c_instance
  39. {
  40.   /* Base class.  Note that the base class vtable actually points to a
  41.      gcc_c_fe_vtable.  */

  42.   struct compile_instance base;

  43.   /* Map from gdb types to gcc types.  */

  44.   htab_t type_map;

  45.   /* Map from gdb symbols to gcc error messages to emit.  */

  46.   htab_t symbol_err_map;
  47. };

  48. /* A helper macro that takes a compile_c_instance and returns its
  49.    corresponding gcc_c_context.  */

  50. #define C_CTX(I) ((struct gcc_c_context *) ((I)->base.fe))

  51. /* Define header and footers for different scopes.  */

  52. /* A simple scope just declares a function named "_gdb_expr", takes no
  53.    arguments and returns no value.  */

  54. #define COMPILE_I_SIMPLE_REGISTER_STRUCT_TAG "__gdb_regs"
  55. #define COMPILE_I_SIMPLE_REGISTER_ARG_NAME "__regs"
  56. #define COMPILE_I_SIMPLE_REGISTER_DUMMY "_dummy"

  57. /* Call gdbarch_register_name (GDBARCH, REGNUM) and convert its result
  58.    to a form suitable for the compiler source.  The register names
  59.    should not clash with inferior defined macros.  Returned pointer is
  60.    never NULL.  Returned pointer needs to be deallocated by xfree.  */

  61. extern char *compile_register_name_mangled (struct gdbarch *gdbarch,
  62.                                             int regnum);

  63. /* Convert compiler source register name to register number of
  64.    GDBARCH.  Returned value is always >= 0, function throws an error
  65.    for non-matching REG_NAME.  */

  66. extern int compile_register_name_demangle (struct gdbarch *gdbarch,
  67.                                            const char *reg_name);

  68. /* Convert a gdb type, TYPE, to a GCC type.  CONTEXT is used to do the
  69.    actual conversion.  The new GCC type is returned.  */

  70. struct type;
  71. extern gcc_type convert_type (struct compile_c_instance *context,
  72.                               struct type *type);

  73. /* A callback suitable for use as the GCC C symbol oracle.  */

  74. extern gcc_c_oracle_function gcc_convert_symbol;

  75. /* A callback suitable for use as the GCC C address oracle.  */

  76. extern gcc_c_symbol_address_function gcc_symbol_address;

  77. /* Instantiate a GDB object holding state for the GCC context FE.  The
  78.    new object is returned.  */

  79. extern struct compile_instance *new_compile_instance (struct gcc_c_context *fe);

  80. /* Emit code to compute the address for all the local variables in
  81.    scope at PC in BLOCK.  Returns a malloc'd vector, indexed by gdb
  82.    register number, where each element indicates if the corresponding
  83.    register is needed to compute a local variable.  */

  84. extern unsigned char *generate_c_for_variable_locations
  85.      (struct compile_c_instance *compiler,
  86.       struct ui_file *stream,
  87.       struct gdbarch *gdbarch,
  88.       const struct block *block,
  89.       CORE_ADDR pc);

  90. /* Get the GCC mode attribute value for a given type size.  */

  91. extern const char *c_get_mode_for_size (int size);

  92. /* Given a dynamic property, return an xmallocd name that is used to
  93.    represent its size.  The result must be freed by the caller.  The
  94.    contents of the resulting string will be the same each time for
  95.    each call with the same argument.  */

  96. struct dynamic_prop;
  97. extern char *c_get_range_decl_name (const struct dynamic_prop *prop);

  98. #endif /* GDB_COMPILE_INTERNAL_H */