1 /* Interface between gdb and its extension languages.
3 Copyright (C) 2014 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 /* Enum of each extension(/scripting) language. */
53 enum extension_language
61 /* Extension language frame-filter status return values. */
63 enum ext_lang_bt_status
65 /* Return when an error has occurred in processing frame filters,
66 or when printing the stack. */
67 EXT_LANG_BT_ERROR = -1,
69 /* Return from internal routines to indicate that the function
73 /* Return when the frame filter process is complete, and all
74 operations have succeeded. */
75 EXT_LANG_BT_COMPLETED = 2,
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
82 /* Flags to pass to apply_extlang_frame_filter. */
84 enum frame_filter_flags
86 /* Set this flag if frame level is to be printed. */
89 /* Set this flag if frame information is to be printed. */
92 /* Set this flag if frame arguments are to be printed. */
95 /* Set this flag if frame locals are to be printed. */
99 /* A choice of the different frame argument printing strategies that
100 can occur in different cases of frame filter instantiation. */
102 enum ext_lang_frame_args
104 /* Print no values for arguments when invoked from the MI. */
105 NO_VALUES = PRINT_NO_VALUES,
107 MI_PRINT_ALL_VALUES = PRINT_ALL_VALUES,
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,
113 /* Print only scalar values for arguments when invoked from the CLI. */
116 /* Print all values for arguments when invoked from the CLI. */
120 /* The possible results of
121 extension_language_ops.breakpoint_cond_says_stop. */
123 enum ext_lang_bp_stop
125 /* No "stop" condition is set. */
126 EXT_LANG_BP_STOP_UNSET,
128 /* A "stop" condition is set, and it says "don't stop". */
131 /* A "stop" condition is set, and it says "stop". */
135 /* Table of type printers associated with the global typedef table. */
137 struct ext_lang_type_printers
139 /* Type-printers from Python. */
140 void *py_type_printers;
143 /* A type which holds its extension language specific xmethod worker data. */
145 struct xmethod_worker
147 /* The language the xmethod worker is implemented in. */
148 const struct extension_language_defn *extlang;
150 /* The extension language specific data for this xmethod worker. */
153 /* The TYPE_CODE_XMETHOD value corresponding to this worker.
154 Always use value_of_xmethod to access it. */
158 typedef struct xmethod_worker *xmethod_worker_ptr;
159 DEF_VEC_P (xmethod_worker_ptr);
160 typedef VEC (xmethod_worker_ptr) xmethod_worker_vec;
163 /* The interface for gdb's own extension(/scripting) language. */
164 extern const struct extension_language_defn extension_language_gdb;
166 extern const struct extension_language_defn *get_ext_lang_defn
167 (enum extension_language lang);
169 extern const struct extension_language_defn *get_ext_lang_of_file
172 extern int ext_lang_present_p (const struct extension_language_defn *);
174 extern int ext_lang_initialized_p (const struct extension_language_defn *);
176 extern void throw_ext_lang_unsupported
177 (const struct extension_language_defn *);
179 /* Accessors for "public" attributes of the extension language definition. */
181 extern enum extension_language ext_lang_kind
182 (const struct extension_language_defn *);
184 extern const char *ext_lang_name (const struct extension_language_defn *);
186 extern const char *ext_lang_capitalized_name
187 (const struct extension_language_defn *);
189 extern const char *ext_lang_suffix (const struct extension_language_defn *);
191 extern const char *ext_lang_auto_load_suffix
192 (const struct extension_language_defn *);
194 extern script_sourcer_func *ext_lang_script_sourcer
195 (const struct extension_language_defn *);
197 extern objfile_script_sourcer_func *ext_lang_objfile_script_sourcer
198 (const struct extension_language_defn *);
200 extern int ext_lang_auto_load_enabled (const struct extension_language_defn *);
202 /* Wrappers for each extension language API function that iterate over all
203 extension languages. */
205 extern void finish_ext_lang_initialization (void);
207 extern void eval_ext_lang_from_control_command (struct command_line *cmd);
209 extern void auto_load_ext_lang_scripts_for_objfile (struct objfile *);
211 extern struct ext_lang_type_printers *start_ext_lang_type_printers (void);
213 extern char *apply_ext_lang_type_printers (struct ext_lang_type_printers *,
216 extern void free_ext_lang_type_printers (struct ext_lang_type_printers *);
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);
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);
229 extern void preserve_ext_lang_values (struct objfile *, htab_t copied_types);
231 extern const struct extension_language_defn *get_breakpoint_cond_ext_lang
232 (struct breakpoint *b, enum extension_language skip_lang);
234 extern int breakpoint_ext_lang_cond_says_stop (struct breakpoint *);
236 extern struct value *invoke_xmethod (struct xmethod_worker *,
238 struct value **, int nargs);
240 extern struct xmethod_worker *clone_xmethod_worker (struct xmethod_worker *);
242 extern struct xmethod_worker *new_xmethod_worker
243 (const struct extension_language_defn *extlang, void *data);
245 extern void free_xmethod_worker (struct xmethod_worker *);
247 extern void free_xmethod_worker_vec (void *vec);
249 extern xmethod_worker_vec *get_matching_xmethod_workers
250 (struct type *, const char *);
252 extern struct type **get_xmethod_arg_types (struct xmethod_worker *, int *);
254 #endif /* EXTENSION_H */