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