[gdb/testsuite] Fix gdb.base/coredump-filter-build-id.exp with older eu-unstrip
[deliverable/binutils-gdb.git] / gdb / p-lang.h
1 /* Pascal language support definitions for GDB, the GNU debugger.
2
3 Copyright (C) 2000-2021 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 P_LANG_H
21 #define P_LANG_H
22
23 /* This file is derived from c-lang.h */
24
25 struct value;
26 struct parser_state;
27
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
38 extern 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
43 /* Defined in p-lang.c */
44
45 extern const char *pascal_main_name (void);
46
47 /* These are in p-lang.c: */
48
49 extern int is_pascal_string_type (struct type *, int *, int *, int *,
50 struct type **, const char **);
51
52 extern int pascal_object_is_vtbl_ptr_type (struct type *);
53
54 extern int pascal_object_is_vtbl_member (struct type *);
55
56 /* Class representing the Pascal language. */
57
58 class pascal_language : public language_defn
59 {
60 public:
61 pascal_language ()
62 : language_defn (language_pascal)
63 { /* Nothing. */ }
64
65 /* See language.h. */
66
67 const char *name () const override
68 { return "pascal"; }
69
70 /* See language.h. */
71
72 const char *natural_name () const override
73 { return "Pascal"; }
74
75 /* See language.h. */
76
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 }
83
84 /* See language.h. */
85
86 void language_arch_info (struct gdbarch *gdbarch,
87 struct language_arch_info *lai) const override;
88
89 /* See language.h. */
90
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 private:
158
159 /* Print the character C on STREAM as part of the contents of a literal
160 string. IN_QUOTES is reset to 0 if a char is written with #4 notation. */
161
162 void print_one_char (int c, struct ui_file *stream, int *in_quotes) const;
163
164 /* Print the name of the type (or the ultimate pointer target,
165 function value or array element), or the description of a
166 structure or union.
167
168 SHOW positive means print details about the type (e.g. enum values),
169 and print structure elements passing SHOW - 1 for show. SHOW negative
170 means just print the type name or struct tag if there is one. If
171 there is no name, print something sensible but concise like "struct
172 {...}".
173 SHOW zero means just print the type name or struct tag if there is one.
174 If there is no name, print something sensible but not as concise like
175 "struct {int x; int y;}".
176
177 LEVEL is the number of spaces to indent by.
178 We increase it for some recursive calls. */
179
180 void type_print_base (struct type *type, struct ui_file *stream, int show,
181 int level,
182 const struct type_print_options *flags) const;
183
184
185 /* Print any array sizes, function arguments or close parentheses
186 needed after the variable name (to describe its type).
187 Args work like pascal_type_print_varspec_prefix. */
188
189 void type_print_varspec_suffix (struct type *type, struct ui_file *stream,
190 int show, int passed_a_ptr,
191 int demangled_args,
192 const struct type_print_options *flags) const;
193
194 /* Helper for pascal_language::type_print_varspec_suffix to print the
195 suffix of a function or method. */
196
197 void type_print_func_varspec_suffix
198 (struct type *type, struct ui_file *stream, int show,
199 int passed_a_ptr, int demangled_args,
200 const struct type_print_options *flags) const;
201
202 /* Print any asterisks or open-parentheses needed before the
203 variable name (to describe its type).
204
205 On outermost call, pass 0 for PASSED_A_PTR.
206 On outermost call, SHOW > 0 means should ignore
207 any typename for TYPE and show its details.
208 SHOW is always zero on recursive calls. */
209
210 void type_print_varspec_prefix
211 (struct type *type, struct ui_file *stream, int show,
212 int passed_a_ptr, const struct type_print_options *flags) const;
213
214 /* Print the function args from TYPE (a TYPE_CODE_FUNC) to STREAM taking
215 FLAGS into account where appropriate. */
216
217 void print_func_args (struct type *type, struct ui_file *stream,
218 const struct type_print_options *flags) const;
219
220 /* Print the Pascal method arguments for PHYSNAME and METHODNAME to the
221 file STREAM. */
222
223 void type_print_method_args (const char *physname, const char *methodname,
224 struct ui_file *stream) const;
225
226 /* If TYPE is a derived type, then print out derivation information.
227 Print only the actual base classes of this type, not the base classes
228 of the base classes. I.e. for the derivation hierarchy:
229
230 class A { int a; };
231 class B : public A {int b; };
232 class C : public B {int c; };
233
234 Print the type of class C as:
235
236 class C : public B {
237 int c;
238 }
239
240 Not as the following (like gdb used to), which is not legal C++ syntax
241 for derived types and may be confused with the multiple inheritance
242 form:
243
244 class C : public B : public A {
245 int c;
246 }
247
248 In general, gdb should try to print the types as closely as possible
249 to the form that they appear in the source code. */
250
251 void type_print_derivation_info (struct ui_file *stream,
252 struct type *type) const;
253 };
254
255 #endif /* P_LANG_H */
This page took 0.035787 seconds and 4 git commands to generate.