1 /* Header file for GDB compile command and supporting functions.
2 Copyright (C) 2014-2018 Free Software Foundation, Inc.
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.
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.
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/>. */
17 #ifndef GDB_COMPILE_INTERNAL_H
18 #define GDB_COMPILE_INTERNAL_H
20 #include "gcc-c-interface.h"
22 /* Debugging flag for the "compile" family of commands. */
24 extern int compile_debug
;
28 /* An object of this type holds state associated with a given
31 struct compile_instance
33 /* The GCC front end. */
35 struct gcc_base_context
*fe
;
37 /* The "scope" of this compilation. */
39 enum compile_i_scope_types scope
;
41 /* The block in which an expression is being parsed. */
43 const struct block
*block
;
45 /* Specify "-std=gnu11", "-std=gnu++11" or similar. These options are put
46 after CU's DW_AT_producer compilation options to override them. */
48 const char *gcc_target_options
;
50 /* How to destroy this object. */
52 void (*destroy
) (struct compile_instance
*);
55 /* Define header and footers for different scopes. */
57 /* A simple scope just declares a function named "_gdb_expr", takes no
58 arguments and returns no value. */
60 #define COMPILE_I_SIMPLE_REGISTER_STRUCT_TAG "__gdb_regs"
61 #define COMPILE_I_SIMPLE_REGISTER_ARG_NAME "__regs"
62 #define COMPILE_I_SIMPLE_REGISTER_DUMMY "_dummy"
63 #define COMPILE_I_PRINT_OUT_ARG_TYPE "void *"
64 #define COMPILE_I_PRINT_OUT_ARG "__gdb_out_param"
65 #define COMPILE_I_EXPR_VAL "__gdb_expr_val"
66 #define COMPILE_I_EXPR_PTR_TYPE "__gdb_expr_ptr_type"
68 /* Call gdbarch_register_name (GDBARCH, REGNUM) and convert its result
69 to a form suitable for the compiler source. The register names
70 should not clash with inferior defined macros. */
72 extern std::string
compile_register_name_mangled (struct gdbarch
*gdbarch
,
75 /* Convert compiler source register name to register number of
76 GDBARCH. Returned value is always >= 0, function throws an error
77 for non-matching REG_NAME. */
79 extern int compile_register_name_demangle (struct gdbarch
*gdbarch
,
80 const char *reg_name
);
82 /* Convert a gdb type, TYPE, to a GCC type. CONTEXT is used to do the
83 actual conversion. The new GCC type is returned. */
86 extern gcc_type
convert_type (struct compile_c_instance
*context
,
89 /* Instantiate a GDB object holding state for the GCC context FE. The
90 new object is returned. */
92 extern struct compile_instance
*new_compile_instance (struct gcc_c_context
*fe
);
94 /* Type used to hold and pass around the source and object file names
95 to use for compilation. */
96 class compile_file_names
99 compile_file_names (std::string source_file
, std::string object_file
)
100 : m_source_file (source_file
), m_object_file (object_file
)
103 /* Provide read-only views only. Return 'const char *' instead of
104 std::string to avoid having to use c_str() everywhere in client
107 const char *source_file () const
108 { return m_source_file
.c_str (); }
110 const char *object_file () const
111 { return m_object_file
.c_str (); }
114 /* Storage for the file names. */
115 std::string m_source_file
;
116 std::string m_object_file
;
119 #endif /* GDB_COMPILE_INTERNAL_H */