Commit | Line | Data |
---|---|---|
bb2ec1b3 | 1 | /* Header file for GDB compile command and supporting functions. |
e2882c85 | 2 | Copyright (C) 2014-2018 Free Software Foundation, Inc. |
bb2ec1b3 TT |
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 GDB_COMPILE_INTERNAL_H | |
18 | #define GDB_COMPILE_INTERNAL_H | |
19 | ||
bb2ec1b3 TT |
20 | #include "gcc-c-interface.h" |
21 | ||
22 | /* Debugging flag for the "compile" family of commands. */ | |
23 | ||
24 | extern int compile_debug; | |
25 | ||
26 | struct block; | |
27 | ||
28 | /* An object of this type holds state associated with a given | |
29 | compilation job. */ | |
30 | ||
31 | struct compile_instance | |
32 | { | |
33 | /* The GCC front end. */ | |
34 | ||
35 | struct gcc_base_context *fe; | |
36 | ||
37 | /* The "scope" of this compilation. */ | |
38 | ||
39 | enum compile_i_scope_types scope; | |
40 | ||
41 | /* The block in which an expression is being parsed. */ | |
42 | ||
43 | const struct block *block; | |
44 | ||
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. */ | |
47 | ||
48 | const char *gcc_target_options; | |
49 | ||
50 | /* How to destroy this object. */ | |
51 | ||
52 | void (*destroy) (struct compile_instance *); | |
53 | }; | |
54 | ||
bb2ec1b3 TT |
55 | /* Define header and footers for different scopes. */ |
56 | ||
57 | /* A simple scope just declares a function named "_gdb_expr", takes no | |
58 | arguments and returns no value. */ | |
59 | ||
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" | |
36de76f9 JK |
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" | |
bb2ec1b3 TT |
67 | |
68 | /* Call gdbarch_register_name (GDBARCH, REGNUM) and convert its result | |
69 | to a form suitable for the compiler source. The register names | |
8f84fb0e | 70 | should not clash with inferior defined macros. */ |
bb2ec1b3 | 71 | |
8f84fb0e TT |
72 | extern std::string compile_register_name_mangled (struct gdbarch *gdbarch, |
73 | int regnum); | |
bb2ec1b3 TT |
74 | |
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. */ | |
78 | ||
79 | extern int compile_register_name_demangle (struct gdbarch *gdbarch, | |
80 | const char *reg_name); | |
81 | ||
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. */ | |
84 | ||
85 | struct type; | |
86 | extern gcc_type convert_type (struct compile_c_instance *context, | |
87 | struct type *type); | |
88 | ||
bb2ec1b3 TT |
89 | /* Instantiate a GDB object holding state for the GCC context FE. The |
90 | new object is returned. */ | |
91 | ||
92 | extern struct compile_instance *new_compile_instance (struct gcc_c_context *fe); | |
93 | ||
aaee65ae PA |
94 | /* Type used to hold and pass around the source and object file names |
95 | to use for compilation. */ | |
96 | class compile_file_names | |
97 | { | |
98 | public: | |
99 | compile_file_names (std::string source_file, std::string object_file) | |
100 | : m_source_file (source_file), m_object_file (object_file) | |
101 | {} | |
102 | ||
103 | /* Provide read-only views only. Return 'const char *' instead of | |
104 | std::string to avoid having to use c_str() everywhere in client | |
105 | code. */ | |
106 | ||
107 | const char *source_file () const | |
108 | { return m_source_file.c_str (); } | |
109 | ||
110 | const char *object_file () const | |
111 | { return m_object_file.c_str (); } | |
112 | ||
113 | private: | |
114 | /* Storage for the file names. */ | |
115 | std::string m_source_file; | |
116 | std::string m_object_file; | |
117 | }; | |
118 | ||
bb2ec1b3 | 119 | #endif /* GDB_COMPILE_INTERNAL_H */ |