GDB (xrefs)
Loading...
Searching...
No Matches
language.c
Go to the documentation of this file.
1/* Multiple source language support for GDB.
2
3 Copyright (C) 1991-2023 Free Software Foundation, Inc.
4
5 Contributed by the Department of Computer Science at the State University
6 of New York at Buffalo.
7
8 This file is part of GDB.
9
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.
14
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.
19
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/>. */
22
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. */
26
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. */
30
31#include "defs.h"
32#include <ctype.h>
33#include "symtab.h"
34#include "gdbtypes.h"
35#include "value.h"
36#include "gdbcmd.h"
37#include "expression.h"
38#include "language.h"
39#include "varobj.h"
40#include "target.h"
41#include "parser-defs.h"
42#include "demangle.h"
43#include "symfile.h"
44#include "cp-support.h"
45#include "frame.h"
46#include "c-lang.h"
47#include <algorithm>
48#include "gdbarch.h"
50
51static void set_range_case (void);
52
53/* range_mode ==
54 range_mode_auto: range_check set automatically to default of language.
55 range_mode_manual: range_check set manually by user. */
56
58 {
60 };
61
62/* case_mode ==
63 case_mode_auto: case_sensitivity set upon selection of scope.
64 case_mode_manual: case_sensitivity set only by user. */
65
67 {
69 };
70
71/* The current (default at startup) state of type and range checking.
72 (If the modes are set to "auto", though, these are changed based
73 on the default language at startup, and then again based on the
74 language of the first source file. */
75
80
81/* The current language and language_mode (see language.h). */
82
83const struct language_defn *current_language = nullptr;
85
86/* The language that the user expects to be typing in (the language
87 of main(), or the last language we notified them about, or C). */
88
90
91/* Define the array containing all languages. */
92
94
95/* The current values of the "set language/range/case-sensitive" enum
96 commands. */
97static const char *language;
98static const char *range;
99static const char *case_sensitive;
100
101/* See language.h. */
103N_("Warning: the current language does not match this frame.");
104
105/* This page contains the functions corresponding to GDB commands
106 and their helpers. */
107
108/* Show command. Display a warning if the language set
109 does not match the frame. */
110static void
111show_language_command (struct ui_file *file, int from_tty,
112 struct cmd_list_element *c, const char *value)
113{
114 enum language flang; /* The language of the frame. */
115
117 gdb_printf (file,
118 _("The current source language is "
119 "\"auto; currently %s\".\n"),
121 else
122 gdb_printf (file,
123 _("The current source language is \"%s\".\n"),
125
126 if (has_stack_frames ())
127 {
128 frame_info_ptr frame;
129
130 frame = get_selected_frame (NULL);
131 flang = get_frame_language (frame);
132 if (flang != language_unknown
134 && current_language->la_language != flang)
135 gdb_printf (file, "%s\n", _(lang_frame_mismatch_warn));
136 }
137}
138
139/* Set command. Change the current working language. */
140static void
141set_language_command (const char *ignore,
142 int from_tty, struct cmd_list_element *c)
143{
144 enum language flang = language_unknown;
145
146 /* "local" is a synonym of "auto". */
147 if (strcmp (language, "local") == 0)
148 language = "auto";
149
150 /* Search the list of languages for a match. */
151 for (const auto &lang : language_defn::languages)
152 {
153 if (strcmp (lang->name (), language) == 0)
154 {
155 /* Found it! Go into manual mode, and use this language. */
156 if (lang->la_language == language_auto)
157 {
158 /* Enter auto mode. Set to the current frame's language, if
159 known, or fallback to the initial language. */
161 try
162 {
163 frame_info_ptr frame;
164
165 frame = get_selected_frame (NULL);
166 flang = get_frame_language (frame);
167 }
168 catch (const gdb_exception_error &ex)
169 {
170 flang = language_unknown;
171 }
172
173 if (flang != language_unknown)
174 set_language (flang);
175 else
178 return;
179 }
180 else
181 {
182 /* Enter manual mode. Set the specified language. */
184 current_language = lang;
187 return;
188 }
189 }
190 }
191
192 internal_error ("Couldn't find language `%s' in known languages list.",
193 language);
194}
195
196/* Show command. Display a warning if the range setting does
197 not match the current language. */
198static void
199show_range_command (struct ui_file *file, int from_tty,
200 struct cmd_list_element *c, const char *value)
201{
203 {
204 const char *tmp;
205
206 switch (range_check)
207 {
208 case range_check_on:
209 tmp = "on";
210 break;
211 case range_check_off:
212 tmp = "off";
213 break;
214 case range_check_warn:
215 tmp = "warn";
216 break;
217 default:
218 internal_error ("Unrecognized range check setting.");
219 }
220
221 gdb_printf (file,
222 _("Range checking is \"auto; currently %s\".\n"),
223 tmp);
224 }
225 else
226 gdb_printf (file, _("Range checking is \"%s\".\n"),
227 value);
228
232 warning (_("the current range check setting "
233 "does not match the language.\n"));
234}
235
236/* Set command. Change the setting for range checking. */
237static void
238set_range_command (const char *ignore,
239 int from_tty, struct cmd_list_element *c)
240{
241 if (strcmp (range, "on") == 0)
242 {
245 }
246 else if (strcmp (range, "warn") == 0)
247 {
250 }
251 else if (strcmp (range, "off") == 0)
252 {
255 }
256 else if (strcmp (range, "auto") == 0)
257 {
260 return;
261 }
262 else
263 {
264 internal_error (_("Unrecognized range check setting: \"%s\""), range);
265 }
269 warning (_("the current range check setting "
270 "does not match the language.\n"));
271}
272
273/* Show command. Display a warning if the case sensitivity setting does
274 not match the current language. */
275static void
276show_case_command (struct ui_file *file, int from_tty,
277 struct cmd_list_element *c, const char *value)
278{
280 {
281 const char *tmp = NULL;
282
283 switch (case_sensitivity)
284 {
286 tmp = "on";
287 break;
289 tmp = "off";
290 break;
291 default:
292 internal_error ("Unrecognized case-sensitive setting.");
293 }
294
295 gdb_printf (file,
296 _("Case sensitivity in "
297 "name search is \"auto; currently %s\".\n"),
298 tmp);
299 }
300 else
301 gdb_printf (file,
302 _("Case sensitivity in name search is \"%s\".\n"),
303 value);
304
306 warning (_("the current case sensitivity setting does not match "
307 "the language.\n"));
308}
309
310/* Set command. Change the setting for case sensitivity. */
311
312static void
313set_case_command (const char *ignore, int from_tty, struct cmd_list_element *c)
314{
315 if (strcmp (case_sensitive, "on") == 0)
316 {
319 }
320 else if (strcmp (case_sensitive, "off") == 0)
321 {
324 }
325 else if (strcmp (case_sensitive, "auto") == 0)
326 {
329 return;
330 }
331 else
332 {
333 internal_error ("Unrecognized case-sensitive setting: \"%s\"",
335 }
336
338 warning (_("the current case sensitivity setting does not match "
339 "the language.\n"));
340}
341
342/* Set the status of range and type checking and case sensitivity based on
343 the current modes and the current language.
344 If SHOW is non-zero, then print out the current language,
345 type and range checking status. */
346static void
348{
352
355}
356
357/* Set current language to (enum language) LANG. Returns previous
358 language. */
359
360enum language
362{
363 enum language prev_language;
364
365 prev_language = current_language->la_language;
368 return prev_language;
369}
370
371
372/* See language.h. */
373
374void
376{
378 return;
379
381 gdb_printf (_("Current language: %s\n"), language);
382 show_language_command (gdb_stdout, 1, NULL, NULL);
383}
384
385/* This page contains functions for the printing out of
386 error messages that occur during type- and range-
387 checking. */
388
389/* This is called when a language fails a range-check. The
390 first argument should be a printf()-style format string, and the
391 rest of the arguments should be its arguments. If range_check is
392 range_check_on, an error is printed; if range_check_warn, a warning;
393 otherwise just the message. */
394
395void
396range_error (const char *string,...)
397{
398 va_list args;
399
400 va_start (args, string);
401 switch (range_check)
402 {
403 case range_check_warn:
404 vwarning (string, args);
405 break;
406 case range_check_on:
407 verror (string, args);
408 break;
409 case range_check_off:
410 /* FIXME: cagney/2002-01-30: Should this function print anything
411 when range error is off? */
412 gdb_vprintf (gdb_stderr, string, args);
413 gdb_printf (gdb_stderr, "\n");
414 break;
415 default:
416 internal_error (_("bad switch"));
417 }
418 va_end (args);
419}
420
421
422/* This page contains miscellaneous functions. */
423
424/* Return the language enum for a given language string. */
425
426enum language
427language_enum (const char *str)
428{
429 for (const auto &lang : language_defn::languages)
430 if (strcmp (lang->name (), str) == 0)
431 return lang->la_language;
432
433 if (strcmp (str, "local") == 0)
434 return language_auto;
435
436 return language_unknown;
437}
438
439/* Return the language struct for a given language enum. */
440
441const struct language_defn *
443{
444 const struct language_defn *l = language_defn::languages[lang];
445 gdb_assert (l != nullptr);
446 return l;
447}
448
449/* Return the language as a string. */
450
451const char *
453{
454 return language_def (lang)->name ();
455}
456
457
458
459/* Build and install the "set language LANG" command. */
460
461static void
463{
464 static const char **language_names;
465
466 /* Build the language names array, to be used as enumeration in the
467 "set language" enum command. +1 for "local" and +1 for NULL
468 termination. */
469 language_names = new const char *[ARRAY_SIZE (language_defn::languages) + 2];
470
471 /* Display "auto", "local" and "unknown" first, and then the rest,
472 alpha sorted. */
473 const char **language_names_p = language_names;
475 *language_names_p++ = language;
476 *language_names_p++ = "local";
477 *language_names_p++ = language_def (language_unknown)->name ();
478 const char **sort_begin = language_names_p;
479 for (const auto &lang : language_defn::languages)
480 {
481 /* Already handled above. */
482 if (lang->la_language == language_auto
483 || lang->la_language == language_unknown)
484 continue;
485 *language_names_p++ = lang->name ();
486 }
487 *language_names_p = NULL;
488 std::sort (sort_begin, language_names_p, compare_cstrings);
489
490 /* Add the filename extensions. */
491 for (const auto &lang : language_defn::languages)
492 for (const char * const &ext : lang->filename_extensions ())
493 add_filename_language (ext, lang->la_language);
494
495 /* Build the "help set language" docs. */
496 string_file doc;
497
498 doc.printf (_("Set the current source language.\n"
499 "The currently understood settings are:\n\nlocal or "
500 "auto Automatic setting based on source file"));
501
502 for (const auto &lang : language_defn::languages)
503 {
504 /* Already dealt with these above. */
505 if (lang->la_language == language_unknown
506 || lang->la_language == language_auto)
507 continue;
508
509 /* Note that we add the newline at the front, so we don't wind
510 up with a trailing newline. */
511 doc.printf ("\n%-16s Use the %s language",
512 lang->name (),
513 lang->natural_name ());
514 }
515
517 language_names,
518 &language,
519 doc.c_str (),
520 _("Show the current source language."),
523 &setlist, &showlist);
524}
525
526/* Iterate through all registered languages looking for and calling
527 any non-NULL struct language_defn.skip_trampoline() functions.
528 Return the result from the first that returns non-zero, or 0 if all
529 `fail'. */
530CORE_ADDR
532{
533 for (const auto &lang : language_defn::languages)
534 {
535 CORE_ADDR real_pc = lang->skip_trampoline (frame, pc);
536
537 if (real_pc != 0)
538 return real_pc;
539 }
540
541 return 0;
542}
543
544/* Return demangled language symbol, or NULL.
545 FIXME: Options are only useful for certain languages and ignored
546 by others, so it would be better to remove them here and have a
547 more flexible demangler for the languages that need it.
548 FIXME: Sometimes the demangler is invoked when we don't know the
549 language, so we can't use this everywhere. */
550gdb::unique_xmalloc_ptr<char>
552 const char *mangled, int options)
553{
554 if (current_language != NULL)
555 return current_language->demangle_symbol (mangled, options);
556 return NULL;
557}
558
559/* Return information about whether TYPE should be passed
560 (and returned) by reference at the language level. */
561
564{
566}
567
568/* Return the default string containing the list of characters
569 delimiting words. This is a reasonable default value that
570 most languages should be able to use. */
571
572const char *
574{
575 return " \t\n!@#$%^&*()+=|~`}{[]\"';:?/>.<,-";
576}
577
578/* See language.h. */
579
580void
581language_defn::print_array_index (struct type *index_type, LONGEST index,
582 struct ui_file *stream,
583 const value_print_options *options) const
584{
585 struct value *index_value = value_from_longest (index_type, index);
586
587 gdb_printf (stream, "[");
588 value_print (index_value, stream, options);
589 gdb_printf (stream, "] = ");
590}
591
592/* See language.h. */
593
594gdb::unique_xmalloc_ptr<char>
596 CORE_ADDR addr) const
597{
598 /* Generates an expression that assumes a C like syntax is valid. */
599 type = check_typedef (check_typedef (type)->target_type ());
600 std::string name = type_to_string (type);
601 return xstrprintf ("* (%s *) %s", name.c_str (), core_addr_to_string (addr));
602}
603
604/* See language.h. */
605
606void
607language_defn::value_print (struct value *val, struct ui_file *stream,
608 const struct value_print_options *options) const
609{
610 return c_value_print (val, stream, options);
611}
612
613/* See language.h. */
614
615int
617{
618 return c_parse (ps);
619}
620
621/* See language.h. */
622
623void
625 (struct value *val, struct ui_file *stream, int recurse,
626 const struct value_print_options *options) const
627{
628 return c_value_print_inner (val, stream, recurse, options);
629}
630
631/* See language.h. */
632
633void
635 struct ui_file *stream) const
636{
638}
639
640/* See language.h. */
641
642bool
644{
645 return c_is_string_type_p (type);
646}
647
648/* See language.h. */
649
650std::unique_ptr<compile_instance>
652{
653 return {};
654}
655
656/* The default implementation of the get_symbol_name_matcher_inner method
657 from the language_defn class. Matches with strncmp_iw. */
658
659static bool
660default_symbol_name_matcher (const char *symbol_search_name,
661 const lookup_name_info &lookup_name,
662 completion_match_result *comp_match_res)
663{
664 gdb::string_view name = lookup_name.name ();
665 completion_match_for_lcd *match_for_lcd
666 = (comp_match_res != NULL ? &comp_match_res->match_for_lcd : NULL);
667 strncmp_iw_mode mode = (lookup_name.completion_mode ()
670
671 if (strncmp_iw_with_mode (symbol_search_name, name.data (), name.size (),
672 mode, language_minimal, match_for_lcd) == 0)
673 {
674 if (comp_match_res != NULL)
675 comp_match_res->set_match (symbol_search_name);
676 return true;
677 }
678 else
679 return false;
680}
681
682/* See language.h. */
683
686 (const lookup_name_info &lookup_name) const
687{
688 /* If currently in Ada mode, and the lookup name is wrapped in
689 '<...>', hijack all symbol name comparisons using the Ada
690 matcher, which handles the verbatim matching. */
692 && lookup_name.ada ().verbatim_p ())
694
695 return this->get_symbol_name_matcher_inner (lookup_name);
696}
697
698/* See language.h. */
699
702 (const lookup_name_info &lookup_name) const
703{
705}
706
707/* See language.h. */
708
709const struct lang_varobj_ops *
711{
712 /* The ops for the C language are suitable for the vast majority of the
713 supported languages. */
714 return &c_varobj_ops;
715}
716
717/* Parent class for both the "auto" and "unknown" languages. These two
718 pseudo-languages are very similar so merging their implementations like
719 this makes sense. */
720
722{
723public:
725 : language_defn (lang)
726 { /* Nothing. */ }
727
728 /* See language.h. */
730 struct language_arch_info *lai) const override
731 {
732 lai->set_string_char_type (builtin_type (gdbarch)->builtin_char);
733 lai->set_bool_type (builtin_type (gdbarch)->builtin_int);
734 }
735
736 /* See language.h. */
737
738 void print_type (struct type *type, const char *varstring,
739 struct ui_file *stream, int show, int level,
740 const struct type_print_options *flags) const override
741 {
742 error (_("type printing not implemented for language \"%s\""),
743 natural_name ());
744 }
745
746 /* See language.h. */
747
748 gdb::unique_xmalloc_ptr<char> demangle_symbol (const char *mangled,
749 int options) const override
750 {
751 /* The auto language just uses the C++ demangler. */
752 return gdb_demangle (mangled, options);
753 }
754
755 /* See language.h. */
756
757 void value_print (struct value *val, struct ui_file *stream,
758 const struct value_print_options *options) const override
759 {
760 error (_("value printing not implemented for language \"%s\""),
761 natural_name ());
762 }
763
764 /* See language.h. */
765
767 (struct value *val, struct ui_file *stream, int recurse,
768 const struct value_print_options *options) const override
769 {
770 error (_("inner value printing not implemented for language \"%s\""),
771 natural_name ());
772 }
773
774 /* See language.h. */
775
776 int parser (struct parser_state *ps) const override
777 {
778 error (_("expression parsing not implemented for language \"%s\""),
779 natural_name ());
780 }
781
782 /* See language.h. */
783
784 void emitchar (int ch, struct type *chtype,
785 struct ui_file *stream, int quoter) const override
786 {
787 error (_("emit character not implemented for language \"%s\""),
788 natural_name ());
789 }
790
791 /* See language.h. */
792
793 void printchar (int ch, struct type *chtype,
794 struct ui_file *stream) const override
795 {
796 error (_("print character not implemented for language \"%s\""),
797 natural_name ());
798 }
799
800 /* See language.h. */
801
802 void printstr (struct ui_file *stream, struct type *elttype,
803 const gdb_byte *string, unsigned int length,
804 const char *encoding, int force_ellipses,
805 const struct value_print_options *options) const override
806 {
807 error (_("print string not implemented for language \"%s\""),
808 natural_name ());
809 }
810
811 /* See language.h. */
812
813 void print_typedef (struct type *type, struct symbol *new_symbol,
814 struct ui_file *stream) const override
815 {
816 error (_("print typedef not implemented for language \"%s\""),
817 natural_name ());
818 }
819
820 /* See language.h. */
821
822 bool is_string_type_p (struct type *type) const override
823 {
825 while (type->code () == TYPE_CODE_REF)
826 {
827 type = type->target_type ();
829 }
830 return (type->code () == TYPE_CODE_STRING);
831 }
832
833 /* See language.h. */
834
835 const char *name_of_this () const override
836 { return "this"; }
837};
838
839/* Class representing the fake "auto" language. */
840
842{
843public:
846 { /* Nothing. */ }
847
848 /* See language.h. */
849
850 const char *name () const override
851 { return "auto"; }
852
853 /* See language.h. */
854
855 const char *natural_name () const override
856 { return "Auto"; }
857};
858
859/* Single instance of the fake "auto" language. */
860
862
863/* Class representing the unknown language. */
864
866{
867public:
870 { /* Nothing. */ }
871
872 /* See language.h. */
873
874 const char *name () const override
875 { return "unknown"; }
876
877 /* See language.h. */
878
879 const char *natural_name () const override
880 { return "Unknown"; }
881
882 /* See language.h. */
883
885 { return true; }
886};
887
888/* Single instance of the unknown language class. */
889
891
892
893/* Per-architecture language information. */
894
896{
897 /* A vector of per-language per-architecture info. Indexed by "enum
898 language". */
900};
901
903
904static language_gdbarch *
906{
908 if (l == nullptr)
909 {
910 l = new struct language_gdbarch;
911 for (const auto &lang : language_defn::languages)
912 {
913 gdb_assert (lang != nullptr);
914 lang->language_arch_info (gdbarch, &l->arch_info[lang->la_language]);
915 }
917 }
918
919 return l;
920}
921
922/* See language.h. */
923
924struct type *
926 struct gdbarch *gdbarch)
927{
929 return ld->arch_info[la->la_language].string_char_type ();
930}
931
932/* See language.h. */
933
934struct type *
936 struct gdbarch *gdbarch)
937{
939 return ld->arch_info[la->la_language].bool_type ();
940}
941
942/* See language.h. */
943
944struct type *
946{
947 if (m_bool_type_name != nullptr)
948 {
949 struct symbol *sym;
950
951 sym = lookup_symbol (m_bool_type_name, NULL, VAR_DOMAIN, NULL).symbol;
952 if (sym != nullptr)
953 {
954 struct type *type = sym->type ();
955 if (type != nullptr && type->code () == TYPE_CODE_BOOL)
956 return type;
957 }
958 }
959
960 return m_bool_type_default;
961}
962
963/* See language.h. */
964
965struct symbol *
967 (enum language lang, struct type *type)
968{
969 struct symbol *symbol;
970 struct gdbarch *gdbarch;
971 gdb_assert (!type->is_objfile_owned ());
972 gdbarch = type->arch_owner ();
973 symbol = new (gdbarch_obstack (gdbarch)) struct symbol ();
974 symbol->m_name = type->name ();
975 symbol->set_language (lang, nullptr);
982 return symbol;
983}
984
985/* See language.h. */
986
989{
991 {
992 if (strcmp (tas.type ()->name (), name) == 0)
993 return &tas;
994 }
995
996 return nullptr;
997}
998
999/* See language.h. */
1000
1001struct type *
1003{
1005 if (tas != nullptr)
1006 return tas->type ();
1007 return nullptr;
1008}
1009
1010/* See language.h. */
1011
1012struct type *
1014 (gdb::function_view<bool (struct type *)> filter)
1015{
1017 {
1018 if (filter (tas.type ()))
1019 return tas.type ();
1020 }
1021
1022 return nullptr;
1023}
1024
1025/* See language.h. */
1026
1027struct symbol *
1029 enum language lang)
1030{
1032 if (tas != nullptr)
1033 return tas->symbol (lang);
1034 return nullptr;
1035}
1036
1037/* Helper for the language_lookup_primitive_type overloads to forward
1038 to the corresponding language's lookup_primitive_type overload. */
1039
1040template<typename T>
1041static struct type *
1043 struct gdbarch *gdbarch,
1044 T arg)
1045{
1047 return ld->arch_info[la->la_language].lookup_primitive_type (arg);
1048}
1049
1050/* See language.h. */
1051
1052struct type *
1054 struct gdbarch *gdbarch,
1055 const char *name)
1056{
1058}
1059
1060/* See language.h. */
1061
1062struct type *
1064 struct gdbarch *gdbarch,
1065 gdb::function_view<bool (struct type *)> filter)
1066{
1067 return language_lookup_primitive_type_1 (la, gdbarch, filter);
1068}
1069
1070/* See language.h. */
1071
1072struct symbol *
1074 struct gdbarch *gdbarch,
1075 const char *name)
1076{
1078 struct language_arch_info *lai = &ld->arch_info[la->la_language];
1079
1081 ("language = \"%s\", gdbarch @ %s, type = \"%s\")",
1082 la->name (), host_address_to_string (gdbarch), name);
1083
1084 struct symbol *sym
1086
1087 symbol_lookup_debug_printf ("found symbol @ %s",
1088 host_address_to_string (sym));
1089
1090 /* Note: The result of symbol lookup is normally a symbol *and* the block
1091 it was found in. Builtin types don't live in blocks. We *could* give
1092 them one, but there is no current need so to keep things simple symbol
1093 lookup is extended to allow for BLOCK_FOUND to be NULL. */
1094
1095 return sym;
1096}
1097
1098/* Initialize the language routines. */
1099
1100void _initialize_language ();
1101void
1103{
1104 static const char *const type_or_range_names[]
1105 = { "on", "off", "warn", "auto", NULL };
1106
1107 static const char *const case_sensitive_names[]
1108 = { "on", "off", "auto", NULL };
1109
1110 /* GDB commands for language specific stuff. */
1111
1112 set_show_commands setshow_check_cmds
1113 = add_setshow_prefix_cmd ("check", no_class,
1114 _("Set the status of the type/range checker."),
1115 _("Show the status of the type/range checker."),
1117 &setlist, &showlist);
1118 add_alias_cmd ("c", setshow_check_cmds.set, no_class, 1, &setlist);
1119 add_alias_cmd ("ch", setshow_check_cmds.set, no_class, 1, &setlist);
1120 add_alias_cmd ("c", setshow_check_cmds.show, no_class, 1, &showlist);
1121 add_alias_cmd ("ch", setshow_check_cmds.show, no_class, 1, &showlist);
1122
1123 range = type_or_range_names[3];
1124 gdb_assert (strcmp (range, "auto") == 0);
1125 add_setshow_enum_cmd ("range", class_support, type_or_range_names,
1126 &range,
1127 _("Set range checking (on/warn/off/auto)."),
1128 _("Show range checking (on/warn/off/auto)."),
1129 NULL, set_range_command,
1132
1133 case_sensitive = case_sensitive_names[2];
1134 gdb_assert (strcmp (case_sensitive, "auto") == 0);
1135 add_setshow_enum_cmd ("case-sensitive", class_support, case_sensitive_names,
1136 &case_sensitive, _("\
1137Set case sensitivity in name search (on/off/auto)."), _("\
1138Show case sensitivity in name search (on/off/auto)."), _("\
1139For Fortran the default is off; for other languages the default is on."),
1142 &setlist, &showlist);
1143
1144 /* In order to call SET_LANGUAGE (below) we need to make sure that
1145 CURRENT_LANGUAGE is not NULL. So first set the language to unknown,
1146 then we can change the language to 'auto'. */
1148
1150
1151 /* Have the above take effect. */
1153}
const char *const name
obstack * gdbarch_obstack(gdbarch *arch)
int c_parse(struct parser_state *par_state)
Definition c-exp.c:6064
bool c_is_string_type_p(struct type *type)
Definition c-lang.c:695
void c_print_typedef(struct type *, struct symbol *, struct ui_file *)
void c_value_print_inner(struct value *, struct ui_file *, int, const struct value_print_options *)
Definition c-valprint.c:421
void c_value_print(struct value *, struct ui_file *, const struct value_print_options *)
Definition c-valprint.c:471
const struct lang_varobj_ops c_varobj_ops
Definition c-varobj.c:533
bool verbatim_p() const
Definition symtab.h:123
const char * natural_name() const override
Definition language.c:855
const char * name() const override
Definition language.c:850
auto_or_unknown_language(enum language lang)
Definition language.c:724
void value_print(struct value *val, struct ui_file *stream, const struct value_print_options *options) const override
Definition language.c:757
void print_typedef(struct type *type, struct symbol *new_symbol, struct ui_file *stream) const override
Definition language.c:813
void language_arch_info(struct gdbarch *gdbarch, struct language_arch_info *lai) const override
Definition language.c:729
void print_type(struct type *type, const char *varstring, struct ui_file *stream, int show, int level, const struct type_print_options *flags) const override
Definition language.c:738
bool is_string_type_p(struct type *type) const override
Definition language.c:822
void value_print_inner(struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options) const override
Definition language.c:767
void printchar(int ch, struct type *chtype, struct ui_file *stream) const override
Definition language.c:793
gdb::unique_xmalloc_ptr< char > demangle_symbol(const char *mangled, int options) const override
Definition language.c:748
int parser(struct parser_state *ps) const override
Definition language.c:776
const char * name_of_this() const override
Definition language.c:835
void printstr(struct ui_file *stream, struct type *elttype, const gdb_byte *string, unsigned int length, const char *encoding, int force_ellipses, const struct value_print_options *options) const override
Definition language.c:802
void emitchar(int ch, struct type *chtype, struct ui_file *stream, int quoter) const override
Definition language.c:784
const ada_lookup_name_info & ada() const
Definition symtab.h:314
gdb::string_view name() const
Definition symtab.h:240
bool completion_mode() const
Definition symtab.h:239
void set(unsigned key, void *datum)
Definition registry.h:204
void * get(unsigned key)
Definition registry.h:211
const char * c_str() const
Definition ui-file.h:218
void printf(const char *,...) ATTRIBUTE_PRINTF(2
Definition ui-file.c:40
const char * name() const override
Definition language.c:874
const char * natural_name() const override
Definition language.c:879
bool store_sym_names_in_linkage_form_p() const override
Definition language.c:884
struct cmd_list_element * showlist
Definition cli-cmds.c:125
struct cmd_list_element * setchecklist
Definition cli-cmds.c:167
struct cmd_list_element * setlist
Definition cli-cmds.c:117
struct cmd_list_element * showchecklist
Definition cli-cmds.c:169
struct cmd_list_element * add_alias_cmd(const char *name, cmd_list_element *target, enum command_class theclass, int abbrev_flag, struct cmd_list_element **list)
Definition cli-decode.c:294
set_show_commands add_setshow_enum_cmd(const char *name, enum command_class theclass, const char *const *enumlist, const char **var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition cli-decode.c:618
set_show_commands add_setshow_prefix_cmd(const char *name, command_class theclass, const char *set_doc, const char *show_doc, cmd_list_element **set_subcommands_list, cmd_list_element **show_subcommands_list, cmd_list_element **set_list, cmd_list_element **show_list)
Definition cli-decode.c:428
@ class_support
Definition command.h:58
@ no_class
Definition command.h:53
gdb::unique_xmalloc_ptr< char > gdb_demangle(const char *name, int options)
language
Definition defs.h:211
@ language_ada
Definition defs.h:226
@ language_unknown
Definition defs.h:212
@ language_minimal
Definition defs.h:225
@ language_auto
Definition defs.h:213
@ nr_languages
Definition defs.h:227
bool has_stack_frames()
Definition frame.c:1784
frame_info_ptr get_selected_frame(const char *message)
Definition frame.c:1813
enum language get_frame_language(frame_info_ptr frame)
Definition frame.c:2954
struct type * check_typedef(struct type *type)
Definition gdbtypes.c:3010
mach_port_t kern_return_t mach_port_t mach_msg_type_name_t msgportsPoly mach_port_t kern_return_t pid_t pid mach_port_t kern_return_t mach_port_t task mach_port_t kern_return_t int flags
Definition gnu-nat.c:1862
initialize_file_ftype _initialize_language
Definition language.c:1102
enum language language_enum(const char *str)
Definition language.c:427
const char lang_frame_mismatch_warn[]
Definition language.c:102
static void set_range_command(const char *ignore, int from_tty, struct cmd_list_element *c)
Definition language.c:238
case_mode
Definition language.c:67
@ case_mode_auto
Definition language.c:68
@ case_mode_manual
Definition language.c:68
const char * language_str(enum language lang)
Definition language.c:452
static const char * case_sensitive
Definition language.c:99
static struct type * language_lookup_primitive_type_1(const struct language_defn *la, struct gdbarch *gdbarch, T arg)
Definition language.c:1042
const struct language_defn * language_def(enum language lang)
Definition language.c:442
void range_error(const char *string,...)
Definition language.c:396
static void set_range_case(void)
Definition language.c:347
const struct language_defn * current_language
Definition language.c:83
static void show_range_command(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition language.c:199
range_mode
Definition language.c:58
@ range_mode_auto
Definition language.c:59
@ range_mode_manual
Definition language.c:59
static auto_language auto_language_defn
Definition language.c:861
gdb::unique_xmalloc_ptr< char > language_demangle(const struct language_defn *current_language, const char *mangled, int options)
Definition language.c:551
static language_gdbarch * get_language_gdbarch(struct gdbarch *gdbarch)
Definition language.c:905
enum language set_language(enum language lang)
Definition language.c:361
static void show_case_command(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition language.c:276
static unknown_language unknown_language_defn
Definition language.c:890
struct language_pass_by_ref_info language_pass_by_reference(struct type *type)
Definition language.c:563
static void show_language_command(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition language.c:111
void language_info()
Definition language.c:375
struct type * language_bool_type(const struct language_defn *la, struct gdbarch *gdbarch)
Definition language.c:935
struct type * language_string_char_type(const struct language_defn *la, struct gdbarch *gdbarch)
Definition language.c:925
static const char * range
Definition language.c:98
static const char * language
Definition language.c:97
const struct language_defn * expected_language
Definition language.c:89
static void set_case_command(const char *ignore, int from_tty, struct cmd_list_element *c)
Definition language.c:313
static void add_set_language_command()
Definition language.c:462
CORE_ADDR skip_language_trampoline(frame_info_ptr frame, CORE_ADDR pc)
Definition language.c:531
static const registry< gdbarch >::key< language_gdbarch > language_gdbarch_data
Definition language.c:902
static void set_language_command(const char *ignore, int from_tty, struct cmd_list_element *c)
Definition language.c:141
static bool default_symbol_name_matcher(const char *symbol_search_name, const lookup_name_info &lookup_name, completion_match_result *comp_match_res)
Definition language.c:660
const char * default_word_break_characters(void)
Definition language.c:573
const struct language_defn * current_language
Definition language.c:83
range_check
Definition language.h:51
@ range_check_warn
Definition language.h:52
@ range_check_on
Definition language.h:52
@ range_check_off
Definition language.h:52
enum language set_language(enum language)
Definition language.c:361
struct type * language_lookup_primitive_type(const struct language_defn *l, struct gdbarch *gdbarch, const char *name)
Definition language.c:1053
case_sensitivity
Definition language.h:72
@ case_sensitive_on
Definition language.h:73
@ case_sensitive_off
Definition language.h:73
language_mode
Definition language.h:700
@ language_mode_auto
Definition language.h:701
@ language_mode_manual
Definition language.h:701
const struct language_defn * language_def(enum language)
Definition language.c:442
struct symbol * language_lookup_primitive_type_as_symbol(const struct language_defn *l, struct gdbarch *gdbarch, const char *name)
Definition language.c:1073
static struct symbol * new_symbol(struct die_info *, struct type *, struct dwarf2_cu *, struct symbol *=NULL)
Definition read.c:20766
Definition 1.cc:26
struct symbol * symbol
Definition symtab.h:1494
void set_match(const char *m, const char *m_for_lcd=NULL)
Definition completer.h:216
completion_match_for_lcd match_for_lcd
Definition completer.h:212
void set_section_index(short idx)
Definition symtab.h:597
void set_language(enum language language, struct obstack *obstack)
Definition symtab.c:771
const char * m_name
Definition symtab.h:532
struct type * type() const
Definition language.h:167
static struct symbol * alloc_type_symbol(enum language lang, struct type *type)
Definition language.c:967
struct symbol * symbol(enum language lang)
Definition language.h:171
struct type * m_bool_type_default
Definition language.h:214
struct type * bool_type() const
Definition language.c:945
void set_string_char_type(struct type *type)
Definition language.h:114
struct symbol * lookup_primitive_type_as_symbol(const char *name, enum language lang)
Definition language.c:1028
std::vector< type_and_symbol > primitive_types_and_symbols
Definition language.h:205
const char * m_bool_type_name
Definition language.h:211
void set_bool_type(struct type *type, const char *name=nullptr)
Definition language.h:102
type_and_symbol * lookup_primitive_type_and_symbol(const char *name)
Definition language.c:988
struct type * lookup_primitive_type(const char *name)
Definition language.c:1002
struct type * string_char_type() const
Definition language.h:122
virtual bool is_string_type_p(struct type *type) const
Definition language.c:643
virtual symbol_name_matcher_ftype * get_symbol_name_matcher_inner(const lookup_name_info &lookup_name) const
Definition language.c:702
virtual const struct lang_varobj_ops * varobj_ops() const
Definition language.c:710
virtual struct language_pass_by_ref_info pass_by_reference_info(struct type *type) const
Definition language.h:332
enum language la_language
Definition language.h:275
virtual gdb::unique_xmalloc_ptr< char > watch_location_expression(struct type *type, CORE_ADDR addr) const
Definition language.c:595
virtual const char * natural_name() const =0
virtual const char * name() const =0
virtual void print_array_index(struct type *index_type, LONGEST index_value, struct ui_file *stream, const value_print_options *options) const
Definition language.c:581
symbol_name_matcher_ftype * get_symbol_name_matcher(const lookup_name_info &lookup_name) const
Definition language.c:686
virtual void value_print(struct value *val, struct ui_file *stream, const struct value_print_options *options) const
Definition language.c:607
static const struct language_defn * languages[nr_languages]
Definition language.h:525
virtual bool range_checking_on_by_default() const
Definition language.h:630
virtual int parser(struct parser_state *ps) const
Definition language.c:616
virtual enum case_sensitivity case_sensitivity() const
Definition language.h:637
virtual gdb::unique_xmalloc_ptr< char > demangle_symbol(const char *mangled, int options) const
Definition language.h:448
virtual void print_typedef(struct type *type, struct symbol *new_symbol, struct ui_file *stream) const
Definition language.c:634
virtual void value_print_inner(struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options) const
Definition language.c:625
virtual std::unique_ptr< compile_instance > get_compile_instance() const
Definition language.c:651
struct language_arch_info arch_info[nr_languages]
Definition language.c:899
Definition value.c:72
cmd_list_element * set
Definition command.h:406
cmd_list_element * show
Definition command.h:406
struct type * type() const
Definition symtab.h:1285
void set_aclass_index(unsigned int aclass_index)
Definition symtab.h:1225
union symbol::@179 owner
void set_type(struct type *type)
Definition symtab.h:1290
struct gdbarch * arch
Definition symtab.h:1417
void set_is_objfile_owned(bool is_objfile_owned)
Definition symtab.h:1255
void set_domain(domain_enum domain)
Definition symtab.h:1245
struct type * target_type() const
Definition gdbtypes.h:1000
type_code code() const
Definition gdbtypes.h:927
gdbarch * arch_owner() const
Definition gdbtypes.h:1353
const char * name() const
Definition gdbtypes.h:939
bool is_objfile_owned() const
Definition gdbtypes.h:1316
Definition value.c:181
void add_filename_language(const char *ext, enum language lang)
Definition symfile.c:2672
void set_initial_language(void)
Definition symfile.c:1668
struct block_symbol lookup_symbol(const char *name, const struct block *block, domain_enum domain, struct field_of_this_result *is_a_field_of_this)
Definition symtab.c:1967
bool() symbol_name_matcher_ftype(const char *symbol_search_name, const lookup_name_info &lookup_name, completion_match_result *comp_match_res)
Definition symtab.h:398
@ LOC_TYPEDEF
Definition symtab.h:989
#define symbol_lookup_debug_printf(fmt,...)
Definition symtab.h:2646
@ VAR_DOMAIN
Definition symtab.h:881
std::string type_to_string(struct type *type)
Definition typeprint.c:402
void verror(const char *string, va_list args)
Definition utils.c:162
void gdb_vprintf(struct ui_file *stream, const char *format, va_list args)
Definition utils.c:1853
int strncmp_iw_with_mode(const char *string1, const char *string2, size_t string2_len, strncmp_iw_mode mode, enum language language, completion_match_for_lcd *match_for_lcd, bool ignore_template_params)
Definition utils.c:2129
void gdb_printf(struct ui_file *stream, const char *format,...)
Definition utils.c:1865
void vwarning(const char *string, va_list args)
Definition utils.c:138
strncmp_iw_mode
Definition utils.h:43
#define gdb_stderr
Definition utils.h:193
#define gdb_stdout
Definition utils.h:188
struct value * value_from_longest(struct type *type, LONGEST num)
Definition value.c:3625