1 /* C language support routines for GDB, the GNU debugger.
3 Copyright (C) 1992-2023 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"
39 #include "compile/compile-internal.h"
42 /* Given a C string type, STR_TYPE, return the corresponding target
43 character set name. */
46 charset_for_string_type (c_string_type str_type
, struct gdbarch
*gdbarch
)
48 switch (str_type
& ~C_CHAR
)
51 return target_charset (gdbarch
);
53 return target_wide_charset (gdbarch
);
55 /* FIXME: UTF-16 is not always correct. */
56 if (gdbarch_byte_order (gdbarch
) == BFD_ENDIAN_BIG
)
61 /* FIXME: UTF-32 is not always correct. */
62 if (gdbarch_byte_order (gdbarch
) == BFD_ENDIAN_BIG
)
67 internal_error (_("unhandled c_string_type"));
70 /* Classify ELTTYPE according to what kind of character it is. Return
71 the enum constant representing the character type. Also set
72 *ENCODING to the name of the character set to use when converting
73 characters of this type in target BYTE_ORDER to the host character
77 classify_type (struct type
*elttype
, struct gdbarch
*gdbarch
,
78 const char **encoding
)
82 /* We loop because ELTTYPE may be a typedef, and we want to
83 successively peel each typedef until we reach a type we
84 understand. We don't use CHECK_TYPEDEF because that will strip
85 all typedefs at once -- but in C, wchar_t is itself a typedef, so
86 that would do the wrong thing. */
89 const char *name
= elttype
->name ();
97 if (!strcmp (name
, "wchar_t"))
103 if (!strcmp (name
, "char16_t"))
109 if (!strcmp (name
, "char32_t"))
115 if (elttype
->code () != TYPE_CODE_TYPEDEF
)
118 /* Call for side effects. */
119 check_typedef (elttype
);
121 if (elttype
->target_type ())
122 elttype
= elttype
->target_type ();
125 /* Perhaps check_typedef did not update the target type. In
126 this case, force the lookup again and hope it works out.
127 It never will for C, but it might for C++. */
128 elttype
= check_typedef (elttype
);
137 *encoding
= charset_for_string_type (result
, gdbarch
);
142 /* Print the character C on STREAM as part of the contents of a
143 literal string whose delimiter is QUOTER. Note that that format
144 for printing characters and strings is language specific. */
147 language_defn::emitchar (int c
, struct type
*type
,
148 struct ui_file
*stream
, int quoter
) const
150 const char *encoding
;
152 classify_type (type
, type
->arch (), &encoding
);
153 generic_emit_char (c
, type
, stream
, quoter
, encoding
);
156 /* See language.h. */
159 language_defn::printchar (int c
, struct type
*type
,
160 struct ui_file
* stream
) const
162 c_string_type str_type
;
164 str_type
= classify_type (type
, type
->arch (), NULL
);
170 gdb_putc ('L', stream
);
173 gdb_putc ('u', stream
);
176 gdb_putc ('U', stream
);
180 gdb_putc ('\'', stream
);
181 emitchar (c
, type
, stream
, '\'');
182 gdb_putc ('\'', stream
);
185 /* Print the character string STRING, printing at most LENGTH
186 characters. LENGTH is -1 if the string is nul terminated. Each
187 character is WIDTH bytes long. Printing stops early if the number
188 hits print_max_chars; repeat counts are printed as appropriate.
189 Print ellipses at the end if we had to stop before printing LENGTH
190 characters, or if FORCE_ELLIPSES. */
193 language_defn::printstr (struct ui_file
*stream
, struct type
*type
,
194 const gdb_byte
*string
, unsigned int length
,
195 const char *user_encoding
, int force_ellipses
,
196 const struct value_print_options
*options
) const
198 c_string_type str_type
;
199 const char *type_encoding
;
200 const char *encoding
;
202 str_type
= (classify_type (type
, type
->arch (), &type_encoding
)
209 gdb_puts ("L", stream
);
212 gdb_puts ("u", stream
);
215 gdb_puts ("U", stream
);
219 encoding
= (user_encoding
&& *user_encoding
) ? user_encoding
: type_encoding
;
221 generic_printstr (stream
, type
, string
, length
, encoding
, force_ellipses
,
225 /* Obtain a C string from the inferior storing it in a newly allocated
226 buffer in BUFFER, which should be freed by the caller. If the in-
227 and out-parameter *LENGTH is specified at -1, the string is read
228 until a null character of the appropriate width is found, otherwise
229 the string is read to the length of characters specified. The size
230 of a character is determined by the length of the target type of
231 the pointer or array.
233 If VALUE is an array with a known length, and *LENGTH is -1,
234 the function will not read past the end of the array. However, any
235 declared size of the array is ignored if *LENGTH > 0.
237 On completion, *LENGTH will be set to the size of the string read in
238 characters. (If a length of -1 is specified, the length returned
239 will not include the null character). CHARSET is always set to the
243 c_get_string (struct value
*value
, gdb::unique_xmalloc_ptr
<gdb_byte
> *buffer
,
244 int *length
, struct type
**char_type
,
245 const char **charset
)
248 unsigned int fetchlimit
;
249 struct type
*type
= check_typedef (value_type (value
));
250 struct type
*element_type
= type
->target_type ();
251 int req_length
= *length
;
252 enum bfd_endian byte_order
253 = type_byte_order (type
);
255 if (element_type
== NULL
)
258 if (type
->code () == TYPE_CODE_ARRAY
)
260 /* If we know the size of the array, we can use it as a limit on
261 the number of characters to be fetched. */
262 if (type
->num_fields () == 1
263 && type
->field (0).type ()->code () == TYPE_CODE_RANGE
)
265 LONGEST low_bound
, high_bound
;
267 get_discrete_bounds (type
->field (0).type (),
268 &low_bound
, &high_bound
);
269 fetchlimit
= high_bound
- low_bound
+ 1;
272 fetchlimit
= UINT_MAX
;
274 else if (type
->code () == TYPE_CODE_PTR
)
275 fetchlimit
= UINT_MAX
;
277 /* We work only with arrays and pointers. */
280 if (! c_textual_element_type (element_type
, 0))
282 classify_type (element_type
, element_type
->arch (), charset
);
283 width
= element_type
->length ();
285 /* If the string lives in GDB's memory instead of the inferior's,
286 then we just need to copy it to BUFFER. Also, since such strings
287 are arrays with known size, FETCHLIMIT will hold the size of the
290 An array is assumed to live in GDB's memory, so we take this path
293 However, it's possible for the caller to request more array
294 elements than apparently exist -- this can happen when using the
295 C struct hack. So, only do this if either no length was
296 specified, or the length is within the existing bounds. This
297 avoids running off the end of the value's contents. */
298 if ((VALUE_LVAL (value
) == not_lval
299 || VALUE_LVAL (value
) == lval_internalvar
300 || type
->code () == TYPE_CODE_ARRAY
)
301 && fetchlimit
!= UINT_MAX
302 && (*length
< 0 || *length
<= fetchlimit
))
305 const gdb_byte
*contents
= value_contents (value
).data ();
307 /* If a length is specified, use that. */
311 /* Otherwise, look for a null character. */
312 for (i
= 0; i
< fetchlimit
; i
++)
313 if (extract_unsigned_integer (contents
+ i
* width
,
314 width
, byte_order
) == 0)
317 /* I is now either a user-defined length, the number of non-null
318 characters, or FETCHLIMIT. */
320 buffer
->reset ((gdb_byte
*) xmalloc (*length
));
321 memcpy (buffer
->get (), contents
, *length
);
326 /* value_as_address does not return an address for an array when
327 c_style_arrays is false, so we handle that specially
330 if (type
->code () == TYPE_CODE_ARRAY
)
332 if (VALUE_LVAL (value
) != lval_memory
)
333 error (_("Attempt to take address of value "
334 "not located in memory."));
335 addr
= value_address (value
);
338 addr
= value_as_address (value
);
340 /* Prior to the fix for PR 16196 read_string would ignore fetchlimit
341 if length > 0. The old "broken" behaviour is the behaviour we want:
342 The caller may want to fetch 100 bytes from a variable length array
343 implemented using the common idiom of having an array of length 1 at
344 the end of a struct. In this case we want to ignore the declared
345 size of the array. However, it's counterintuitive to implement that
346 behaviour in read_string: what does fetchlimit otherwise mean if
347 length > 0. Therefore we implement the behaviour we want here:
348 If *length > 0, don't specify a fetchlimit. This preserves the
349 previous behaviour. We could move this check above where we know
350 whether the array is declared with a fixed size, but we only want
351 to apply this behaviour when calling read_string. PR 16286. */
353 fetchlimit
= UINT_MAX
;
355 err
= target_read_string (addr
, *length
, width
, fetchlimit
,
358 memory_error (TARGET_XFER_E_IO
, addr
);
361 /* If the LENGTH is specified at -1, we want to return the string
362 length up to the terminating null character. If an actual length
363 was specified, we want to return the length of exactly what was
365 if (req_length
== -1)
366 /* If the last character is null, subtract it from LENGTH. */
368 && extract_unsigned_integer (buffer
->get () + *length
- width
,
369 width
, byte_order
) == 0)
372 /* The read_string function will return the number of bytes read.
373 If length returned from read_string was > 0, return the number of
374 characters read by dividing the number of bytes by width. */
376 *length
= *length
/ width
;
378 *char_type
= element_type
;
384 std::string type_str
= type_to_string (type
);
385 if (!type_str
.empty ())
387 error (_("Trying to read string with inappropriate type `%s'."),
391 error (_("Trying to read string with inappropriate type."));
396 /* Evaluating C and C++ expressions. */
398 /* Convert a UCN. The digits of the UCN start at P and extend no
399 farther than LIMIT. DEST_CHARSET is the name of the character set
400 into which the UCN should be converted. The results are written to
401 OUTPUT. LENGTH is the maximum length of the UCN, either 4 or 8.
402 Returns a pointer to just after the final digit of the UCN. */
405 convert_ucn (const char *p
, const char *limit
, const char *dest_charset
,
406 struct obstack
*output
, int length
)
408 unsigned long result
= 0;
412 for (i
= 0; i
< length
&& p
< limit
&& ISXDIGIT (*p
); ++i
, ++p
)
413 result
= (result
<< 4) + fromhex (*p
);
415 for (i
= 3; i
>= 0; --i
)
417 data
[i
] = result
& 0xff;
421 convert_between_encodings ("UTF-32BE", dest_charset
, data
,
422 4, 4, output
, translit_none
);
427 /* Emit a character, VALUE, which was specified numerically, to
428 OUTPUT. TYPE is the target character type. */
431 emit_numeric_character (struct type
*type
, unsigned long value
,
432 struct obstack
*output
)
436 buffer
= (gdb_byte
*) alloca (type
->length ());
437 pack_long (buffer
, type
, value
);
438 obstack_grow (output
, buffer
, type
->length ());
441 /* Convert an octal escape sequence. TYPE is the target character
442 type. The digits of the escape sequence begin at P and extend no
443 farther than LIMIT. The result is written to OUTPUT. Returns a
444 pointer to just after the final digit of the escape sequence. */
447 convert_octal (struct type
*type
, const char *p
,
448 const char *limit
, struct obstack
*output
)
451 unsigned long value
= 0;
454 i
< 3 && p
< limit
&& ISDIGIT (*p
) && *p
!= '8' && *p
!= '9';
457 value
= 8 * value
+ fromhex (*p
);
461 emit_numeric_character (type
, value
, output
);
466 /* Convert a hex escape sequence. TYPE is the target character type.
467 The digits of the escape sequence begin at P and extend no farther
468 than LIMIT. The result is written to OUTPUT. Returns a pointer to
469 just after the final digit of the escape sequence. */
472 convert_hex (struct type
*type
, const char *p
,
473 const char *limit
, struct obstack
*output
)
475 unsigned long value
= 0;
477 while (p
< limit
&& ISXDIGIT (*p
))
479 value
= 16 * value
+ fromhex (*p
);
483 emit_numeric_character (type
, value
, output
);
492 error (_("Malformed escape sequence")); \
495 /* Convert an escape sequence to a target format. TYPE is the target
496 character type to use, and DEST_CHARSET is the name of the target
497 character set. The backslash of the escape sequence is at *P, and
498 the escape sequence will not extend past LIMIT. The results are
499 written to OUTPUT. Returns a pointer to just past the final
500 character of the escape sequence. */
503 convert_escape (struct type
*type
, const char *dest_charset
,
504 const char *p
, const char *limit
, struct obstack
*output
)
506 /* Skip the backslash. */
512 obstack_1grow (output
, '\\');
519 error (_("\\x used with no following hex digits."));
520 p
= convert_hex (type
, p
, limit
, output
);
531 p
= convert_octal (type
, p
, limit
, output
);
537 int length
= *p
== 'u' ? 4 : 8;
541 error (_("\\u used with no following hex digits"));
542 p
= convert_ucn (p
, limit
, dest_charset
, output
, length
);
549 /* Given a single string from a (C-specific) OP_STRING list, convert
550 it to a target string, handling escape sequences specially. The
551 output is written to OUTPUT. DATA is the input string, which has
552 length LEN. DEST_CHARSET is the name of the target character set,
553 and TYPE is the type of target character to use. */
556 parse_one_string (struct obstack
*output
, const char *data
, int len
,
557 const char *dest_charset
, struct type
*type
)
565 const char *p
= data
;
567 /* Look for next escape, or the end of the input. */
568 while (p
< limit
&& *p
!= '\\')
570 /* If we saw a run of characters, convert them all. */
572 convert_between_encodings (host_charset (), dest_charset
,
573 (const gdb_byte
*) data
, p
- data
, 1,
574 output
, translit_none
);
575 /* If we saw an escape, convert it. */
577 p
= convert_escape (type
, dest_charset
, p
, limit
, output
);
586 c_string_operation::evaluate (struct type
*expect_type
,
587 struct expression
*exp
,
591 struct value
*result
;
592 c_string_type dest_type
;
593 const char *dest_charset
;
594 int satisfy_expected
= 0;
598 dest_type
= std::get
<0> (m_storage
);
600 switch (dest_type
& ~C_CHAR
)
603 type
= language_string_char_type (exp
->language_defn
,
607 type
= lookup_typename (exp
->language_defn
, "wchar_t", NULL
, 0);
610 type
= lookup_typename (exp
->language_defn
, "char16_t", NULL
, 0);
613 type
= lookup_typename (exp
->language_defn
, "char32_t", NULL
, 0);
616 internal_error (_("unhandled c_string_type"));
619 /* Ensure TYPE_LENGTH is valid for TYPE. */
620 check_typedef (type
);
622 /* If the caller expects an array of some integral type,
623 satisfy them. If something odder is expected, rely on the
625 if (expect_type
&& expect_type
->code () == TYPE_CODE_ARRAY
)
627 struct type
*element_type
628 = check_typedef (expect_type
->target_type ());
630 if (element_type
->code () == TYPE_CODE_INT
631 || element_type
->code () == TYPE_CODE_CHAR
)
634 satisfy_expected
= 1;
638 dest_charset
= charset_for_string_type (dest_type
, exp
->gdbarch
);
640 for (const std::string
&item
: std::get
<1> (m_storage
))
641 parse_one_string (&output
, item
.c_str (), item
.size (),
644 if ((dest_type
& C_CHAR
) != 0)
648 if (obstack_object_size (&output
) != type
->length ())
649 error (_("Could not convert character "
650 "constant to target character set"));
651 value
= unpack_long (type
, (gdb_byte
*) obstack_base (&output
));
652 result
= value_from_longest (type
, value
);
658 /* Write the terminating character. */
659 for (i
= 0; i
< type
->length (); ++i
)
660 obstack_1grow (&output
, 0);
662 if (satisfy_expected
)
664 LONGEST low_bound
, high_bound
;
665 int element_size
= type
->length ();
667 if (!get_discrete_bounds (expect_type
->index_type (),
668 &low_bound
, &high_bound
))
671 high_bound
= (expect_type
->length () / element_size
) - 1;
673 if (obstack_object_size (&output
) / element_size
674 > (high_bound
- low_bound
+ 1))
675 error (_("Too many array elements"));
677 result
= allocate_value (expect_type
);
678 memcpy (value_contents_raw (result
).data (), obstack_base (&output
),
679 obstack_object_size (&output
));
682 result
= value_cstring ((const char *) obstack_base (&output
),
683 obstack_object_size (&output
),
689 } /* namespace expr */
695 c_is_string_type_p (struct type
*type
)
697 type
= check_typedef (type
);
698 while (type
->code () == TYPE_CODE_REF
)
700 type
= type
->target_type ();
701 type
= check_typedef (type
);
704 switch (type
->code ())
706 case TYPE_CODE_ARRAY
:
708 /* See if target type looks like a string. */
709 struct type
*array_target_type
= type
->target_type ();
710 return (type
->length () > 0
711 && array_target_type
->length () > 0
712 && c_textual_element_type (array_target_type
, 0));
714 case TYPE_CODE_STRING
:
718 struct type
*element_type
= type
->target_type ();
719 return c_textual_element_type (element_type
, 0);
732 gdb::unique_xmalloc_ptr
<char>
733 c_canonicalize_name (const char *name
)
735 if (strchr (name
, ' ') != nullptr
736 || streq (name
, "signed")
737 || streq (name
, "unsigned"))
738 return cp_canonicalize_string (name
);
745 c_language_arch_info (struct gdbarch
*gdbarch
,
746 struct language_arch_info
*lai
)
748 const struct builtin_type
*builtin
= builtin_type (gdbarch
);
750 /* Helper function to allow shorter lines below. */
751 auto add
= [&] (struct type
* t
)
753 lai
->add_primitive_type (t
);
756 add (builtin
->builtin_int
);
757 add (builtin
->builtin_long
);
758 add (builtin
->builtin_short
);
759 add (builtin
->builtin_char
);
760 add (builtin
->builtin_float
);
761 add (builtin
->builtin_double
);
762 add (builtin
->builtin_void
);
763 add (builtin
->builtin_long_long
);
764 add (builtin
->builtin_signed_char
);
765 add (builtin
->builtin_unsigned_char
);
766 add (builtin
->builtin_unsigned_short
);
767 add (builtin
->builtin_unsigned_int
);
768 add (builtin
->builtin_unsigned_long
);
769 add (builtin
->builtin_unsigned_long_long
);
770 add (builtin
->builtin_long_double
);
771 add (builtin
->builtin_complex
);
772 add (builtin
->builtin_double_complex
);
773 add (builtin
->builtin_decfloat
);
774 add (builtin
->builtin_decdouble
);
775 add (builtin
->builtin_declong
);
777 lai
->set_string_char_type (builtin
->builtin_char
);
778 lai
->set_bool_type (builtin
->builtin_int
);
781 /* Class representing the C language. */
783 class c_language
: public language_defn
787 : language_defn (language_c
)
790 /* See language.h. */
792 const char *name () const override
795 /* See language.h. */
797 const char *natural_name () const override
800 /* See language.h. */
802 const std::vector
<const char *> &filename_extensions () const override
804 static const std::vector
<const char *> extensions
= { ".c" };
808 /* See language.h. */
809 void language_arch_info (struct gdbarch
*gdbarch
,
810 struct language_arch_info
*lai
) const override
812 c_language_arch_info (gdbarch
, lai
);
815 /* See language.h. */
816 std::unique_ptr
<compile_instance
> get_compile_instance () const override
818 return c_get_compile_context ();
821 /* See language.h. */
822 std::string
compute_program (compile_instance
*inst
,
824 struct gdbarch
*gdbarch
,
825 const struct block
*expr_block
,
826 CORE_ADDR expr_pc
) const override
828 return c_compute_program (inst
, input
, gdbarch
, expr_block
, expr_pc
);
831 /* See language.h. */
833 bool can_print_type_offsets () const override
838 /* See language.h. */
840 void print_type (struct type
*type
, const char *varstring
,
841 struct ui_file
*stream
, int show
, int level
,
842 const struct type_print_options
*flags
) const override
844 c_print_type (type
, varstring
, stream
, show
, level
, la_language
, flags
);
847 /* See language.h. */
849 bool store_sym_names_in_linkage_form_p () const override
852 /* See language.h. */
854 enum macro_expansion
macro_expansion () const override
855 { return macro_expansion_c
; }
858 /* Single instance of the C language class. */
860 static c_language c_language_defn
;
862 /* A class for the C++ language. */
864 class cplus_language
: public language_defn
868 : language_defn (language_cplus
)
871 /* See language.h. */
873 const char *name () const override
876 /* See language.h. */
878 const char *natural_name () const override
882 const char *get_digit_separator () const override
885 /* See language.h. */
887 const std::vector
<const char *> &filename_extensions () const override
889 static const std::vector
<const char *> extensions
890 = { ".C", ".cc", ".cp", ".cpp", ".cxx", ".c++" };
894 /* See language.h. */
896 struct language_pass_by_ref_info pass_by_reference_info
897 (struct type
*type
) const override
899 return cp_pass_by_reference (type
);
902 /* See language.h. */
903 void language_arch_info (struct gdbarch
*gdbarch
,
904 struct language_arch_info
*lai
) const override
906 const struct builtin_type
*builtin
= builtin_type (gdbarch
);
908 /* Helper function to allow shorter lines below. */
909 auto add
= [&] (struct type
* t
)
911 lai
->add_primitive_type (t
);
914 add (builtin
->builtin_int
);
915 add (builtin
->builtin_long
);
916 add (builtin
->builtin_short
);
917 add (builtin
->builtin_char
);
918 add (builtin
->builtin_float
);
919 add (builtin
->builtin_double
);
920 add (builtin
->builtin_void
);
921 add (builtin
->builtin_long_long
);
922 add (builtin
->builtin_signed_char
);
923 add (builtin
->builtin_unsigned_char
);
924 add (builtin
->builtin_unsigned_short
);
925 add (builtin
->builtin_unsigned_int
);
926 add (builtin
->builtin_unsigned_long
);
927 add (builtin
->builtin_unsigned_long_long
);
928 add (builtin
->builtin_long_double
);
929 add (builtin
->builtin_complex
);
930 add (builtin
->builtin_double_complex
);
931 add (builtin
->builtin_bool
);
932 add (builtin
->builtin_decfloat
);
933 add (builtin
->builtin_decdouble
);
934 add (builtin
->builtin_declong
);
935 add (builtin
->builtin_char16
);
936 add (builtin
->builtin_char32
);
937 add (builtin
->builtin_wchar
);
939 lai
->set_string_char_type (builtin
->builtin_char
);
940 lai
->set_bool_type (builtin
->builtin_bool
, "bool");
943 /* See language.h. */
944 struct type
*lookup_transparent_type (const char *name
) const override
946 return cp_lookup_transparent_type (name
);
949 /* See language.h. */
950 std::unique_ptr
<compile_instance
> get_compile_instance () const override
952 return cplus_get_compile_context ();
955 /* See language.h. */
956 std::string
compute_program (compile_instance
*inst
,
958 struct gdbarch
*gdbarch
,
959 const struct block
*expr_block
,
960 CORE_ADDR expr_pc
) const override
962 return cplus_compute_program (inst
, input
, gdbarch
, expr_block
, expr_pc
);
965 /* See language.h. */
966 unsigned int search_name_hash (const char *name
) const override
968 return cp_search_name_hash (name
);
971 /* See language.h. */
972 bool sniff_from_mangled_name
973 (const char *mangled
,
974 gdb::unique_xmalloc_ptr
<char> *demangled
) const override
976 *demangled
= gdb_demangle (mangled
, DMGL_PARAMS
| DMGL_ANSI
);
977 return *demangled
!= NULL
;
980 /* See language.h. */
982 gdb::unique_xmalloc_ptr
<char> demangle_symbol (const char *mangled
,
983 int options
) const override
985 return gdb_demangle (mangled
, options
);
988 /* See language.h. */
990 bool can_print_type_offsets () const override
995 /* See language.h. */
997 void print_type (struct type
*type
, const char *varstring
,
998 struct ui_file
*stream
, int show
, int level
,
999 const struct type_print_options
*flags
) const override
1001 c_print_type (type
, varstring
, stream
, show
, level
, la_language
, flags
);
1004 /* See language.h. */
1006 CORE_ADDR
skip_trampoline (frame_info_ptr fi
,
1007 CORE_ADDR pc
) const override
1009 return cplus_skip_trampoline (fi
, pc
);
1012 /* See language.h. */
1014 char *class_name_from_physname (const char *physname
) const override
1016 return cp_class_name_from_physname (physname
);
1019 /* See language.h. */
1021 struct block_symbol lookup_symbol_nonlocal
1022 (const char *name
, const struct block
*block
,
1023 const domain_enum domain
) const override
1025 return cp_lookup_symbol_nonlocal (this, name
, block
, domain
);
1028 /* See language.h. */
1030 const char *name_of_this () const override
1033 /* See language.h. */
1035 enum macro_expansion
macro_expansion () const override
1036 { return macro_expansion_c
; }
1038 /* See language.h. */
1040 const struct lang_varobj_ops
*varobj_ops () const override
1041 { return &cplus_varobj_ops
; }
1045 /* See language.h. */
1047 symbol_name_matcher_ftype
*get_symbol_name_matcher_inner
1048 (const lookup_name_info
&lookup_name
) const override
1050 return cp_get_symbol_name_matcher (lookup_name
);
1054 /* The single instance of the C++ language class. */
1056 static cplus_language cplus_language_defn
;
1058 /* A class for the ASM language. */
1060 class asm_language
: public language_defn
1064 : language_defn (language_asm
)
1067 /* See language.h. */
1069 const char *name () const override
1072 /* See language.h. */
1074 const char *natural_name () const override
1075 { return "Assembly"; }
1077 /* See language.h. */
1079 const std::vector
<const char *> &filename_extensions () const override
1081 static const std::vector
<const char *> extensions
1082 = { ".s", ".sx", ".S" };
1088 FIXME: Should this have its own arch info method? */
1089 void language_arch_info (struct gdbarch
*gdbarch
,
1090 struct language_arch_info
*lai
) const override
1092 c_language_arch_info (gdbarch
, lai
);
1095 /* See language.h. */
1097 bool can_print_type_offsets () const override
1102 /* See language.h. */
1104 void print_type (struct type
*type
, const char *varstring
,
1105 struct ui_file
*stream
, int show
, int level
,
1106 const struct type_print_options
*flags
) const override
1108 c_print_type (type
, varstring
, stream
, show
, level
, la_language
, flags
);
1111 /* See language.h. */
1113 bool store_sym_names_in_linkage_form_p () const override
1116 /* See language.h. */
1118 enum macro_expansion
macro_expansion () const override
1119 { return macro_expansion_c
; }
1122 /* The single instance of the ASM language class. */
1123 static asm_language asm_language_defn
;
1125 /* A class for the minimal language. This does not represent a real
1126 language. It just provides a minimal support a-la-C that should allow
1127 users to do some simple operations when debugging applications that use
1128 a language currently not supported by GDB. */
1130 class minimal_language
: public language_defn
1134 : language_defn (language_minimal
)
1137 /* See language.h. */
1139 const char *name () const override
1140 { return "minimal"; }
1142 /* See language.h. */
1144 const char *natural_name () const override
1145 { return "Minimal"; }
1147 /* See language.h. */
1148 void language_arch_info (struct gdbarch
*gdbarch
,
1149 struct language_arch_info
*lai
) const override
1151 c_language_arch_info (gdbarch
, lai
);
1154 /* See language.h. */
1156 bool can_print_type_offsets () const override
1161 /* See language.h. */
1163 void print_type (struct type
*type
, const char *varstring
,
1164 struct ui_file
*stream
, int show
, int level
,
1165 const struct type_print_options
*flags
) const override
1167 c_print_type (type
, varstring
, stream
, show
, level
, la_language
, flags
);
1170 /* See language.h. */
1172 bool store_sym_names_in_linkage_form_p () const override
1175 /* See language.h. */
1177 enum macro_expansion
macro_expansion () const override
1178 { return macro_expansion_c
; }
1181 /* The single instance of the minimal language class. */
1182 static minimal_language minimal_language_defn
;