Extension Language API
[deliverable/binutils-gdb.git] / gdb / extension.h
CommitLineData
6dddc817
DE
1/* Interface between gdb and its extension languages.
2
3 Copyright (C) 2013 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
25struct breakpoint;
26struct command_line;
27struct frame_info;
28struct language_defn;
29struct objfile;
30struct extension_language_defn;
31struct type;
32struct ui_file;
33struct ui_out;
34struct value;
35struct value_print_options;
36
37/* A function to load and process a script file.
38 The file has been opened and is ready to be read from the beginning.
39 Any exceptions are not caught, and are passed to the caller. */
40typedef void script_sourcer_func (const struct extension_language_defn *,
41 FILE *stream, const char *filename);
42
43/* A function to load and process a script for an objfile.
44 The file has been opened and is ready to be read from the beginning.
45 Any exceptions are not caught, and are passed to the caller. */
46typedef void objfile_script_sourcer_func
47 (const struct extension_language_defn *,
48 struct objfile *, FILE *stream, const char *filename);
49
50/* Enum of each extension(/scripting) language. */
51
52enum extension_language
53 {
54 EXT_LANG_NONE,
55 EXT_LANG_GDB,
56 EXT_LANG_PYTHON
57 };
58
59/* Extension language frame-filter status return values. */
60
61enum ext_lang_bt_status
62 {
63 /* Return when an error has occurred in processing frame filters,
64 or when printing the stack. */
65 EXT_LANG_BT_ERROR = -1,
66
67 /* Return from internal routines to indicate that the function
68 succeeded. */
69 EXT_LANG_BT_OK = 1,
70
71 /* Return when the frame filter process is complete, and all
72 operations have succeeded. */
73 EXT_LANG_BT_COMPLETED = 2,
74
75 /* Return when the frame filter process is complete, but there
76 were no filter registered and enabled to process. */
77 EXT_LANG_BT_NO_FILTERS = 3
78 };
79
80/* Flags to pass to apply_extlang_frame_filter. */
81
82enum frame_filter_flags
83 {
84 /* Set this flag if frame level is to be printed. */
85 PRINT_LEVEL = 1,
86
87 /* Set this flag if frame information is to be printed. */
88 PRINT_FRAME_INFO = 2,
89
90 /* Set this flag if frame arguments are to be printed. */
91 PRINT_ARGS = 4,
92
93 /* Set this flag if frame locals are to be printed. */
94 PRINT_LOCALS = 8,
95 };
96
97/* A choice of the different frame argument printing strategies that
98 can occur in different cases of frame filter instantiation. */
99
100enum ext_lang_frame_args
101 {
102 /* Print no values for arguments when invoked from the MI. */
103 NO_VALUES = PRINT_NO_VALUES,
104
105 MI_PRINT_ALL_VALUES = PRINT_ALL_VALUES,
106
107 /* Print only simple values (what MI defines as "simple") for
108 arguments when invoked from the MI. */
109 MI_PRINT_SIMPLE_VALUES = PRINT_SIMPLE_VALUES,
110
111 /* Print only scalar values for arguments when invoked from the CLI. */
112 CLI_SCALAR_VALUES,
113
114 /* Print all values for arguments when invoked from the CLI. */
115 CLI_ALL_VALUES
116 };
117
118/* The possible results of
119 extension_language_ops.breakpoint_cond_says_stop. */
120
121enum ext_lang_bp_stop
122 {
123 /* No "stop" condition is set. */
124 EXT_LANG_BP_STOP_UNSET,
125
126 /* A "stop" condition is set, and it says "don't stop". */
127 EXT_LANG_BP_STOP_NO,
128
129 /* A "stop" condition is set, and it says "stop". */
130 EXT_LANG_BP_STOP_YES
131 };
132
133/* Table of type printers associated with the global typedef table. */
134
135struct ext_lang_type_printers
136{
137 /* Type-printers from Python. */
138 void *py_type_printers;
139};
140\f
141/* The interface for gdb's own extension(/scripting) language. */
142extern const struct extension_language_defn extension_language_gdb;
143
144extern const struct extension_language_defn *get_ext_lang_defn
145 (enum extension_language lang);
146
147extern const struct extension_language_defn *get_ext_lang_of_file
148 (const char *file);
149
150extern int ext_lang_present_p (const struct extension_language_defn *);
151
152extern int ext_lang_initialized_p (const struct extension_language_defn *);
153
154extern void throw_ext_lang_unsupported
155 (const struct extension_language_defn *);
156
157/* Accessors for "public" attributes of the extension language definition. */
158
159extern enum extension_language ext_lang_kind
160 (const struct extension_language_defn *);
161
162extern const char *ext_lang_name (const struct extension_language_defn *);
163
164extern const char *ext_lang_capitalized_name
165 (const struct extension_language_defn *);
166
167extern const char *ext_lang_suffix (const struct extension_language_defn *);
168
169extern const char *ext_lang_auto_load_suffix
170 (const struct extension_language_defn *);
171
172extern script_sourcer_func *ext_lang_script_sourcer
173 (const struct extension_language_defn *);
174
175extern objfile_script_sourcer_func *ext_lang_objfile_script_sourcer
176 (const struct extension_language_defn *);
177
178extern int ext_lang_auto_load_enabled (const struct extension_language_defn *);
179
180/* Wrappers for each extension language API function that iterate over all
181 extension languages. */
182
183extern void finish_ext_lang_initialization (void);
184
185extern void eval_ext_lang_from_control_command (struct command_line *cmd);
186
187extern void auto_load_ext_lang_scripts_for_objfile (struct objfile *);
188
189extern struct ext_lang_type_printers *start_ext_lang_type_printers (void);
190
191extern char *apply_ext_lang_type_printers (struct ext_lang_type_printers *,
192 struct type *);
193
194extern void free_ext_lang_type_printers (struct ext_lang_type_printers *);
195
196extern int apply_ext_lang_val_pretty_printer
197 (struct type *type, const gdb_byte *valaddr,
198 int embedded_offset, CORE_ADDR address,
199 struct ui_file *stream, int recurse,
200 const struct value *val, const struct value_print_options *options,
201 const struct language_defn *language);
202
203extern enum ext_lang_bt_status apply_ext_lang_frame_filter
204 (struct frame_info *frame, int flags, enum ext_lang_frame_args args_type,
205 struct ui_out *out, int frame_low, int frame_high);
206
207extern void preserve_ext_lang_values (struct objfile *, htab_t copied_types);
208
209extern const struct extension_language_defn *get_breakpoint_cond_ext_lang
210 (struct breakpoint *b, enum extension_language skip_lang);
211
212extern int breakpoint_ext_lang_cond_says_stop (struct breakpoint *);
213
214#endif /* EXTENSION_H */
This page took 0.033012 seconds and 4 git commands to generate.