1 /* C language support routines for GDB, the GNU debugger.
3 Copyright (C) 1992-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 #include "expression.h"
24 #include "parser-defs.h"
28 #include "c-support.h"
30 #include "macroscope.h"
34 #include "cp-support.h"
35 #include "gdbsupport/gdb_obstack.h"
41 /* Given a C string type, STR_TYPE, return the corresponding target
42 character set name. */
45 charset_for_string_type (c_string_type str_type
, struct gdbarch
*gdbarch
)
47 switch (str_type
& ~C_CHAR
)
50 return target_charset (gdbarch
);
52 return target_wide_charset (gdbarch
);
54 /* FIXME: UTF-16 is not always correct. */
55 if (gdbarch_byte_order (gdbarch
) == BFD_ENDIAN_BIG
)
60 /* FIXME: UTF-32 is not always correct. */
61 if (gdbarch_byte_order (gdbarch
) == BFD_ENDIAN_BIG
)
66 internal_error (_("unhandled c_string_type"));
69 /* Classify ELTTYPE according to what kind of character it is. Return
70 the enum constant representing the character type. Also set
71 *ENCODING to the name of the character set to use when converting
72 characters of this type in target BYTE_ORDER to the host character
76 classify_type (struct type
*elttype
, struct gdbarch
*gdbarch
,
77 const char **encoding
)
81 /* We loop because ELTTYPE may be a typedef, and we want to
82 successively peel each typedef until we reach a type we
83 understand. We don't use CHECK_TYPEDEF because that will strip
84 all typedefs at once -- but in C, wchar_t is itself a typedef, so
85 that would do the wrong thing. */
88 const char *name
= elttype
->name ();
96 if (!strcmp (name
, "wchar_t"))
102 if (!strcmp (name
, "char16_t"))
108 if (!strcmp (name
, "char32_t"))
114 if (elttype
->code () != TYPE_CODE_TYPEDEF
)
117 /* Call for side effects. */
118 check_typedef (elttype
);
120 if (elttype
->target_type ())
121 elttype
= elttype
->target_type ();
124 /* Perhaps check_typedef did not update the target type. In
125 this case, force the lookup again and hope it works out.
126 It never will for C, but it might for C++. */
127 elttype
= check_typedef (elttype
);
136 *encoding
= charset_for_string_type (result
, gdbarch
);
141 /* Print the character C on STREAM as part of the contents of a
142 literal string whose delimiter is QUOTER. Note that that format
143 for printing characters and strings is language specific. */
146 language_defn::emitchar (int c
, struct type
*type
,
147 struct ui_file
*stream
, int quoter
) const
149 const char *encoding
;
151 classify_type (type
, type
->arch (), &encoding
);
152 generic_emit_char (c
, type
, stream
, quoter
, encoding
);
155 /* See language.h. */
158 language_defn::printchar (int c
, struct type
*type
,
159 struct ui_file
* stream
) const
161 c_string_type str_type
;
163 str_type
= classify_type (type
, type
->arch (), NULL
);
169 gdb_putc ('L', stream
);
172 gdb_putc ('u', stream
);
175 gdb_putc ('U', stream
);
179 gdb_putc ('\'', stream
);
180 emitchar (c
, type
, stream
, '\'');
181 gdb_putc ('\'', stream
);
184 /* Print the character string STRING, printing at most LENGTH
185 characters. LENGTH is -1 if the string is nul terminated. Each
186 character is WIDTH bytes long. Printing stops early if the number
187 hits print_max_chars; repeat counts are printed as appropriate.
188 Print ellipses at the end if we had to stop before printing LENGTH
189 characters, or if FORCE_ELLIPSES. */
192 language_defn::printstr (struct ui_file
*stream
, struct type
*type
,
193 const gdb_byte
*string
, unsigned int length
,
194 const char *user_encoding
, int force_ellipses
,
195 const struct value_print_options
*options
) const
197 c_string_type str_type
;
198 const char *type_encoding
;
199 const char *encoding
;
201 str_type
= (classify_type (type
, type
->arch (), &type_encoding
)
208 gdb_puts ("L", stream
);
211 gdb_puts ("u", stream
);
214 gdb_puts ("U", stream
);
218 encoding
= (user_encoding
&& *user_encoding
) ? user_encoding
: type_encoding
;
220 generic_printstr (stream
, type
, string
, length
, encoding
, force_ellipses
,
224 /* Obtain a C string from the inferior storing it in a newly allocated
225 buffer in BUFFER, which should be freed by the caller. If the in-
226 and out-parameter *LENGTH is specified at -1, the string is read
227 until a null character of the appropriate width is found, otherwise
228 the string is read to the length of characters specified. The size
229 of a character is determined by the length of the target type of
230 the pointer or array.
232 If VALUE is an array with a known length, and *LENGTH is -1,
233 the function will not read past the end of the array. However, any
234 declared size of the array is ignored if *LENGTH > 0.
236 On completion, *LENGTH will be set to the size of the string read in
237 characters. (If a length of -1 is specified, the length returned
238 will not include the null character). CHARSET is always set to the
242 c_get_string (struct value
*value
, gdb::unique_xmalloc_ptr
<gdb_byte
> *buffer
,
243 int *length
, struct type
**char_type
,
244 const char **charset
)
247 unsigned int fetchlimit
;
248 struct type
*type
= check_typedef (value
->type ());
249 struct type
*element_type
= type
->target_type ();
250 int req_length
= *length
;
251 enum bfd_endian byte_order
252 = type_byte_order (type
);
254 if (element_type
== NULL
)
257 if (type
->code () == TYPE_CODE_ARRAY
)
259 /* If we know the size of the array, we can use it as a limit on
260 the number of characters to be fetched. */
261 if (type
->num_fields () == 1
262 && type
->field (0).type ()->code () == TYPE_CODE_RANGE
)
264 LONGEST low_bound
, high_bound
;
266 get_discrete_bounds (type
->field (0).type (),
267 &low_bound
, &high_bound
);
268 fetchlimit
= high_bound
- low_bound
+ 1;
271 fetchlimit
= UINT_MAX
;
273 else if (type
->code () == TYPE_CODE_PTR
)
274 fetchlimit
= UINT_MAX
;
276 /* We work only with arrays and pointers. */
279 if (! c_textual_element_type (element_type
, 0))
281 classify_type (element_type
, element_type
->arch (), charset
);
282 width
= element_type
->length ();
284 /* If the string lives in GDB's memory instead of the inferior's,
285 then we just need to copy it to BUFFER. Also, since such strings
286 are arrays with known size, FETCHLIMIT will hold the size of the
289 An array is assumed to live in GDB's memory, so we take this path
292 However, it's possible for the caller to request more array
293 elements than apparently exist -- this can happen when using the
294 C struct hack. So, only do this if either no length was
295 specified, or the length is within the existing bounds. This
296 avoids running off the end of the value's contents. */
297 if ((value
->lval () == not_lval
298 || value
->lval () == lval_internalvar
299 || type
->code () == TYPE_CODE_ARRAY
)
300 && fetchlimit
!= UINT_MAX
301 && (*length
< 0 || *length
<= fetchlimit
))
304 const gdb_byte
*contents
= value
->contents ().data ();
306 /* If a length is specified, use that. */
310 /* Otherwise, look for a null character. */
311 for (i
= 0; i
< fetchlimit
; i
++)
312 if (extract_unsigned_integer (contents
+ i
* width
,
313 width
, byte_order
) == 0)
316 /* I is now either a user-defined length, the number of non-null
317 characters, or FETCHLIMIT. */
319 buffer
->reset ((gdb_byte
*) xmalloc (*length
));
320 memcpy (buffer
->get (), contents
, *length
);
325 /* value_as_address does not return an address for an array when
326 c_style_arrays is false, so we handle that specially
329 if (type
->code () == TYPE_CODE_ARRAY
)
331 if (value
->lval () != lval_memory
)
332 error (_("Attempt to take address of value "
333 "not located in memory."));
334 addr
= value
->address ();
337 addr
= value_as_address (value
);
339 /* Prior to the fix for PR 16196 read_string would ignore fetchlimit
340 if length > 0. The old "broken" behaviour is the behaviour we want:
341 The caller may want to fetch 100 bytes from a variable length array
342 implemented using the common idiom of having an array of length 1 at
343 the end of a struct. In this case we want to ignore the declared
344 size of the array. However, it's counterintuitive to implement that
345 behaviour in read_string: what does fetchlimit otherwise mean if
346 length > 0. Therefore we implement the behaviour we want here:
347 If *length > 0, don't specify a fetchlimit. This preserves the
348 previous behaviour. We could move this check above where we know
349 whether the array is declared with a fixed size, but we only want
350 to apply this behaviour when calling read_string. PR 16286. */
352 fetchlimit
= UINT_MAX
;
354 err
= target_read_string (addr
, *length
, width
, fetchlimit
,
357 memory_error (TARGET_XFER_E_IO
, addr
);
360 /* If the LENGTH is specified at -1, we want to return the string
361 length up to the terminating null character. If an actual length
362 was specified, we want to return the length of exactly what was
364 if (req_length
== -1)
365 /* If the last character is null, subtract it from LENGTH. */
367 && extract_unsigned_integer (buffer
->get () + *length
- width
,
368 width
, byte_order
) == 0)
371 /* The read_string function will return the number of bytes read.
372 If length returned from read_string was > 0, return the number of
373 characters read by dividing the number of bytes by width. */
375 *length
= *length
/ width
;
377 *char_type
= element_type
;
383 std::string type_str
= type_to_string (type
);
384 if (!type_str
.empty ())
386 error (_("Trying to read string with inappropriate type `%s'."),
390 error (_("Trying to read string with inappropriate type."));
395 /* Evaluating C and C++ expressions. */
397 /* Convert a UCN. The digits of the UCN start at P and extend no
398 farther than LIMIT. DEST_CHARSET is the name of the character set
399 into which the UCN should be converted. The results are written to
400 OUTPUT. LENGTH is the maximum length of the UCN, either 4 or 8.
401 Returns a pointer to just after the final digit of the UCN. */
404 convert_ucn (const char *p
, const char *limit
, const char *dest_charset
,
405 struct obstack
*output
, int length
)
407 unsigned long result
= 0;
411 for (i
= 0; i
< length
&& p
< limit
&& ISXDIGIT (*p
); ++i
, ++p
)
412 result
= (result
<< 4) + fromhex (*p
);
414 for (i
= 3; i
>= 0; --i
)
416 data
[i
] = result
& 0xff;
420 convert_between_encodings ("UTF-32BE", dest_charset
, data
,
421 4, 4, output
, translit_none
);
426 /* Emit a character, VALUE, which was specified numerically, to
427 OUTPUT. TYPE is the target character type. */
430 emit_numeric_character (struct type
*type
, unsigned long value
,
431 struct obstack
*output
)
435 buffer
= (gdb_byte
*) alloca (type
->length ());
436 pack_long (buffer
, type
, value
);
437 obstack_grow (output
, buffer
, type
->length ());
440 /* Convert an octal escape sequence. TYPE is the target character
441 type. The digits of the escape sequence begin at P and extend no
442 farther than LIMIT. The result is written to OUTPUT. Returns a
443 pointer to just after the final digit of the escape sequence. */
446 convert_octal (struct type
*type
, const char *p
,
447 const char *limit
, struct obstack
*output
)
450 unsigned long value
= 0;
453 i
< 3 && p
< limit
&& ISDIGIT (*p
) && *p
!= '8' && *p
!= '9';
456 value
= 8 * value
+ fromhex (*p
);
460 emit_numeric_character (type
, value
, output
);
465 /* Convert a hex escape sequence. TYPE is the target character type.
466 The digits of the escape sequence begin at P and extend no farther
467 than LIMIT. The result is written to OUTPUT. Returns a pointer to
468 just after the final digit of the escape sequence. */
471 convert_hex (struct type
*type
, const char *p
,
472 const char *limit
, struct obstack
*output
)
474 unsigned long value
= 0;
476 while (p
< limit
&& ISXDIGIT (*p
))
478 value
= 16 * value
+ fromhex (*p
);
482 emit_numeric_character (type
, value
, output
);
491 error (_("Malformed escape sequence")); \
494 /* Convert an escape sequence to a target format. TYPE is the target
495 character type to use, and DEST_CHARSET is the name of the target
496 character set. The backslash of the escape sequence is at *P, and
497 the escape sequence will not extend past LIMIT. The results are
498 written to OUTPUT. Returns a pointer to just past the final
499 character of the escape sequence. */
502 convert_escape (struct type
*type
, const char *dest_charset
,
503 const char *p
, const char *limit
, struct obstack
*output
)
505 /* Skip the backslash. */
511 obstack_1grow (output
, '\\');
518 error (_("\\x used with no following hex digits."));
519 p
= convert_hex (type
, p
, limit
, output
);
530 p
= convert_octal (type
, p
, limit
, output
);
536 int length
= *p
== 'u' ? 4 : 8;
540 error (_("\\u used with no following hex digits"));
541 p
= convert_ucn (p
, limit
, dest_charset
, output
, length
);
548 /* Given a single string from a (C-specific) OP_STRING list, convert
549 it to a target string, handling escape sequences specially. The
550 output is written to OUTPUT. DATA is the input string, which has
551 length LEN. DEST_CHARSET is the name of the target character set,
552 and TYPE is the type of target character to use. */
555 parse_one_string (struct obstack
*output
, const char *data
, int len
,
556 const char *dest_charset
, struct type
*type
)
564 const char *p
= data
;
566 /* Look for next escape, or the end of the input. */
567 while (p
< limit
&& *p
!= '\\')
569 /* If we saw a run of characters, convert them all. */
571 convert_between_encodings (host_charset (), dest_charset
,
572 (const gdb_byte
*) data
, p
- data
, 1,
573 output
, translit_none
);
574 /* If we saw an escape, convert it. */
576 p
= convert_escape (type
, dest_charset
, p
, limit
, output
);
585 c_string_operation::evaluate (struct type
*expect_type
,
586 struct expression
*exp
,
590 struct value
*result
;
591 c_string_type dest_type
;
592 const char *dest_charset
;
593 int satisfy_expected
= 0;
597 dest_type
= std::get
<0> (m_storage
);
599 switch (dest_type
& ~C_CHAR
)
602 type
= language_string_char_type (exp
->language_defn
,
606 type
= lookup_typename (exp
->language_defn
, "wchar_t", NULL
, 0);
609 type
= lookup_typename (exp
->language_defn
, "char16_t", NULL
, 0);
612 type
= lookup_typename (exp
->language_defn
, "char32_t", NULL
, 0);
615 internal_error (_("unhandled c_string_type"));
618 /* If the caller expects an array of some integral type,
619 satisfy them. If something odder is expected, rely on the
621 if (expect_type
&& expect_type
->code () == TYPE_CODE_ARRAY
)
623 struct type
*element_type
624 = check_typedef (expect_type
->target_type ());
626 if (element_type
->code () == TYPE_CODE_INT
627 || element_type
->code () == TYPE_CODE_CHAR
)
630 satisfy_expected
= 1;
634 dest_charset
= charset_for_string_type (dest_type
, exp
->gdbarch
);
636 for (const std::string
&item
: std::get
<1> (m_storage
))
637 parse_one_string (&output
, item
.c_str (), item
.size (),
640 if ((dest_type
& C_CHAR
) != 0)
644 if (obstack_object_size (&output
) != type
->length ())
645 error (_("Could not convert character "
646 "constant to target character set"));
647 value
= unpack_long (type
, (gdb_byte
*) obstack_base (&output
));
648 result
= value_from_longest (type
, value
);
652 int element_size
= type
->length ();
654 if (satisfy_expected
)
656 LONGEST low_bound
, high_bound
;
658 if (!get_discrete_bounds (expect_type
->index_type (),
659 &low_bound
, &high_bound
))
662 high_bound
= (expect_type
->length () / element_size
) - 1;
664 if (obstack_object_size (&output
) / element_size
665 > (high_bound
- low_bound
+ 1))
666 error (_("Too many array elements"));
668 result
= value::allocate (expect_type
);
669 memcpy (result
->contents_raw ().data (), obstack_base (&output
),
670 obstack_object_size (&output
));
671 /* Write the terminating character. */
672 memset (result
->contents_raw ().data () + obstack_object_size (&output
),
676 result
= value_cstring ((const gdb_byte
*) obstack_base (&output
),
677 obstack_object_size (&output
) / element_size
,
683 } /* namespace expr */
689 c_is_string_type_p (struct type
*type
)
691 type
= check_typedef (type
);
692 while (type
->code () == TYPE_CODE_REF
)
694 type
= type
->target_type ();
695 type
= check_typedef (type
);
698 switch (type
->code ())
700 case TYPE_CODE_ARRAY
:
702 /* See if target type looks like a string. */
703 struct type
*array_target_type
= type
->target_type ();
704 return (type
->length () > 0
705 && array_target_type
->length () > 0
706 && c_textual_element_type (array_target_type
, 0));
708 case TYPE_CODE_STRING
:
712 struct type
*element_type
= type
->target_type ();
713 return c_textual_element_type (element_type
, 0);
726 gdb::unique_xmalloc_ptr
<char>
727 c_canonicalize_name (const char *name
)
729 if (strchr (name
, ' ') != nullptr
730 || streq (name
, "signed")
731 || streq (name
, "unsigned"))
732 return cp_canonicalize_string (name
);
739 c_language_arch_info (struct gdbarch
*gdbarch
,
740 struct language_arch_info
*lai
)
742 const struct builtin_type
*builtin
= builtin_type (gdbarch
);
744 /* Helper function to allow shorter lines below. */
745 auto add
= [&] (struct type
* t
)
747 lai
->add_primitive_type (t
);
750 add (builtin
->builtin_int
);
751 add (builtin
->builtin_long
);
752 add (builtin
->builtin_short
);
753 add (builtin
->builtin_char
);
754 add (builtin
->builtin_float
);
755 add (builtin
->builtin_double
);
756 add (builtin
->builtin_void
);
757 add (builtin
->builtin_long_long
);
758 add (builtin
->builtin_signed_char
);
759 add (builtin
->builtin_unsigned_char
);
760 add (builtin
->builtin_unsigned_short
);
761 add (builtin
->builtin_unsigned_int
);
762 add (builtin
->builtin_unsigned_long
);
763 add (builtin
->builtin_unsigned_long_long
);
764 add (builtin
->builtin_long_double
);
765 add (builtin
->builtin_complex
);
766 add (builtin
->builtin_double_complex
);
767 add (builtin
->builtin_decfloat
);
768 add (builtin
->builtin_decdouble
);
769 add (builtin
->builtin_declong
);
771 lai
->set_string_char_type (builtin
->builtin_char
);
772 lai
->set_bool_type (builtin
->builtin_int
);
775 /* Class representing the C language. */
777 class c_language
: public language_defn
781 : language_defn (language_c
)
784 /* See language.h. */
786 const char *name () const override
789 /* See language.h. */
791 const char *natural_name () const override
794 /* See language.h. */
796 const std::vector
<const char *> &filename_extensions () const override
798 static const std::vector
<const char *> extensions
= { ".c" };
802 /* See language.h. */
803 void language_arch_info (struct gdbarch
*gdbarch
,
804 struct language_arch_info
*lai
) const override
806 c_language_arch_info (gdbarch
, lai
);
809 /* See language.h. */
810 std::unique_ptr
<compile_instance
> get_compile_instance () const override
812 return c_get_compile_context ();
815 /* See language.h. */
816 std::string
compute_program (compile_instance
*inst
,
818 struct gdbarch
*gdbarch
,
819 const struct block
*expr_block
,
820 CORE_ADDR expr_pc
) const override
822 return c_compute_program (inst
, input
, gdbarch
, expr_block
, expr_pc
);
825 /* See language.h. */
827 bool can_print_type_offsets () const override
832 /* See language.h. */
834 void print_type (struct type
*type
, const char *varstring
,
835 struct ui_file
*stream
, int show
, int level
,
836 const struct type_print_options
*flags
) const override
838 c_print_type (type
, varstring
, stream
, show
, level
, la_language
, flags
);
841 /* See language.h. */
843 bool store_sym_names_in_linkage_form_p () const override
846 /* See language.h. */
848 enum macro_expansion
macro_expansion () const override
849 { return macro_expansion_c
; }
852 /* Single instance of the C language class. */
854 static c_language c_language_defn
;
856 /* A class for the C++ language. */
858 class cplus_language
: public language_defn
862 : language_defn (language_cplus
)
865 /* See language.h. */
867 const char *name () const override
870 /* See language.h. */
872 const char *natural_name () const override
876 const char *get_digit_separator () const override
879 /* See language.h. */
881 const std::vector
<const char *> &filename_extensions () const override
883 static const std::vector
<const char *> extensions
884 = { ".C", ".cc", ".cp", ".cpp", ".cxx", ".c++" };
888 /* See language.h. */
890 struct language_pass_by_ref_info pass_by_reference_info
891 (struct type
*type
) const override
893 return cp_pass_by_reference (type
);
896 /* See language.h. */
897 void language_arch_info (struct gdbarch
*gdbarch
,
898 struct language_arch_info
*lai
) const override
900 const struct builtin_type
*builtin
= builtin_type (gdbarch
);
902 /* Helper function to allow shorter lines below. */
903 auto add
= [&] (struct type
* t
)
905 lai
->add_primitive_type (t
);
908 add (builtin
->builtin_int
);
909 add (builtin
->builtin_long
);
910 add (builtin
->builtin_short
);
911 add (builtin
->builtin_char
);
912 add (builtin
->builtin_float
);
913 add (builtin
->builtin_double
);
914 add (builtin
->builtin_void
);
915 add (builtin
->builtin_long_long
);
916 add (builtin
->builtin_signed_char
);
917 add (builtin
->builtin_unsigned_char
);
918 add (builtin
->builtin_unsigned_short
);
919 add (builtin
->builtin_unsigned_int
);
920 add (builtin
->builtin_unsigned_long
);
921 add (builtin
->builtin_unsigned_long_long
);
922 add (builtin
->builtin_long_double
);
923 add (builtin
->builtin_complex
);
924 add (builtin
->builtin_double_complex
);
925 add (builtin
->builtin_bool
);
926 add (builtin
->builtin_decfloat
);
927 add (builtin
->builtin_decdouble
);
928 add (builtin
->builtin_declong
);
929 add (builtin
->builtin_char16
);
930 add (builtin
->builtin_char32
);
931 add (builtin
->builtin_wchar
);
933 lai
->set_string_char_type (builtin
->builtin_char
);
934 lai
->set_bool_type (builtin
->builtin_bool
, "bool");
937 /* See language.h. */
938 struct type
*lookup_transparent_type (const char *name
) const override
940 return cp_lookup_transparent_type (name
);
943 /* See language.h. */
944 std::unique_ptr
<compile_instance
> get_compile_instance () const override
946 return cplus_get_compile_context ();
949 /* See language.h. */
950 std::string
compute_program (compile_instance
*inst
,
952 struct gdbarch
*gdbarch
,
953 const struct block
*expr_block
,
954 CORE_ADDR expr_pc
) const override
956 return cplus_compute_program (inst
, input
, gdbarch
, expr_block
, expr_pc
);
959 /* See language.h. */
960 unsigned int search_name_hash (const char *name
) const override
962 return cp_search_name_hash (name
);
965 /* See language.h. */
966 bool sniff_from_mangled_name
967 (const char *mangled
,
968 gdb::unique_xmalloc_ptr
<char> *demangled
) const override
970 *demangled
= gdb_demangle (mangled
, DMGL_PARAMS
| DMGL_ANSI
);
971 return *demangled
!= NULL
;
974 /* See language.h. */
976 gdb::unique_xmalloc_ptr
<char> demangle_symbol (const char *mangled
,
977 int options
) const override
979 return gdb_demangle (mangled
, options
);
982 /* See language.h. */
984 bool can_print_type_offsets () const override
989 /* See language.h. */
991 void print_type (struct type
*type
, const char *varstring
,
992 struct ui_file
*stream
, int show
, int level
,
993 const struct type_print_options
*flags
) const override
995 c_print_type (type
, varstring
, stream
, show
, level
, la_language
, flags
);
998 /* See language.h. */
1000 CORE_ADDR
skip_trampoline (const frame_info_ptr
&fi
,
1001 CORE_ADDR pc
) const override
1003 return cplus_skip_trampoline (fi
, pc
);
1006 /* See language.h. */
1008 char *class_name_from_physname (const char *physname
) const override
1010 return cp_class_name_from_physname (physname
);
1013 /* See language.h. */
1015 struct block_symbol lookup_symbol_nonlocal
1016 (const char *name
, const struct block
*block
,
1017 const domain_search_flags domain
) const override
1019 return cp_lookup_symbol_nonlocal (this, name
, block
, domain
);
1022 /* See language.h. */
1024 const char *name_of_this () const override
1027 /* See language.h. */
1029 enum macro_expansion
macro_expansion () const override
1030 { return macro_expansion_c
; }
1032 /* See language.h. */
1034 const struct lang_varobj_ops
*varobj_ops () const override
1035 { return &cplus_varobj_ops
; }
1039 /* See language.h. */
1041 symbol_name_matcher_ftype
*get_symbol_name_matcher_inner
1042 (const lookup_name_info
&lookup_name
) const override
1044 return cp_get_symbol_name_matcher (lookup_name
);
1048 /* The single instance of the C++ language class. */
1050 static cplus_language cplus_language_defn
;
1052 /* A class for the ASM language. */
1054 class asm_language
: public language_defn
1058 : language_defn (language_asm
)
1061 /* See language.h. */
1063 const char *name () const override
1066 /* See language.h. */
1068 const char *natural_name () const override
1069 { return "Assembly"; }
1071 /* See language.h. */
1073 const std::vector
<const char *> &filename_extensions () const override
1075 static const std::vector
<const char *> extensions
1076 = { ".s", ".sx", ".S" };
1082 FIXME: Should this have its own arch info method? */
1083 void language_arch_info (struct gdbarch
*gdbarch
,
1084 struct language_arch_info
*lai
) const override
1086 c_language_arch_info (gdbarch
, lai
);
1089 /* See language.h. */
1091 bool can_print_type_offsets () const override
1096 /* See language.h. */
1098 void print_type (struct type
*type
, const char *varstring
,
1099 struct ui_file
*stream
, int show
, int level
,
1100 const struct type_print_options
*flags
) const override
1102 c_print_type (type
, varstring
, stream
, show
, level
, la_language
, flags
);
1105 /* See language.h. */
1107 bool store_sym_names_in_linkage_form_p () const override
1110 /* See language.h. */
1112 enum macro_expansion
macro_expansion () const override
1113 { return macro_expansion_c
; }
1116 /* The single instance of the ASM language class. */
1117 static asm_language asm_language_defn
;
1119 /* A class for the minimal language. This does not represent a real
1120 language. It just provides a minimal support a-la-C that should allow
1121 users to do some simple operations when debugging applications that use
1122 a language currently not supported by GDB. */
1124 class minimal_language
: public language_defn
1128 : language_defn (language_minimal
)
1131 /* See language.h. */
1133 const char *name () const override
1134 { return "minimal"; }
1136 /* See language.h. */
1138 const char *natural_name () const override
1139 { return "Minimal"; }
1141 /* See language.h. */
1142 void language_arch_info (struct gdbarch
*gdbarch
,
1143 struct language_arch_info
*lai
) const override
1145 c_language_arch_info (gdbarch
, lai
);
1148 /* See language.h. */
1150 bool can_print_type_offsets () const override
1155 /* See language.h. */
1157 void print_type (struct type
*type
, const char *varstring
,
1158 struct ui_file
*stream
, int show
, int level
,
1159 const struct type_print_options
*flags
) const override
1161 c_print_type (type
, varstring
, stream
, show
, level
, la_language
, flags
);
1164 /* See language.h. */
1166 bool store_sym_names_in_linkage_form_p () const override
1169 /* See language.h. */
1171 enum macro_expansion
macro_expansion () const override
1172 { return macro_expansion_c
; }
1175 /* The single instance of the minimal language class. */
1176 static minimal_language minimal_language_defn
;