1 /* Pascal language support definitions for GDB, the GNU debugger.
3 Copyright (C) 2000-2024 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 /* This file is derived from c-lang.h */
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
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
);
43 /* Defined in p-lang.c */
45 extern const char *pascal_main_name (void);
47 /* These are in p-lang.c: */
49 extern int is_pascal_string_type (struct type
*, int *, int *, int *,
50 struct type
**, const char **);
52 extern int pascal_object_is_vtbl_ptr_type (struct type
*);
54 extern int pascal_object_is_vtbl_member (struct type
*);
56 /* Class representing the Pascal language. */
58 class pascal_language
: public language_defn
62 : language_defn (language_pascal
)
67 const char *name () const override
72 const char *natural_name () const override
77 const std::vector
<const char *> &filename_extensions () const override
79 static const std::vector
<const char *> extensions
80 = { ".pas", ".p", ".pp" };
86 void language_arch_info (struct gdbarch
*gdbarch
,
87 struct language_arch_info
*lai
) const override
;
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
;
97 void value_print (struct value
*val
, struct ui_file
*stream
,
98 const struct value_print_options
*options
) const override
;
100 /* See language.h. */
102 void value_print_inner
103 (struct value
*val
, struct ui_file
*stream
, int recurse
,
104 const struct value_print_options
*options
) const override
;
106 /* See language.h. */
108 int parser (struct parser_state
*ps
) const override
;
110 /* See language.h. */
112 void emitchar (int ch
, struct type
*chtype
,
113 struct ui_file
*stream
, int quoter
) const override
117 print_one_char (ch
, stream
, &in_quotes
);
119 gdb_puts ("'", stream
);
122 /* See language.h. */
124 void printchar (int ch
, struct type
*chtype
,
125 struct ui_file
*stream
) const override
;
127 /* See language.h. */
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
;
134 /* See language.h. */
136 void print_typedef (struct type
*type
, struct symbol
*new_symbol
,
137 struct ui_file
*stream
) const override
;
139 /* See language.h. */
141 bool is_string_type_p (struct type
*type
) const override
143 return pascal_is_string_type(type
, nullptr, nullptr, nullptr,
144 nullptr, nullptr) > 0;
147 /* See language.h. */
149 const char *name_of_this () const override
152 /* See language.h. */
154 bool range_checking_on_by_default () const override
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. */
162 void print_one_char (int c
, struct ui_file
*stream
, int *in_quotes
) const;
164 /* Print the name of the type (or the ultimate pointer target,
165 function value or array element), or the description of a
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
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;}".
177 LEVEL is the number of spaces to indent by.
178 We increase it for some recursive calls. */
180 void type_print_base (struct type
*type
, struct ui_file
*stream
, int show
,
182 const struct type_print_options
*flags
) const;
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. */
189 void type_print_varspec_suffix (struct type
*type
, struct ui_file
*stream
,
190 int show
, int passed_a_ptr
,
192 const struct type_print_options
*flags
) const;
194 /* Helper for pascal_language::type_print_varspec_suffix to print the
195 suffix of a function or method. */
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;
202 /* Print any asterisks or open-parentheses needed before the
203 variable name (to describe its type).
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. */
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;
214 /* Print the function args from TYPE (a TYPE_CODE_FUNC) to STREAM taking
215 FLAGS into account where appropriate. */
217 void print_func_args (struct type
*type
, struct ui_file
*stream
,
218 const struct type_print_options
*flags
) const;
220 /* Print the Pascal method arguments for PHYSNAME and METHODNAME to the
223 void type_print_method_args (const char *physname
, const char *methodname
,
224 struct ui_file
*stream
) const;
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:
231 class B : public A {int b; };
232 class C : public B {int c; };
234 Print the type of class C as:
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
244 class C : public B : public A {
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. */
251 void type_print_derivation_info (struct ui_file
*stream
,
252 struct type
*type
) const;
255 #endif /* P_LANG_H */