1 /* Multiple source language support for GDB.
2 Copyright 1991, 1992 Free Software Foundation, Inc.
3 Contributed by the Department of Computer Science at the State University
4 of New York at Buffalo.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
22 /* This file contains functions that return things that are specific
23 to languages. Each function should examine current_language if necessary,
24 and return the appropriate result. */
26 /* FIXME: Most of these would be better organized as macros which
27 return data out of a "language-specific" struct pointer that is set
28 whenever the working language changes. That would be a lot faster. */
39 #include "expression.h"
42 #include "parser-defs.h"
45 show_language_command PARAMS ((char *, int));
48 set_language_command PARAMS ((char *, int));
51 show_type_command PARAMS ((char *, int));
54 set_type_command PARAMS ((char *, int));
57 show_range_command PARAMS ((char *, int));
60 set_range_command PARAMS ((char *, int));
63 set_range_str PARAMS ((void));
66 set_type_str PARAMS ((void));
69 set_lang_str PARAMS ((void));
72 unk_lang_error PARAMS ((char *));
75 unk_lang_parser PARAMS ((void));
78 show_check PARAMS ((char *, int));
81 set_check PARAMS ((char *, int));
84 set_type_range PARAMS ((void));
86 /* Forward declaration */
87 extern const struct language_defn unknown_language_defn;
88 extern char *warning_pre_print;
90 /* The current (default at startup) state of type and range checking.
91 (If the modes are set to "auto", though, these are changed based
92 on the default language at startup, and then again based on the
93 language of the first source file. */
95 enum range_mode range_mode = range_mode_auto;
96 enum range_check range_check = range_check_off;
97 enum type_mode type_mode = type_mode_auto;
98 enum type_check type_check = type_check_off;
100 /* The current language and language_mode (see language.h) */
102 const struct language_defn *current_language = &unknown_language_defn;
103 enum language_mode language_mode = language_mode_auto;
105 /* The language that the user expects to be typing in (the language
106 of main(), or the last language we notified them about, or C). */
108 const struct language_defn *expected_language;
110 /* The list of supported languages. The list itself is malloc'd. */
112 static const struct language_defn **languages;
113 static unsigned languages_size;
114 static unsigned languages_allocsize;
115 #define DEFAULT_ALLOCSIZE 4
117 /* The "set language/type/range" commands all put stuff in these
118 buffers. This is to make them work as set/show commands. The
119 user's string is copied here, then the set_* commands look at
120 them and update them to something that looks nice when it is
123 static char *language;
127 /* Warning issued when current_language and the language of the current
128 frame do not match. */
129 char lang_frame_mismatch_warn[] =
130 "Warning: the current language does not match this frame.";
133 /* This page contains the functions corresponding to GDB commands
134 and their helpers. */
136 /* Show command. Display a warning if the language set
137 does not match the frame. */
139 show_language_command (ignore, from_tty)
143 enum language flang; /* The language of the current frame */
145 flang = get_frame_language();
146 if (flang != language_unknown &&
147 language_mode == language_mode_manual &&
148 current_language->la_language != flang)
149 printf_filtered("%s\n",lang_frame_mismatch_warn);
152 /* Set command. Change the current working language. */
154 set_language_command (ignore, from_tty)
162 /* FIXME -- do this from the list, with HELP. */
163 if (!language || !language[0]) {
164 printf_unfiltered("The currently understood settings are:\n\n");
165 printf_unfiltered ("local or auto Automatic setting based on source file\n");
166 printf_unfiltered ("c Use the C language\n");
167 printf_unfiltered ("c++ Use the C++ language\n");
168 printf_unfiltered ("chill Use the Chill language\n");
169 printf_unfiltered ("modula-2 Use the Modula-2 language\n");
170 /* Restore the silly string. */
171 set_language(current_language->la_language);
175 /* Search the list of languages for a match. */
176 for (i = 0; i < languages_size; i++) {
177 if (STREQ (languages[i]->la_name, language)) {
178 /* Found it! Go into manual mode, and use this language. */
179 if (languages[i]->la_language == language_auto) {
180 /* Enter auto mode. Set to the current frame's language, if known. */
181 language_mode = language_mode_auto;
182 flang = get_frame_language();
183 if (flang!=language_unknown)
185 expected_language = current_language;
188 /* Enter manual mode. Set the specified language. */
189 language_mode = language_mode_manual;
190 current_language = languages[i];
193 expected_language = current_language;
199 /* Reset the language (esp. the global string "language") to the
201 err_lang=savestring(language,strlen(language));
202 make_cleanup (free, err_lang); /* Free it after error */
203 set_language(current_language->la_language);
204 error ("Unknown language `%s'.",err_lang);
207 /* Show command. Display a warning if the type setting does
208 not match the current language. */
210 show_type_command(ignore, from_tty)
214 if (type_check != current_language->la_type_check)
216 "Warning: the current type check setting does not match the language.\n");
219 /* Set command. Change the setting for type checking. */
221 set_type_command(ignore, from_tty)
225 if (STREQ(type,"on"))
227 type_check = type_check_on;
228 type_mode = type_mode_manual;
230 else if (STREQ(type,"warn"))
232 type_check = type_check_warn;
233 type_mode = type_mode_manual;
235 else if (STREQ(type,"off"))
237 type_check = type_check_off;
238 type_mode = type_mode_manual;
240 else if (STREQ(type,"auto"))
242 type_mode = type_mode_auto;
244 /* Avoid hitting the set_type_str call below. We
245 did it in set_type_range. */
249 show_type_command((char *)NULL, from_tty);
252 /* Show command. Display a warning if the range setting does
253 not match the current language. */
255 show_range_command(ignore, from_tty)
260 if (range_check != current_language->la_range_check)
262 "Warning: the current range check setting does not match the language.\n");
265 /* Set command. Change the setting for range checking. */
267 set_range_command(ignore, from_tty)
271 if (STREQ(range,"on"))
273 range_check = range_check_on;
274 range_mode = range_mode_manual;
276 else if (STREQ(range,"warn"))
278 range_check = range_check_warn;
279 range_mode = range_mode_manual;
281 else if (STREQ(range,"off"))
283 range_check = range_check_off;
284 range_mode = range_mode_manual;
286 else if (STREQ(range,"auto"))
288 range_mode = range_mode_auto;
290 /* Avoid hitting the set_range_str call below. We
291 did it in set_type_range. */
295 show_range_command((char *)0, from_tty);
298 /* Set the status of range and type checking based on
299 the current modes and the current language.
300 If SHOW is non-zero, then print out the current language,
301 type and range checking status. */
306 if (range_mode == range_mode_auto)
307 range_check = current_language->la_range_check;
309 if (type_mode == type_mode_auto)
310 type_check = current_language->la_type_check;
316 /* Set current language to (enum language) LANG. */
324 for (i = 0; i < languages_size; i++) {
325 if (languages[i]->la_language == lang) {
326 current_language = languages[i];
334 /* This page contains functions that update the global vars
335 language, type and range. */
342 if (language_mode == language_mode_auto)
343 prefix = "auto; currently ";
345 language = concat(prefix, current_language->la_name, NULL);
351 char *tmp, *prefix = "";
354 if (type_mode==type_mode_auto)
355 prefix = "auto; currently ";
365 case type_check_warn:
369 error ("Unrecognized type check setting.");
372 type = concat(prefix,tmp,NULL);
378 char *tmp, *pref = "";
381 if (range_mode==range_mode_auto)
382 pref = "auto; currently ";
389 case range_check_off:
392 case range_check_warn:
396 error ("Unrecognized range check setting.");
399 range = concat(pref,tmp,NULL);
403 /* Print out the current language settings: language, range and
404 type checking. If QUIETLY, print only what has changed. */
407 language_info (quietly)
410 if (quietly && expected_language == current_language)
413 expected_language = current_language;
414 printf_unfiltered("Current language: %s\n",language);
415 show_language_command((char *)0, 1);
419 printf_unfiltered("Type checking: %s\n",type);
420 show_type_command((char *)0, 1);
421 printf_unfiltered("Range checking: %s\n",range);
422 show_range_command((char *)0, 1);
426 /* Return the result of a binary operation. */
428 #if 0 /* Currently unused */
431 binop_result_type (v1, v2)
436 l1 = TYPE_LENGTH(VALUE_TYPE(v1));
437 l2 = TYPE_LENGTH(VALUE_TYPE(v2));
439 switch(current_language->la_language)
443 if (TYPE_CODE(VALUE_TYPE(v1))==TYPE_CODE_FLT)
444 return TYPE_CODE(VALUE_TYPE(v2)) == TYPE_CODE_FLT && l2 > l1 ?
445 VALUE_TYPE(v2) : VALUE_TYPE(v1);
446 else if (TYPE_CODE(VALUE_TYPE(v2))==TYPE_CODE_FLT)
447 return TYPE_CODE(VALUE_TYPE(v1)) == TYPE_CODE_FLT && l1 > l2 ?
448 VALUE_TYPE(v1) : VALUE_TYPE(v2);
449 else if (TYPE_UNSIGNED(VALUE_TYPE(v1)) && l1 > l2)
450 return VALUE_TYPE(v1);
451 else if (TYPE_UNSIGNED(VALUE_TYPE(v2)) && l2 > l1)
452 return VALUE_TYPE(v2);
453 else /* Both are signed. Result is the longer type */
454 return l1 > l2 ? VALUE_TYPE(v1) : VALUE_TYPE(v2);
457 /* If we are doing type-checking, l1 should equal l2, so this is
459 return l1 > l2 ? VALUE_TYPE(v1) : VALUE_TYPE(v2);
462 error ("Missing Chill support in function binop_result_check.");/*FIXME*/
465 return (struct type *)0; /* For lint */
471 /* This page contains functions that return format strings for
472 printf for printing out numbers in different formats */
474 /* Returns the appropriate printf format for hexadecimal
477 local_hex_format_custom(pre)
480 static char form[50];
482 strcpy (form, local_hex_format_prefix ());
485 strcat (form, local_hex_format_specifier ());
486 strcat (form, local_hex_format_suffix ());
490 /* Converts a number to hexadecimal and stores it in a static
491 string. Returns a pointer to this string. */
493 local_hex_string (num)
498 sprintf (res, local_hex_format(), num);
502 /* Converts a number to custom hexadecimal and stores it in a static
503 string. Returns a pointer to this string. */
505 local_hex_string_custom(num,pre)
511 sprintf (res, local_hex_format_custom(pre), num);
515 /* Returns the appropriate printf format for octal
518 local_octal_format_custom(pre)
521 static char form[50];
523 strcpy (form, local_octal_format_prefix ());
526 strcat (form, local_octal_format_specifier ());
527 strcat (form, local_octal_format_suffix ());
531 /* Returns the appropriate printf format for decimal numbers. */
533 local_decimal_format_custom(pre)
536 static char form[50];
538 strcpy (form, local_decimal_format_prefix ());
541 strcat (form, local_decimal_format_specifier ());
542 strcat (form, local_decimal_format_suffix ());
546 /* This page contains functions that are used in type/range checking.
547 They all return zero if the type/range check fails.
549 It is hoped that these will make extending GDB to parse different
550 languages a little easier. These are primarily used in eval.c when
551 evaluating expressions and making sure that their types are correct.
552 Instead of having a mess of conjucted/disjuncted expressions in an "if",
553 the ideas of type can be wrapped up in the following functions.
555 Note that some of them are not currently dependent upon which language
556 is currently being parsed. For example, floats are the same in
557 C and Modula-2 (ie. the only floating point type has TYPE_CODE of
558 TYPE_CODE_FLT), while booleans are different. */
560 /* Returns non-zero if its argument is a simple type. This is the same for
561 both Modula-2 and for C. In the C case, TYPE_CODE_CHAR will never occur,
562 and thus will never cause the failure of the test. */
567 switch (TYPE_CODE (type)) {
572 case TYPE_CODE_RANGE:
581 /* Returns non-zero if its argument is of an ordered type.
582 An ordered type is one in which the elements can be tested for the
583 properties of "greater than", "less than", etc, or for which the
584 operations "increment" or "decrement" make sense. */
589 switch (TYPE_CODE (type)) {
594 case TYPE_CODE_RANGE:
602 /* Returns non-zero if the two types are the same */
604 same_type (arg1, arg2)
605 struct type *arg1, *arg2;
607 if (structured_type(arg1) ? !structured_type(arg2) : structured_type(arg2))
608 /* One is structured and one isn't */
610 else if (structured_type(arg1) && structured_type(arg2))
612 else if (numeric_type(arg1) && numeric_type(arg2))
613 return (TYPE_CODE(arg2) == TYPE_CODE(arg1)) &&
614 (TYPE_UNSIGNED(arg1) == TYPE_UNSIGNED(arg2))
620 /* Returns non-zero if the type is integral */
625 switch(current_language->la_language)
629 return (TYPE_CODE(type) != TYPE_CODE_INT) &&
630 (TYPE_CODE(type) != TYPE_CODE_ENUM) ? 0 : 1;
632 return TYPE_CODE(type) != TYPE_CODE_INT ? 0 : 1;
634 error ("Missing Chill support in function integral_type."); /*FIXME*/
636 error ("Language not supported.");
640 /* Returns non-zero if the value is numeric */
645 switch (TYPE_CODE (type)) {
655 /* Returns non-zero if the value is a character type */
657 character_type (type)
660 switch(current_language->la_language)
664 return TYPE_CODE(type) != TYPE_CODE_CHAR ? 0 : 1;
668 return (TYPE_CODE(type) == TYPE_CODE_INT) &&
669 TYPE_LENGTH(type) == sizeof(char)
676 /* Returns non-zero if the value is a string type */
681 switch(current_language->la_language)
685 return TYPE_CODE(type) != TYPE_CODE_STRING ? 0 : 1;
689 /* C does not have distinct string type. */
696 /* Returns non-zero if the value is a boolean type */
701 if (TYPE_CODE (type) == TYPE_CODE_BOOL)
703 switch(current_language->la_language)
707 /* Might be more cleanly handled by having a TYPE_CODE_INT_NOT_BOOL
708 for CHILL and such languages, or a TYPE_CODE_INT_OR_BOOL for C. */
709 if (TYPE_CODE (type) == TYPE_CODE_INT)
717 /* Returns non-zero if the value is a floating-point type */
722 return TYPE_CODE(type) == TYPE_CODE_FLT;
725 /* Returns non-zero if the value is a pointer type */
730 return TYPE_CODE(type) == TYPE_CODE_PTR ||
731 TYPE_CODE(type) == TYPE_CODE_REF;
734 /* Returns non-zero if the value is a structured type */
736 structured_type(type)
739 switch(current_language->la_language)
743 return (TYPE_CODE(type) == TYPE_CODE_STRUCT) ||
744 (TYPE_CODE(type) == TYPE_CODE_UNION) ||
745 (TYPE_CODE(type) == TYPE_CODE_ARRAY);
747 return (TYPE_CODE(type) == TYPE_CODE_STRUCT) ||
748 (TYPE_CODE(type) == TYPE_CODE_SET) ||
749 (TYPE_CODE(type) == TYPE_CODE_ARRAY);
751 error ("Missing Chill support in function structured_type."); /*FIXME*/
757 /* This page contains functions that return info about
758 (struct value) values used in GDB. */
760 /* Returns non-zero if the value VAL represents a true value. */
765 /* It is possible that we should have some sort of error if a non-boolean
766 value is used in this context. Possibly dependent on some kind of
767 "boolean-checking" option like range checking. But it should probably
768 not depend on the language except insofar as is necessary to identify
769 a "boolean" value (i.e. in C using a float, pointer, etc., as a boolean
770 should be an error, probably). */
771 return !value_logical_not (val);
774 /* Returns non-zero if the operator OP is defined on
775 the values ARG1 and ARG2. */
777 #if 0 /* Currently unused */
780 binop_type_check(arg1,arg2,op)
784 struct type *t1, *t2;
786 /* If we're not checking types, always return success. */
800 if ((numeric_type(t1) && pointer_type(t2)) ||
801 (pointer_type(t1) && numeric_type(t2)))
803 warning ("combining pointer and integer.\n");
809 if (!numeric_type(t1) || !numeric_type(t2))
810 type_op_error ("Arguments to %s must be numbers.",op);
811 else if (!same_type(t1,t2))
812 type_op_error ("Arguments to %s must be of the same type.",op);
815 case BINOP_LOGICAL_AND:
816 case BINOP_LOGICAL_OR:
817 if (!boolean_type(t1) || !boolean_type(t2))
818 type_op_error ("Arguments to %s must be of boolean type.",op);
822 if ((pointer_type(t1) && !(pointer_type(t2) || integral_type(t2))) ||
823 (pointer_type(t2) && !(pointer_type(t1) || integral_type(t1))))
824 type_op_error ("A pointer can only be compared to an integer or pointer.",op);
825 else if ((pointer_type(t1) && integral_type(t2)) ||
826 (integral_type(t1) && pointer_type(t2)))
828 warning ("combining integer and pointer.\n");
831 else if (!simple_type(t1) || !simple_type(t2))
832 type_op_error ("Arguments to %s must be of simple type.",op);
833 else if (!same_type(t1,t2))
834 type_op_error ("Arguments to %s must be of the same type.",op);
839 if (!integral_type(t1) || !integral_type(t2))
840 type_op_error ("Arguments to %s must be of integral type.",op);
847 if (!ordered_type(t1) || !ordered_type(t2))
848 type_op_error ("Arguments to %s must be of ordered type.",op);
849 else if (!same_type(t1,t2))
850 type_op_error ("Arguments to %s must be of the same type.",op);
854 if (pointer_type(t1) && !integral_type(t2))
855 type_op_error ("A pointer can only be assigned an integer.",op);
856 else if (pointer_type(t1) && integral_type(t2))
858 warning ("combining integer and pointer.");
861 else if (!simple_type(t1) || !simple_type(t2))
862 type_op_error ("Arguments to %s must be of simple type.",op);
863 else if (!same_type(t1,t2))
864 type_op_error ("Arguments to %s must be of the same type.",op);
868 /* FIXME: Needs to handle bitstrings as well. */
869 if (!(string_type(t1) || character_type(t1) || integral_type(t1))
870 || !(string_type(t2) || character_type(t2) || integral_type(t2)))
871 type_op_error ("Arguments to %s must be strings or characters.", op);
874 /* Unary checks -- arg2 is null */
876 case UNOP_LOGICAL_NOT:
877 if (!boolean_type(t1))
878 type_op_error ("Argument to %s must be of boolean type.",op);
883 if (!numeric_type(t1))
884 type_op_error ("Argument to %s must be of numeric type.",op);
888 if (integral_type(t1))
890 warning ("combining pointer and integer.\n");
893 else if (!pointer_type(t1))
894 type_op_error ("Argument to %s must be a pointer.",op);
897 case UNOP_PREINCREMENT:
898 case UNOP_POSTINCREMENT:
899 case UNOP_PREDECREMENT:
900 case UNOP_POSTDECREMENT:
901 if (!ordered_type(t1))
902 type_op_error ("Argument to %s must be of an ordered type.",op);
906 /* Ok. The following operators have different meanings in
907 different languages. */
908 switch(current_language->la_language)
916 if (!numeric_type(t1) || !numeric_type(t2))
917 type_op_error ("Arguments to %s must be numbers.",op);
928 if (!float_type(t1) || !float_type(t2))
929 type_op_error ("Arguments to %s must be floating point numbers.",op);
932 if (!integral_type(t1) || !integral_type(t2))
933 type_op_error ("Arguments to %s must be of integral type.",op);
940 error ("Missing Chill support in function binop_type_check.");/*FIXME*/
950 /* This page contains functions for the printing out of
951 error messages that occur during type- and range-
954 /* Prints the format string FMT with the operator as a string
955 corresponding to the opcode OP. If FATAL is non-zero, then
956 this is an error and error () is called. Otherwise, it is
957 a warning and printf() is called. */
959 op_error (fmt,op,fatal)
965 error (fmt,op_string(op));
968 warning (fmt,op_string(op));
972 /* These are called when a language fails a type- or range-check.
973 The first argument should be a printf()-style format string, and
974 the rest of the arguments should be its arguments. If
975 [type|range]_check is [type|range]_check_on, then return_to_top_level()
976 is called in the style of error (). Otherwise, the message is prefixed
977 by the value of warning_pre_print and we do not return to the top level. */
980 type_error (va_alist)
986 if (type_check==type_check_warn)
987 fprintf_unfiltered(gdb_stderr,warning_pre_print);
989 target_terminal_ours();
992 string = va_arg (args, char *);
993 vfprintf_unfiltered (gdb_stderr, string, args);
994 fprintf_unfiltered (gdb_stderr, "\n");
996 if (type_check==type_check_on)
997 return_to_top_level (RETURN_ERROR);
1001 range_error (va_alist)
1007 if (range_check==range_check_warn)
1008 fprintf_unfiltered(gdb_stderr,warning_pre_print);
1010 target_terminal_ours();
1013 string = va_arg (args, char *);
1014 vfprintf_unfiltered (gdb_stderr, string, args);
1015 fprintf_unfiltered (gdb_stderr, "\n");
1017 if (range_check==range_check_on)
1018 return_to_top_level (RETURN_ERROR);
1022 /* This page contains miscellaneous functions */
1024 /* Return the language struct for a given language enum. */
1026 const struct language_defn *
1032 for (i = 0; i < languages_size; i++) {
1033 if (languages[i]->la_language == lang) {
1034 return languages[i];
1040 /* Return the language as a string */
1047 for (i = 0; i < languages_size; i++) {
1048 if (languages[i]->la_language == lang) {
1049 return languages[i]->la_name;
1056 set_check (ignore, from_tty)
1061 "\"set check\" must be followed by the name of a check subcommand.\n");
1062 help_list(setchecklist, "set check ", -1, gdb_stdout);
1066 show_check (ignore, from_tty)
1070 cmd_show_list(showchecklist, from_tty, "");
1073 /* Add a language to the set of known languages. */
1077 const struct language_defn *lang;
1079 if (lang->la_magic != LANG_MAGIC)
1081 fprintf_unfiltered(gdb_stderr, "Magic number of %s language struct wrong\n",
1088 languages_allocsize = DEFAULT_ALLOCSIZE;
1089 languages = (const struct language_defn **) xmalloc
1090 (languages_allocsize * sizeof (*languages));
1092 if (languages_size >= languages_allocsize)
1094 languages_allocsize *= 2;
1095 languages = (const struct language_defn **) xrealloc ((char *) languages,
1096 languages_allocsize * sizeof (*languages));
1098 languages[languages_size++] = lang;
1101 /* Define the language that is no language. */
1110 unk_lang_error (msg)
1113 error ("Attempted to parse an expression with unknown language");
1117 unk_lang_printchar (c, stream)
1121 error ("internal error - unimplemented function unk_lang_printchar called.");
1125 unk_lang_printstr (stream, string, length, force_ellipses)
1128 unsigned int length;
1131 error ("internal error - unimplemented function unk_lang_printstr called.");
1134 static struct type *
1135 unk_lang_create_fundamental_type (objfile, typeid)
1136 struct objfile *objfile;
1139 error ("internal error - unimplemented function unk_lang_create_fundamental_type called.");
1143 unk_lang_print_type (type, varstring, stream, show, level)
1150 error ("internal error - unimplemented function unk_lang_print_type called.");
1154 unk_lang_val_print (type, valaddr, address, stream, format, deref_ref,
1163 enum val_prettyprint pretty;
1165 error ("internal error - unimplemented function unk_lang_val_print called.");
1168 static struct type ** const (unknown_builtin_types[]) = { 0 };
1169 static const struct op_print unk_op_print_tab[] = {
1170 {NULL, OP_NULL, PREC_NULL, 0}
1173 const struct language_defn unknown_language_defn = {
1176 &unknown_builtin_types[0],
1181 unk_lang_printchar, /* Print character constant */
1183 unk_lang_create_fundamental_type,
1184 unk_lang_print_type, /* Print a type using appropriate syntax */
1185 unk_lang_val_print, /* Print a value using appropriate syntax */
1186 &builtin_type_error, /* longest floating point type */
1187 {"", "", "", ""}, /* Binary format info */
1188 {"0%lo", "0", "o", ""}, /* Octal format info */
1189 {"%ld", "", "d", ""}, /* Decimal format info */
1190 {"0x%lx", "0x", "x", ""}, /* Hex format info */
1191 unk_op_print_tab, /* expression operators for printing */
1195 /* These two structs define fake entries for the "local" and "auto" options. */
1196 const struct language_defn auto_language_defn = {
1199 &unknown_builtin_types[0],
1204 unk_lang_printchar, /* Print character constant */
1206 unk_lang_create_fundamental_type,
1207 unk_lang_print_type, /* Print a type using appropriate syntax */
1208 unk_lang_val_print, /* Print a value using appropriate syntax */
1209 &builtin_type_error, /* longest floating point type */
1210 {"", "", "", ""}, /* Binary format info */
1211 {"0%lo", "0", "o", ""}, /* Octal format info */
1212 {"%ld", "", "d", ""}, /* Decimal format info */
1213 {"0x%lx", "0x", "x", ""}, /* Hex format info */
1214 unk_op_print_tab, /* expression operators for printing */
1218 const struct language_defn local_language_defn = {
1221 &unknown_builtin_types[0],
1226 unk_lang_printchar, /* Print character constant */
1228 unk_lang_create_fundamental_type,
1229 unk_lang_print_type, /* Print a type using appropriate syntax */
1230 unk_lang_val_print, /* Print a value using appropriate syntax */
1231 &builtin_type_error, /* longest floating point type */
1232 {"", "", "", ""}, /* Binary format info */
1233 {"0%lo", "0", "o", ""}, /* Octal format info */
1234 {"%ld", "", "d", ""}, /* Decimal format info */
1235 {"0x%lx", "0x", "x", ""}, /* Hex format info */
1236 unk_op_print_tab, /* expression operators for printing */
1240 /* Initialize the language routines */
1243 _initialize_language()
1245 struct cmd_list_element *set, *show;
1247 /* GDB commands for language specific stuff */
1249 set = add_set_cmd ("language", class_support, var_string_noescape,
1251 "Set the current source language.",
1253 show = add_show_from_set (set, &showlist);
1254 set->function.cfunc = set_language_command;
1255 show->function.cfunc = show_language_command;
1257 add_prefix_cmd ("check", no_class, set_check,
1258 "Set the status of the type/range checker",
1259 &setchecklist, "set check ", 0, &setlist);
1260 add_alias_cmd ("c", "check", no_class, 1, &setlist);
1261 add_alias_cmd ("ch", "check", no_class, 1, &setlist);
1263 add_prefix_cmd ("check", no_class, show_check,
1264 "Show the status of the type/range checker",
1265 &showchecklist, "show check ", 0, &showlist);
1266 add_alias_cmd ("c", "check", no_class, 1, &showlist);
1267 add_alias_cmd ("ch", "check", no_class, 1, &showlist);
1269 set = add_set_cmd ("type", class_support, var_string_noescape,
1271 "Set type checking. (on/warn/off/auto)",
1273 show = add_show_from_set (set, &showchecklist);
1274 set->function.cfunc = set_type_command;
1275 show->function.cfunc = show_type_command;
1277 set = add_set_cmd ("range", class_support, var_string_noescape,
1279 "Set range checking. (on/warn/off/auto)",
1281 show = add_show_from_set (set, &showchecklist);
1282 set->function.cfunc = set_range_command;
1283 show->function.cfunc = show_range_command;
1285 add_language (&unknown_language_defn);
1286 add_language (&local_language_defn);
1287 add_language (&auto_language_defn);
1289 language = savestring ("auto",strlen("auto"));
1290 range = savestring ("auto",strlen("auto"));
1291 type = savestring ("auto",strlen("auto"));
1293 /* Have the above take effect */
1295 set_language_command (language, 0);
1296 set_type_command (NULL, 0);
1297 set_range_command (NULL, 0);