Import alloca explicitly
[deliverable/binutils-gdb.git] / gdb / extension.h
1 /* Interface between gdb and its extension languages.
2
3 Copyright (C) 2014 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 #ifndef EXTENSION_H
21 #define EXTENSION_H
22
23 #include "mi/mi-cmds.h" /* For PRINT_NO_VALUES, etc. */
24 #include "common/vec.h"
25
26 struct breakpoint;
27 struct command_line;
28 struct frame_info;
29 struct language_defn;
30 struct objfile;
31 struct extension_language_defn;
32 struct type;
33 struct ui_file;
34 struct ui_out;
35 struct value;
36 struct value_print_options;
37
38 /* A function to load and process a script file.
39 The file has been opened and is ready to be read from the beginning.
40 Any exceptions are not caught, and are passed to the caller. */
41 typedef void script_sourcer_func (const struct extension_language_defn *,
42 FILE *stream, const char *filename);
43
44 /* A function to load and process a script for an objfile.
45 The file has been opened and is ready to be read from the beginning.
46 Any exceptions are not caught, and are passed to the caller. */
47 typedef void objfile_script_sourcer_func
48 (const struct extension_language_defn *,
49 struct objfile *, FILE *stream, const char *filename);
50
51 /* Enum of each extension(/scripting) language. */
52
53 enum extension_language
54 {
55 EXT_LANG_NONE,
56 EXT_LANG_GDB,
57 EXT_LANG_PYTHON,
58 EXT_LANG_GUILE
59 };
60
61 /* Extension language frame-filter status return values. */
62
63 enum ext_lang_bt_status
64 {
65 /* Return when an error has occurred in processing frame filters,
66 or when printing the stack. */
67 EXT_LANG_BT_ERROR = -1,
68
69 /* Return from internal routines to indicate that the function
70 succeeded. */
71 EXT_LANG_BT_OK = 1,
72
73 /* Return when the frame filter process is complete, and all
74 operations have succeeded. */
75 EXT_LANG_BT_COMPLETED = 2,
76
77 /* Return when the frame filter process is complete, but there
78 were no filter registered and enabled to process. */
79 EXT_LANG_BT_NO_FILTERS = 3
80 };
81
82 /* Flags to pass to apply_extlang_frame_filter. */
83
84 enum frame_filter_flags
85 {
86 /* Set this flag if frame level is to be printed. */
87 PRINT_LEVEL = 1,
88
89 /* Set this flag if frame information is to be printed. */
90 PRINT_FRAME_INFO = 2,
91
92 /* Set this flag if frame arguments are to be printed. */
93 PRINT_ARGS = 4,
94
95 /* Set this flag if frame locals are to be printed. */
96 PRINT_LOCALS = 8,
97 };
98
99 /* A choice of the different frame argument printing strategies that
100 can occur in different cases of frame filter instantiation. */
101
102 enum ext_lang_frame_args
103 {
104 /* Print no values for arguments when invoked from the MI. */
105 NO_VALUES = PRINT_NO_VALUES,
106
107 MI_PRINT_ALL_VALUES = PRINT_ALL_VALUES,
108
109 /* Print only simple values (what MI defines as "simple") for
110 arguments when invoked from the MI. */
111 MI_PRINT_SIMPLE_VALUES = PRINT_SIMPLE_VALUES,
112
113 /* Print only scalar values for arguments when invoked from the CLI. */
114 CLI_SCALAR_VALUES,
115
116 /* Print all values for arguments when invoked from the CLI. */
117 CLI_ALL_VALUES
118 };
119
120 /* The possible results of
121 extension_language_ops.breakpoint_cond_says_stop. */
122
123 enum ext_lang_bp_stop
124 {
125 /* No "stop" condition is set. */
126 EXT_LANG_BP_STOP_UNSET,
127
128 /* A "stop" condition is set, and it says "don't stop". */
129 EXT_LANG_BP_STOP_NO,
130
131 /* A "stop" condition is set, and it says "stop". */
132 EXT_LANG_BP_STOP_YES
133 };
134
135 /* Table of type printers associated with the global typedef table. */
136
137 struct ext_lang_type_printers
138 {
139 /* Type-printers from Python. */
140 void *py_type_printers;
141 };
142
143 /* A type which holds its extension language specific xmethod worker data. */
144
145 struct xmethod_worker
146 {
147 /* The language the xmethod worker is implemented in. */
148 const struct extension_language_defn *extlang;
149
150 /* The extension language specific data for this xmethod worker. */
151 void *data;
152
153 /* The TYPE_CODE_XMETHOD value corresponding to this worker.
154 Always use value_of_xmethod to access it. */
155 struct value *value;
156 };
157
158 typedef struct xmethod_worker *xmethod_worker_ptr;
159 DEF_VEC_P (xmethod_worker_ptr);
160 typedef VEC (xmethod_worker_ptr) xmethod_worker_vec;
161
162 \f
163 /* The interface for gdb's own extension(/scripting) language. */
164 extern const struct extension_language_defn extension_language_gdb;
165
166 extern const struct extension_language_defn *get_ext_lang_defn
167 (enum extension_language lang);
168
169 extern const struct extension_language_defn *get_ext_lang_of_file
170 (const char *file);
171
172 extern int ext_lang_present_p (const struct extension_language_defn *);
173
174 extern int ext_lang_initialized_p (const struct extension_language_defn *);
175
176 extern void throw_ext_lang_unsupported
177 (const struct extension_language_defn *);
178
179 /* Accessors for "public" attributes of the extension language definition. */
180
181 extern enum extension_language ext_lang_kind
182 (const struct extension_language_defn *);
183
184 extern const char *ext_lang_name (const struct extension_language_defn *);
185
186 extern const char *ext_lang_capitalized_name
187 (const struct extension_language_defn *);
188
189 extern const char *ext_lang_suffix (const struct extension_language_defn *);
190
191 extern const char *ext_lang_auto_load_suffix
192 (const struct extension_language_defn *);
193
194 extern script_sourcer_func *ext_lang_script_sourcer
195 (const struct extension_language_defn *);
196
197 extern objfile_script_sourcer_func *ext_lang_objfile_script_sourcer
198 (const struct extension_language_defn *);
199
200 extern int ext_lang_auto_load_enabled (const struct extension_language_defn *);
201
202 /* Wrappers for each extension language API function that iterate over all
203 extension languages. */
204
205 extern void finish_ext_lang_initialization (void);
206
207 extern void eval_ext_lang_from_control_command (struct command_line *cmd);
208
209 extern void auto_load_ext_lang_scripts_for_objfile (struct objfile *);
210
211 extern struct ext_lang_type_printers *start_ext_lang_type_printers (void);
212
213 extern char *apply_ext_lang_type_printers (struct ext_lang_type_printers *,
214 struct type *);
215
216 extern void free_ext_lang_type_printers (struct ext_lang_type_printers *);
217
218 extern int apply_ext_lang_val_pretty_printer
219 (struct type *type, const gdb_byte *valaddr,
220 int embedded_offset, CORE_ADDR address,
221 struct ui_file *stream, int recurse,
222 const struct value *val, const struct value_print_options *options,
223 const struct language_defn *language);
224
225 extern enum ext_lang_bt_status apply_ext_lang_frame_filter
226 (struct frame_info *frame, int flags, enum ext_lang_frame_args args_type,
227 struct ui_out *out, int frame_low, int frame_high);
228
229 extern void preserve_ext_lang_values (struct objfile *, htab_t copied_types);
230
231 extern const struct extension_language_defn *get_breakpoint_cond_ext_lang
232 (struct breakpoint *b, enum extension_language skip_lang);
233
234 extern int breakpoint_ext_lang_cond_says_stop (struct breakpoint *);
235
236 extern struct value *invoke_xmethod (struct xmethod_worker *,
237 struct value *,
238 struct value **, int nargs);
239
240 extern struct xmethod_worker *clone_xmethod_worker (struct xmethod_worker *);
241
242 extern struct xmethod_worker *new_xmethod_worker
243 (const struct extension_language_defn *extlang, void *data);
244
245 extern void free_xmethod_worker (struct xmethod_worker *);
246
247 extern void free_xmethod_worker_vec (void *vec);
248
249 extern xmethod_worker_vec *get_matching_xmethod_workers
250 (struct type *, const char *);
251
252 extern struct type **get_xmethod_arg_types (struct xmethod_worker *, int *);
253
254 #endif /* EXTENSION_H */
This page took 0.039602 seconds and 4 git commands to generate.