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("The currently understood settings are:\n\n");
165 printf ("local or auto Automatic setting based on source file\n");
166 printf ("c Use the C language\n");
167 printf ("c++ Use the C++ language\n");
168 /* start-sanitize-chill */
169 printf ("chill Use the Chill language\n");
170 /* end-sanitize-chill */
171 printf ("modula-2 Use the Modula-2 language\n");
172 /* Restore the silly string. */
173 set_language(current_language
->la_language
);
177 /* Search the list of languages for a match. */
178 for (i
= 0; i
< languages_size
; i
++) {
179 if (STREQ (languages
[i
]->la_name
, language
)) {
180 /* Found it! Go into manual mode, and use this language. */
181 if (languages
[i
]->la_language
== language_auto
) {
182 /* Enter auto mode. Set to the current frame's language, if known. */
183 language_mode
= language_mode_auto
;
184 flang
= get_frame_language();
185 if (flang
!=language_unknown
)
187 expected_language
= current_language
;
190 /* Enter manual mode. Set the specified language. */
191 language_mode
= language_mode_manual
;
192 current_language
= languages
[i
];
195 expected_language
= current_language
;
201 /* Reset the language (esp. the global string "language") to the
203 err_lang
=savestring(language
,strlen(language
));
204 make_cleanup (free
, err_lang
); /* Free it after error */
205 set_language(current_language
->la_language
);
206 error ("Unknown language `%s'.",err_lang
);
209 /* Show command. Display a warning if the type setting does
210 not match the current language. */
212 show_type_command(ignore
, from_tty
)
216 if (type_check
!= current_language
->la_type_check
)
218 "Warning: the current type check setting does not match the language.\n");
221 /* Set command. Change the setting for type checking. */
223 set_type_command(ignore
, from_tty
)
227 if (STREQ(type
,"on"))
229 type_check
= type_check_on
;
230 type_mode
= type_mode_manual
;
232 else if (STREQ(type
,"warn"))
234 type_check
= type_check_warn
;
235 type_mode
= type_mode_manual
;
237 else if (STREQ(type
,"off"))
239 type_check
= type_check_off
;
240 type_mode
= type_mode_manual
;
242 else if (STREQ(type
,"auto"))
244 type_mode
= type_mode_auto
;
246 /* Avoid hitting the set_type_str call below. We
247 did it in set_type_range. */
251 show_type_command((char *)NULL
, from_tty
);
254 /* Show command. Display a warning if the range setting does
255 not match the current language. */
257 show_range_command(ignore
, from_tty
)
262 if (range_check
!= current_language
->la_range_check
)
264 "Warning: the current range check setting does not match the language.\n");
267 /* Set command. Change the setting for range checking. */
269 set_range_command(ignore
, from_tty
)
273 if (STREQ(range
,"on"))
275 range_check
= range_check_on
;
276 range_mode
= range_mode_manual
;
278 else if (STREQ(range
,"warn"))
280 range_check
= range_check_warn
;
281 range_mode
= range_mode_manual
;
283 else if (STREQ(range
,"off"))
285 range_check
= range_check_off
;
286 range_mode
= range_mode_manual
;
288 else if (STREQ(range
,"auto"))
290 range_mode
= range_mode_auto
;
292 /* Avoid hitting the set_range_str call below. We
293 did it in set_type_range. */
297 show_range_command((char *)0, from_tty
);
300 /* Set the status of range and type checking based on
301 the current modes and the current language.
302 If SHOW is non-zero, then print out the current language,
303 type and range checking status. */
308 if (range_mode
== range_mode_auto
)
309 range_check
= current_language
->la_range_check
;
311 if (type_mode
== type_mode_auto
)
312 type_check
= current_language
->la_type_check
;
318 /* Set current language to (enum language) LANG. */
326 for (i
= 0; i
< languages_size
; i
++) {
327 if (languages
[i
]->la_language
== lang
) {
328 current_language
= languages
[i
];
336 /* This page contains functions that update the global vars
337 language, type and range. */
344 if (language_mode
== language_mode_auto
)
345 prefix
= "auto; currently ";
347 language
= concat(prefix
, current_language
->la_name
, NULL
);
353 char *tmp
, *prefix
= "";
356 if (type_mode
==type_mode_auto
)
357 prefix
= "auto; currently ";
367 case type_check_warn
:
371 error ("Unrecognized type check setting.");
374 type
= concat(prefix
,tmp
,NULL
);
380 char *tmp
, *pref
= "";
383 if (range_mode
==range_mode_auto
)
384 pref
= "auto; currently ";
391 case range_check_off
:
394 case range_check_warn
:
398 error ("Unrecognized range check setting.");
401 range
= concat(pref
,tmp
,NULL
);
405 /* Print out the current language settings: language, range and
406 type checking. If QUIETLY, print only what has changed. */
409 language_info (quietly
)
412 if (quietly
&& expected_language
== current_language
)
415 expected_language
= current_language
;
416 printf("Current language: %s\n",language
);
417 show_language_command((char *)0, 1);
421 printf("Type checking: %s\n",type
);
422 show_type_command((char *)0, 1);
423 printf("Range checking: %s\n",range
);
424 show_range_command((char *)0, 1);
428 /* Return the result of a binary operation. */
430 #if 0 /* Currently unused */
433 binop_result_type(v1
,v2
)
438 l1
= TYPE_LENGTH(VALUE_TYPE(v1
));
439 l2
= TYPE_LENGTH(VALUE_TYPE(v2
));
441 switch(current_language
->la_language
)
445 if (TYPE_CODE(VALUE_TYPE(v1
))==TYPE_CODE_FLT
)
446 return TYPE_CODE(VALUE_TYPE(v2
)) == TYPE_CODE_FLT
&& l2
> l1
?
447 VALUE_TYPE(v2
) : VALUE_TYPE(v1
);
448 else if (TYPE_CODE(VALUE_TYPE(v2
))==TYPE_CODE_FLT
)
449 return TYPE_CODE(VALUE_TYPE(v1
)) == TYPE_CODE_FLT
&& l1
> l2
?
450 VALUE_TYPE(v1
) : VALUE_TYPE(v2
);
451 else if (TYPE_UNSIGNED(VALUE_TYPE(v1
)) && l1
> l2
)
452 return VALUE_TYPE(v1
);
453 else if (TYPE_UNSIGNED(VALUE_TYPE(v2
)) && l2
> l1
)
454 return VALUE_TYPE(v2
);
455 else /* Both are signed. Result is the longer type */
456 return l1
> l2
? VALUE_TYPE(v1
) : VALUE_TYPE(v2
);
459 /* If we are doing type-checking, l1 should equal l2, so this is
461 return l1
> l2
? VALUE_TYPE(v1
) : VALUE_TYPE(v2
);
463 /* start-sanitize-chill */
465 error ("Missing Chill support in function binop_result_check.");/*FIXME*/
466 /* end-sanitize-chill */
469 return (struct type
*)0; /* For lint */
475 /* This page contains functions that return format strings for
476 printf for printing out numbers in different formats */
478 /* Returns the appropriate printf format for hexadecimal
481 local_hex_format_custom(pre
)
484 static char form
[50];
486 strcpy (form
, local_hex_format_prefix ());
489 strcat (form
, local_hex_format_specifier ());
490 strcat (form
, local_hex_format_suffix ());
494 /* Converts a number to hexadecimal and stores it in a static
495 string. Returns a pointer to this string. */
497 local_hex_string (num
)
502 sprintf (res
, local_hex_format(), num
);
506 /* Converts a number to custom hexadecimal and stores it in a static
507 string. Returns a pointer to this string. */
509 local_hex_string_custom(num
,pre
)
515 sprintf (res
, local_hex_format_custom(pre
), num
);
519 /* Returns the appropriate printf format for octal
522 local_octal_format_custom(pre
)
525 static char form
[50];
527 strcpy (form
, local_octal_format_prefix ());
530 strcat (form
, local_octal_format_specifier ());
531 strcat (form
, local_octal_format_suffix ());
535 /* This page contains functions that are used in type/range checking.
536 They all return zero if the type/range check fails.
538 It is hoped that these will make extending GDB to parse different
539 languages a little easier. These are primarily used in eval.c when
540 evaluating expressions and making sure that their types are correct.
541 Instead of having a mess of conjucted/disjuncted expressions in an "if",
542 the ideas of type can be wrapped up in the following functions.
544 Note that some of them are not currently dependent upon which language
545 is currently being parsed. For example, floats are the same in
546 C and Modula-2 (ie. the only floating point type has TYPE_CODE of
547 TYPE_CODE_FLT), while booleans are different. */
549 /* Returns non-zero if its argument is a simple type. This is the same for
550 both Modula-2 and for C. In the C case, TYPE_CODE_CHAR will never occur,
551 and thus will never cause the failure of the test. */
556 switch (TYPE_CODE (type
)) {
561 case TYPE_CODE_RANGE
:
570 /* Returns non-zero if its argument is of an ordered type.
571 An ordered type is one in which the elements can be tested for the
572 properties of "greater than", "less than", etc, or for which the
573 operations "increment" or "decrement" make sense. */
578 switch (TYPE_CODE (type
)) {
583 case TYPE_CODE_RANGE
:
591 /* Returns non-zero if the two types are the same */
593 same_type (arg1
, arg2
)
594 struct type
*arg1
, *arg2
;
596 if (structured_type(arg1
) ? !structured_type(arg2
) : structured_type(arg2
))
597 /* One is structured and one isn't */
599 else if (structured_type(arg1
) && structured_type(arg2
))
601 else if (numeric_type(arg1
) && numeric_type(arg2
))
602 return (TYPE_CODE(arg2
) == TYPE_CODE(arg1
)) &&
603 (TYPE_UNSIGNED(arg1
) == TYPE_UNSIGNED(arg2
))
609 /* Returns non-zero if the type is integral */
614 switch(current_language
->la_language
)
618 return (TYPE_CODE(type
) != TYPE_CODE_INT
) &&
619 (TYPE_CODE(type
) != TYPE_CODE_ENUM
) ? 0 : 1;
621 return TYPE_CODE(type
) != TYPE_CODE_INT
? 0 : 1;
622 /* start-sanitize-chill */
624 error ("Missing Chill support in function integral_type."); /*FIXME*/
625 /* end-sanitize-chill */
627 error ("Language not supported.");
631 /* Returns non-zero if the value is numeric */
636 switch (TYPE_CODE (type
)) {
646 /* Returns non-zero if the value is a character type */
648 character_type (type
)
651 switch(current_language
->la_language
)
653 /* start-sanitize-chill */
655 /* end-sanitize-chill */
657 return TYPE_CODE(type
) != TYPE_CODE_CHAR
? 0 : 1;
661 return (TYPE_CODE(type
) == TYPE_CODE_INT
) &&
662 TYPE_LENGTH(type
) == sizeof(char)
669 /* Returns non-zero if the value is a string type */
674 switch(current_language
->la_language
)
676 /* start-sanitize-chill */
678 /* end-sanitize-chill */
680 return TYPE_CODE(type
) != TYPE_CODE_STRING
? 0 : 1;
684 /* C does not have distinct string type. */
691 /* Returns non-zero if the value is a boolean type */
696 switch(current_language
->la_language
)
698 /* start-sanitize-chill */
700 /* end-sanitize-chill */
702 return TYPE_CODE(type
) != TYPE_CODE_BOOL
? 0 : 1;
706 return TYPE_CODE(type
) != TYPE_CODE_INT
? 0 : 1;
712 /* Returns non-zero if the value is a floating-point type */
717 return TYPE_CODE(type
) == TYPE_CODE_FLT
;
720 /* Returns non-zero if the value is a pointer type */
725 return TYPE_CODE(type
) == TYPE_CODE_PTR
||
726 TYPE_CODE(type
) == TYPE_CODE_REF
;
729 /* Returns non-zero if the value is a structured type */
731 structured_type(type
)
734 switch(current_language
->la_language
)
738 return (TYPE_CODE(type
) == TYPE_CODE_STRUCT
) ||
739 (TYPE_CODE(type
) == TYPE_CODE_UNION
) ||
740 (TYPE_CODE(type
) == TYPE_CODE_ARRAY
);
742 return (TYPE_CODE(type
) == TYPE_CODE_STRUCT
) ||
743 (TYPE_CODE(type
) == TYPE_CODE_SET
) ||
744 (TYPE_CODE(type
) == TYPE_CODE_ARRAY
);
745 /* start-sanitize-chill */
747 error ("Missing Chill support in function structured_type."); /*FIXME*/
748 /* end-sanitize-chill */
754 /* This page contains functions that return info about
755 (struct value) values used in GDB. */
757 /* Returns non-zero if the value VAL represents a true value. */
766 switch (current_language
->la_language
) {
770 return !value_logical_not (val
);
773 type
= VALUE_TYPE(val
);
774 if (TYPE_CODE (type
) != TYPE_CODE_BOOL
)
775 return 0; /* Not a BOOLEAN at all */
776 /* Search the fields for one that matches the current value. */
777 len
= TYPE_NFIELDS (type
);
778 v
= value_as_long (val
);
779 for (i
= 0; i
< len
; i
++)
782 if (v
== TYPE_FIELD_BITPOS (type
, i
))
786 return 0; /* Not a valid BOOLEAN value */
787 if (STREQ ("TRUE", TYPE_FIELD_NAME(VALUE_TYPE(val
), i
)))
788 return 1; /* BOOLEAN with value TRUE */
790 return 0; /* BOOLEAN with value FALSE */
793 /* start-sanitize-chill */
795 error ("Missing Chill support in function value_type."); /*FIXME*/
796 /* end-sanitize-chill */
799 error ("Language not supported.");
803 /* Returns non-zero if the operator OP is defined on
804 the values ARG1 and ARG2. */
806 #if 0 /* Currently unused */
809 binop_type_check(arg1
,arg2
,op
)
813 struct type
*t1
, *t2
;
815 /* If we're not checking types, always return success. */
820 if (arg2
!=(value
)NULL
)
829 if ((numeric_type(t1
) && pointer_type(t2
)) ||
830 (pointer_type(t1
) && numeric_type(t2
)))
832 warning ("combining pointer and integer.\n");
838 if (!numeric_type(t1
) || !numeric_type(t2
))
839 type_op_error ("Arguments to %s must be numbers.",op
);
840 else if (!same_type(t1
,t2
))
841 type_op_error ("Arguments to %s must be of the same type.",op
);
844 case BINOP_LOGICAL_AND
:
845 case BINOP_LOGICAL_OR
:
846 if (!boolean_type(t1
) || !boolean_type(t2
))
847 type_op_error ("Arguments to %s must be of boolean type.",op
);
851 if ((pointer_type(t1
) && !(pointer_type(t2
) || integral_type(t2
))) ||
852 (pointer_type(t2
) && !(pointer_type(t1
) || integral_type(t1
))))
853 type_op_error ("A pointer can only be compared to an integer or pointer.",op
);
854 else if ((pointer_type(t1
) && integral_type(t2
)) ||
855 (integral_type(t1
) && pointer_type(t2
)))
857 warning ("combining integer and pointer.\n");
860 else if (!simple_type(t1
) || !simple_type(t2
))
861 type_op_error ("Arguments to %s must be of simple type.",op
);
862 else if (!same_type(t1
,t2
))
863 type_op_error ("Arguments to %s must be of the same type.",op
);
868 if (!integral_type(t1
) || !integral_type(t2
))
869 type_op_error ("Arguments to %s must be of integral type.",op
);
876 if (!ordered_type(t1
) || !ordered_type(t2
))
877 type_op_error ("Arguments to %s must be of ordered type.",op
);
878 else if (!same_type(t1
,t2
))
879 type_op_error ("Arguments to %s must be of the same type.",op
);
883 if (pointer_type(t1
) && !integral_type(t2
))
884 type_op_error ("A pointer can only be assigned an integer.",op
);
885 else if (pointer_type(t1
) && integral_type(t2
))
887 warning ("combining integer and pointer.");
890 else if (!simple_type(t1
) || !simple_type(t2
))
891 type_op_error ("Arguments to %s must be of simple type.",op
);
892 else if (!same_type(t1
,t2
))
893 type_op_error ("Arguments to %s must be of the same type.",op
);
897 /* FIXME: Needs to handle bitstrings as well. */
898 if (!(string_type(t1
) || character_type(t1
) || integral_type(t1
))
899 || !(string_type(t2
) || character_type(t2
) || integral_type(t2
)))
900 type_op_error ("Arguments to %s must be strings or characters.", op
);
903 /* Unary checks -- arg2 is null */
905 case UNOP_LOGICAL_NOT
:
906 if (!boolean_type(t1
))
907 type_op_error ("Argument to %s must be of boolean type.",op
);
912 if (!numeric_type(t1
))
913 type_op_error ("Argument to %s must be of numeric type.",op
);
917 if (integral_type(t1
))
919 warning ("combining pointer and integer.\n");
922 else if (!pointer_type(t1
))
923 type_op_error ("Argument to %s must be a pointer.",op
);
926 case UNOP_PREINCREMENT
:
927 case UNOP_POSTINCREMENT
:
928 case UNOP_PREDECREMENT
:
929 case UNOP_POSTDECREMENT
:
930 if (!ordered_type(t1
))
931 type_op_error ("Argument to %s must be of an ordered type.",op
);
935 /* Ok. The following operators have different meanings in
936 different languages. */
937 switch(current_language
->la_language
)
945 if (!numeric_type(t1
) || !numeric_type(t2
))
946 type_op_error ("Arguments to %s must be numbers.",op
);
957 if (!float_type(t1
) || !float_type(t2
))
958 type_op_error ("Arguments to %s must be floating point numbers.",op
);
961 if (!integral_type(t1
) || !integral_type(t2
))
962 type_op_error ("Arguments to %s must be of integral type.",op
);
967 /* start-sanitize-chill */
970 error ("Missing Chill support in function binop_type_check.");/*FIXME*/
972 /* end-sanitize-chill */
981 /* This page contains functions for the printing out of
982 error messages that occur during type- and range-
985 /* Prints the format string FMT with the operator as a string
986 corresponding to the opcode OP. If FATAL is non-zero, then
987 this is an error and error () is called. Otherwise, it is
988 a warning and printf() is called. */
990 op_error (fmt
,op
,fatal
)
996 error (fmt
,op_string(op
));
999 warning (fmt
,op_string(op
));
1003 /* These are called when a language fails a type- or range-check.
1004 The first argument should be a printf()-style format string, and
1005 the rest of the arguments should be its arguments. If
1006 [type|range]_check is [type|range]_check_on, then return_to_top_level()
1007 is called in the style of error (). Otherwise, the message is prefixed
1008 by the value of warning_pre_print and we do not return to the top level. */
1011 type_error (va_alist
)
1017 if (type_check
==type_check_warn
)
1018 fprintf(stderr
,warning_pre_print
);
1020 target_terminal_ours();
1023 string
= va_arg (args
, char *);
1024 vfprintf (stderr
, string
, args
);
1025 fprintf (stderr
, "\n");
1027 if (type_check
==type_check_on
)
1028 return_to_top_level();
1032 range_error (va_alist
)
1038 if (range_check
==range_check_warn
)
1039 fprintf(stderr
,warning_pre_print
);
1041 target_terminal_ours();
1044 string
= va_arg (args
, char *);
1045 vfprintf (stderr
, string
, args
);
1046 fprintf (stderr
, "\n");
1048 if (range_check
==range_check_on
)
1049 return_to_top_level();
1053 /* This page contains miscellaneous functions */
1055 /* Return the language struct for a given language enum. */
1057 const struct language_defn
*
1063 for (i
= 0; i
< languages_size
; i
++) {
1064 if (languages
[i
]->la_language
== lang
) {
1065 return languages
[i
];
1071 /* Return the language as a string */
1078 for (i
= 0; i
< languages_size
; i
++) {
1079 if (languages
[i
]->la_language
== lang
) {
1080 return languages
[i
]->la_name
;
1087 set_check (ignore
, from_tty
)
1092 "\"set check\" must be followed by the name of a check subcommand.\n");
1093 help_list(setchecklist
, "set check ", -1, stdout
);
1097 show_check (ignore
, from_tty
)
1101 cmd_show_list(showchecklist
, from_tty
, "");
1104 /* Add a language to the set of known languages. */
1108 const struct language_defn
*lang
;
1110 if (lang
->la_magic
!= LANG_MAGIC
)
1112 fprintf(stderr
, "Magic number of %s language struct wrong\n",
1119 languages_allocsize
= DEFAULT_ALLOCSIZE
;
1120 languages
= (const struct language_defn
**) xmalloc
1121 (languages_allocsize
* sizeof (*languages
));
1123 if (languages_size
>= languages_allocsize
)
1125 languages_allocsize
*= 2;
1126 languages
= (const struct language_defn
**) xrealloc ((char *) languages
,
1127 languages_allocsize
* sizeof (*languages
));
1129 languages
[languages_size
++] = lang
;
1132 /* Define the language that is no language. */
1141 unk_lang_error (msg
)
1144 error ("Attempted to parse an expression with unknown language");
1148 unk_lang_printchar (c
, stream
)
1152 error ("internal error - unimplemented function unk_lang_printchar called.");
1156 unk_lang_printstr (stream
, string
, length
, force_ellipses
)
1159 unsigned int length
;
1162 error ("internal error - unimplemented function unk_lang_printstr called.");
1165 static struct type
*
1166 unk_lang_create_fundamental_type (objfile
, typeid)
1167 struct objfile
*objfile
;
1170 error ("internal error - unimplemented function unk_lang_create_fundamental_type called.");
1174 unk_lang_print_type (type
, varstring
, stream
, show
, level
)
1181 error ("internal error - unimplemented function unk_lang_print_type called.");
1185 unk_lang_val_print (type
, valaddr
, address
, stream
, format
, deref_ref
,
1194 enum val_prettyprint pretty
;
1196 error ("internal error - unimplemented function unk_lang_val_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 unk_lang_printchar
, /* Print character constant */
1214 unk_lang_create_fundamental_type
,
1215 unk_lang_print_type
, /* Print a type using appropriate syntax */
1216 unk_lang_val_print
, /* Print a value using appropriate syntax */
1217 &builtin_type_error
, /* longest signed integral type */
1218 &builtin_type_error
, /* longest unsigned integral type */
1219 &builtin_type_error
, /* longest floating point type */
1220 {"", "", "", ""}, /* Binary format info */
1221 {"0%o", "0", "o", ""}, /* Octal format info */
1222 {"%d", "", "d", ""}, /* Decimal format info */
1223 {"0x%x", "0x", "x", ""}, /* Hex format info */
1224 unk_op_print_tab
, /* expression operators for printing */
1228 /* These two structs define fake entries for the "local" and "auto" options. */
1229 const struct language_defn auto_language_defn
= {
1232 &unknown_builtin_types
[0],
1237 unk_lang_printchar
, /* Print character constant */
1239 unk_lang_create_fundamental_type
,
1240 unk_lang_print_type
, /* Print a type using appropriate syntax */
1241 unk_lang_val_print
, /* Print a value using appropriate syntax */
1242 &builtin_type_error
, /* longest signed integral type */
1243 &builtin_type_error
, /* longest unsigned integral type */
1244 &builtin_type_error
, /* longest floating point type */
1245 {"", "", "", ""}, /* Binary format info */
1246 {"0%o", "0", "o", ""}, /* Octal format info */
1247 {"%d", "", "d", ""}, /* Decimal format info */
1248 {"0x%x", "0x", "x", ""}, /* Hex format info */
1249 unk_op_print_tab
, /* expression operators for printing */
1253 const struct language_defn local_language_defn
= {
1256 &unknown_builtin_types
[0],
1261 unk_lang_printchar
, /* Print character constant */
1263 unk_lang_create_fundamental_type
,
1264 unk_lang_print_type
, /* Print a type using appropriate syntax */
1265 unk_lang_val_print
, /* Print a value using appropriate syntax */
1266 &builtin_type_error
, /* longest signed integral type */
1267 &builtin_type_error
, /* longest unsigned integral type */
1268 &builtin_type_error
, /* longest floating point type */
1269 {"", "", "", ""}, /* Binary format info */
1270 {"0%o", "0", "o", ""}, /* Octal format info */
1271 {"%d", "", "d", ""}, /* Decimal format info */
1272 {"0x%x", "0x", "x", ""}, /* Hex format info */
1273 unk_op_print_tab
, /* expression operators for printing */
1277 /* Initialize the language routines */
1280 _initialize_language()
1282 struct cmd_list_element
*set
, *show
;
1284 /* GDB commands for language specific stuff */
1286 set
= add_set_cmd ("language", class_support
, var_string_noescape
,
1288 "Set the current source language.",
1290 show
= add_show_from_set (set
, &showlist
);
1291 set
->function
.cfunc
= set_language_command
;
1292 show
->function
.cfunc
= show_language_command
;
1294 add_prefix_cmd ("check", no_class
, set_check
,
1295 "Set the status of the type/range checker",
1296 &setchecklist
, "set check ", 0, &setlist
);
1297 add_alias_cmd ("c", "check", no_class
, 1, &setlist
);
1298 add_alias_cmd ("ch", "check", no_class
, 1, &setlist
);
1300 add_prefix_cmd ("check", no_class
, show_check
,
1301 "Show the status of the type/range checker",
1302 &showchecklist
, "show check ", 0, &showlist
);
1303 add_alias_cmd ("c", "check", no_class
, 1, &showlist
);
1304 add_alias_cmd ("ch", "check", no_class
, 1, &showlist
);
1306 set
= add_set_cmd ("type", class_support
, var_string_noescape
,
1308 "Set type checking. (on/warn/off/auto)",
1310 show
= add_show_from_set (set
, &showchecklist
);
1311 set
->function
.cfunc
= set_type_command
;
1312 show
->function
.cfunc
= show_type_command
;
1314 set
= add_set_cmd ("range", class_support
, var_string_noescape
,
1316 "Set range checking. (on/warn/off/auto)",
1318 show
= add_show_from_set (set
, &showchecklist
);
1319 set
->function
.cfunc
= set_range_command
;
1320 show
->function
.cfunc
= show_range_command
;
1322 add_language (&unknown_language_defn
);
1323 add_language (&local_language_defn
);
1324 add_language (&auto_language_defn
);
1326 language
= savestring ("auto",strlen("auto"));
1327 range
= savestring ("auto",strlen("auto"));
1328 type
= savestring ("auto",strlen("auto"));
1330 /* Have the above take effect */
1332 set_language_command (language
, 0);
1333 set_type_command (NULL
, 0);
1334 set_range_command (NULL
, 0);