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 ("fortran Use the Fortran language\n");
170 printf_unfiltered ("modula-2 Use the Modula-2 language\n");
171 /* Restore the silly string. */
172 set_language(current_language->la_language);
176 /* Search the list of languages for a match. */
177 for (i = 0; i < languages_size; i++) {
178 if (STREQ (languages[i]->la_name, language)) {
179 /* Found it! Go into manual mode, and use this language. */
180 if (languages[i]->la_language == language_auto) {
181 /* Enter auto mode. Set to the current frame's language, if known. */
182 language_mode = language_mode_auto;
183 flang = get_frame_language();
184 if (flang!=language_unknown)
186 expected_language = current_language;
189 /* Enter manual mode. Set the specified language. */
190 language_mode = language_mode_manual;
191 current_language = languages[i];
194 expected_language = current_language;
200 /* Reset the language (esp. the global string "language") to the
202 err_lang=savestring(language,strlen(language));
203 make_cleanup (free, err_lang); /* Free it after error */
204 set_language(current_language->la_language);
205 error ("Unknown language `%s'.",err_lang);
208 /* Show command. Display a warning if the type setting does
209 not match the current language. */
211 show_type_command(ignore, from_tty)
215 if (type_check != current_language->la_type_check)
217 "Warning: the current type check setting does not match the language.\n");
220 /* Set command. Change the setting for type checking. */
222 set_type_command(ignore, from_tty)
226 if (STREQ(type,"on"))
228 type_check = type_check_on;
229 type_mode = type_mode_manual;
231 else if (STREQ(type,"warn"))
233 type_check = type_check_warn;
234 type_mode = type_mode_manual;
236 else if (STREQ(type,"off"))
238 type_check = type_check_off;
239 type_mode = type_mode_manual;
241 else if (STREQ(type,"auto"))
243 type_mode = type_mode_auto;
245 /* Avoid hitting the set_type_str call below. We
246 did it in set_type_range. */
250 show_type_command((char *)NULL, from_tty);
253 /* Show command. Display a warning if the range setting does
254 not match the current language. */
256 show_range_command(ignore, from_tty)
261 if (range_check != current_language->la_range_check)
263 "Warning: the current range check setting does not match the language.\n");
266 /* Set command. Change the setting for range checking. */
268 set_range_command(ignore, from_tty)
272 if (STREQ(range,"on"))
274 range_check = range_check_on;
275 range_mode = range_mode_manual;
277 else if (STREQ(range,"warn"))
279 range_check = range_check_warn;
280 range_mode = range_mode_manual;
282 else if (STREQ(range,"off"))
284 range_check = range_check_off;
285 range_mode = range_mode_manual;
287 else if (STREQ(range,"auto"))
289 range_mode = range_mode_auto;
291 /* Avoid hitting the set_range_str call below. We
292 did it in set_type_range. */
296 show_range_command((char *)0, from_tty);
299 /* Set the status of range and type checking based on
300 the current modes and the current language.
301 If SHOW is non-zero, then print out the current language,
302 type and range checking status. */
307 if (range_mode == range_mode_auto)
308 range_check = current_language->la_range_check;
310 if (type_mode == type_mode_auto)
311 type_check = current_language->la_type_check;
317 /* Set current language to (enum language) LANG. */
325 for (i = 0; i < languages_size; i++) {
326 if (languages[i]->la_language == lang) {
327 current_language = languages[i];
335 /* This page contains functions that update the global vars
336 language, type and range. */
343 if (language_mode == language_mode_auto)
344 prefix = "auto; currently ";
346 language = concat(prefix, current_language->la_name, NULL);
352 char *tmp, *prefix = "";
355 if (type_mode==type_mode_auto)
356 prefix = "auto; currently ";
366 case type_check_warn:
370 error ("Unrecognized type check setting.");
373 type = concat(prefix,tmp,NULL);
379 char *tmp, *pref = "";
382 if (range_mode==range_mode_auto)
383 pref = "auto; currently ";
390 case range_check_off:
393 case range_check_warn:
397 error ("Unrecognized range check setting.");
400 range = concat(pref,tmp,NULL);
404 /* Print out the current language settings: language, range and
405 type checking. If QUIETLY, print only what has changed. */
408 language_info (quietly)
411 if (quietly && expected_language == current_language)
414 expected_language = current_language;
415 printf_unfiltered("Current language: %s\n",language);
416 show_language_command((char *)0, 1);
420 printf_unfiltered("Type checking: %s\n",type);
421 show_type_command((char *)0, 1);
422 printf_unfiltered("Range checking: %s\n",range);
423 show_range_command((char *)0, 1);
427 /* Return the result of a binary operation. */
429 #if 0 /* Currently unused */
432 binop_result_type (v1, v2)
437 l1 = TYPE_LENGTH(VALUE_TYPE(v1));
438 l2 = TYPE_LENGTH(VALUE_TYPE(v2));
440 switch(current_language->la_language)
444 if (TYPE_CODE(VALUE_TYPE(v1))==TYPE_CODE_FLT)
445 return TYPE_CODE(VALUE_TYPE(v2)) == TYPE_CODE_FLT && l2 > l1 ?
446 VALUE_TYPE(v2) : VALUE_TYPE(v1);
447 else if (TYPE_CODE(VALUE_TYPE(v2))==TYPE_CODE_FLT)
448 return TYPE_CODE(VALUE_TYPE(v1)) == TYPE_CODE_FLT && l1 > l2 ?
449 VALUE_TYPE(v1) : VALUE_TYPE(v2);
450 else if (TYPE_UNSIGNED(VALUE_TYPE(v1)) && l1 > l2)
451 return VALUE_TYPE(v1);
452 else if (TYPE_UNSIGNED(VALUE_TYPE(v2)) && l2 > l1)
453 return VALUE_TYPE(v2);
454 else /* Both are signed. Result is the longer type */
455 return l1 > l2 ? VALUE_TYPE(v1) : VALUE_TYPE(v2);
458 /* If we are doing type-checking, l1 should equal l2, so this is
460 return l1 > l2 ? VALUE_TYPE(v1) : VALUE_TYPE(v2);
463 error ("Missing Chill support in function binop_result_check.");/*FIXME*/
466 return (struct type *)0; /* For lint */
472 /* This page contains functions that return format strings for
473 printf for printing out numbers in different formats */
475 /* Returns the appropriate printf format for hexadecimal
478 local_hex_format_custom(pre)
481 static char form[50];
483 strcpy (form, local_hex_format_prefix ());
486 strcat (form, local_hex_format_specifier ());
487 strcat (form, local_hex_format_suffix ());
491 /* Converts a number to hexadecimal and stores it in a static
492 string. Returns a pointer to this string. */
494 local_hex_string (num)
499 sprintf (res, local_hex_format(), num);
503 /* Converts a number to custom hexadecimal and stores it in a static
504 string. Returns a pointer to this string. */
506 local_hex_string_custom(num,pre)
512 sprintf (res, local_hex_format_custom(pre), num);
516 /* Returns the appropriate printf format for octal
519 local_octal_format_custom(pre)
522 static char form[50];
524 strcpy (form, local_octal_format_prefix ());
527 strcat (form, local_octal_format_specifier ());
528 strcat (form, local_octal_format_suffix ());
532 /* Returns the appropriate printf format for decimal numbers. */
534 local_decimal_format_custom(pre)
537 static char form[50];
539 strcpy (form, local_decimal_format_prefix ());
542 strcat (form, local_decimal_format_specifier ());
543 strcat (form, local_decimal_format_suffix ());
547 /* This page contains functions that are used in type/range checking.
548 They all return zero if the type/range check fails.
550 It is hoped that these will make extending GDB to parse different
551 languages a little easier. These are primarily used in eval.c when
552 evaluating expressions and making sure that their types are correct.
553 Instead of having a mess of conjucted/disjuncted expressions in an "if",
554 the ideas of type can be wrapped up in the following functions.
556 Note that some of them are not currently dependent upon which language
557 is currently being parsed. For example, floats are the same in
558 C and Modula-2 (ie. the only floating point type has TYPE_CODE of
559 TYPE_CODE_FLT), while booleans are different. */
561 /* Returns non-zero if its argument is a simple type. This is the same for
562 both Modula-2 and for C. In the C case, TYPE_CODE_CHAR will never occur,
563 and thus will never cause the failure of the test. */
568 switch (TYPE_CODE (type)) {
573 case TYPE_CODE_RANGE:
582 /* Returns non-zero if its argument is of an ordered type.
583 An ordered type is one in which the elements can be tested for the
584 properties of "greater than", "less than", etc, or for which the
585 operations "increment" or "decrement" make sense. */
590 switch (TYPE_CODE (type)) {
595 case TYPE_CODE_RANGE:
603 /* Returns non-zero if the two types are the same */
605 same_type (arg1, arg2)
606 struct type *arg1, *arg2;
608 if (structured_type(arg1) ? !structured_type(arg2) : structured_type(arg2))
609 /* One is structured and one isn't */
611 else if (structured_type(arg1) && structured_type(arg2))
613 else if (numeric_type(arg1) && numeric_type(arg2))
614 return (TYPE_CODE(arg2) == TYPE_CODE(arg1)) &&
615 (TYPE_UNSIGNED(arg1) == TYPE_UNSIGNED(arg2))
621 /* Returns non-zero if the type is integral */
626 switch(current_language->la_language)
630 return (TYPE_CODE(type) != TYPE_CODE_INT) &&
631 (TYPE_CODE(type) != TYPE_CODE_ENUM) ? 0 : 1;
633 return TYPE_CODE(type) != TYPE_CODE_INT ? 0 : 1;
635 error ("Missing Chill support in function integral_type."); /*FIXME*/
637 error ("Language not supported.");
641 /* Returns non-zero if the value is numeric */
646 switch (TYPE_CODE (type)) {
656 /* Returns non-zero if the value is a character type */
658 character_type (type)
661 switch(current_language->la_language)
665 return TYPE_CODE(type) != TYPE_CODE_CHAR ? 0 : 1;
669 return (TYPE_CODE(type) == TYPE_CODE_INT) &&
670 TYPE_LENGTH(type) == sizeof(char)
677 /* Returns non-zero if the value is a string type */
682 switch(current_language->la_language)
686 return TYPE_CODE(type) != TYPE_CODE_STRING ? 0 : 1;
690 /* C does not have distinct string type. */
697 /* Returns non-zero if the value is a boolean type */
702 if (TYPE_CODE (type) == TYPE_CODE_BOOL)
704 switch(current_language->la_language)
708 /* Might be more cleanly handled by having a TYPE_CODE_INT_NOT_BOOL
709 for CHILL and such languages, or a TYPE_CODE_INT_OR_BOOL for C. */
710 if (TYPE_CODE (type) == TYPE_CODE_INT)
718 /* Returns non-zero if the value is a floating-point type */
723 return TYPE_CODE(type) == TYPE_CODE_FLT;
726 /* Returns non-zero if the value is a pointer type */
731 return TYPE_CODE(type) == TYPE_CODE_PTR ||
732 TYPE_CODE(type) == TYPE_CODE_REF;
735 /* Returns non-zero if the value is a structured type */
737 structured_type(type)
740 switch(current_language->la_language)
744 return (TYPE_CODE(type) == TYPE_CODE_STRUCT) ||
745 (TYPE_CODE(type) == TYPE_CODE_UNION) ||
746 (TYPE_CODE(type) == TYPE_CODE_ARRAY);
748 return (TYPE_CODE(type) == TYPE_CODE_STRUCT) ||
749 (TYPE_CODE(type) == TYPE_CODE_SET) ||
750 (TYPE_CODE(type) == TYPE_CODE_ARRAY);
752 error ("Missing Chill support in function structured_type."); /*FIXME*/
758 /* This page contains functions that return info about
759 (struct value) values used in GDB. */
761 /* Returns non-zero if the value VAL represents a true value. */
766 /* It is possible that we should have some sort of error if a non-boolean
767 value is used in this context. Possibly dependent on some kind of
768 "boolean-checking" option like range checking. But it should probably
769 not depend on the language except insofar as is necessary to identify
770 a "boolean" value (i.e. in C using a float, pointer, etc., as a boolean
771 should be an error, probably). */
772 return !value_logical_not (val);
775 /* Returns non-zero if the operator OP is defined on
776 the values ARG1 and ARG2. */
778 #if 0 /* Currently unused */
781 binop_type_check(arg1,arg2,op)
785 struct type *t1, *t2;
787 /* If we're not checking types, always return success. */
801 if ((numeric_type(t1) && pointer_type(t2)) ||
802 (pointer_type(t1) && numeric_type(t2)))
804 warning ("combining pointer and integer.\n");
810 if (!numeric_type(t1) || !numeric_type(t2))
811 type_op_error ("Arguments to %s must be numbers.",op);
812 else if (!same_type(t1,t2))
813 type_op_error ("Arguments to %s must be of the same type.",op);
816 case BINOP_LOGICAL_AND:
817 case BINOP_LOGICAL_OR:
818 if (!boolean_type(t1) || !boolean_type(t2))
819 type_op_error ("Arguments to %s must be of boolean type.",op);
823 if ((pointer_type(t1) && !(pointer_type(t2) || integral_type(t2))) ||
824 (pointer_type(t2) && !(pointer_type(t1) || integral_type(t1))))
825 type_op_error ("A pointer can only be compared to an integer or pointer.",op);
826 else if ((pointer_type(t1) && integral_type(t2)) ||
827 (integral_type(t1) && pointer_type(t2)))
829 warning ("combining integer and pointer.\n");
832 else if (!simple_type(t1) || !simple_type(t2))
833 type_op_error ("Arguments to %s must be of simple type.",op);
834 else if (!same_type(t1,t2))
835 type_op_error ("Arguments to %s must be of the same type.",op);
840 if (!integral_type(t1) || !integral_type(t2))
841 type_op_error ("Arguments to %s must be of integral type.",op);
848 if (!ordered_type(t1) || !ordered_type(t2))
849 type_op_error ("Arguments to %s must be of ordered type.",op);
850 else if (!same_type(t1,t2))
851 type_op_error ("Arguments to %s must be of the same type.",op);
855 if (pointer_type(t1) && !integral_type(t2))
856 type_op_error ("A pointer can only be assigned an integer.",op);
857 else if (pointer_type(t1) && integral_type(t2))
859 warning ("combining integer and pointer.");
862 else if (!simple_type(t1) || !simple_type(t2))
863 type_op_error ("Arguments to %s must be of simple type.",op);
864 else if (!same_type(t1,t2))
865 type_op_error ("Arguments to %s must be of the same type.",op);
869 /* FIXME: Needs to handle bitstrings as well. */
870 if (!(string_type(t1) || character_type(t1) || integral_type(t1))
871 || !(string_type(t2) || character_type(t2) || integral_type(t2)))
872 type_op_error ("Arguments to %s must be strings or characters.", op);
875 /* Unary checks -- arg2 is null */
877 case UNOP_LOGICAL_NOT:
878 if (!boolean_type(t1))
879 type_op_error ("Argument to %s must be of boolean type.",op);
884 if (!numeric_type(t1))
885 type_op_error ("Argument to %s must be of numeric type.",op);
889 if (integral_type(t1))
891 warning ("combining pointer and integer.\n");
894 else if (!pointer_type(t1))
895 type_op_error ("Argument to %s must be a pointer.",op);
898 case UNOP_PREINCREMENT:
899 case UNOP_POSTINCREMENT:
900 case UNOP_PREDECREMENT:
901 case UNOP_POSTDECREMENT:
902 if (!ordered_type(t1))
903 type_op_error ("Argument to %s must be of an ordered type.",op);
907 /* Ok. The following operators have different meanings in
908 different languages. */
909 switch(current_language->la_language)
917 if (!numeric_type(t1) || !numeric_type(t2))
918 type_op_error ("Arguments to %s must be numbers.",op);
929 if (!float_type(t1) || !float_type(t2))
930 type_op_error ("Arguments to %s must be floating point numbers.",op);
933 if (!integral_type(t1) || !integral_type(t2))
934 type_op_error ("Arguments to %s must be of integral type.",op);
941 error ("Missing Chill support in function binop_type_check.");/*FIXME*/
951 /* This page contains functions for the printing out of
952 error messages that occur during type- and range-
955 /* Prints the format string FMT with the operator as a string
956 corresponding to the opcode OP. If FATAL is non-zero, then
957 this is an error and error () is called. Otherwise, it is
958 a warning and printf() is called. */
960 op_error (fmt,op,fatal)
966 error (fmt,op_string(op));
969 warning (fmt,op_string(op));
973 /* These are called when a language fails a type- or range-check.
974 The first argument should be a printf()-style format string, and
975 the rest of the arguments should be its arguments. If
976 [type|range]_check is [type|range]_check_on, then return_to_top_level()
977 is called in the style of error (). Otherwise, the message is prefixed
978 by the value of warning_pre_print and we do not return to the top level. */
981 type_error (va_alist)
987 if (type_check == type_check_warn)
988 fprintf_filtered (gdb_stderr, warning_pre_print);
993 string = va_arg (args, char *);
994 vfprintf_filtered (gdb_stderr, string, args);
995 fprintf_filtered (gdb_stderr, "\n");
997 if (type_check == type_check_on)
998 return_to_top_level (RETURN_ERROR);
1002 range_error (va_alist)
1008 if (range_check == range_check_warn)
1009 fprintf_filtered (gdb_stderr, warning_pre_print);
1014 string = va_arg (args, char *);
1015 vfprintf_filtered (gdb_stderr, string, args);
1016 fprintf_filtered (gdb_stderr, "\n");
1018 if (range_check == range_check_on)
1019 return_to_top_level (RETURN_ERROR);
1023 /* This page contains miscellaneous functions */
1025 /* Return the language struct for a given language enum. */
1027 const struct language_defn *
1033 for (i = 0; i < languages_size; i++) {
1034 if (languages[i]->la_language == lang) {
1035 return languages[i];
1041 /* Return the language as a string */
1048 for (i = 0; i < languages_size; i++) {
1049 if (languages[i]->la_language == lang) {
1050 return languages[i]->la_name;
1057 set_check (ignore, from_tty)
1062 "\"set check\" must be followed by the name of a check subcommand.\n");
1063 help_list(setchecklist, "set check ", -1, gdb_stdout);
1067 show_check (ignore, from_tty)
1071 cmd_show_list(showchecklist, from_tty, "");
1074 /* Add a language to the set of known languages. */
1078 const struct language_defn *lang;
1080 if (lang->la_magic != LANG_MAGIC)
1082 fprintf_unfiltered(gdb_stderr, "Magic number of %s language struct wrong\n",
1089 languages_allocsize = DEFAULT_ALLOCSIZE;
1090 languages = (const struct language_defn **) xmalloc
1091 (languages_allocsize * sizeof (*languages));
1093 if (languages_size >= languages_allocsize)
1095 languages_allocsize *= 2;
1096 languages = (const struct language_defn **) xrealloc ((char *) languages,
1097 languages_allocsize * sizeof (*languages));
1099 languages[languages_size++] = lang;
1102 /* Define the language that is no language. */
1111 unk_lang_error (msg)
1114 error ("Attempted to parse an expression with unknown language");
1118 unk_lang_printchar (c, stream)
1122 error ("internal error - unimplemented function unk_lang_printchar called.");
1126 unk_lang_printstr (stream, string, length, force_ellipses)
1129 unsigned int length;
1132 error ("internal error - unimplemented function unk_lang_printstr called.");
1135 static struct type *
1136 unk_lang_create_fundamental_type (objfile, typeid)
1137 struct objfile *objfile;
1140 error ("internal error - unimplemented function unk_lang_create_fundamental_type called.");
1144 unk_lang_print_type (type, varstring, stream, show, level)
1151 error ("internal error - unimplemented function unk_lang_print_type called.");
1155 unk_lang_val_print (type, valaddr, address, stream, format, deref_ref,
1164 enum val_prettyprint pretty;
1166 error ("internal error - unimplemented function unk_lang_val_print called.");
1170 unk_lang_value_print (val, stream, format, pretty)
1174 enum val_prettyprint pretty;
1176 error ("internal error - unimplemented function unk_lang_value_print called.");
1179 static struct type ** const (unknown_builtin_types[]) = { 0 };
1180 static const struct op_print unk_op_print_tab[] = {
1181 {NULL, OP_NULL, PREC_NULL, 0}
1184 const struct language_defn unknown_language_defn = {
1187 &unknown_builtin_types[0],
1192 unk_lang_printchar, /* Print character constant */
1194 unk_lang_create_fundamental_type,
1195 unk_lang_print_type, /* Print a type using appropriate syntax */
1196 unk_lang_val_print, /* Print a value using appropriate syntax */
1197 unk_lang_value_print, /* Print a top-level value */
1198 {"", "", "", ""}, /* Binary format info */
1199 {"0%lo", "0", "o", ""}, /* Octal format info */
1200 {"%ld", "", "d", ""}, /* Decimal format info */
1201 {"0x%lx", "0x", "x", ""}, /* Hex format info */
1202 unk_op_print_tab, /* expression operators for printing */
1203 1, /* c-style arrays */
1204 0, /* String lower bound */
1205 &builtin_type_char, /* Type of string elements */
1209 /* These two structs define fake entries for the "local" and "auto" options. */
1210 const struct language_defn auto_language_defn = {
1213 &unknown_builtin_types[0],
1218 unk_lang_printchar, /* Print character constant */
1220 unk_lang_create_fundamental_type,
1221 unk_lang_print_type, /* Print a type using appropriate syntax */
1222 unk_lang_val_print, /* Print a value using appropriate syntax */
1223 unk_lang_value_print, /* Print a top-level value */
1224 {"", "", "", ""}, /* Binary format info */
1225 {"0%lo", "0", "o", ""}, /* Octal format info */
1226 {"%ld", "", "d", ""}, /* Decimal format info */
1227 {"0x%lx", "0x", "x", ""}, /* Hex format info */
1228 unk_op_print_tab, /* expression operators for printing */
1229 1, /* c-style arrays */
1230 0, /* String lower bound */
1231 &builtin_type_char, /* Type of string elements */
1235 const struct language_defn local_language_defn = {
1238 &unknown_builtin_types[0],
1243 unk_lang_printchar, /* Print character constant */
1245 unk_lang_create_fundamental_type,
1246 unk_lang_print_type, /* Print a type using appropriate syntax */
1247 unk_lang_val_print, /* Print a value using appropriate syntax */
1248 unk_lang_value_print, /* Print a top-level value */
1249 {"", "", "", ""}, /* Binary format info */
1250 {"0%lo", "0", "o", ""}, /* Octal format info */
1251 {"%ld", "", "d", ""}, /* Decimal format info */
1252 {"0x%lx", "0x", "x", ""}, /* Hex format info */
1253 unk_op_print_tab, /* expression operators for printing */
1254 1, /* c-style arrays */
1255 0, /* String lower bound */
1256 &builtin_type_char, /* Type of string elements */
1260 /* Initialize the language routines */
1263 _initialize_language()
1265 struct cmd_list_element *set, *show;
1267 /* GDB commands for language specific stuff */
1269 set = add_set_cmd ("language", class_support, var_string_noescape,
1271 "Set the current source language.",
1273 show = add_show_from_set (set, &showlist);
1274 set->function.cfunc = set_language_command;
1275 show->function.cfunc = show_language_command;
1277 add_prefix_cmd ("check", no_class, set_check,
1278 "Set the status of the type/range checker",
1279 &setchecklist, "set check ", 0, &setlist);
1280 add_alias_cmd ("c", "check", no_class, 1, &setlist);
1281 add_alias_cmd ("ch", "check", no_class, 1, &setlist);
1283 add_prefix_cmd ("check", no_class, show_check,
1284 "Show the status of the type/range checker",
1285 &showchecklist, "show check ", 0, &showlist);
1286 add_alias_cmd ("c", "check", no_class, 1, &showlist);
1287 add_alias_cmd ("ch", "check", no_class, 1, &showlist);
1289 set = add_set_cmd ("type", class_support, var_string_noescape,
1291 "Set type checking. (on/warn/off/auto)",
1293 show = add_show_from_set (set, &showchecklist);
1294 set->function.cfunc = set_type_command;
1295 show->function.cfunc = show_type_command;
1297 set = add_set_cmd ("range", class_support, var_string_noescape,
1299 "Set range checking. (on/warn/off/auto)",
1301 show = add_show_from_set (set, &showchecklist);
1302 set->function.cfunc = set_range_command;
1303 show->function.cfunc = show_range_command;
1305 add_language (&unknown_language_defn);
1306 add_language (&local_language_defn);
1307 add_language (&auto_language_defn);
1309 language = savestring ("auto",strlen("auto"));
1310 range = savestring ("auto",strlen("auto"));
1311 type = savestring ("auto",strlen("auto"));
1313 /* Have the above take effect */
1315 set_language_command (language, 0);
1316 set_type_command (NULL, 0);
1317 set_range_command (NULL, 0);