1 /* Multiple source language support for GDB.
3 Copyright (C) 1991-2014 Free Software Foundation, Inc.
5 Contributed by the Department of Computer Science at the State University
6 of New York at Buffalo.
8 This file is part of GDB.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>. */
23 /* This file contains functions that return things that are specific
24 to languages. Each function should examine current_language if necessary,
25 and return the appropriate result. */
27 /* FIXME: Most of these would be better organized as macros which
28 return data out of a "language-specific" struct pointer that is set
29 whenever the working language changes. That would be a lot faster. */
37 #include "expression.h"
41 #include "parser-defs.h"
45 #include "cp-support.h"
47 extern void _initialize_language (void);
49 static void unk_lang_error (char *);
51 static int unk_lang_parser (struct parser_state *);
53 static void show_check (char *, int);
55 static void set_check (char *, int);
57 static void set_range_case (void);
59 static void unk_lang_emit_char (int c, struct type *type,
60 struct ui_file *stream, int quoter);
62 static void unk_lang_printchar (int c, struct type *type,
63 struct ui_file *stream);
65 static void unk_lang_value_print (struct value *, struct ui_file *,
66 const struct value_print_options *);
68 static CORE_ADDR unk_lang_trampoline (struct frame_info *, CORE_ADDR pc);
70 /* Forward declaration */
71 extern const struct language_defn unknown_language_defn;
73 /* The current (default at startup) state of type and range checking.
74 (If the modes are set to "auto", though, these are changed based
75 on the default language at startup, and then again based on the
76 language of the first source file. */
78 enum range_mode range_mode = range_mode_auto;
79 enum range_check range_check = range_check_off;
80 enum case_mode case_mode = case_mode_auto;
81 enum case_sensitivity case_sensitivity = case_sensitive_on;
83 /* The current language and language_mode (see language.h). */
85 const struct language_defn *current_language = &unknown_language_defn;
86 enum language_mode language_mode = language_mode_auto;
88 /* The language that the user expects to be typing in (the language
89 of main(), or the last language we notified them about, or C). */
91 const struct language_defn *expected_language;
93 /* The list of supported languages. The list itself is malloc'd. */
95 static const struct language_defn **languages;
96 static unsigned languages_size;
97 static unsigned languages_allocsize;
98 #define DEFAULT_ALLOCSIZE 4
100 /* The current values of the "set language/type/range" enum
102 static const char *language;
103 static const char *type;
104 static const char *range;
105 static const char *case_sensitive;
107 /* Warning issued when current_language and the language of the current
108 frame do not match. */
109 char lang_frame_mismatch_warn[] =
110 "Warning: the current language does not match this frame.";
112 /* This page contains the functions corresponding to GDB commands
113 and their helpers. */
115 /* Show command. Display a warning if the language set
116 does not match the frame. */
118 show_language_command (struct ui_file *file, int from_tty,
119 struct cmd_list_element *c, const char *value)
121 enum language flang; /* The language of the current frame. */
123 if (language_mode == language_mode_auto)
124 fprintf_filtered (gdb_stdout,
125 _("The current source language is "
126 "\"auto; currently %s\".\n"),
127 current_language->la_name);
129 fprintf_filtered (gdb_stdout,
130 _("The current source language is \"%s\".\n"),
131 current_language->la_name);
133 flang = get_frame_language ();
134 if (flang != language_unknown &&
135 language_mode == language_mode_manual &&
136 current_language->la_language != flang)
137 printf_filtered ("%s\n", lang_frame_mismatch_warn);
140 /* Set command. Change the current working language. */
142 set_language_command (char *ignore, int from_tty, struct cmd_list_element *c)
147 /* Search the list of languages for a match. */
148 for (i = 0; i < languages_size; i++)
150 if (strcmp (languages[i]->la_name, language) == 0)
152 /* Found it! Go into manual mode, and use this language. */
153 if (languages[i]->la_language == language_auto)
155 /* Enter auto mode. Set to the current frame's language, if
156 known, or fallback to the initial language. */
157 language_mode = language_mode_auto;
158 flang = get_frame_language ();
159 if (flang != language_unknown)
160 set_language (flang);
162 set_initial_language ();
163 expected_language = current_language;
168 /* Enter manual mode. Set the specified language. */
169 language_mode = language_mode_manual;
170 current_language = languages[i];
172 expected_language = current_language;
178 internal_error (__FILE__, __LINE__,
179 "Couldn't find language `%s' in known languages list.",
183 /* Show command. Display a warning if the range setting does
184 not match the current language. */
186 show_range_command (struct ui_file *file, int from_tty,
187 struct cmd_list_element *c, const char *value)
189 if (range_mode == range_mode_auto)
198 case range_check_off:
201 case range_check_warn:
205 internal_error (__FILE__, __LINE__,
206 "Unrecognized range check setting.");
209 fprintf_filtered (gdb_stdout,
210 _("Range checking is \"auto; currently %s\".\n"),
214 fprintf_filtered (gdb_stdout, _("Range checking is \"%s\".\n"),
217 if (range_check != current_language->la_range_check)
218 warning (_("the current range check setting "
219 "does not match the language.\n"));
222 /* Set command. Change the setting for range checking. */
224 set_range_command (char *ignore, int from_tty, struct cmd_list_element *c)
226 if (strcmp (range, "on") == 0)
228 range_check = range_check_on;
229 range_mode = range_mode_manual;
231 else if (strcmp (range, "warn") == 0)
233 range_check = range_check_warn;
234 range_mode = range_mode_manual;
236 else if (strcmp (range, "off") == 0)
238 range_check = range_check_off;
239 range_mode = range_mode_manual;
241 else if (strcmp (range, "auto") == 0)
243 range_mode = range_mode_auto;
249 internal_error (__FILE__, __LINE__,
250 _("Unrecognized range check setting: \"%s\""), range);
252 if (range_check != current_language->la_range_check)
253 warning (_("the current range check setting "
254 "does not match the language.\n"));
257 /* Show command. Display a warning if the case sensitivity setting does
258 not match the current language. */
260 show_case_command (struct ui_file *file, int from_tty,
261 struct cmd_list_element *c, const char *value)
263 if (case_mode == case_mode_auto)
267 switch (case_sensitivity)
269 case case_sensitive_on:
272 case case_sensitive_off:
276 internal_error (__FILE__, __LINE__,
277 "Unrecognized case-sensitive setting.");
280 fprintf_filtered (gdb_stdout,
281 _("Case sensitivity in "
282 "name search is \"auto; currently %s\".\n"),
286 fprintf_filtered (gdb_stdout,
287 _("Case sensitivity in name search is \"%s\".\n"),
290 if (case_sensitivity != current_language->la_case_sensitivity)
291 warning (_("the current case sensitivity setting does not match "
295 /* Set command. Change the setting for case sensitivity. */
298 set_case_command (char *ignore, int from_tty, struct cmd_list_element *c)
300 if (strcmp (case_sensitive, "on") == 0)
302 case_sensitivity = case_sensitive_on;
303 case_mode = case_mode_manual;
305 else if (strcmp (case_sensitive, "off") == 0)
307 case_sensitivity = case_sensitive_off;
308 case_mode = case_mode_manual;
310 else if (strcmp (case_sensitive, "auto") == 0)
312 case_mode = case_mode_auto;
318 internal_error (__FILE__, __LINE__,
319 "Unrecognized case-sensitive setting: \"%s\"",
323 if (case_sensitivity != current_language->la_case_sensitivity)
324 warning (_("the current case sensitivity setting does not match "
328 /* Set the status of range and type checking and case sensitivity based on
329 the current modes and the current language.
330 If SHOW is non-zero, then print out the current language,
331 type and range checking status. */
333 set_range_case (void)
335 if (range_mode == range_mode_auto)
336 range_check = current_language->la_range_check;
338 if (case_mode == case_mode_auto)
339 case_sensitivity = current_language->la_case_sensitivity;
342 /* Set current language to (enum language) LANG. Returns previous
346 set_language (enum language lang)
349 enum language prev_language;
351 prev_language = current_language->la_language;
353 for (i = 0; i < languages_size; i++)
355 if (languages[i]->la_language == lang)
357 current_language = languages[i];
363 return prev_language;
367 /* Print out the current language settings: language, range and
368 type checking. If QUIETLY, print only what has changed. */
371 language_info (int quietly)
373 if (quietly && expected_language == current_language)
376 expected_language = current_language;
377 printf_unfiltered (_("Current language: %s\n"), language);
378 show_language_command (NULL, 1, NULL, NULL);
382 printf_unfiltered (_("Range checking: %s\n"), range);
383 show_range_command (NULL, 1, NULL, NULL);
384 printf_unfiltered (_("Case sensitivity: %s\n"), case_sensitive);
385 show_case_command (NULL, 1, NULL, NULL);
390 /* Returns non-zero if the value is a pointer type. */
392 pointer_type (struct type *type)
394 return TYPE_CODE (type) == TYPE_CODE_PTR ||
395 TYPE_CODE (type) == TYPE_CODE_REF;
399 /* This page contains functions that return info about
400 (struct value) values used in GDB. */
402 /* Returns non-zero if the value VAL represents a true value. */
404 value_true (struct value *val)
406 /* It is possible that we should have some sort of error if a non-boolean
407 value is used in this context. Possibly dependent on some kind of
408 "boolean-checking" option like range checking. But it should probably
409 not depend on the language except insofar as is necessary to identify
410 a "boolean" value (i.e. in C using a float, pointer, etc., as a boolean
411 should be an error, probably). */
412 return !value_logical_not (val);
415 /* This page contains functions for the printing out of
416 error messages that occur during type- and range-
419 /* This is called when a language fails a range-check. The
420 first argument should be a printf()-style format string, and the
421 rest of the arguments should be its arguments. If range_check is
422 range_check_on, an error is printed; if range_check_warn, a warning;
423 otherwise just the message. */
426 range_error (const char *string,...)
430 va_start (args, string);
433 case range_check_warn:
434 vwarning (string, args);
437 verror (string, args);
439 case range_check_off:
440 /* FIXME: cagney/2002-01-30: Should this function print anything
441 when range error is off? */
442 vfprintf_filtered (gdb_stderr, string, args);
443 fprintf_filtered (gdb_stderr, "\n");
446 internal_error (__FILE__, __LINE__, _("bad switch"));
452 /* This page contains miscellaneous functions. */
454 /* Return the language enum for a given language string. */
457 language_enum (char *str)
461 for (i = 0; i < languages_size; i++)
462 if (strcmp (languages[i]->la_name, str) == 0)
463 return languages[i]->la_language;
465 return language_unknown;
468 /* Return the language struct for a given language enum. */
470 const struct language_defn *
471 language_def (enum language lang)
475 for (i = 0; i < languages_size; i++)
477 if (languages[i]->la_language == lang)
485 /* Return the language as a string. */
487 language_str (enum language lang)
491 for (i = 0; i < languages_size; i++)
493 if (languages[i]->la_language == lang)
495 return languages[i]->la_name;
502 set_check (char *ignore, int from_tty)
505 "\"set check\" must be followed by the name of a check subcommand.\n");
506 help_list (setchecklist, "set check ", all_commands, gdb_stdout);
510 show_check (char *ignore, int from_tty)
512 cmd_show_list (showchecklist, from_tty, "");
515 /* Add a language to the set of known languages. */
518 add_language (const struct language_defn *lang)
520 /* For the "set language" command. */
521 static const char **language_names = NULL;
522 /* For the "help set language" command. */
523 char *language_set_doc = NULL;
526 struct ui_file *tmp_stream;
528 if (lang->la_magic != LANG_MAGIC)
530 fprintf_unfiltered (gdb_stderr,
531 "Magic number of %s language struct wrong\n",
533 internal_error (__FILE__, __LINE__,
534 _("failed internal consistency check"));
539 languages_allocsize = DEFAULT_ALLOCSIZE;
540 languages = (const struct language_defn **) xmalloc
541 (languages_allocsize * sizeof (*languages));
543 if (languages_size >= languages_allocsize)
545 languages_allocsize *= 2;
546 languages = (const struct language_defn **) xrealloc ((char *) languages,
547 languages_allocsize * sizeof (*languages));
549 languages[languages_size++] = lang;
551 /* Build the language names array, to be used as enumeration in the
552 set language" enum command. */
553 language_names = xrealloc (language_names,
554 (languages_size + 1) * sizeof (const char *));
555 for (i = 0; i < languages_size; ++i)
556 language_names[i] = languages[i]->la_name;
557 language_names[i] = NULL;
559 /* Build the "help set language" docs. */
560 tmp_stream = mem_fileopen ();
562 fprintf_unfiltered (tmp_stream,
563 _("Set the current source language.\n"
564 "The currently understood settings are:\n\nlocal or "
565 "auto Automatic setting based on source file\n"));
567 for (i = 0; i < languages_size; ++i)
569 /* Already dealt with these above. */
570 if (languages[i]->la_language == language_unknown
571 || languages[i]->la_language == language_auto)
574 /* FIXME: i18n: for now assume that the human-readable name
575 is just a capitalization of the internal name. */
576 fprintf_unfiltered (tmp_stream, "%-16s Use the %c%s language\n",
577 languages[i]->la_name,
578 /* Capitalize first letter of language
580 toupper (languages[i]->la_name[0]),
581 languages[i]->la_name + 1);
584 language_set_doc = ui_file_xstrdup (tmp_stream, NULL);
585 ui_file_delete (tmp_stream);
587 add_setshow_enum_cmd ("language", class_support,
588 (const char **) language_names,
591 _("Show the current source language."),
592 NULL, set_language_command,
593 show_language_command,
594 &setlist, &showlist);
596 xfree (language_set_doc);
599 /* Iterate through all registered languages looking for and calling
600 any non-NULL struct language_defn.skip_trampoline() functions.
601 Return the result from the first that returns non-zero, or 0 if all
604 skip_language_trampoline (struct frame_info *frame, CORE_ADDR pc)
608 for (i = 0; i < languages_size; i++)
610 if (languages[i]->skip_trampoline)
612 CORE_ADDR real_pc = (languages[i]->skip_trampoline) (frame, pc);
622 /* Return demangled language symbol, or NULL.
623 FIXME: Options are only useful for certain languages and ignored
624 by others, so it would be better to remove them here and have a
625 more flexible demangler for the languages that need it.
626 FIXME: Sometimes the demangler is invoked when we don't know the
627 language, so we can't use this everywhere. */
629 language_demangle (const struct language_defn *current_language,
630 const char *mangled, int options)
632 if (current_language != NULL && current_language->la_demangle)
633 return current_language->la_demangle (mangled, options);
637 /* Return class name from physname or NULL. */
639 language_class_name_from_physname (const struct language_defn *lang,
640 const char *physname)
642 if (lang != NULL && lang->la_class_name_from_physname)
643 return lang->la_class_name_from_physname (physname);
647 /* Return non-zero if TYPE should be passed (and returned) by
648 reference at the language level. */
650 language_pass_by_reference (struct type *type)
652 return current_language->la_pass_by_reference (type);
655 /* Return zero; by default, types are passed by value at the language
656 level. The target ABI may pass or return some structs by reference
657 independent of this. */
659 default_pass_by_reference (struct type *type)
664 /* Return the default string containing the list of characters
665 delimiting words. This is a reasonable default value that
666 most languages should be able to use. */
669 default_word_break_characters (void)
671 return " \t\n!@#$%^&*()+=|~`}{[]\"';:?/>.<,-";
674 /* Print the index of array elements using the C99 syntax. */
677 default_print_array_index (struct value *index_value, struct ui_file *stream,
678 const struct value_print_options *options)
680 fprintf_filtered (stream, "[");
681 LA_VALUE_PRINT (index_value, stream, options);
682 fprintf_filtered (stream, "] = ");
686 default_get_string (struct value *value, gdb_byte **buffer, int *length,
687 struct type **char_type, const char **charset)
689 error (_("Getting a string is unsupported in this language."));
692 /* Define the language that is no language. */
695 unk_lang_parser (struct parser_state *ps)
701 unk_lang_error (char *msg)
703 error (_("Attempted to parse an expression with unknown language"));
707 unk_lang_emit_char (int c, struct type *type, struct ui_file *stream,
710 error (_("internal error - unimplemented "
711 "function unk_lang_emit_char called."));
715 unk_lang_printchar (int c, struct type *type, struct ui_file *stream)
717 error (_("internal error - unimplemented "
718 "function unk_lang_printchar called."));
722 unk_lang_printstr (struct ui_file *stream, struct type *type,
723 const gdb_byte *string, unsigned int length,
724 const char *encoding, int force_ellipses,
725 const struct value_print_options *options)
727 error (_("internal error - unimplemented "
728 "function unk_lang_printstr called."));
732 unk_lang_print_type (struct type *type, const char *varstring,
733 struct ui_file *stream, int show, int level,
734 const struct type_print_options *flags)
736 error (_("internal error - unimplemented "
737 "function unk_lang_print_type called."));
741 unk_lang_val_print (struct type *type, const gdb_byte *valaddr,
742 int embedded_offset, CORE_ADDR address,
743 struct ui_file *stream, int recurse,
744 const struct value *val,
745 const struct value_print_options *options)
747 error (_("internal error - unimplemented "
748 "function unk_lang_val_print called."));
752 unk_lang_value_print (struct value *val, struct ui_file *stream,
753 const struct value_print_options *options)
755 error (_("internal error - unimplemented "
756 "function unk_lang_value_print called."));
759 static CORE_ADDR unk_lang_trampoline (struct frame_info *frame, CORE_ADDR pc)
764 /* Unknown languages just use the cplus demangler. */
765 static char *unk_lang_demangle (const char *mangled, int options)
767 return gdb_demangle (mangled, options);
770 static char *unk_lang_class_name (const char *mangled)
775 static const struct op_print unk_op_print_tab[] =
777 {NULL, OP_NULL, PREC_NULL, 0}
781 unknown_language_arch_info (struct gdbarch *gdbarch,
782 struct language_arch_info *lai)
784 lai->string_char_type = builtin_type (gdbarch)->builtin_char;
785 lai->bool_type_default = builtin_type (gdbarch)->builtin_int;
786 lai->primitive_type_vector = GDBARCH_OBSTACK_CALLOC (gdbarch, 1,
790 const struct language_defn unknown_language_defn =
799 &exp_descriptor_standard,
803 unk_lang_printchar, /* Print character constant */
806 unk_lang_print_type, /* Print a type using appropriate syntax */
807 default_print_typedef, /* Print a typedef using appropriate syntax */
808 unk_lang_val_print, /* Print a value using appropriate syntax */
809 unk_lang_value_print, /* Print a top-level value */
810 default_read_var_value, /* la_read_var_value */
811 unk_lang_trampoline, /* Language specific skip_trampoline */
812 "this", /* name_of_this */
813 basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
814 basic_lookup_transparent_type,/* lookup_transparent_type */
815 unk_lang_demangle, /* Language specific symbol demangler */
816 unk_lang_class_name, /* Language specific
817 class_name_from_physname */
818 unk_op_print_tab, /* expression operators for printing */
819 1, /* c-style arrays */
820 0, /* String lower bound */
821 default_word_break_characters,
822 default_make_symbol_completion_list,
823 unknown_language_arch_info, /* la_language_arch_info. */
824 default_print_array_index,
825 default_pass_by_reference,
827 NULL, /* la_get_symbol_name_cmp */
828 iterate_over_symbols,
835 /* These two structs define fake entries for the "local" and "auto"
837 const struct language_defn auto_language_defn =
846 &exp_descriptor_standard,
850 unk_lang_printchar, /* Print character constant */
853 unk_lang_print_type, /* Print a type using appropriate syntax */
854 default_print_typedef, /* Print a typedef using appropriate syntax */
855 unk_lang_val_print, /* Print a value using appropriate syntax */
856 unk_lang_value_print, /* Print a top-level value */
857 default_read_var_value, /* la_read_var_value */
858 unk_lang_trampoline, /* Language specific skip_trampoline */
859 "this", /* name_of_this */
860 basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
861 basic_lookup_transparent_type,/* lookup_transparent_type */
862 unk_lang_demangle, /* Language specific symbol demangler */
863 unk_lang_class_name, /* Language specific
864 class_name_from_physname */
865 unk_op_print_tab, /* expression operators for printing */
866 1, /* c-style arrays */
867 0, /* String lower bound */
868 default_word_break_characters,
869 default_make_symbol_completion_list,
870 unknown_language_arch_info, /* la_language_arch_info. */
871 default_print_array_index,
872 default_pass_by_reference,
874 NULL, /* la_get_symbol_name_cmp */
875 iterate_over_symbols,
882 const struct language_defn local_language_defn =
891 &exp_descriptor_standard,
895 unk_lang_printchar, /* Print character constant */
898 unk_lang_print_type, /* Print a type using appropriate syntax */
899 default_print_typedef, /* Print a typedef using appropriate syntax */
900 unk_lang_val_print, /* Print a value using appropriate syntax */
901 unk_lang_value_print, /* Print a top-level value */
902 default_read_var_value, /* la_read_var_value */
903 unk_lang_trampoline, /* Language specific skip_trampoline */
904 "this", /* name_of_this */
905 basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
906 basic_lookup_transparent_type,/* lookup_transparent_type */
907 unk_lang_demangle, /* Language specific symbol demangler */
908 unk_lang_class_name, /* Language specific
909 class_name_from_physname */
910 unk_op_print_tab, /* expression operators for printing */
911 1, /* c-style arrays */
912 0, /* String lower bound */
913 default_word_break_characters,
914 default_make_symbol_completion_list,
915 unknown_language_arch_info, /* la_language_arch_info. */
916 default_print_array_index,
917 default_pass_by_reference,
919 NULL, /* la_get_symbol_name_cmp */
920 iterate_over_symbols,
927 /* Per-architecture language information. */
929 static struct gdbarch_data *language_gdbarch_data;
931 struct language_gdbarch
933 /* A vector of per-language per-architecture info. Indexed by "enum
935 struct language_arch_info arch_info[nr_languages];
939 language_gdbarch_post_init (struct gdbarch *gdbarch)
941 struct language_gdbarch *l;
944 l = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct language_gdbarch);
945 for (i = 0; i < languages_size; i++)
947 if (languages[i] != NULL
948 && languages[i]->la_language_arch_info != NULL)
949 languages[i]->la_language_arch_info
950 (gdbarch, l->arch_info + languages[i]->la_language);
956 language_string_char_type (const struct language_defn *la,
957 struct gdbarch *gdbarch)
959 struct language_gdbarch *ld = gdbarch_data (gdbarch,
960 language_gdbarch_data);
962 return ld->arch_info[la->la_language].string_char_type;
966 language_bool_type (const struct language_defn *la,
967 struct gdbarch *gdbarch)
969 struct language_gdbarch *ld = gdbarch_data (gdbarch,
970 language_gdbarch_data);
972 if (ld->arch_info[la->la_language].bool_type_symbol)
976 sym = lookup_symbol (ld->arch_info[la->la_language].bool_type_symbol,
977 NULL, VAR_DOMAIN, NULL);
980 struct type *type = SYMBOL_TYPE (sym);
982 if (type && TYPE_CODE (type) == TYPE_CODE_BOOL)
987 return ld->arch_info[la->la_language].bool_type_default;
991 language_lookup_primitive_type (const struct language_defn *la,
992 struct gdbarch *gdbarch,
995 struct language_gdbarch *ld = gdbarch_data (gdbarch,
996 language_gdbarch_data);
997 struct type *const *p;
999 if (symbol_lookup_debug)
1001 fprintf_unfiltered (gdb_stdlog,
1002 "language_lookup_primitive_type (%s, %s, %s)",
1003 la->la_name, host_address_to_string (gdbarch), name);
1006 for (p = ld->arch_info[la->la_language].primitive_type_vector;
1010 if (strcmp (TYPE_NAME (*p), name) == 0)
1012 if (symbol_lookup_debug)
1014 fprintf_unfiltered (gdb_stdlog, " = %s\n",
1015 host_address_to_string (*p));
1021 if (symbol_lookup_debug)
1022 fprintf_unfiltered (gdb_stdlog, " = NULL\n");
1026 /* Initialize the language routines. */
1029 _initialize_language (void)
1031 static const char *const type_or_range_names[]
1032 = { "on", "off", "warn", "auto", NULL };
1034 static const char *const case_sensitive_names[]
1035 = { "on", "off", "auto", NULL };
1037 language_gdbarch_data
1038 = gdbarch_data_register_post_init (language_gdbarch_post_init);
1040 /* GDB commands for language specific stuff. */
1042 add_prefix_cmd ("check", no_class, set_check,
1043 _("Set the status of the type/range checker."),
1044 &setchecklist, "set check ", 0, &setlist);
1045 add_alias_cmd ("c", "check", no_class, 1, &setlist);
1046 add_alias_cmd ("ch", "check", no_class, 1, &setlist);
1048 add_prefix_cmd ("check", no_class, show_check,
1049 _("Show the status of the type/range checker."),
1050 &showchecklist, "show check ", 0, &showlist);
1051 add_alias_cmd ("c", "check", no_class, 1, &showlist);
1052 add_alias_cmd ("ch", "check", no_class, 1, &showlist);
1054 add_setshow_enum_cmd ("range", class_support, type_or_range_names,
1056 _("Set range checking. (on/warn/off/auto)"),
1057 _("Show range checking. (on/warn/off/auto)"),
1058 NULL, set_range_command,
1060 &setchecklist, &showchecklist);
1062 add_setshow_enum_cmd ("case-sensitive", class_support, case_sensitive_names,
1063 &case_sensitive, _("\
1064 Set case sensitivity in name search. (on/off/auto)"), _("\
1065 Show case sensitivity in name search. (on/off/auto)"), _("\
1066 For Fortran the default is off; for other languages the default is on."),
1069 &setlist, &showlist);
1071 add_language (&auto_language_defn);
1072 add_language (&local_language_defn);
1073 add_language (&unknown_language_defn);
1075 language = xstrdup ("auto");
1076 type = xstrdup ("auto");
1077 range = xstrdup ("auto");
1078 case_sensitive = xstrdup ("auto");
1080 /* Have the above take effect. */
1081 set_language (language_auto);