Home | History | Annotate | Line # | Download | only in compile
      1 /* Header file for GDB compile command and supporting functions.
      2    Copyright (C) 2014-2024 Free Software Foundation, Inc.
      3 
      4    This program is free software; you can redistribute it and/or modify
      5    it under the terms of the GNU General Public License as published by
      6    the Free Software Foundation; either version 3 of the License, or
      7    (at your option) any later version.
      8 
      9    This program is distributed in the hope that it will be useful,
     10    but WITHOUT ANY WARRANTY; without even the implied warranty of
     11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12    GNU General Public License for more details.
     13 
     14    You should have received a copy of the GNU General Public License
     15    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
     16 
     17 #ifndef COMPILE_COMPILE_INTERNAL_H
     18 #define COMPILE_COMPILE_INTERNAL_H
     19 
     20 #include "gcc-c-interface.h"
     21 #include "gdbsupport/gdb-hashtab.h"
     22 
     23 /* Debugging flag for the "compile" family of commands.  */
     24 
     25 extern bool compile_debug;
     26 
     27 /* Define header and footers for different scopes.  */
     28 
     29 /* A simple scope just declares a function named "_gdb_expr", takes no
     30    arguments and returns no value.  */
     31 
     32 #define COMPILE_I_SIMPLE_REGISTER_STRUCT_TAG "__gdb_regs"
     33 #define COMPILE_I_SIMPLE_REGISTER_ARG_NAME "__regs"
     34 #define COMPILE_I_SIMPLE_REGISTER_DUMMY "_dummy"
     35 #define COMPILE_I_PRINT_OUT_ARG_TYPE "void *"
     36 #define COMPILE_I_PRINT_OUT_ARG "__gdb_out_param"
     37 #define COMPILE_I_EXPR_VAL "__gdb_expr_val"
     38 #define COMPILE_I_EXPR_PTR_TYPE "__gdb_expr_ptr_type"
     39 
     40 /* A "type" to indicate a NULL type.  */
     41 
     42 const gcc_type GCC_TYPE_NONE = (gcc_type) -1;
     43 
     44 /* Call gdbarch_register_name (GDBARCH, REGNUM) and convert its result
     45    to a form suitable for the compiler source.  The register names
     46    should not clash with inferior defined macros. */
     47 
     48 extern std::string compile_register_name_mangled (struct gdbarch *gdbarch,
     49 						  int regnum);
     50 
     51 /* Convert compiler source register name to register number of
     52    GDBARCH.  Returned value is always >= 0, function throws an error
     53    for non-matching REG_NAME.  */
     54 
     55 extern int compile_register_name_demangle (struct gdbarch *gdbarch,
     56 					   const char *reg_name);
     57 
     58 /* Type used to hold and pass around the source and object file names
     59    to use for compilation.  */
     60 class compile_file_names
     61 {
     62 public:
     63   compile_file_names (std::string source_file, std::string object_file)
     64     : m_source_file (source_file), m_object_file (object_file)
     65   {}
     66 
     67   /* Provide read-only views only.  Return 'const char *' instead of
     68      std::string to avoid having to use c_str() everywhere in client
     69      code.  */
     70 
     71   const char *source_file () const
     72   { return m_source_file.c_str (); }
     73 
     74   const char *object_file () const
     75   { return m_object_file.c_str (); }
     76 
     77 private:
     78   /* Storage for the file names.  */
     79   std::string m_source_file;
     80   std::string m_object_file;
     81 };
     82 
     83 #endif /* COMPILE_COMPILE_INTERNAL_H */
     84