1 /* Multiple source language support for GDB.
3 Copyright (C) 1991-1996, 1998-2005, 2007-2012 Free Software
6 Contributed by the Department of Computer Science at the State University
7 of New York at Buffalo.
9 This file is part of GDB.
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 3 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program. If not, see <http://www.gnu.org/licenses/>. */
24 /* This file contains functions that return things that are specific
25 to languages. Each function should examine current_language if necessary,
26 and return the appropriate result. */
28 /* FIXME: Most of these would be better organized as macros which
29 return data out of a "language-specific" struct pointer that is set
30 whenever the working language changes. That would be a lot faster. */
34 #include "gdb_string.h"
40 #include "expression.h"
43 #include "parser-defs.h"
48 extern void _initialize_language (void);
50 static void unk_lang_error (char *);
52 static int unk_lang_parser (void);
54 static void show_check (char *, int);
56 static void set_check (char *, int);
58 static void set_range_case (void);
60 static void unk_lang_emit_char (int c
, struct type
*type
,
61 struct ui_file
*stream
, int quoter
);
63 static void unk_lang_printchar (int c
, struct type
*type
,
64 struct ui_file
*stream
);
66 static void unk_lang_print_type (struct type
*, const char *, struct ui_file
*,
69 static void unk_lang_value_print (struct value
*, struct ui_file
*,
70 const struct value_print_options
*);
72 static CORE_ADDR
unk_lang_trampoline (struct frame_info
*, CORE_ADDR pc
);
74 /* Forward declaration */
75 extern const struct language_defn unknown_language_defn
;
77 /* The current (default at startup) state of type and range checking.
78 (If the modes are set to "auto", though, these are changed based
79 on the default language at startup, and then again based on the
80 language of the first source file. */
82 enum range_mode range_mode
= range_mode_auto
;
83 enum range_check range_check
= range_check_off
;
84 enum case_mode case_mode
= case_mode_auto
;
85 enum case_sensitivity case_sensitivity
= case_sensitive_on
;
87 /* The current language and language_mode (see language.h). */
89 const struct language_defn
*current_language
= &unknown_language_defn
;
90 enum language_mode language_mode
= language_mode_auto
;
92 /* The language that the user expects to be typing in (the language
93 of main(), or the last language we notified them about, or C). */
95 const struct language_defn
*expected_language
;
97 /* The list of supported languages. The list itself is malloc'd. */
99 static const struct language_defn
**languages
;
100 static unsigned languages_size
;
101 static unsigned languages_allocsize
;
102 #define DEFAULT_ALLOCSIZE 4
104 /* The current values of the "set language/type/range" enum
106 static const char *language
;
107 static const char *type
;
108 static const char *range
;
109 static const char *case_sensitive
;
111 /* Warning issued when current_language and the language of the current
112 frame do not match. */
113 char lang_frame_mismatch_warn
[] =
114 "Warning: the current language does not match this frame.";
116 /* This page contains the functions corresponding to GDB commands
117 and their helpers. */
119 /* Show command. Display a warning if the language set
120 does not match the frame. */
122 show_language_command (struct ui_file
*file
, int from_tty
,
123 struct cmd_list_element
*c
, const char *value
)
125 enum language flang
; /* The language of the current frame. */
127 if (language_mode
== language_mode_auto
)
128 fprintf_filtered (gdb_stdout
,
129 _("The current source language is "
130 "\"auto; currently %s\".\n"),
131 current_language
->la_name
);
133 fprintf_filtered (gdb_stdout
,
134 _("The current source language is \"%s\".\n"),
135 current_language
->la_name
);
137 flang
= get_frame_language ();
138 if (flang
!= language_unknown
&&
139 language_mode
== language_mode_manual
&&
140 current_language
->la_language
!= flang
)
141 printf_filtered ("%s\n", lang_frame_mismatch_warn
);
144 /* Set command. Change the current working language. */
146 set_language_command (char *ignore
, int from_tty
, struct cmd_list_element
*c
)
151 /* Search the list of languages for a match. */
152 for (i
= 0; i
< languages_size
; i
++)
154 if (strcmp (languages
[i
]->la_name
, language
) == 0)
156 /* Found it! Go into manual mode, and use this language. */
157 if (languages
[i
]->la_language
== language_auto
)
159 /* Enter auto mode. Set to the current frame's language, if
160 known, or fallback to the initial language. */
161 language_mode
= language_mode_auto
;
162 flang
= get_frame_language ();
163 if (flang
!= language_unknown
)
164 set_language (flang
);
166 set_initial_language ();
167 expected_language
= current_language
;
172 /* Enter manual mode. Set the specified language. */
173 language_mode
= language_mode_manual
;
174 current_language
= languages
[i
];
176 expected_language
= current_language
;
182 internal_error (__FILE__
, __LINE__
,
183 "Couldn't find language `%s' in known languages list.",
187 /* Show command. Display a warning if the range setting does
188 not match the current language. */
190 show_range_command (struct ui_file
*file
, int from_tty
,
191 struct cmd_list_element
*c
, const char *value
)
193 if (range_mode
== range_mode_auto
)
202 case range_check_off
:
205 case range_check_warn
:
209 internal_error (__FILE__
, __LINE__
,
210 "Unrecognized range check setting.");
213 fprintf_filtered (gdb_stdout
,
214 _("Range checking is \"auto; currently %s\".\n"),
218 fprintf_filtered (gdb_stdout
, _("Range checking is \"%s\".\n"),
221 if (range_check
!= current_language
->la_range_check
)
222 warning (_("the current range check setting "
223 "does not match the language.\n"));
226 /* Set command. Change the setting for range checking. */
228 set_range_command (char *ignore
, int from_tty
, struct cmd_list_element
*c
)
230 if (strcmp (range
, "on") == 0)
232 range_check
= range_check_on
;
233 range_mode
= range_mode_manual
;
235 else if (strcmp (range
, "warn") == 0)
237 range_check
= range_check_warn
;
238 range_mode
= range_mode_manual
;
240 else if (strcmp (range
, "off") == 0)
242 range_check
= range_check_off
;
243 range_mode
= range_mode_manual
;
245 else if (strcmp (range
, "auto") == 0)
247 range_mode
= range_mode_auto
;
253 internal_error (__FILE__
, __LINE__
,
254 _("Unrecognized range check setting: \"%s\""), range
);
256 if (range_check
!= current_language
->la_range_check
)
257 warning (_("the current range check setting "
258 "does not match the language.\n"));
261 /* Show command. Display a warning if the case sensitivity setting does
262 not match the current language. */
264 show_case_command (struct ui_file
*file
, int from_tty
,
265 struct cmd_list_element
*c
, const char *value
)
267 if (case_mode
== case_mode_auto
)
271 switch (case_sensitivity
)
273 case case_sensitive_on
:
276 case case_sensitive_off
:
280 internal_error (__FILE__
, __LINE__
,
281 "Unrecognized case-sensitive setting.");
284 fprintf_filtered (gdb_stdout
,
285 _("Case sensitivity in "
286 "name search is \"auto; currently %s\".\n"),
290 fprintf_filtered (gdb_stdout
,
291 _("Case sensitivity in name search is \"%s\".\n"),
294 if (case_sensitivity
!= current_language
->la_case_sensitivity
)
295 warning (_("the current case sensitivity setting does not match "
299 /* Set command. Change the setting for case sensitivity. */
302 set_case_command (char *ignore
, int from_tty
, struct cmd_list_element
*c
)
304 if (strcmp (case_sensitive
, "on") == 0)
306 case_sensitivity
= case_sensitive_on
;
307 case_mode
= case_mode_manual
;
309 else if (strcmp (case_sensitive
, "off") == 0)
311 case_sensitivity
= case_sensitive_off
;
312 case_mode
= case_mode_manual
;
314 else if (strcmp (case_sensitive
, "auto") == 0)
316 case_mode
= case_mode_auto
;
322 internal_error (__FILE__
, __LINE__
,
323 "Unrecognized case-sensitive setting: \"%s\"",
327 if (case_sensitivity
!= current_language
->la_case_sensitivity
)
328 warning (_("the current case sensitivity setting does not match "
332 /* Set the status of range and type checking and case sensitivity based on
333 the current modes and the current language.
334 If SHOW is non-zero, then print out the current language,
335 type and range checking status. */
337 set_range_case (void)
339 if (range_mode
== range_mode_auto
)
340 range_check
= current_language
->la_range_check
;
342 if (case_mode
== case_mode_auto
)
343 case_sensitivity
= current_language
->la_case_sensitivity
;
346 /* Set current language to (enum language) LANG. Returns previous
350 set_language (enum language lang
)
353 enum language prev_language
;
355 prev_language
= current_language
->la_language
;
357 for (i
= 0; i
< languages_size
; i
++)
359 if (languages
[i
]->la_language
== lang
)
361 current_language
= languages
[i
];
367 return prev_language
;
371 /* Print out the current language settings: language, range and
372 type checking. If QUIETLY, print only what has changed. */
375 language_info (int quietly
)
377 if (quietly
&& expected_language
== current_language
)
380 expected_language
= current_language
;
381 printf_unfiltered (_("Current language: %s\n"), language
);
382 show_language_command (NULL
, 1, NULL
, NULL
);
386 printf_unfiltered (_("Range checking: %s\n"), range
);
387 show_range_command (NULL
, 1, NULL
, NULL
);
388 printf_unfiltered (_("Case sensitivity: %s\n"), case_sensitive
);
389 show_case_command (NULL
, 1, NULL
, NULL
);
394 /* Returns non-zero if the value is a pointer type. */
396 pointer_type (struct type
*type
)
398 return TYPE_CODE (type
) == TYPE_CODE_PTR
||
399 TYPE_CODE (type
) == TYPE_CODE_REF
;
403 /* This page contains functions that return info about
404 (struct value) values used in GDB. */
406 /* Returns non-zero if the value VAL represents a true value. */
408 value_true (struct value
*val
)
410 /* It is possible that we should have some sort of error if a non-boolean
411 value is used in this context. Possibly dependent on some kind of
412 "boolean-checking" option like range checking. But it should probably
413 not depend on the language except insofar as is necessary to identify
414 a "boolean" value (i.e. in C using a float, pointer, etc., as a boolean
415 should be an error, probably). */
416 return !value_logical_not (val
);
419 /* This page contains functions for the printing out of
420 error messages that occur during type- and range-
423 /* This is called when a language fails a range-check. The
424 first argument should be a printf()-style format string, and the
425 rest of the arguments should be its arguments. If range_check is
426 range_check_on, an error is printed; if range_check_warn, a warning;
427 otherwise just the message. */
430 range_error (const char *string
,...)
434 va_start (args
, string
);
437 case range_check_warn
:
438 vwarning (string
, args
);
441 verror (string
, args
);
443 case range_check_off
:
444 /* FIXME: cagney/2002-01-30: Should this function print anything
445 when range error is off? */
446 vfprintf_filtered (gdb_stderr
, string
, args
);
447 fprintf_filtered (gdb_stderr
, "\n");
450 internal_error (__FILE__
, __LINE__
, _("bad switch"));
456 /* This page contains miscellaneous functions. */
458 /* Return the language enum for a given language string. */
461 language_enum (char *str
)
465 for (i
= 0; i
< languages_size
; i
++)
466 if (strcmp (languages
[i
]->la_name
, str
) == 0)
467 return languages
[i
]->la_language
;
469 return language_unknown
;
472 /* Return the language struct for a given language enum. */
474 const struct language_defn
*
475 language_def (enum language lang
)
479 for (i
= 0; i
< languages_size
; i
++)
481 if (languages
[i
]->la_language
== lang
)
489 /* Return the language as a string. */
491 language_str (enum language lang
)
495 for (i
= 0; i
< languages_size
; i
++)
497 if (languages
[i
]->la_language
== lang
)
499 return languages
[i
]->la_name
;
506 set_check (char *ignore
, int from_tty
)
509 "\"set check\" must be followed by the name of a check subcommand.\n");
510 help_list (setchecklist
, "set check ", -1, gdb_stdout
);
514 show_check (char *ignore
, int from_tty
)
516 cmd_show_list (showchecklist
, from_tty
, "");
519 /* Add a language to the set of known languages. */
522 add_language (const struct language_defn
*lang
)
524 /* For the "set language" command. */
525 static char **language_names
= NULL
;
526 /* For the "help set language" command. */
527 char *language_set_doc
= NULL
;
530 struct ui_file
*tmp_stream
;
532 if (lang
->la_magic
!= LANG_MAGIC
)
534 fprintf_unfiltered (gdb_stderr
,
535 "Magic number of %s language struct wrong\n",
537 internal_error (__FILE__
, __LINE__
,
538 _("failed internal consistency check"));
543 languages_allocsize
= DEFAULT_ALLOCSIZE
;
544 languages
= (const struct language_defn
**) xmalloc
545 (languages_allocsize
* sizeof (*languages
));
547 if (languages_size
>= languages_allocsize
)
549 languages_allocsize
*= 2;
550 languages
= (const struct language_defn
**) xrealloc ((char *) languages
,
551 languages_allocsize
* sizeof (*languages
));
553 languages
[languages_size
++] = lang
;
555 /* Build the language names array, to be used as enumeration in the
556 set language" enum command. */
557 language_names
= xrealloc (language_names
,
558 (languages_size
+ 1) * sizeof (const char *));
559 for (i
= 0; i
< languages_size
; ++i
)
560 language_names
[i
] = languages
[i
]->la_name
;
561 language_names
[i
] = NULL
;
563 /* Build the "help set language" docs. */
564 tmp_stream
= mem_fileopen ();
566 fprintf_unfiltered (tmp_stream
,
567 _("Set the current source language.\n"
568 "The currently understood settings are:\n\nlocal or "
569 "auto Automatic setting based on source file\n"));
571 for (i
= 0; i
< languages_size
; ++i
)
573 /* Already dealt with these above. */
574 if (languages
[i
]->la_language
== language_unknown
575 || languages
[i
]->la_language
== language_auto
)
578 /* FIXME: i18n: for now assume that the human-readable name
579 is just a capitalization of the internal name. */
580 fprintf_unfiltered (tmp_stream
, "%-16s Use the %c%s language\n",
581 languages
[i
]->la_name
,
582 /* Capitalize first letter of language
584 toupper (languages
[i
]->la_name
[0]),
585 languages
[i
]->la_name
+ 1);
588 language_set_doc
= ui_file_xstrdup (tmp_stream
, NULL
);
589 ui_file_delete (tmp_stream
);
591 add_setshow_enum_cmd ("language", class_support
,
592 (const char **) language_names
,
595 _("Show the current source language."),
596 NULL
, set_language_command
,
597 show_language_command
,
598 &setlist
, &showlist
);
600 xfree (language_set_doc
);
603 /* Iterate through all registered languages looking for and calling
604 any non-NULL struct language_defn.skip_trampoline() functions.
605 Return the result from the first that returns non-zero, or 0 if all
608 skip_language_trampoline (struct frame_info
*frame
, CORE_ADDR pc
)
612 for (i
= 0; i
< languages_size
; i
++)
614 if (languages
[i
]->skip_trampoline
)
616 CORE_ADDR real_pc
= (languages
[i
]->skip_trampoline
) (frame
, pc
);
626 /* Return demangled language symbol, or NULL.
627 FIXME: Options are only useful for certain languages and ignored
628 by others, so it would be better to remove them here and have a
629 more flexible demangler for the languages that need it.
630 FIXME: Sometimes the demangler is invoked when we don't know the
631 language, so we can't use this everywhere. */
633 language_demangle (const struct language_defn
*current_language
,
634 const char *mangled
, int options
)
636 if (current_language
!= NULL
&& current_language
->la_demangle
)
637 return current_language
->la_demangle (mangled
, options
);
641 /* Return class name from physname or NULL. */
643 language_class_name_from_physname (const struct language_defn
*lang
,
644 const char *physname
)
646 if (lang
!= NULL
&& lang
->la_class_name_from_physname
)
647 return lang
->la_class_name_from_physname (physname
);
651 /* Return non-zero if TYPE should be passed (and returned) by
652 reference at the language level. */
654 language_pass_by_reference (struct type
*type
)
656 return current_language
->la_pass_by_reference (type
);
659 /* Return zero; by default, types are passed by value at the language
660 level. The target ABI may pass or return some structs by reference
661 independent of this. */
663 default_pass_by_reference (struct type
*type
)
668 /* Return the default string containing the list of characters
669 delimiting words. This is a reasonable default value that
670 most languages should be able to use. */
673 default_word_break_characters (void)
675 return " \t\n!@#$%^&*()+=|~`}{[]\"';:?/>.<,-";
678 /* Print the index of array elements using the C99 syntax. */
681 default_print_array_index (struct value
*index_value
, struct ui_file
*stream
,
682 const struct value_print_options
*options
)
684 fprintf_filtered (stream
, "[");
685 LA_VALUE_PRINT (index_value
, stream
, options
);
686 fprintf_filtered (stream
, "] = ");
690 default_get_string (struct value
*value
, gdb_byte
**buffer
, int *length
,
691 struct type
**char_type
, const char **charset
)
693 error (_("Getting a string is unsupported in this language."));
696 /* Define the language that is no language. */
699 unk_lang_parser (void)
705 unk_lang_error (char *msg
)
707 error (_("Attempted to parse an expression with unknown language"));
711 unk_lang_emit_char (int c
, struct type
*type
, struct ui_file
*stream
,
714 error (_("internal error - unimplemented "
715 "function unk_lang_emit_char called."));
719 unk_lang_printchar (int c
, struct type
*type
, struct ui_file
*stream
)
721 error (_("internal error - unimplemented "
722 "function unk_lang_printchar called."));
726 unk_lang_printstr (struct ui_file
*stream
, struct type
*type
,
727 const gdb_byte
*string
, unsigned int length
,
728 const char *encoding
, int force_ellipses
,
729 const struct value_print_options
*options
)
731 error (_("internal error - unimplemented "
732 "function unk_lang_printstr called."));
736 unk_lang_print_type (struct type
*type
, const char *varstring
,
737 struct ui_file
*stream
, int show
, int level
)
739 error (_("internal error - unimplemented "
740 "function unk_lang_print_type called."));
744 unk_lang_val_print (struct type
*type
, const gdb_byte
*valaddr
,
745 int embedded_offset
, CORE_ADDR address
,
746 struct ui_file
*stream
, int recurse
,
747 const struct value
*val
,
748 const struct value_print_options
*options
)
750 error (_("internal error - unimplemented "
751 "function unk_lang_val_print called."));
755 unk_lang_value_print (struct value
*val
, struct ui_file
*stream
,
756 const struct value_print_options
*options
)
758 error (_("internal error - unimplemented "
759 "function unk_lang_value_print called."));
762 static CORE_ADDR
unk_lang_trampoline (struct frame_info
*frame
, CORE_ADDR pc
)
767 /* Unknown languages just use the cplus demangler. */
768 static char *unk_lang_demangle (const char *mangled
, int options
)
770 return cplus_demangle (mangled
, options
);
773 static char *unk_lang_class_name (const char *mangled
)
778 static const struct op_print unk_op_print_tab
[] =
780 {NULL
, OP_NULL
, PREC_NULL
, 0}
784 unknown_language_arch_info (struct gdbarch
*gdbarch
,
785 struct language_arch_info
*lai
)
787 lai
->string_char_type
= builtin_type (gdbarch
)->builtin_char
;
788 lai
->bool_type_default
= builtin_type (gdbarch
)->builtin_int
;
789 lai
->primitive_type_vector
= GDBARCH_OBSTACK_CALLOC (gdbarch
, 1,
793 const struct language_defn unknown_language_defn
=
801 &exp_descriptor_standard
,
805 unk_lang_printchar
, /* Print character constant */
808 unk_lang_print_type
, /* Print a type using appropriate syntax */
809 default_print_typedef
, /* Print a typedef using appropriate syntax */
810 unk_lang_val_print
, /* Print a value using appropriate syntax */
811 unk_lang_value_print
, /* Print a top-level value */
812 default_read_var_value
, /* la_read_var_value */
813 unk_lang_trampoline
, /* Language specific skip_trampoline */
814 "this", /* name_of_this */
815 basic_lookup_symbol_nonlocal
, /* lookup_symbol_nonlocal */
816 basic_lookup_transparent_type
,/* lookup_transparent_type */
817 unk_lang_demangle
, /* Language specific symbol demangler */
818 unk_lang_class_name
, /* Language specific
819 class_name_from_physname */
820 unk_op_print_tab
, /* expression operators for printing */
821 1, /* c-style arrays */
822 0, /* String lower bound */
823 default_word_break_characters
,
824 default_make_symbol_completion_list
,
825 unknown_language_arch_info
, /* la_language_arch_info. */
826 default_print_array_index
,
827 default_pass_by_reference
,
829 NULL
, /* la_get_symbol_name_cmp */
830 iterate_over_symbols
,
834 /* These two structs define fake entries for the "local" and "auto"
836 const struct language_defn auto_language_defn
=
844 &exp_descriptor_standard
,
848 unk_lang_printchar
, /* Print character constant */
851 unk_lang_print_type
, /* Print a type using appropriate syntax */
852 default_print_typedef
, /* Print a typedef using appropriate syntax */
853 unk_lang_val_print
, /* Print a value using appropriate syntax */
854 unk_lang_value_print
, /* Print a top-level value */
855 default_read_var_value
, /* la_read_var_value */
856 unk_lang_trampoline
, /* Language specific skip_trampoline */
857 "this", /* name_of_this */
858 basic_lookup_symbol_nonlocal
, /* lookup_symbol_nonlocal */
859 basic_lookup_transparent_type
,/* lookup_transparent_type */
860 unk_lang_demangle
, /* Language specific symbol demangler */
861 unk_lang_class_name
, /* Language specific
862 class_name_from_physname */
863 unk_op_print_tab
, /* expression operators for printing */
864 1, /* c-style arrays */
865 0, /* String lower bound */
866 default_word_break_characters
,
867 default_make_symbol_completion_list
,
868 unknown_language_arch_info
, /* la_language_arch_info. */
869 default_print_array_index
,
870 default_pass_by_reference
,
872 NULL
, /* la_get_symbol_name_cmp */
873 iterate_over_symbols
,
877 const struct language_defn local_language_defn
=
885 &exp_descriptor_standard
,
889 unk_lang_printchar
, /* Print character constant */
892 unk_lang_print_type
, /* Print a type using appropriate syntax */
893 default_print_typedef
, /* Print a typedef using appropriate syntax */
894 unk_lang_val_print
, /* Print a value using appropriate syntax */
895 unk_lang_value_print
, /* Print a top-level value */
896 default_read_var_value
, /* la_read_var_value */
897 unk_lang_trampoline
, /* Language specific skip_trampoline */
898 "this", /* name_of_this */
899 basic_lookup_symbol_nonlocal
, /* lookup_symbol_nonlocal */
900 basic_lookup_transparent_type
,/* lookup_transparent_type */
901 unk_lang_demangle
, /* Language specific symbol demangler */
902 unk_lang_class_name
, /* Language specific
903 class_name_from_physname */
904 unk_op_print_tab
, /* expression operators for printing */
905 1, /* c-style arrays */
906 0, /* String lower bound */
907 default_word_break_characters
,
908 default_make_symbol_completion_list
,
909 unknown_language_arch_info
, /* la_language_arch_info. */
910 default_print_array_index
,
911 default_pass_by_reference
,
913 NULL
, /* la_get_symbol_name_cmp */
914 iterate_over_symbols
,
918 /* Per-architecture language information. */
920 static struct gdbarch_data
*language_gdbarch_data
;
922 struct language_gdbarch
924 /* A vector of per-language per-architecture info. Indexed by "enum
926 struct language_arch_info arch_info
[nr_languages
];
930 language_gdbarch_post_init (struct gdbarch
*gdbarch
)
932 struct language_gdbarch
*l
;
935 l
= GDBARCH_OBSTACK_ZALLOC (gdbarch
, struct language_gdbarch
);
936 for (i
= 0; i
< languages_size
; i
++)
938 if (languages
[i
] != NULL
939 && languages
[i
]->la_language_arch_info
!= NULL
)
940 languages
[i
]->la_language_arch_info
941 (gdbarch
, l
->arch_info
+ languages
[i
]->la_language
);
947 language_string_char_type (const struct language_defn
*la
,
948 struct gdbarch
*gdbarch
)
950 struct language_gdbarch
*ld
= gdbarch_data (gdbarch
,
951 language_gdbarch_data
);
953 return ld
->arch_info
[la
->la_language
].string_char_type
;
957 language_bool_type (const struct language_defn
*la
,
958 struct gdbarch
*gdbarch
)
960 struct language_gdbarch
*ld
= gdbarch_data (gdbarch
,
961 language_gdbarch_data
);
963 if (ld
->arch_info
[la
->la_language
].bool_type_symbol
)
967 sym
= lookup_symbol (ld
->arch_info
[la
->la_language
].bool_type_symbol
,
968 NULL
, VAR_DOMAIN
, NULL
);
971 struct type
*type
= SYMBOL_TYPE (sym
);
973 if (type
&& TYPE_CODE (type
) == TYPE_CODE_BOOL
)
978 return ld
->arch_info
[la
->la_language
].bool_type_default
;
982 language_lookup_primitive_type_by_name (const struct language_defn
*la
,
983 struct gdbarch
*gdbarch
,
986 struct language_gdbarch
*ld
= gdbarch_data (gdbarch
,
987 language_gdbarch_data
);
988 struct type
*const *p
;
990 for (p
= ld
->arch_info
[la
->la_language
].primitive_type_vector
;
994 if (strcmp (TYPE_NAME (*p
), name
) == 0)
1000 /* Initialize the language routines. */
1003 _initialize_language (void)
1005 static const char *const type_or_range_names
[]
1006 = { "on", "off", "warn", "auto", NULL
};
1008 static const char *const case_sensitive_names
[]
1009 = { "on", "off", "auto", NULL
};
1011 language_gdbarch_data
1012 = gdbarch_data_register_post_init (language_gdbarch_post_init
);
1014 /* GDB commands for language specific stuff. */
1016 add_prefix_cmd ("check", no_class
, set_check
,
1017 _("Set the status of the type/range checker."),
1018 &setchecklist
, "set check ", 0, &setlist
);
1019 add_alias_cmd ("c", "check", no_class
, 1, &setlist
);
1020 add_alias_cmd ("ch", "check", no_class
, 1, &setlist
);
1022 add_prefix_cmd ("check", no_class
, show_check
,
1023 _("Show the status of the type/range checker."),
1024 &showchecklist
, "show check ", 0, &showlist
);
1025 add_alias_cmd ("c", "check", no_class
, 1, &showlist
);
1026 add_alias_cmd ("ch", "check", no_class
, 1, &showlist
);
1028 add_setshow_enum_cmd ("range", class_support
, type_or_range_names
,
1030 _("Set range checking. (on/warn/off/auto)"),
1031 _("Show range checking. (on/warn/off/auto)"),
1032 NULL
, set_range_command
,
1034 &setchecklist
, &showchecklist
);
1036 add_setshow_enum_cmd ("case-sensitive", class_support
, case_sensitive_names
,
1037 &case_sensitive
, _("\
1038 Set case sensitivity in name search. (on/off/auto)"), _("\
1039 Show case sensitivity in name search. (on/off/auto)"), _("\
1040 For Fortran the default is off; for other languages the default is on."),
1043 &setlist
, &showlist
);
1045 add_language (&auto_language_defn
);
1046 add_language (&local_language_defn
);
1047 add_language (&unknown_language_defn
);
1049 language
= xstrdup ("auto");
1050 type
= xstrdup ("auto");
1051 range
= xstrdup ("auto");
1052 case_sensitive
= xstrdup ("auto");
1054 /* Have the above take effect. */
1055 set_language (language_auto
);