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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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. */
31 #include "gdb_string.h"
32 #ifdef ANSI_PROTOTYPES
43 #include "expression.h"
46 #include "parser-defs.h"
49 show_language_command PARAMS ((char *, int));
52 set_language_command PARAMS ((char *, int));
55 show_type_command PARAMS ((char *, int));
58 set_type_command PARAMS ((char *, int));
61 show_range_command PARAMS ((char *, int));
64 set_range_command PARAMS ((char *, int));
67 set_range_str PARAMS ((void));
70 set_type_str PARAMS ((void));
73 set_lang_str PARAMS ((void));
76 unk_lang_error PARAMS ((char *));
79 unk_lang_parser PARAMS ((void));
82 show_check PARAMS ((char *, int));
85 set_check PARAMS ((char *, int));
88 set_type_range PARAMS ((void));
90 /* Forward declaration */
91 extern const struct language_defn unknown_language_defn;
92 extern char *warning_pre_print;
94 /* The current (default at startup) state of type and range checking.
95 (If the modes are set to "auto", though, these are changed based
96 on the default language at startup, and then again based on the
97 language of the first source file. */
99 enum range_mode range_mode = range_mode_auto;
100 enum range_check range_check = range_check_off;
101 enum type_mode type_mode = type_mode_auto;
102 enum type_check type_check = type_check_off;
104 /* The current language and language_mode (see language.h) */
106 const struct language_defn *current_language = &unknown_language_defn;
107 enum language_mode language_mode = language_mode_auto;
109 /* The language that the user expects to be typing in (the language
110 of main(), or the last language we notified them about, or C). */
112 const struct language_defn *expected_language;
114 /* The list of supported languages. The list itself is malloc'd. */
116 static const struct language_defn **languages;
117 static unsigned languages_size;
118 static unsigned languages_allocsize;
119 #define DEFAULT_ALLOCSIZE 4
121 /* The "set language/type/range" commands all put stuff in these
122 buffers. This is to make them work as set/show commands. The
123 user's string is copied here, then the set_* commands look at
124 them and update them to something that looks nice when it is
127 static char *language;
131 /* Warning issued when current_language and the language of the current
132 frame do not match. */
133 char lang_frame_mismatch_warn[] =
134 "Warning: the current language does not match this frame.";
137 /* This page contains the functions corresponding to GDB commands
138 and their helpers. */
140 /* Show command. Display a warning if the language set
141 does not match the frame. */
143 show_language_command (ignore, from_tty)
147 enum language flang; /* The language of the current frame */
149 flang = get_frame_language();
150 if (flang != language_unknown &&
151 language_mode == language_mode_manual &&
152 current_language->la_language != flang)
153 printf_filtered("%s\n",lang_frame_mismatch_warn);
156 /* Set command. Change the current working language. */
158 set_language_command (ignore, from_tty)
166 /* FIXME -- do this from the list, with HELP. */
167 if (!language || !language[0]) {
168 printf_unfiltered("The currently understood settings are:\n\n");
169 printf_unfiltered ("local or auto Automatic setting based on source file\n");
170 printf_unfiltered ("c Use the C language\n");
171 printf_unfiltered ("c++ Use the C++ language\n");
172 printf_unfiltered ("chill Use the Chill language\n");
173 printf_unfiltered ("fortran Use the Fortran language\n");
174 printf_unfiltered ("modula-2 Use the Modula-2 language\n");
175 /* Restore the silly string. */
176 set_language(current_language->la_language);
180 /* Search the list of languages for a match. */
181 for (i = 0; i < languages_size; i++) {
182 if (STREQ (languages[i]->la_name, language)) {
183 /* Found it! Go into manual mode, and use this language. */
184 if (languages[i]->la_language == language_auto) {
185 /* Enter auto mode. Set to the current frame's language, if known. */
186 language_mode = language_mode_auto;
187 flang = get_frame_language();
188 if (flang!=language_unknown)
190 expected_language = current_language;
193 /* Enter manual mode. Set the specified language. */
194 language_mode = language_mode_manual;
195 current_language = languages[i];
198 expected_language = current_language;
204 /* Reset the language (esp. the global string "language") to the
206 err_lang=savestring(language,strlen(language));
207 make_cleanup (free, err_lang); /* Free it after error */
208 set_language(current_language->la_language);
209 error ("Unknown language `%s'.",err_lang);
212 /* Show command. Display a warning if the type setting does
213 not match the current language. */
215 show_type_command(ignore, from_tty)
219 if (type_check != current_language->la_type_check)
221 "Warning: the current type check setting does not match the language.\n");
224 /* Set command. Change the setting for type checking. */
226 set_type_command(ignore, from_tty)
230 if (STREQ(type,"on"))
232 type_check = type_check_on;
233 type_mode = type_mode_manual;
235 else if (STREQ(type,"warn"))
237 type_check = type_check_warn;
238 type_mode = type_mode_manual;
240 else if (STREQ(type,"off"))
242 type_check = type_check_off;
243 type_mode = type_mode_manual;
245 else if (STREQ(type,"auto"))
247 type_mode = type_mode_auto;
249 /* Avoid hitting the set_type_str call below. We
250 did it in set_type_range. */
254 show_type_command((char *)NULL, from_tty);
257 /* Show command. Display a warning if the range setting does
258 not match the current language. */
260 show_range_command(ignore, from_tty)
265 if (range_check != current_language->la_range_check)
267 "Warning: the current range check setting does not match the language.\n");
270 /* Set command. Change the setting for range checking. */
272 set_range_command(ignore, from_tty)
276 if (STREQ(range,"on"))
278 range_check = range_check_on;
279 range_mode = range_mode_manual;
281 else if (STREQ(range,"warn"))
283 range_check = range_check_warn;
284 range_mode = range_mode_manual;
286 else if (STREQ(range,"off"))
288 range_check = range_check_off;
289 range_mode = range_mode_manual;
291 else if (STREQ(range,"auto"))
293 range_mode = range_mode_auto;
295 /* Avoid hitting the set_range_str call below. We
296 did it in set_type_range. */
300 show_range_command((char *)0, from_tty);
303 /* Set the status of range and type checking based on
304 the current modes and the current language.
305 If SHOW is non-zero, then print out the current language,
306 type and range checking status. */
311 if (range_mode == range_mode_auto)
312 range_check = current_language->la_range_check;
314 if (type_mode == type_mode_auto)
315 type_check = current_language->la_type_check;
321 /* Set current language to (enum language) LANG. */
329 for (i = 0; i < languages_size; i++) {
330 if (languages[i]->la_language == lang) {
331 current_language = languages[i];
339 /* This page contains functions that update the global vars
340 language, type and range. */
347 if (language_mode == language_mode_auto)
348 prefix = "auto; currently ";
350 language = concat(prefix, current_language->la_name, NULL);
356 char *tmp, *prefix = "";
359 if (type_mode==type_mode_auto)
360 prefix = "auto; currently ";
370 case type_check_warn:
374 error ("Unrecognized type check setting.");
377 type = concat(prefix,tmp,NULL);
383 char *tmp, *pref = "";
386 if (range_mode==range_mode_auto)
387 pref = "auto; currently ";
394 case range_check_off:
397 case range_check_warn:
401 error ("Unrecognized range check setting.");
404 range = concat(pref,tmp,NULL);
408 /* Print out the current language settings: language, range and
409 type checking. If QUIETLY, print only what has changed. */
412 language_info (quietly)
415 if (quietly && expected_language == current_language)
418 expected_language = current_language;
419 printf_unfiltered("Current language: %s\n",language);
420 show_language_command((char *)0, 1);
424 printf_unfiltered("Type checking: %s\n",type);
425 show_type_command((char *)0, 1);
426 printf_unfiltered("Range checking: %s\n",range);
427 show_range_command((char *)0, 1);
431 /* Return the result of a binary operation. */
433 #if 0 /* Currently unused */
436 binop_result_type (v1, v2)
441 l1 = TYPE_LENGTH(VALUE_TYPE(v1));
442 l2 = TYPE_LENGTH(VALUE_TYPE(v2));
444 switch(current_language->la_language)
448 if (TYPE_CODE(VALUE_TYPE(v1))==TYPE_CODE_FLT)
449 return TYPE_CODE(VALUE_TYPE(v2)) == TYPE_CODE_FLT && l2 > l1 ?
450 VALUE_TYPE(v2) : VALUE_TYPE(v1);
451 else if (TYPE_CODE(VALUE_TYPE(v2))==TYPE_CODE_FLT)
452 return TYPE_CODE(VALUE_TYPE(v1)) == TYPE_CODE_FLT && l1 > l2 ?
453 VALUE_TYPE(v1) : VALUE_TYPE(v2);
454 else if (TYPE_UNSIGNED(VALUE_TYPE(v1)) && l1 > l2)
455 return VALUE_TYPE(v1);
456 else if (TYPE_UNSIGNED(VALUE_TYPE(v2)) && l2 > l1)
457 return VALUE_TYPE(v2);
458 else /* Both are signed. Result is the longer type */
459 return l1 > l2 ? VALUE_TYPE(v1) : VALUE_TYPE(v2);
462 /* If we are doing type-checking, l1 should equal l2, so this is
464 return l1 > l2 ? VALUE_TYPE(v1) : VALUE_TYPE(v2);
467 error ("Missing Chill support in function binop_result_check.");/*FIXME*/
470 return (struct type *)0; /* For lint */
476 /* This page contains functions that return format strings for
477 printf for printing out numbers in different formats */
479 /* Returns the appropriate printf format for hexadecimal
482 local_hex_format_custom(pre)
485 static char form[50];
487 strcpy (form, local_hex_format_prefix ());
490 strcat (form, local_hex_format_specifier ());
491 strcat (form, local_hex_format_suffix ());
495 /* Converts a number to hexadecimal and stores it in a static
496 string. Returns a pointer to this string. */
498 local_hex_string (num)
503 sprintf (res, local_hex_format(), num);
507 /* Converts a number to custom hexadecimal and stores it in a static
508 string. Returns a pointer to this string. */
510 local_hex_string_custom(num,pre)
516 sprintf (res, local_hex_format_custom(pre), num);
520 /* Returns the appropriate printf format for octal
523 local_octal_format_custom(pre)
526 static char form[50];
528 strcpy (form, local_octal_format_prefix ());
531 strcat (form, local_octal_format_specifier ());
532 strcat (form, local_octal_format_suffix ());
536 /* Returns the appropriate printf format for decimal numbers. */
538 local_decimal_format_custom(pre)
541 static char form[50];
543 strcpy (form, local_decimal_format_prefix ());
546 strcat (form, local_decimal_format_specifier ());
547 strcat (form, local_decimal_format_suffix ());
551 /* This page contains functions that are used in type/range checking.
552 They all return zero if the type/range check fails.
554 It is hoped that these will make extending GDB to parse different
555 languages a little easier. These are primarily used in eval.c when
556 evaluating expressions and making sure that their types are correct.
557 Instead of having a mess of conjucted/disjuncted expressions in an "if",
558 the ideas of type can be wrapped up in the following functions.
560 Note that some of them are not currently dependent upon which language
561 is currently being parsed. For example, floats are the same in
562 C and Modula-2 (ie. the only floating point type has TYPE_CODE of
563 TYPE_CODE_FLT), while booleans are different. */
565 /* Returns non-zero if its argument is a simple type. This is the same for
566 both Modula-2 and for C. In the C case, TYPE_CODE_CHAR will never occur,
567 and thus will never cause the failure of the test. */
572 switch (TYPE_CODE (type)) {
577 case TYPE_CODE_RANGE:
586 /* Returns non-zero if its argument is of an ordered type.
587 An ordered type is one in which the elements can be tested for the
588 properties of "greater than", "less than", etc, or for which the
589 operations "increment" or "decrement" make sense. */
594 switch (TYPE_CODE (type)) {
599 case TYPE_CODE_RANGE:
607 /* Returns non-zero if the two types are the same */
609 same_type (arg1, arg2)
610 struct type *arg1, *arg2;
612 if (structured_type(arg1) ? !structured_type(arg2) : structured_type(arg2))
613 /* One is structured and one isn't */
615 else if (structured_type(arg1) && structured_type(arg2))
617 else if (numeric_type(arg1) && numeric_type(arg2))
618 return (TYPE_CODE(arg2) == TYPE_CODE(arg1)) &&
619 (TYPE_UNSIGNED(arg1) == TYPE_UNSIGNED(arg2))
625 /* Returns non-zero if the type is integral */
630 switch(current_language->la_language)
634 return (TYPE_CODE(type) != TYPE_CODE_INT) &&
635 (TYPE_CODE(type) != TYPE_CODE_ENUM) ? 0 : 1;
637 return TYPE_CODE(type) != TYPE_CODE_INT ? 0 : 1;
639 error ("Missing Chill support in function integral_type."); /*FIXME*/
641 error ("Language not supported.");
645 /* Returns non-zero if the value is numeric */
650 switch (TYPE_CODE (type)) {
660 /* Returns non-zero if the value is a character type */
662 character_type (type)
665 switch(current_language->la_language)
669 return TYPE_CODE(type) != TYPE_CODE_CHAR ? 0 : 1;
673 return (TYPE_CODE(type) == TYPE_CODE_INT) &&
674 TYPE_LENGTH(type) == sizeof(char)
681 /* Returns non-zero if the value is a string type */
686 switch(current_language->la_language)
690 return TYPE_CODE(type) != TYPE_CODE_STRING ? 0 : 1;
694 /* C does not have distinct string type. */
701 /* Returns non-zero if the value is a boolean type */
706 if (TYPE_CODE (type) == TYPE_CODE_BOOL)
708 switch(current_language->la_language)
712 /* Might be more cleanly handled by having a TYPE_CODE_INT_NOT_BOOL
713 for CHILL and such languages, or a TYPE_CODE_INT_OR_BOOL for C. */
714 if (TYPE_CODE (type) == TYPE_CODE_INT)
722 /* Returns non-zero if the value is a floating-point type */
727 return TYPE_CODE(type) == TYPE_CODE_FLT;
730 /* Returns non-zero if the value is a pointer type */
735 return TYPE_CODE(type) == TYPE_CODE_PTR ||
736 TYPE_CODE(type) == TYPE_CODE_REF;
739 /* Returns non-zero if the value is a structured type */
741 structured_type(type)
744 switch(current_language->la_language)
748 return (TYPE_CODE(type) == TYPE_CODE_STRUCT) ||
749 (TYPE_CODE(type) == TYPE_CODE_UNION) ||
750 (TYPE_CODE(type) == TYPE_CODE_ARRAY);
752 return (TYPE_CODE(type) == TYPE_CODE_STRUCT) ||
753 (TYPE_CODE(type) == TYPE_CODE_SET) ||
754 (TYPE_CODE(type) == TYPE_CODE_ARRAY);
756 error ("Missing Chill support in function structured_type."); /*FIXME*/
762 /* This page contains functions that return info about
763 (struct value) values used in GDB. */
765 /* Returns non-zero if the value VAL represents a true value. */
770 /* It is possible that we should have some sort of error if a non-boolean
771 value is used in this context. Possibly dependent on some kind of
772 "boolean-checking" option like range checking. But it should probably
773 not depend on the language except insofar as is necessary to identify
774 a "boolean" value (i.e. in C using a float, pointer, etc., as a boolean
775 should be an error, probably). */
776 return !value_logical_not (val);
779 /* Returns non-zero if the operator OP is defined on
780 the values ARG1 and ARG2. */
782 #if 0 /* Currently unused */
785 binop_type_check(arg1,arg2,op)
789 struct type *t1, *t2;
791 /* If we're not checking types, always return success. */
805 if ((numeric_type(t1) && pointer_type(t2)) ||
806 (pointer_type(t1) && numeric_type(t2)))
808 warning ("combining pointer and integer.\n");
814 if (!numeric_type(t1) || !numeric_type(t2))
815 type_op_error ("Arguments to %s must be numbers.",op);
816 else if (!same_type(t1,t2))
817 type_op_error ("Arguments to %s must be of the same type.",op);
820 case BINOP_LOGICAL_AND:
821 case BINOP_LOGICAL_OR:
822 if (!boolean_type(t1) || !boolean_type(t2))
823 type_op_error ("Arguments to %s must be of boolean type.",op);
827 if ((pointer_type(t1) && !(pointer_type(t2) || integral_type(t2))) ||
828 (pointer_type(t2) && !(pointer_type(t1) || integral_type(t1))))
829 type_op_error ("A pointer can only be compared to an integer or pointer.",op);
830 else if ((pointer_type(t1) && integral_type(t2)) ||
831 (integral_type(t1) && pointer_type(t2)))
833 warning ("combining integer and pointer.\n");
836 else if (!simple_type(t1) || !simple_type(t2))
837 type_op_error ("Arguments to %s must be of simple type.",op);
838 else if (!same_type(t1,t2))
839 type_op_error ("Arguments to %s must be of the same type.",op);
844 if (!integral_type(t1) || !integral_type(t2))
845 type_op_error ("Arguments to %s must be of integral type.",op);
852 if (!ordered_type(t1) || !ordered_type(t2))
853 type_op_error ("Arguments to %s must be of ordered type.",op);
854 else if (!same_type(t1,t2))
855 type_op_error ("Arguments to %s must be of the same type.",op);
859 if (pointer_type(t1) && !integral_type(t2))
860 type_op_error ("A pointer can only be assigned an integer.",op);
861 else if (pointer_type(t1) && integral_type(t2))
863 warning ("combining integer and pointer.");
866 else if (!simple_type(t1) || !simple_type(t2))
867 type_op_error ("Arguments to %s must be of simple type.",op);
868 else if (!same_type(t1,t2))
869 type_op_error ("Arguments to %s must be of the same type.",op);
873 /* FIXME: Needs to handle bitstrings as well. */
874 if (!(string_type(t1) || character_type(t1) || integral_type(t1))
875 || !(string_type(t2) || character_type(t2) || integral_type(t2)))
876 type_op_error ("Arguments to %s must be strings or characters.", op);
879 /* Unary checks -- arg2 is null */
881 case UNOP_LOGICAL_NOT:
882 if (!boolean_type(t1))
883 type_op_error ("Argument to %s must be of boolean type.",op);
888 if (!numeric_type(t1))
889 type_op_error ("Argument to %s must be of numeric type.",op);
893 if (integral_type(t1))
895 warning ("combining pointer and integer.\n");
898 else if (!pointer_type(t1))
899 type_op_error ("Argument to %s must be a pointer.",op);
902 case UNOP_PREINCREMENT:
903 case UNOP_POSTINCREMENT:
904 case UNOP_PREDECREMENT:
905 case UNOP_POSTDECREMENT:
906 if (!ordered_type(t1))
907 type_op_error ("Argument to %s must be of an ordered type.",op);
911 /* Ok. The following operators have different meanings in
912 different languages. */
913 switch(current_language->la_language)
921 if (!numeric_type(t1) || !numeric_type(t2))
922 type_op_error ("Arguments to %s must be numbers.",op);
933 if (!float_type(t1) || !float_type(t2))
934 type_op_error ("Arguments to %s must be floating point numbers.",op);
937 if (!integral_type(t1) || !integral_type(t2))
938 type_op_error ("Arguments to %s must be of integral type.",op);
945 error ("Missing Chill support in function binop_type_check.");/*FIXME*/
955 /* This page contains functions for the printing out of
956 error messages that occur during type- and range-
959 /* Prints the format string FMT with the operator as a string
960 corresponding to the opcode OP. If FATAL is non-zero, then
961 this is an error and error () is called. Otherwise, it is
962 a warning and printf() is called. */
964 op_error (fmt,op,fatal)
970 error (fmt,op_string(op));
973 warning (fmt,op_string(op));
977 /* These are called when a language fails a type- or range-check.
978 The first argument should be a printf()-style format string, and
979 the rest of the arguments should be its arguments. If
980 [type|range]_check is [type|range]_check_on, then return_to_top_level()
981 is called in the style of error (). Otherwise, the message is prefixed
982 by the value of warning_pre_print and we do not return to the top level. */
985 #ifdef ANSI_PROTOTYPES
986 type_error (char *string, ...)
988 type_error (va_alist)
993 #ifdef ANSI_PROTOTYPES
994 va_start (args, string);
998 string = va_arg (args, char *);
1001 if (type_check == type_check_warn)
1002 fprintf_filtered (gdb_stderr, warning_pre_print);
1006 vfprintf_filtered (gdb_stderr, string, args);
1007 fprintf_filtered (gdb_stderr, "\n");
1009 if (type_check == type_check_on)
1010 return_to_top_level (RETURN_ERROR);
1014 #ifdef ANSI_PROTOTYPES
1015 range_error (char *string, ...)
1017 range_error (va_alist)
1022 #ifdef ANSI_PROTOTYPES
1023 va_start (args, string);
1027 string = va_arg (args, char *);
1030 if (range_check == range_check_warn)
1031 fprintf_filtered (gdb_stderr, warning_pre_print);
1035 vfprintf_filtered (gdb_stderr, string, args);
1036 fprintf_filtered (gdb_stderr, "\n");
1038 if (range_check == range_check_on)
1039 return_to_top_level (RETURN_ERROR);
1043 /* This page contains miscellaneous functions */
1045 /* Return the language struct for a given language enum. */
1047 const struct language_defn *
1053 for (i = 0; i < languages_size; i++) {
1054 if (languages[i]->la_language == lang) {
1055 return languages[i];
1061 /* Return the language as a string */
1068 for (i = 0; i < languages_size; i++) {
1069 if (languages[i]->la_language == lang) {
1070 return languages[i]->la_name;
1077 set_check (ignore, from_tty)
1082 "\"set check\" must be followed by the name of a check subcommand.\n");
1083 help_list(setchecklist, "set check ", -1, gdb_stdout);
1087 show_check (ignore, from_tty)
1091 cmd_show_list(showchecklist, from_tty, "");
1094 /* Add a language to the set of known languages. */
1098 const struct language_defn *lang;
1100 if (lang->la_magic != LANG_MAGIC)
1102 fprintf_unfiltered(gdb_stderr, "Magic number of %s language struct wrong\n",
1109 languages_allocsize = DEFAULT_ALLOCSIZE;
1110 languages = (const struct language_defn **) xmalloc
1111 (languages_allocsize * sizeof (*languages));
1113 if (languages_size >= languages_allocsize)
1115 languages_allocsize *= 2;
1116 languages = (const struct language_defn **) xrealloc ((char *) languages,
1117 languages_allocsize * sizeof (*languages));
1119 languages[languages_size++] = lang;
1122 /* Define the language that is no language. */
1131 unk_lang_error (msg)
1134 error ("Attempted to parse an expression with unknown language");
1138 unk_lang_printchar (c, stream)
1142 error ("internal error - unimplemented function unk_lang_printchar called.");
1146 unk_lang_printstr (stream, string, length, force_ellipses)
1149 unsigned int length;
1152 error ("internal error - unimplemented function unk_lang_printstr called.");
1155 static struct type *
1156 unk_lang_create_fundamental_type (objfile, typeid)
1157 struct objfile *objfile;
1160 error ("internal error - unimplemented function unk_lang_create_fundamental_type called.");
1164 unk_lang_print_type (type, varstring, stream, show, level)
1171 error ("internal error - unimplemented function unk_lang_print_type called.");
1175 unk_lang_val_print (type, valaddr, address, stream, format, deref_ref,
1184 enum val_prettyprint pretty;
1186 error ("internal error - unimplemented function unk_lang_val_print called.");
1190 unk_lang_value_print (val, stream, format, pretty)
1194 enum val_prettyprint pretty;
1196 error ("internal error - unimplemented function unk_lang_value_print called.");
1199 static struct type ** const (unknown_builtin_types[]) = { 0 };
1200 static const struct op_print unk_op_print_tab[] = {
1201 {NULL, OP_NULL, PREC_NULL, 0}
1204 const struct language_defn unknown_language_defn = {
1207 &unknown_builtin_types[0],
1212 evaluate_subexp_standard,
1213 unk_lang_printchar, /* Print character constant */
1215 unk_lang_create_fundamental_type,
1216 unk_lang_print_type, /* Print a type using appropriate syntax */
1217 unk_lang_val_print, /* Print a value using appropriate syntax */
1218 unk_lang_value_print, /* Print a top-level value */
1219 {"", "", "", ""}, /* Binary format info */
1220 {"0%lo", "0", "o", ""}, /* Octal format info */
1221 {"%ld", "", "d", ""}, /* Decimal format info */
1222 {"0x%lx", "0x", "x", ""}, /* Hex format info */
1223 unk_op_print_tab, /* expression operators for printing */
1224 1, /* c-style arrays */
1225 0, /* String lower bound */
1226 &builtin_type_char, /* Type of string elements */
1230 /* These two structs define fake entries for the "local" and "auto" options. */
1231 const struct language_defn auto_language_defn = {
1234 &unknown_builtin_types[0],
1239 evaluate_subexp_standard,
1240 unk_lang_printchar, /* Print character constant */
1242 unk_lang_create_fundamental_type,
1243 unk_lang_print_type, /* Print a type using appropriate syntax */
1244 unk_lang_val_print, /* Print a value using appropriate syntax */
1245 unk_lang_value_print, /* Print a top-level value */
1246 {"", "", "", ""}, /* Binary format info */
1247 {"0%lo", "0", "o", ""}, /* Octal format info */
1248 {"%ld", "", "d", ""}, /* Decimal format info */
1249 {"0x%lx", "0x", "x", ""}, /* Hex format info */
1250 unk_op_print_tab, /* expression operators for printing */
1251 1, /* c-style arrays */
1252 0, /* String lower bound */
1253 &builtin_type_char, /* Type of string elements */
1257 const struct language_defn local_language_defn = {
1260 &unknown_builtin_types[0],
1265 evaluate_subexp_standard,
1266 unk_lang_printchar, /* Print character constant */
1268 unk_lang_create_fundamental_type,
1269 unk_lang_print_type, /* Print a type using appropriate syntax */
1270 unk_lang_val_print, /* Print a value using appropriate syntax */
1271 unk_lang_value_print, /* Print a top-level value */
1272 {"", "", "", ""}, /* Binary format info */
1273 {"0%lo", "0", "o", ""}, /* Octal format info */
1274 {"%ld", "", "d", ""}, /* Decimal format info */
1275 {"0x%lx", "0x", "x", ""}, /* Hex format info */
1276 unk_op_print_tab, /* expression operators for printing */
1277 1, /* c-style arrays */
1278 0, /* String lower bound */
1279 &builtin_type_char, /* Type of string elements */
1283 /* Initialize the language routines */
1286 _initialize_language()
1288 struct cmd_list_element *set, *show;
1290 /* GDB commands for language specific stuff */
1292 set = add_set_cmd ("language", class_support, var_string_noescape,
1294 "Set the current source language.",
1296 show = add_show_from_set (set, &showlist);
1297 set->function.cfunc = set_language_command;
1298 show->function.cfunc = show_language_command;
1300 add_prefix_cmd ("check", no_class, set_check,
1301 "Set the status of the type/range checker",
1302 &setchecklist, "set check ", 0, &setlist);
1303 add_alias_cmd ("c", "check", no_class, 1, &setlist);
1304 add_alias_cmd ("ch", "check", no_class, 1, &setlist);
1306 add_prefix_cmd ("check", no_class, show_check,
1307 "Show the status of the type/range checker",
1308 &showchecklist, "show check ", 0, &showlist);
1309 add_alias_cmd ("c", "check", no_class, 1, &showlist);
1310 add_alias_cmd ("ch", "check", no_class, 1, &showlist);
1312 set = add_set_cmd ("type", class_support, var_string_noescape,
1314 "Set type checking. (on/warn/off/auto)",
1316 show = add_show_from_set (set, &showchecklist);
1317 set->function.cfunc = set_type_command;
1318 show->function.cfunc = show_type_command;
1320 set = add_set_cmd ("range", class_support, var_string_noescape,
1322 "Set range checking. (on/warn/off/auto)",
1324 show = add_show_from_set (set, &showchecklist);
1325 set->function.cfunc = set_range_command;
1326 show->function.cfunc = show_range_command;
1328 add_language (&unknown_language_defn);
1329 add_language (&local_language_defn);
1330 add_language (&auto_language_defn);
1332 language = savestring ("auto",strlen("auto"));
1333 range = savestring ("auto",strlen("auto"));
1334 type = savestring ("auto",strlen("auto"));
1336 /* Have the above take effect */
1338 set_language_command (language, 0);
1339 set_type_command (NULL, 0);
1340 set_range_command (NULL, 0);