1 /* C language support routines for GDB, the GNU debugger.
3 Copyright (C) 1992-2013 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 "macroscope.h"
29 #include "gdb_assert.h"
31 #include "gdb_string.h"
34 #include "cp-support.h"
35 #include "gdb_obstack.h"
37 #include "exceptions.h"
40 extern void _initialize_c_language (void);
42 /* Given a C string type, STR_TYPE, return the corresponding target
43 character set name. */
46 charset_for_string_type (enum c_string_type str_type,
47 struct gdbarch *gdbarch)
49 switch (str_type & ~C_CHAR)
52 return target_charset (gdbarch);
54 return target_wide_charset (gdbarch);
56 /* FIXME: UTF-16 is not always correct. */
57 if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
62 /* FIXME: UTF-32 is not always correct. */
63 if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
68 internal_error (__FILE__, __LINE__, _("unhandled c_string_type"));
71 /* Classify ELTTYPE according to what kind of character it is. Return
72 the enum constant representing the character type. Also set
73 *ENCODING to the name of the character set to use when converting
74 characters of this type in target BYTE_ORDER to the host character
77 static enum c_string_type
78 classify_type (struct type *elttype, struct gdbarch *gdbarch,
79 const char **encoding)
81 enum c_string_type result;
83 /* We loop because ELTTYPE may be a typedef, and we want to
84 successively peel each typedef until we reach a type we
85 understand. We don't use CHECK_TYPEDEF because that will strip
86 all typedefs at once -- but in C, wchar_t is itself a typedef, so
87 that would do the wrong thing. */
90 const char *name = TYPE_NAME (elttype);
92 if (TYPE_CODE (elttype) == TYPE_CODE_CHAR || !name)
98 if (!strcmp (name, "wchar_t"))
100 result = C_WIDE_CHAR;
104 if (!strcmp (name, "char16_t"))
110 if (!strcmp (name, "char32_t"))
116 if (TYPE_CODE (elttype) != TYPE_CODE_TYPEDEF)
119 /* Call for side effects. */
120 check_typedef (elttype);
122 if (TYPE_TARGET_TYPE (elttype))
123 elttype = TYPE_TARGET_TYPE (elttype);
126 /* Perhaps check_typedef did not update the target type. In
127 this case, force the lookup again and hope it works out.
128 It never will for C, but it might for C++. */
129 CHECK_TYPEDEF (elttype);
138 *encoding = charset_for_string_type (result, gdbarch);
143 /* Print the character C on STREAM as part of the contents of a
144 literal string whose delimiter is QUOTER. Note that that format
145 for printing characters and strings is language specific. */
148 c_emit_char (int c, struct type *type,
149 struct ui_file *stream, int quoter)
151 const char *encoding;
153 classify_type (type, get_type_arch (type), &encoding);
154 generic_emit_char (c, type, stream, quoter, encoding);
158 c_printchar (int c, struct type *type, struct ui_file *stream)
160 enum c_string_type str_type;
162 str_type = classify_type (type, get_type_arch (type), NULL);
168 fputc_filtered ('L', stream);
171 fputc_filtered ('u', stream);
174 fputc_filtered ('U', stream);
178 fputc_filtered ('\'', stream);
179 LA_EMIT_CHAR (c, type, stream, '\'');
180 fputc_filtered ('\'', stream);
183 /* Print the character string STRING, printing at most LENGTH
184 characters. LENGTH is -1 if the string is nul terminated. Each
185 character is WIDTH bytes long. Printing stops early if the number
186 hits print_max; repeat counts are printed as appropriate. Print
187 ellipses at the end if we had to stop before printing LENGTH
188 characters, or if FORCE_ELLIPSES. */
191 c_printstr (struct ui_file *stream, struct type *type,
192 const gdb_byte *string, unsigned int length,
193 const char *user_encoding, int force_ellipses,
194 const struct value_print_options *options)
196 enum c_string_type str_type;
197 const char *type_encoding;
198 const char *encoding;
200 str_type = (classify_type (type, get_type_arch (type), &type_encoding)
207 fputs_filtered ("L", stream);
210 fputs_filtered ("u", stream);
213 fputs_filtered ("U", stream);
217 encoding = (user_encoding && *user_encoding) ? user_encoding : type_encoding;
219 generic_printstr (stream, type, string, length, encoding, force_ellipses,
223 /* Obtain a C string from the inferior storing it in a newly allocated
224 buffer in BUFFER, which should be freed by the caller. If the in-
225 and out-parameter *LENGTH is specified at -1, the string is read
226 until a null character of the appropriate width is found, otherwise
227 the string is read to the length of characters specified. The size
228 of a character is determined by the length of the target type of
229 the pointer or array. If VALUE is an array with a known length,
230 the function will not read past the end of the array. On
231 completion, *LENGTH will be set to the size of the string read in
232 characters. (If a length of -1 is specified, the length returned
233 will not include the null character). CHARSET is always set to the
237 c_get_string (struct value *value, gdb_byte **buffer,
238 int *length, struct type **char_type,
239 const char **charset)
242 unsigned int fetchlimit;
243 struct type *type = check_typedef (value_type (value));
244 struct type *element_type = TYPE_TARGET_TYPE (type);
245 int req_length = *length;
246 enum bfd_endian byte_order
247 = gdbarch_byte_order (get_type_arch (type));
249 if (element_type == NULL)
252 if (TYPE_CODE (type) == TYPE_CODE_ARRAY)
254 /* If we know the size of the array, we can use it as a limit on
255 the number of characters to be fetched. */
256 if (TYPE_NFIELDS (type) == 1
257 && TYPE_CODE (TYPE_FIELD_TYPE (type, 0)) == TYPE_CODE_RANGE)
259 LONGEST low_bound, high_bound;
261 get_discrete_bounds (TYPE_FIELD_TYPE (type, 0),
262 &low_bound, &high_bound);
263 fetchlimit = high_bound - low_bound + 1;
266 fetchlimit = UINT_MAX;
268 else if (TYPE_CODE (type) == TYPE_CODE_PTR)
269 fetchlimit = UINT_MAX;
271 /* We work only with arrays and pointers. */
274 if (! c_textual_element_type (element_type, 0))
276 classify_type (element_type, get_type_arch (element_type), charset);
277 width = TYPE_LENGTH (element_type);
279 /* If the string lives in GDB's memory instead of the inferior's,
280 then we just need to copy it to BUFFER. Also, since such strings
281 are arrays with known size, FETCHLIMIT will hold the size of the
283 if ((VALUE_LVAL (value) == not_lval
284 || VALUE_LVAL (value) == lval_internalvar)
285 && fetchlimit != UINT_MAX)
288 const gdb_byte *contents = value_contents (value);
290 /* If a length is specified, use that. */
294 /* Otherwise, look for a null character. */
295 for (i = 0; i < fetchlimit; i++)
296 if (extract_unsigned_integer (contents + i * width,
297 width, byte_order) == 0)
300 /* I is now either a user-defined length, the number of non-null
301 characters, or FETCHLIMIT. */
303 *buffer = xmalloc (*length);
304 memcpy (*buffer, contents, *length);
309 CORE_ADDR addr = value_as_address (value);
311 err = read_string (addr, *length, width, fetchlimit,
312 byte_order, buffer, length);
316 memory_error (err, addr);
320 /* If the LENGTH is specified at -1, we want to return the string
321 length up to the terminating null character. If an actual length
322 was specified, we want to return the length of exactly what was
324 if (req_length == -1)
325 /* If the last character is null, subtract it from LENGTH. */
327 && extract_unsigned_integer (*buffer + *length - width,
328 width, byte_order) == 0)
331 /* The read_string function will return the number of bytes read.
332 If length returned from read_string was > 0, return the number of
333 characters read by dividing the number of bytes by width. */
335 *length = *length / width;
337 *char_type = element_type;
345 type_str = type_to_string (type);
348 make_cleanup (xfree, type_str);
349 error (_("Trying to read string with inappropriate type `%s'."),
353 error (_("Trying to read string with inappropriate type."));
358 /* Evaluating C and C++ expressions. */
360 /* Convert a UCN. The digits of the UCN start at P and extend no
361 farther than LIMIT. DEST_CHARSET is the name of the character set
362 into which the UCN should be converted. The results are written to
363 OUTPUT. LENGTH is the maximum length of the UCN, either 4 or 8.
364 Returns a pointer to just after the final digit of the UCN. */
367 convert_ucn (char *p, char *limit, const char *dest_charset,
368 struct obstack *output, int length)
370 unsigned long result = 0;
374 for (i = 0; i < length && p < limit && isxdigit (*p); ++i, ++p)
375 result = (result << 4) + host_hex_value (*p);
377 for (i = 3; i >= 0; --i)
379 data[i] = result & 0xff;
383 convert_between_encodings ("UTF-32BE", dest_charset, data,
384 4, 4, output, translit_none);
389 /* Emit a character, VALUE, which was specified numerically, to
390 OUTPUT. TYPE is the target character type. */
393 emit_numeric_character (struct type *type, unsigned long value,
394 struct obstack *output)
398 buffer = alloca (TYPE_LENGTH (type));
399 pack_long (buffer, type, value);
400 obstack_grow (output, buffer, TYPE_LENGTH (type));
403 /* Convert an octal escape sequence. TYPE is the target character
404 type. The digits of the escape sequence begin at P and extend no
405 farther than LIMIT. The result is written to OUTPUT. Returns a
406 pointer to just after the final digit of the escape sequence. */
409 convert_octal (struct type *type, char *p,
410 char *limit, struct obstack *output)
413 unsigned long value = 0;
416 i < 3 && p < limit && isdigit (*p) && *p != '8' && *p != '9';
419 value = 8 * value + host_hex_value (*p);
423 emit_numeric_character (type, value, output);
428 /* Convert a hex escape sequence. TYPE is the target character type.
429 The digits of the escape sequence begin at P and extend no farther
430 than LIMIT. The result is written to OUTPUT. Returns a pointer to
431 just after the final digit of the escape sequence. */
434 convert_hex (struct type *type, char *p,
435 char *limit, struct obstack *output)
437 unsigned long value = 0;
439 while (p < limit && isxdigit (*p))
441 value = 16 * value + host_hex_value (*p);
445 emit_numeric_character (type, value, output);
454 error (_("Malformed escape sequence")); \
457 /* Convert an escape sequence to a target format. TYPE is the target
458 character type to use, and DEST_CHARSET is the name of the target
459 character set. The backslash of the escape sequence is at *P, and
460 the escape sequence will not extend past LIMIT. The results are
461 written to OUTPUT. Returns a pointer to just past the final
462 character of the escape sequence. */
465 convert_escape (struct type *type, const char *dest_charset,
466 char *p, char *limit, struct obstack *output)
468 /* Skip the backslash. */
474 obstack_1grow (output, '\\');
481 error (_("\\x used with no following hex digits."));
482 p = convert_hex (type, p, limit, output);
493 p = convert_octal (type, p, limit, output);
499 int length = *p == 'u' ? 4 : 8;
503 error (_("\\u used with no following hex digits"));
504 p = convert_ucn (p, limit, dest_charset, output, length);
511 /* Given a single string from a (C-specific) OP_STRING list, convert
512 it to a target string, handling escape sequences specially. The
513 output is written to OUTPUT. DATA is the input string, which has
514 length LEN. DEST_CHARSET is the name of the target character set,
515 and TYPE is the type of target character to use. */
518 parse_one_string (struct obstack *output, char *data, int len,
519 const char *dest_charset, struct type *type)
529 /* Look for next escape, or the end of the input. */
530 while (p < limit && *p != '\\')
532 /* If we saw a run of characters, convert them all. */
534 convert_between_encodings (host_charset (), dest_charset,
535 (gdb_byte *) data, p - data, 1,
536 output, translit_none);
537 /* If we saw an escape, convert it. */
539 p = convert_escape (type, dest_charset, p, limit, output);
544 /* Expression evaluator for the C language family. Most operations
545 are delegated to evaluate_subexp_standard; see that function for a
546 description of the arguments. */
549 evaluate_subexp_c (struct type *expect_type, struct expression *exp,
550 int *pos, enum noside noside)
552 enum exp_opcode op = exp->elts[*pos].opcode;
560 struct obstack output;
561 struct cleanup *cleanup;
562 struct value *result;
563 enum c_string_type dest_type;
564 const char *dest_charset;
565 int satisfy_expected = 0;
567 obstack_init (&output);
568 cleanup = make_cleanup_obstack_free (&output);
571 oplen = longest_to_int (exp->elts[*pos].longconst);
574 limit = *pos + BYTES_TO_EXP_ELEM (oplen + 1);
576 = (enum c_string_type) longest_to_int (exp->elts[*pos].longconst);
577 switch (dest_type & ~C_CHAR)
580 type = language_string_char_type (exp->language_defn,
584 type = lookup_typename (exp->language_defn, exp->gdbarch,
588 type = lookup_typename (exp->language_defn, exp->gdbarch,
589 "char16_t", NULL, 0);
592 type = lookup_typename (exp->language_defn, exp->gdbarch,
593 "char32_t", NULL, 0);
596 internal_error (__FILE__, __LINE__, _("unhandled c_string_type"));
599 /* Ensure TYPE_LENGTH is valid for TYPE. */
600 check_typedef (type);
602 /* If the caller expects an array of some integral type,
603 satisfy them. If something odder is expected, rely on the
605 if (expect_type && TYPE_CODE (expect_type) == TYPE_CODE_ARRAY)
607 struct type *element_type
608 = check_typedef (TYPE_TARGET_TYPE (expect_type));
610 if (TYPE_CODE (element_type) == TYPE_CODE_INT
611 || TYPE_CODE (element_type) == TYPE_CODE_CHAR)
614 satisfy_expected = 1;
618 dest_charset = charset_for_string_type (dest_type, exp->gdbarch);
625 len = longest_to_int (exp->elts[*pos].longconst);
628 if (noside != EVAL_SKIP)
629 parse_one_string (&output, &exp->elts[*pos].string, len,
631 *pos += BYTES_TO_EXP_ELEM (len);
634 /* Skip the trailing length and opcode. */
637 if (noside == EVAL_SKIP)
639 /* Return a dummy value of the appropriate type. */
640 if (expect_type != NULL)
641 result = allocate_value (expect_type);
642 else if ((dest_type & C_CHAR) != 0)
643 result = allocate_value (type);
645 result = value_cstring ("", 0, type);
646 do_cleanups (cleanup);
650 if ((dest_type & C_CHAR) != 0)
654 if (obstack_object_size (&output) != TYPE_LENGTH (type))
655 error (_("Could not convert character "
656 "constant to target character set"));
657 value = unpack_long (type, (gdb_byte *) obstack_base (&output));
658 result = value_from_longest (type, value);
664 /* Write the terminating character. */
665 for (i = 0; i < TYPE_LENGTH (type); ++i)
666 obstack_1grow (&output, 0);
668 if (satisfy_expected)
670 LONGEST low_bound, high_bound;
671 int element_size = TYPE_LENGTH (type);
673 if (get_discrete_bounds (TYPE_INDEX_TYPE (expect_type),
674 &low_bound, &high_bound) < 0)
677 high_bound = (TYPE_LENGTH (expect_type) / element_size) - 1;
679 if (obstack_object_size (&output) / element_size
680 > (high_bound - low_bound + 1))
681 error (_("Too many array elements"));
683 result = allocate_value (expect_type);
684 memcpy (value_contents_raw (result), obstack_base (&output),
685 obstack_object_size (&output));
688 result = value_cstring (obstack_base (&output),
689 obstack_object_size (&output),
692 do_cleanups (cleanup);
700 return evaluate_subexp_standard (expect_type, exp, pos, noside);
705 /* Table mapping opcodes into strings for printing operators
706 and precedences of the operators. */
708 const struct op_print c_op_print_tab[] =
710 {",", BINOP_COMMA, PREC_COMMA, 0},
711 {"=", BINOP_ASSIGN, PREC_ASSIGN, 1},
712 {"||", BINOP_LOGICAL_OR, PREC_LOGICAL_OR, 0},
713 {"&&", BINOP_LOGICAL_AND, PREC_LOGICAL_AND, 0},
714 {"|", BINOP_BITWISE_IOR, PREC_BITWISE_IOR, 0},
715 {"^", BINOP_BITWISE_XOR, PREC_BITWISE_XOR, 0},
716 {"&", BINOP_BITWISE_AND, PREC_BITWISE_AND, 0},
717 {"==", BINOP_EQUAL, PREC_EQUAL, 0},
718 {"!=", BINOP_NOTEQUAL, PREC_EQUAL, 0},
719 {"<=", BINOP_LEQ, PREC_ORDER, 0},
720 {">=", BINOP_GEQ, PREC_ORDER, 0},
721 {">", BINOP_GTR, PREC_ORDER, 0},
722 {"<", BINOP_LESS, PREC_ORDER, 0},
723 {">>", BINOP_RSH, PREC_SHIFT, 0},
724 {"<<", BINOP_LSH, PREC_SHIFT, 0},
725 {"+", BINOP_ADD, PREC_ADD, 0},
726 {"-", BINOP_SUB, PREC_ADD, 0},
727 {"*", BINOP_MUL, PREC_MUL, 0},
728 {"/", BINOP_DIV, PREC_MUL, 0},
729 {"%", BINOP_REM, PREC_MUL, 0},
730 {"@", BINOP_REPEAT, PREC_REPEAT, 0},
731 {"+", UNOP_PLUS, PREC_PREFIX, 0},
732 {"-", UNOP_NEG, PREC_PREFIX, 0},
733 {"!", UNOP_LOGICAL_NOT, PREC_PREFIX, 0},
734 {"~", UNOP_COMPLEMENT, PREC_PREFIX, 0},
735 {"*", UNOP_IND, PREC_PREFIX, 0},
736 {"&", UNOP_ADDR, PREC_PREFIX, 0},
737 {"sizeof ", UNOP_SIZEOF, PREC_PREFIX, 0},
738 {"++", UNOP_PREINCREMENT, PREC_PREFIX, 0},
739 {"--", UNOP_PREDECREMENT, PREC_PREFIX, 0},
743 enum c_primitive_types {
744 c_primitive_type_int,
745 c_primitive_type_long,
746 c_primitive_type_short,
747 c_primitive_type_char,
748 c_primitive_type_float,
749 c_primitive_type_double,
750 c_primitive_type_void,
751 c_primitive_type_long_long,
752 c_primitive_type_signed_char,
753 c_primitive_type_unsigned_char,
754 c_primitive_type_unsigned_short,
755 c_primitive_type_unsigned_int,
756 c_primitive_type_unsigned_long,
757 c_primitive_type_unsigned_long_long,
758 c_primitive_type_long_double,
759 c_primitive_type_complex,
760 c_primitive_type_double_complex,
761 c_primitive_type_decfloat,
762 c_primitive_type_decdouble,
763 c_primitive_type_declong,
768 c_language_arch_info (struct gdbarch *gdbarch,
769 struct language_arch_info *lai)
771 const struct builtin_type *builtin = builtin_type (gdbarch);
773 lai->string_char_type = builtin->builtin_char;
774 lai->primitive_type_vector
775 = GDBARCH_OBSTACK_CALLOC (gdbarch, nr_c_primitive_types + 1,
777 lai->primitive_type_vector [c_primitive_type_int] = builtin->builtin_int;
778 lai->primitive_type_vector [c_primitive_type_long] = builtin->builtin_long;
779 lai->primitive_type_vector [c_primitive_type_short] = builtin->builtin_short;
780 lai->primitive_type_vector [c_primitive_type_char] = builtin->builtin_char;
781 lai->primitive_type_vector [c_primitive_type_float] = builtin->builtin_float;
782 lai->primitive_type_vector [c_primitive_type_double] = builtin->builtin_double;
783 lai->primitive_type_vector [c_primitive_type_void] = builtin->builtin_void;
784 lai->primitive_type_vector [c_primitive_type_long_long] = builtin->builtin_long_long;
785 lai->primitive_type_vector [c_primitive_type_signed_char] = builtin->builtin_signed_char;
786 lai->primitive_type_vector [c_primitive_type_unsigned_char] = builtin->builtin_unsigned_char;
787 lai->primitive_type_vector [c_primitive_type_unsigned_short] = builtin->builtin_unsigned_short;
788 lai->primitive_type_vector [c_primitive_type_unsigned_int] = builtin->builtin_unsigned_int;
789 lai->primitive_type_vector [c_primitive_type_unsigned_long] = builtin->builtin_unsigned_long;
790 lai->primitive_type_vector [c_primitive_type_unsigned_long_long] = builtin->builtin_unsigned_long_long;
791 lai->primitive_type_vector [c_primitive_type_long_double] = builtin->builtin_long_double;
792 lai->primitive_type_vector [c_primitive_type_complex] = builtin->builtin_complex;
793 lai->primitive_type_vector [c_primitive_type_double_complex] = builtin->builtin_double_complex;
794 lai->primitive_type_vector [c_primitive_type_decfloat] = builtin->builtin_decfloat;
795 lai->primitive_type_vector [c_primitive_type_decdouble] = builtin->builtin_decdouble;
796 lai->primitive_type_vector [c_primitive_type_declong] = builtin->builtin_declong;
798 lai->bool_type_default = builtin->builtin_int;
801 const struct exp_descriptor exp_descriptor_c =
803 print_subexp_standard,
804 operator_length_standard,
805 operator_check_standard,
807 dump_subexp_body_standard,
811 const struct language_defn c_language_defn =
813 "c", /* Language name */
823 c_printchar, /* Print a character constant */
824 c_printstr, /* Function to print string constant */
825 c_emit_char, /* Print a single char */
826 c_print_type, /* Print a type using appropriate syntax */
827 c_print_typedef, /* Print a typedef using appropriate syntax */
828 c_val_print, /* Print a value using appropriate syntax */
829 c_value_print, /* Print a top-level value */
830 default_read_var_value, /* la_read_var_value */
831 NULL, /* Language specific skip_trampoline */
832 NULL, /* name_of_this */
833 basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
834 basic_lookup_transparent_type,/* lookup_transparent_type */
835 NULL, /* Language specific symbol demangler */
836 NULL, /* Language specific
837 class_name_from_physname */
838 c_op_print_tab, /* expression operators for printing */
839 1, /* c-style arrays */
840 0, /* String lower bound */
841 default_word_break_characters,
842 default_make_symbol_completion_list,
843 c_language_arch_info,
844 default_print_array_index,
845 default_pass_by_reference,
847 NULL, /* la_get_symbol_name_cmp */
848 iterate_over_symbols,
852 enum cplus_primitive_types {
853 cplus_primitive_type_int,
854 cplus_primitive_type_long,
855 cplus_primitive_type_short,
856 cplus_primitive_type_char,
857 cplus_primitive_type_float,
858 cplus_primitive_type_double,
859 cplus_primitive_type_void,
860 cplus_primitive_type_long_long,
861 cplus_primitive_type_signed_char,
862 cplus_primitive_type_unsigned_char,
863 cplus_primitive_type_unsigned_short,
864 cplus_primitive_type_unsigned_int,
865 cplus_primitive_type_unsigned_long,
866 cplus_primitive_type_unsigned_long_long,
867 cplus_primitive_type_long_double,
868 cplus_primitive_type_complex,
869 cplus_primitive_type_double_complex,
870 cplus_primitive_type_bool,
871 cplus_primitive_type_decfloat,
872 cplus_primitive_type_decdouble,
873 cplus_primitive_type_declong,
874 nr_cplus_primitive_types
878 cplus_language_arch_info (struct gdbarch *gdbarch,
879 struct language_arch_info *lai)
881 const struct builtin_type *builtin = builtin_type (gdbarch);
883 lai->string_char_type = builtin->builtin_char;
884 lai->primitive_type_vector
885 = GDBARCH_OBSTACK_CALLOC (gdbarch, nr_cplus_primitive_types + 1,
887 lai->primitive_type_vector [cplus_primitive_type_int]
888 = builtin->builtin_int;
889 lai->primitive_type_vector [cplus_primitive_type_long]
890 = builtin->builtin_long;
891 lai->primitive_type_vector [cplus_primitive_type_short]
892 = builtin->builtin_short;
893 lai->primitive_type_vector [cplus_primitive_type_char]
894 = builtin->builtin_char;
895 lai->primitive_type_vector [cplus_primitive_type_float]
896 = builtin->builtin_float;
897 lai->primitive_type_vector [cplus_primitive_type_double]
898 = builtin->builtin_double;
899 lai->primitive_type_vector [cplus_primitive_type_void]
900 = builtin->builtin_void;
901 lai->primitive_type_vector [cplus_primitive_type_long_long]
902 = builtin->builtin_long_long;
903 lai->primitive_type_vector [cplus_primitive_type_signed_char]
904 = builtin->builtin_signed_char;
905 lai->primitive_type_vector [cplus_primitive_type_unsigned_char]
906 = builtin->builtin_unsigned_char;
907 lai->primitive_type_vector [cplus_primitive_type_unsigned_short]
908 = builtin->builtin_unsigned_short;
909 lai->primitive_type_vector [cplus_primitive_type_unsigned_int]
910 = builtin->builtin_unsigned_int;
911 lai->primitive_type_vector [cplus_primitive_type_unsigned_long]
912 = builtin->builtin_unsigned_long;
913 lai->primitive_type_vector [cplus_primitive_type_unsigned_long_long]
914 = builtin->builtin_unsigned_long_long;
915 lai->primitive_type_vector [cplus_primitive_type_long_double]
916 = builtin->builtin_long_double;
917 lai->primitive_type_vector [cplus_primitive_type_complex]
918 = builtin->builtin_complex;
919 lai->primitive_type_vector [cplus_primitive_type_double_complex]
920 = builtin->builtin_double_complex;
921 lai->primitive_type_vector [cplus_primitive_type_bool]
922 = builtin->builtin_bool;
923 lai->primitive_type_vector [cplus_primitive_type_decfloat]
924 = builtin->builtin_decfloat;
925 lai->primitive_type_vector [cplus_primitive_type_decdouble]
926 = builtin->builtin_decdouble;
927 lai->primitive_type_vector [cplus_primitive_type_declong]
928 = builtin->builtin_declong;
930 lai->bool_type_symbol = "bool";
931 lai->bool_type_default = builtin->builtin_bool;
934 const struct language_defn cplus_language_defn =
936 "c++", /* Language name */
946 c_printchar, /* Print a character constant */
947 c_printstr, /* Function to print string constant */
948 c_emit_char, /* Print a single char */
949 c_print_type, /* Print a type using appropriate syntax */
950 c_print_typedef, /* Print a typedef using appropriate syntax */
951 c_val_print, /* Print a value using appropriate syntax */
952 c_value_print, /* Print a top-level value */
953 default_read_var_value, /* la_read_var_value */
954 cplus_skip_trampoline, /* Language specific skip_trampoline */
955 "this", /* name_of_this */
956 cp_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
957 cp_lookup_transparent_type, /* lookup_transparent_type */
958 gdb_demangle, /* Language specific symbol demangler */
959 cp_class_name_from_physname, /* Language specific
960 class_name_from_physname */
961 c_op_print_tab, /* expression operators for printing */
962 1, /* c-style arrays */
963 0, /* String lower bound */
964 default_word_break_characters,
965 default_make_symbol_completion_list,
966 cplus_language_arch_info,
967 default_print_array_index,
968 cp_pass_by_reference,
970 NULL, /* la_get_symbol_name_cmp */
971 iterate_over_symbols,
975 const struct language_defn asm_language_defn =
977 "asm", /* Language name */
987 c_printchar, /* Print a character constant */
988 c_printstr, /* Function to print string constant */
989 c_emit_char, /* Print a single char */
990 c_print_type, /* Print a type using appropriate syntax */
991 c_print_typedef, /* Print a typedef using appropriate syntax */
992 c_val_print, /* Print a value using appropriate syntax */
993 c_value_print, /* Print a top-level value */
994 default_read_var_value, /* la_read_var_value */
995 NULL, /* Language specific skip_trampoline */
996 NULL, /* name_of_this */
997 basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
998 basic_lookup_transparent_type,/* lookup_transparent_type */
999 NULL, /* Language specific symbol demangler */
1000 NULL, /* Language specific
1001 class_name_from_physname */
1002 c_op_print_tab, /* expression operators for printing */
1003 1, /* c-style arrays */
1004 0, /* String lower bound */
1005 default_word_break_characters,
1006 default_make_symbol_completion_list,
1007 c_language_arch_info, /* FIXME: la_language_arch_info. */
1008 default_print_array_index,
1009 default_pass_by_reference,
1011 NULL, /* la_get_symbol_name_cmp */
1012 iterate_over_symbols,
1016 /* The following language_defn does not represent a real language.
1017 It just provides a minimal support a-la-C that should allow users
1018 to do some simple operations when debugging applications that use
1019 a language currently not supported by GDB. */
1021 const struct language_defn minimal_language_defn =
1023 "minimal", /* Language name */
1033 c_printchar, /* Print a character constant */
1034 c_printstr, /* Function to print string constant */
1035 c_emit_char, /* Print a single char */
1036 c_print_type, /* Print a type using appropriate syntax */
1037 c_print_typedef, /* Print a typedef using appropriate syntax */
1038 c_val_print, /* Print a value using appropriate syntax */
1039 c_value_print, /* Print a top-level value */
1040 default_read_var_value, /* la_read_var_value */
1041 NULL, /* Language specific skip_trampoline */
1042 NULL, /* name_of_this */
1043 basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
1044 basic_lookup_transparent_type,/* lookup_transparent_type */
1045 NULL, /* Language specific symbol demangler */
1046 NULL, /* Language specific
1047 class_name_from_physname */
1048 c_op_print_tab, /* expression operators for printing */
1049 1, /* c-style arrays */
1050 0, /* String lower bound */
1051 default_word_break_characters,
1052 default_make_symbol_completion_list,
1053 c_language_arch_info,
1054 default_print_array_index,
1055 default_pass_by_reference,
1057 NULL, /* la_get_symbol_name_cmp */
1058 iterate_over_symbols,
1063 _initialize_c_language (void)
1065 add_language (&c_language_defn);
1066 add_language (&cplus_language_defn);
1067 add_language (&asm_language_defn);
1068 add_language (&minimal_language_defn);