1 /* Interface between gdb and its extension languages.
3 Copyright (C) 2014-2016 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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/>. */
23 #include "mi/mi-cmds.h" /* For PRINT_NO_VALUES, etc. */
24 #include "common/vec.h"
31 struct extension_language_defn;
36 struct value_print_options;
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);
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);
51 /* A function to execute a script for an objfile.
52 Any exceptions are not caught, and are passed to the caller. */
53 typedef void objfile_script_executor_func
54 (const struct extension_language_defn *,
55 struct objfile *, const char *name, const char *script);
57 /* Enum of each extension(/scripting) language. */
59 enum extension_language
67 /* Extension language frame-filter status return values. */
69 enum ext_lang_bt_status
71 /* Return when an error has occurred in processing frame filters,
72 or when printing the stack. */
73 EXT_LANG_BT_ERROR = -1,
75 /* Return from internal routines to indicate that the function
79 /* Return when the frame filter process is complete, and all
80 operations have succeeded. */
81 EXT_LANG_BT_COMPLETED = 2,
83 /* Return when the frame filter process is complete, but there
84 were no filter registered and enabled to process. */
85 EXT_LANG_BT_NO_FILTERS = 3
88 /* Flags to pass to apply_extlang_frame_filter. */
90 enum frame_filter_flags
92 /* Set this flag if frame level is to be printed. */
95 /* Set this flag if frame information is to be printed. */
98 /* Set this flag if frame arguments are to be printed. */
101 /* Set this flag if frame locals are to be printed. */
105 /* A choice of the different frame argument printing strategies that
106 can occur in different cases of frame filter instantiation. */
108 enum ext_lang_frame_args
110 /* Print no values for arguments when invoked from the MI. */
111 NO_VALUES = PRINT_NO_VALUES,
113 MI_PRINT_ALL_VALUES = PRINT_ALL_VALUES,
115 /* Print only simple values (what MI defines as "simple") for
116 arguments when invoked from the MI. */
117 MI_PRINT_SIMPLE_VALUES = PRINT_SIMPLE_VALUES,
119 /* Print only scalar values for arguments when invoked from the CLI. */
122 /* Print all values for arguments when invoked from the CLI. */
126 /* The possible results of
127 extension_language_ops.breakpoint_cond_says_stop. */
129 enum ext_lang_bp_stop
131 /* No "stop" condition is set. */
132 EXT_LANG_BP_STOP_UNSET,
134 /* A "stop" condition is set, and it says "don't stop". */
137 /* A "stop" condition is set, and it says "stop". */
141 /* Table of type printers associated with the global typedef table. */
143 struct ext_lang_type_printers
145 /* Type-printers from Python. */
146 void *py_type_printers;
149 /* A type which holds its extension language specific xmethod worker data. */
151 struct xmethod_worker
153 /* The language the xmethod worker is implemented in. */
154 const struct extension_language_defn *extlang;
156 /* The extension language specific data for this xmethod worker. */
159 /* The TYPE_CODE_XMETHOD value corresponding to this worker.
160 Always use value_of_xmethod to access it. */
164 typedef struct xmethod_worker *xmethod_worker_ptr;
165 DEF_VEC_P (xmethod_worker_ptr);
166 typedef VEC (xmethod_worker_ptr) xmethod_worker_vec;
169 /* The interface for gdb's own extension(/scripting) language. */
170 extern const struct extension_language_defn extension_language_gdb;
172 extern const struct extension_language_defn *get_ext_lang_defn
173 (enum extension_language lang);
175 extern const struct extension_language_defn *get_ext_lang_of_file
178 extern int ext_lang_present_p (const struct extension_language_defn *);
180 extern int ext_lang_initialized_p (const struct extension_language_defn *);
182 extern void throw_ext_lang_unsupported
183 (const struct extension_language_defn *);
185 /* Accessors for "public" attributes of the extension language definition. */
187 extern enum extension_language ext_lang_kind
188 (const struct extension_language_defn *);
190 extern const char *ext_lang_name (const struct extension_language_defn *);
192 extern const char *ext_lang_capitalized_name
193 (const struct extension_language_defn *);
195 extern const char *ext_lang_suffix (const struct extension_language_defn *);
197 extern const char *ext_lang_auto_load_suffix
198 (const struct extension_language_defn *);
200 extern script_sourcer_func *ext_lang_script_sourcer
201 (const struct extension_language_defn *);
203 extern objfile_script_sourcer_func *ext_lang_objfile_script_sourcer
204 (const struct extension_language_defn *);
206 extern objfile_script_executor_func *ext_lang_objfile_script_executor
207 (const struct extension_language_defn *);
209 extern int ext_lang_auto_load_enabled (const struct extension_language_defn *);
211 /* Wrappers for each extension language API function that iterate over all
212 extension languages. */
214 extern void finish_ext_lang_initialization (void);
216 extern void eval_ext_lang_from_control_command (struct command_line *cmd);
218 extern void auto_load_ext_lang_scripts_for_objfile (struct objfile *);
220 extern struct ext_lang_type_printers *start_ext_lang_type_printers (void);
222 extern char *apply_ext_lang_type_printers (struct ext_lang_type_printers *,
225 extern void free_ext_lang_type_printers (struct ext_lang_type_printers *);
227 extern int apply_ext_lang_val_pretty_printer
229 LONGEST embedded_offset, CORE_ADDR address,
230 struct ui_file *stream, int recurse,
231 struct value *val, const struct value_print_options *options,
232 const struct language_defn *language);
234 extern enum ext_lang_bt_status apply_ext_lang_frame_filter
235 (struct frame_info *frame, int flags, enum ext_lang_frame_args args_type,
236 struct ui_out *out, int frame_low, int frame_high);
238 extern void preserve_ext_lang_values (struct objfile *, htab_t copied_types);
240 extern const struct extension_language_defn *get_breakpoint_cond_ext_lang
241 (struct breakpoint *b, enum extension_language skip_lang);
243 extern int breakpoint_ext_lang_cond_says_stop (struct breakpoint *);
245 extern struct value *invoke_xmethod (struct xmethod_worker *,
247 struct value **, int nargs);
249 extern struct xmethod_worker *clone_xmethod_worker (struct xmethod_worker *);
251 extern struct xmethod_worker *new_xmethod_worker
252 (const struct extension_language_defn *extlang, void *data);
254 extern void free_xmethod_worker (struct xmethod_worker *);
256 extern void free_xmethod_worker_vec (void *vec);
258 extern xmethod_worker_vec *get_matching_xmethod_workers
259 (struct type *, const char *);
261 extern struct type **get_xmethod_arg_types (struct xmethod_worker *, int *);
263 extern struct type *get_xmethod_result_type (struct xmethod_worker *,
264 struct value *object,
265 struct value **args, int nargs);
267 #endif /* EXTENSION_H */