Include scoped_fd.h in debuginfod-support.h
[deliverable/binutils-gdb.git] / gdb / p-lang.h
CommitLineData
373a8247 1/* Pascal language support definitions for GDB, the GNU debugger.
5bcca90b 2
3666a048 3 Copyright (C) 2000-2021 Free Software Foundation, Inc.
373a8247
PM
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
a9762ec7 9 the Free Software Foundation; either version 3 of the License, or
373a8247
PM
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
a9762ec7 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
373a8247 19
1a5c2598
TT
20#ifndef P_LANG_H
21#define P_LANG_H
22
373a8247
PM
23/* This file is derived from c-lang.h */
24
373a8247 25struct value;
410a0ff2 26struct parser_state;
373a8247 27
46157d77
AB
28/* Determines if type TYPE is a pascal string type. Returns a positive
29 value if the type is a known pascal string type. This function is used
30 by p-valprint.c code to allow better string display. If it is a pascal
31 string type, then it also sets info needed to get the length and the
32 data of the string length_pos, length_size and string_pos are given in
33 bytes. char_size gives the element size in bytes. FIXME: if the
34 position or the size of these fields are not multiple of TARGET_CHAR_BIT
35 then the results are wrong but this does not happen for Free Pascal nor
36 for GPC. */
37
38extern int pascal_is_string_type (struct type *type,int *length_pos,
39 int *length_size, int *string_pos,
40 struct type **char_type,
41 const char **arrayname);
42
cd6c7346 43/* Defined in p-lang.c */
46157d77 44
cd6c7346
PM
45extern const char *pascal_main_name (void);
46
46157d77 47/* These are in p-lang.c: */
373a8247 48
46157d77
AB
49extern int is_pascal_string_type (struct type *, int *, int *, int *,
50 struct type **, const char **);
373a8247 51
46157d77 52extern int pascal_object_is_vtbl_ptr_type (struct type *);
5c6ce71d 53
46157d77 54extern int pascal_object_is_vtbl_member (struct type *);
c0941be6 55
46157d77 56/* Class representing the Pascal language. */
c0941be6 57
46157d77
AB
58class pascal_language : public language_defn
59{
60public:
61 pascal_language ()
62 : language_defn (language_pascal)
63 { /* Nothing. */ }
373a8247 64
46157d77 65 /* See language.h. */
373a8247 66
46157d77
AB
67 const char *name () const override
68 { return "pascal"; }
373a8247 69
46157d77 70 /* See language.h. */
5598ce11 71
46157d77
AB
72 const char *natural_name () const override
73 { return "Pascal"; }
373a8247 74
46157d77 75 /* See language.h. */
373a8247 76
46157d77
AB
77 const std::vector<const char *> &filename_extensions () const override
78 {
79 static const std::vector<const char *> extensions
80 = { ".pas", ".p", ".pp" };
81 return extensions;
82 }
373a8247 83
46157d77 84 /* See language.h. */
373a8247 85
46157d77
AB
86 void language_arch_info (struct gdbarch *gdbarch,
87 struct language_arch_info *lai) const override;
373a8247 88
46157d77 89 /* See language.h. */
373a8247 90
46157d77
AB
91 void print_type (struct type *type, const char *varstring,
92 struct ui_file *stream, int show, int level,
93 const struct type_print_options *flags) const override;
94
95 /* See language.h. */
96
97 void value_print (struct value *val, struct ui_file *stream,
98 const struct value_print_options *options) const override;
99
100 /* See language.h. */
101
102 void value_print_inner
103 (struct value *val, struct ui_file *stream, int recurse,
104 const struct value_print_options *options) const override;
105
106 /* See language.h. */
107
108 int parser (struct parser_state *ps) const override;
109
110 /* See language.h. */
111
112 void emitchar (int ch, struct type *chtype,
113 struct ui_file *stream, int quoter) const override
114 {
115 int in_quotes = 0;
116
117 print_one_char (ch, stream, &in_quotes);
118 if (in_quotes)
119 fputs_filtered ("'", stream);
120 }
121
122 /* See language.h. */
123
124 void printchar (int ch, struct type *chtype,
125 struct ui_file *stream) const override;
126
127 /* See language.h. */
128
129 void printstr (struct ui_file *stream, struct type *elttype,
130 const gdb_byte *string, unsigned int length,
131 const char *encoding, int force_ellipses,
132 const struct value_print_options *options) const override;
133
134 /* See language.h. */
135
136 void print_typedef (struct type *type, struct symbol *new_symbol,
137 struct ui_file *stream) const override;
138
139 /* See language.h. */
140
141 bool is_string_type_p (struct type *type) const override
142 {
143 return pascal_is_string_type(type, nullptr, nullptr, nullptr,
144 nullptr, nullptr) > 0;
145 }
146
147 /* See language.h. */
148
149 const char *name_of_this () const override
150 { return "this"; }
151
152 /* See language.h. */
153
154 bool range_checking_on_by_default () const override
155 { return true; }
156
157 /* See language.h. */
158
159 const struct op_print *opcode_print_table () const override
160 { return op_print_tab; }
161
162private:
163
164 /* Table of opcode data for use by OPCODE_PRINT_TABLE member function. */
165
166 static const struct op_print op_print_tab[];
167
168 /* Print the character C on STREAM as part of the contents of a literal
169 string. IN_QUOTES is reset to 0 if a char is written with #4 notation. */
170
171 void print_one_char (int c, struct ui_file *stream, int *in_quotes) const;
172
173 /* Print the name of the type (or the ultimate pointer target,
174 function value or array element), or the description of a
175 structure or union.
176
177 SHOW positive means print details about the type (e.g. enum values),
178 and print structure elements passing SHOW - 1 for show. SHOW negative
179 means just print the type name or struct tag if there is one. If
180 there is no name, print something sensible but concise like "struct
181 {...}".
182 SHOW zero means just print the type name or struct tag if there is one.
183 If there is no name, print something sensible but not as concise like
184 "struct {int x; int y;}".
185
186 LEVEL is the number of spaces to indent by.
187 We increase it for some recursive calls. */
188
189 void type_print_base (struct type *type, struct ui_file *stream, int show,
190 int level,
191 const struct type_print_options *flags) const;
192
193
194 /* Print any array sizes, function arguments or close parentheses
195 needed after the variable name (to describe its type).
196 Args work like pascal_type_print_varspec_prefix. */
197
198 void type_print_varspec_suffix (struct type *type, struct ui_file *stream,
199 int show, int passed_a_ptr,
200 int demangled_args,
201 const struct type_print_options *flags) const;
202
203 /* Helper for pascal_language::type_print_varspec_suffix to print the
204 suffix of a function or method. */
205
206 void type_print_func_varspec_suffix
207 (struct type *type, struct ui_file *stream, int show,
208 int passed_a_ptr, int demangled_args,
209 const struct type_print_options *flags) const;
210
211 /* Print any asterisks or open-parentheses needed before the
212 variable name (to describe its type).
213
214 On outermost call, pass 0 for PASSED_A_PTR.
215 On outermost call, SHOW > 0 means should ignore
216 any typename for TYPE and show its details.
217 SHOW is always zero on recursive calls. */
218
219 void type_print_varspec_prefix
220 (struct type *type, struct ui_file *stream, int show,
221 int passed_a_ptr, const struct type_print_options *flags) const;
222
223 /* Print the function args from TYPE (a TYPE_CODE_FUNC) to STREAM taking
224 FLAGS into account where appropriate. */
225
226 void print_func_args (struct type *type, struct ui_file *stream,
227 const struct type_print_options *flags) const;
228
229 /* Print the Pascal method arguments for PHYSNAME and METHODNAME to the
230 file STREAM. */
231
232 void type_print_method_args (const char *physname, const char *methodname,
233 struct ui_file *stream) const;
234
235 /* If TYPE is a derived type, then print out derivation information.
236 Print only the actual base classes of this type, not the base classes
237 of the base classes. I.e. for the derivation hierarchy:
238
239 class A { int a; };
240 class B : public A {int b; };
241 class C : public B {int c; };
242
243 Print the type of class C as:
244
245 class C : public B {
246 int c;
247 }
248
249 Not as the following (like gdb used to), which is not legal C++ syntax
250 for derived types and may be confused with the multiple inheritance
251 form:
252
253 class C : public B : public A {
254 int c;
255 }
256
257 In general, gdb should try to print the types as closely as possible
258 to the form that they appear in the source code. */
259
260 void type_print_derivation_info (struct ui_file *stream,
261 struct type *type) const;
262};
1a5c2598
TT
263
264#endif /* P_LANG_H */
This page took 1.829976 seconds and 4 git commands to generate.