aboutsummaryrefslogtreecommitdiff
path: root/gdb/language.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/language.c')
-rw-r--r--gdb/language.c306
1 files changed, 146 insertions, 160 deletions
diff --git a/gdb/language.c b/gdb/language.c
index 50a53c6..5943387 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -54,18 +54,20 @@ static void set_range_case (void);
range_mode_manual: range_check set manually by user. */
enum range_mode
- {
- range_mode_auto, range_mode_manual
- };
+{
+ range_mode_auto,
+ range_mode_manual
+};
/* case_mode ==
case_mode_auto: case_sensitivity set upon selection of scope.
case_mode_manual: case_sensitivity set only by user. */
enum case_mode
- {
- case_mode_auto, case_mode_manual
- };
+{
+ case_mode_auto,
+ case_mode_manual
+};
/* The current (default at startup) state of type and range checking.
(If the modes are set to "auto", though, these are changed based
@@ -98,9 +100,9 @@ static const char *range;
static const char *case_sensitive;
/* See language.h. */
-const char lang_frame_mismatch_warn[] =
-N_("Warning: the current language does not match this frame.");
-
+const char lang_frame_mismatch_warn[]
+ = N_ ("Warning: the current language does not match this frame.");
+
/* This page contains the functions corresponding to GDB commands
and their helpers. */
@@ -110,16 +112,15 @@ static void
show_language_command (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
- enum language flang; /* The language of the frame. */
+ enum language flang; /* The language of the frame. */
if (language_mode == language_mode_auto)
gdb_printf (file,
- _("The current source language is "
- "\"auto; currently %s\".\n"),
+ _ ("The current source language is "
+ "\"auto; currently %s\".\n"),
current_language->name ());
else
- gdb_printf (file,
- _("The current source language is \"%s\".\n"),
+ gdb_printf (file, _ ("The current source language is \"%s\".\n"),
current_language->name ());
if (has_stack_frames ())
@@ -128,17 +129,16 @@ show_language_command (struct ui_file *file, int from_tty,
frame = get_selected_frame (NULL);
flang = get_frame_language (frame);
- if (flang != language_unknown
- && language_mode == language_mode_manual
+ if (flang != language_unknown && language_mode == language_mode_manual
&& current_language->la_language != flang)
- gdb_printf (file, "%s\n", _(lang_frame_mismatch_warn));
+ gdb_printf (file, "%s\n", _ (lang_frame_mismatch_warn));
}
}
/* Set command. Change the current working language. */
static void
-set_language_command (const char *ignore,
- int from_tty, struct cmd_list_element *c)
+set_language_command (const char *ignore, int from_tty,
+ struct cmd_list_element *c)
{
enum language flang = language_unknown;
@@ -217,25 +217,23 @@ show_range_command (struct ui_file *file, int from_tty,
internal_error ("Unrecognized range check setting.");
}
- gdb_printf (file,
- _("Range checking is \"auto; currently %s\".\n"),
+ gdb_printf (file, _ ("Range checking is \"auto; currently %s\".\n"),
tmp);
}
else
- gdb_printf (file, _("Range checking is \"%s\".\n"),
- value);
+ gdb_printf (file, _ ("Range checking is \"%s\".\n"), value);
if (range_check == range_check_warn
|| ((range_check == range_check_on)
!= current_language->range_checking_on_by_default ()))
- warning (_("the current range check setting "
- "does not match the language.\n"));
+ warning (_ ("the current range check setting "
+ "does not match the language.\n"));
}
/* Set command. Change the setting for range checking. */
static void
-set_range_command (const char *ignore,
- int from_tty, struct cmd_list_element *c)
+set_range_command (const char *ignore, int from_tty,
+ struct cmd_list_element *c)
{
if (strcmp (range, "on") == 0)
{
@@ -260,13 +258,13 @@ set_range_command (const char *ignore,
}
else
{
- internal_error (_("Unrecognized range check setting: \"%s\""), range);
+ internal_error (_ ("Unrecognized range check setting: \"%s\""), range);
}
if (range_check == range_check_warn
|| ((range_check == range_check_on)
!= current_language->range_checking_on_by_default ()))
- warning (_("the current range check setting "
- "does not match the language.\n"));
+ warning (_ ("the current range check setting "
+ "does not match the language.\n"));
}
/* Show command. Display a warning if the case sensitivity setting does
@@ -292,18 +290,17 @@ show_case_command (struct ui_file *file, int from_tty,
}
gdb_printf (file,
- _("Case sensitivity in "
- "name search is \"auto; currently %s\".\n"),
+ _ ("Case sensitivity in "
+ "name search is \"auto; currently %s\".\n"),
tmp);
}
else
- gdb_printf (file,
- _("Case sensitivity in name search is \"%s\".\n"),
+ gdb_printf (file, _ ("Case sensitivity in name search is \"%s\".\n"),
value);
if (case_sensitivity != current_language->case_sensitivity ())
- warning (_("the current case sensitivity setting does not match "
- "the language.\n"));
+ warning (_ ("the current case sensitivity setting does not match "
+ "the language.\n"));
}
/* Set command. Change the setting for case sensitivity. */
@@ -311,30 +308,30 @@ show_case_command (struct ui_file *file, int from_tty,
static void
set_case_command (const char *ignore, int from_tty, struct cmd_list_element *c)
{
- if (strcmp (case_sensitive, "on") == 0)
- {
- case_sensitivity = case_sensitive_on;
- case_mode = case_mode_manual;
- }
- else if (strcmp (case_sensitive, "off") == 0)
- {
- case_sensitivity = case_sensitive_off;
- case_mode = case_mode_manual;
- }
- else if (strcmp (case_sensitive, "auto") == 0)
- {
- case_mode = case_mode_auto;
- set_range_case ();
- return;
- }
- else
- {
- internal_error ("Unrecognized case-sensitive setting: \"%s\"",
- case_sensitive);
- }
-
- if (case_sensitivity != current_language->case_sensitivity ())
- warning (_("the current case sensitivity setting does not match "
+ if (strcmp (case_sensitive, "on") == 0)
+ {
+ case_sensitivity = case_sensitive_on;
+ case_mode = case_mode_manual;
+ }
+ else if (strcmp (case_sensitive, "off") == 0)
+ {
+ case_sensitivity = case_sensitive_off;
+ case_mode = case_mode_manual;
+ }
+ else if (strcmp (case_sensitive, "auto") == 0)
+ {
+ case_mode = case_mode_auto;
+ set_range_case ();
+ return;
+ }
+ else
+ {
+ internal_error ("Unrecognized case-sensitive setting: \"%s\"",
+ case_sensitive);
+ }
+
+ if (case_sensitivity != current_language->case_sensitivity ())
+ warning (_ ("the current case sensitivity setting does not match "
"the language.\n"));
}
@@ -346,8 +343,9 @@ static void
set_range_case (void)
{
if (range_mode == range_mode_auto)
- range_check = (current_language->range_checking_on_by_default ()
- ? range_check_on : range_check_off);
+ range_check
+ = (current_language->range_checking_on_by_default () ? range_check_on
+ : range_check_off);
if (case_mode == case_mode_auto)
case_sensitivity = current_language->case_sensitivity ();
@@ -366,7 +364,6 @@ set_language (enum language lang)
set_range_case ();
return prev_language;
}
-
/* See language.h. */
@@ -377,10 +374,10 @@ language_info ()
return;
expected_language = current_language;
- gdb_printf (_("Current language: %s\n"), language);
+ gdb_printf (_ ("Current language: %s\n"), language);
show_language_command (gdb_stdout, 1, NULL, NULL);
}
-
+
/* This page contains functions for the printing out of
error messages that occur during type- and range-
checking. */
@@ -392,7 +389,7 @@ language_info ()
otherwise just the message. */
void
-range_error (const char *string,...)
+range_error (const char *string, ...)
{
va_list args;
@@ -412,11 +409,10 @@ range_error (const char *string,...)
gdb_printf (gdb_stderr, "\n");
break;
default:
- internal_error (_("bad switch"));
+ internal_error (_ ("bad switch"));
}
va_end (args);
}
-
/* This page contains miscellaneous functions. */
@@ -453,8 +449,6 @@ language_str (enum language lang)
return language_def (lang)->name ();
}
-
-
/* Build and install the "set language LANG" command. */
static void
@@ -488,15 +482,15 @@ add_set_language_command ()
/* Add the filename extensions. */
for (const auto &lang : language_defn::languages)
- for (const char * const &ext : lang->filename_extensions ())
+ for (const char *const &ext : lang->filename_extensions ())
add_filename_language (ext, lang->la_language);
/* Build the "help set language" docs. */
string_file doc;
- doc.printf (_("Set the current source language.\n"
- "The currently understood settings are:\n\nlocal or "
- "auto Automatic setting based on source file"));
+ doc.printf (_ ("Set the current source language.\n"
+ "The currently understood settings are:\n\nlocal or "
+ "auto Automatic setting based on source file"));
for (const auto &lang : language_defn::languages)
{
@@ -507,18 +501,13 @@ add_set_language_command ()
/* Note that we add the newline at the front, so we don't wind
up with a trailing newline. */
- doc.printf ("\n%-16s Use the %s language",
- lang->name (),
+ doc.printf ("\n%-16s Use the %s language", lang->name (),
lang->natural_name ());
}
- add_setshow_enum_cmd ("language", class_support,
- language_names,
- &language,
- doc.c_str (),
- _("Show the current source language."),
- NULL, set_language_command,
- show_language_command,
+ add_setshow_enum_cmd ("language", class_support, language_names, &language,
+ doc.c_str (), _ ("Show the current source language."),
+ NULL, set_language_command, show_language_command,
&setlist, &showlist);
}
@@ -526,7 +515,7 @@ add_set_language_command ()
any non-NULL struct language_defn.skip_trampoline() functions.
Return the result from the first that returns non-zero, or 0 if all
`fail'. */
-CORE_ADDR
+CORE_ADDR
skip_language_trampoline (frame_info_ptr frame, CORE_ADDR pc)
{
for (const auto &lang : language_defn::languages)
@@ -547,8 +536,8 @@ skip_language_trampoline (frame_info_ptr frame, CORE_ADDR pc)
FIXME: Sometimes the demangler is invoked when we don't know the
language, so we can't use this everywhere. */
gdb::unique_xmalloc_ptr<char>
-language_demangle (const struct language_defn *current_language,
- const char *mangled, int options)
+language_demangle (const struct language_defn *current_language,
+ const char *mangled, int options)
{
if (current_language != NULL)
return current_language->demangle_symbol (mangled, options);
@@ -604,7 +593,7 @@ language_defn::watch_location_expression (struct type *type,
void
language_defn::value_print (struct value *val, struct ui_file *stream,
- const struct value_print_options *options) const
+ const struct value_print_options *options) const
{
return c_value_print (val, stream, options);
}
@@ -620,9 +609,9 @@ language_defn::parser (struct parser_state *ps) const
/* See language.h. */
void
-language_defn::value_print_inner
- (struct value *val, struct ui_file *stream, int recurse,
- const struct value_print_options *options) const
+language_defn::value_print_inner (
+ struct value *val, struct ui_file *stream, int recurse,
+ const struct value_print_options *options) const
{
return c_value_print_inner (val, stream, recurse, options);
}
@@ -663,12 +652,13 @@ default_symbol_name_matcher (const char *symbol_search_name,
gdb::string_view name = lookup_name.name ();
completion_match_for_lcd *match_for_lcd
= (comp_match_res != NULL ? &comp_match_res->match_for_lcd : NULL);
- strncmp_iw_mode mode = (lookup_name.completion_mode ()
- ? strncmp_iw_mode::NORMAL
- : strncmp_iw_mode::MATCH_PARAMS);
+ strncmp_iw_mode mode
+ = (lookup_name.completion_mode () ? strncmp_iw_mode::NORMAL
+ : strncmp_iw_mode::MATCH_PARAMS);
if (strncmp_iw_with_mode (symbol_search_name, name.data (), name.size (),
- mode, language_minimal, match_for_lcd) == 0)
+ mode, language_minimal, match_for_lcd)
+ == 0)
{
if (comp_match_res != NULL)
comp_match_res->set_match (symbol_search_name);
@@ -681,8 +671,8 @@ default_symbol_name_matcher (const char *symbol_search_name,
/* See language.h. */
symbol_name_matcher_ftype *
-language_defn::get_symbol_name_matcher
- (const lookup_name_info &lookup_name) const
+language_defn::get_symbol_name_matcher (
+ const lookup_name_info &lookup_name) const
{
/* If currently in Ada mode, and the lookup name is wrapped in
'<...>', hijack all symbol name comparisons using the Ada
@@ -697,8 +687,8 @@ language_defn::get_symbol_name_matcher
/* See language.h. */
symbol_name_matcher_ftype *
-language_defn::get_symbol_name_matcher_inner
- (const lookup_name_info &lookup_name) const
+language_defn::get_symbol_name_matcher_inner (
+ const lookup_name_info &lookup_name) const
{
return default_symbol_name_matcher;
}
@@ -720,9 +710,11 @@ language_defn::varobj_ops () const
class auto_or_unknown_language : public language_defn
{
public:
+
auto_or_unknown_language (enum language lang)
: language_defn (lang)
- { /* Nothing. */ }
+ { /* Nothing. */
+ }
/* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
@@ -738,7 +730,7 @@ public:
struct ui_file *stream, int show, int level,
const struct type_print_options *flags) const override
{
- error (_("type printing not implemented for language \"%s\""),
+ error (_ ("type printing not implemented for language \"%s\""),
natural_name ());
}
@@ -756,17 +748,17 @@ public:
void value_print (struct value *val, struct ui_file *stream,
const struct value_print_options *options) const override
{
- error (_("value printing not implemented for language \"%s\""),
+ error (_ ("value printing not implemented for language \"%s\""),
natural_name ());
}
/* See language.h. */
- void value_print_inner
- (struct value *val, struct ui_file *stream, int recurse,
- const struct value_print_options *options) const override
+ void
+ value_print_inner (struct value *val, struct ui_file *stream, int recurse,
+ const struct value_print_options *options) const override
{
- error (_("inner value printing not implemented for language \"%s\""),
+ error (_ ("inner value printing not implemented for language \"%s\""),
natural_name ());
}
@@ -774,16 +766,16 @@ public:
int parser (struct parser_state *ps) const override
{
- error (_("expression parsing not implemented for language \"%s\""),
+ error (_ ("expression parsing not implemented for language \"%s\""),
natural_name ());
}
/* See language.h. */
- void emitchar (int ch, struct type *chtype,
- struct ui_file *stream, int quoter) const override
+ void emitchar (int ch, struct type *chtype, struct ui_file *stream,
+ int quoter) const override
{
- error (_("emit character not implemented for language \"%s\""),
+ error (_ ("emit character not implemented for language \"%s\""),
natural_name ());
}
@@ -792,7 +784,7 @@ public:
void printchar (int ch, struct type *chtype,
struct ui_file *stream) const override
{
- error (_("print character not implemented for language \"%s\""),
+ error (_ ("print character not implemented for language \"%s\""),
natural_name ());
}
@@ -803,7 +795,7 @@ public:
const char *encoding, int force_ellipses,
const struct value_print_options *options) const override
{
- error (_("print string not implemented for language \"%s\""),
+ error (_ ("print string not implemented for language \"%s\""),
natural_name ());
}
@@ -812,7 +804,7 @@ public:
void print_typedef (struct type *type, struct symbol *new_symbol,
struct ui_file *stream) const override
{
- error (_("print typedef not implemented for language \"%s\""),
+ error (_ ("print typedef not implemented for language \"%s\""),
natural_name ());
}
@@ -831,8 +823,7 @@ public:
/* See language.h. */
- const char *name_of_this () const override
- { return "this"; }
+ const char *name_of_this () const override { return "this"; }
};
/* Class representing the fake "auto" language. */
@@ -840,19 +831,19 @@ public:
class auto_language : public auto_or_unknown_language
{
public:
+
auto_language ()
: auto_or_unknown_language (language_auto)
- { /* Nothing. */ }
+ { /* Nothing. */
+ }
/* See language.h. */
- const char *name () const override
- { return "auto"; }
+ const char *name () const override { return "auto"; }
/* See language.h. */
- const char *natural_name () const override
- { return "Auto"; }
+ const char *natural_name () const override { return "Auto"; }
};
/* Single instance of the fake "auto" language. */
@@ -864,31 +855,29 @@ static auto_language auto_language_defn;
class unknown_language : public auto_or_unknown_language
{
public:
+
unknown_language ()
: auto_or_unknown_language (language_unknown)
- { /* Nothing. */ }
+ { /* Nothing. */
+ }
/* See language.h. */
- const char *name () const override
- { return "unknown"; }
+ const char *name () const override { return "unknown"; }
/* See language.h. */
- const char *natural_name () const override
- { return "Unknown"; }
+ const char *natural_name () const override { return "Unknown"; }
/* See language.h. */
- bool store_sym_names_in_linkage_form_p () const override
- { return true; }
+ bool store_sym_names_in_linkage_form_p () const override { return true; }
};
/* Single instance of the unknown language class. */
static unknown_language unknown_language_defn;
-
/* Per-architecture language information. */
struct language_gdbarch
@@ -931,8 +920,7 @@ language_string_char_type (const struct language_defn *la,
/* See language.h. */
struct type *
-language_bool_type (const struct language_defn *la,
- struct gdbarch *gdbarch)
+language_bool_type (const struct language_defn *la, struct gdbarch *gdbarch)
{
struct language_gdbarch *ld = get_language_gdbarch (gdbarch);
return ld->arch_info[la->la_language].bool_type ();
@@ -962,8 +950,8 @@ language_arch_info::bool_type () const
/* See language.h. */
struct symbol *
-language_arch_info::type_and_symbol::alloc_type_symbol
- (enum language lang, struct type *type)
+language_arch_info::type_and_symbol::alloc_type_symbol (enum language lang,
+ struct type *type)
{
struct symbol *symbol;
struct gdbarch *gdbarch;
@@ -1009,8 +997,8 @@ language_arch_info::lookup_primitive_type (const char *name)
/* See language.h. */
struct type *
-language_arch_info::lookup_primitive_type
- (gdb::function_view<bool (struct type *)> filter)
+language_arch_info::lookup_primitive_type (
+ gdb::function_view<bool (struct type *)> filter)
{
for (struct type_and_symbol &tas : primitive_types_and_symbols)
{
@@ -1039,8 +1027,7 @@ language_arch_info::lookup_primitive_type_as_symbol (const char *name,
template<typename T>
static struct type *
language_lookup_primitive_type_1 (const struct language_defn *la,
- struct gdbarch *gdbarch,
- T arg)
+ struct gdbarch *gdbarch, T arg)
{
struct language_gdbarch *ld = get_language_gdbarch (gdbarch);
return ld->arch_info[la->la_language].lookup_primitive_type (arg);
@@ -1050,8 +1037,7 @@ language_lookup_primitive_type_1 (const struct language_defn *la,
struct type *
language_lookup_primitive_type (const struct language_defn *la,
- struct gdbarch *gdbarch,
- const char *name)
+ struct gdbarch *gdbarch, const char *name)
{
return language_lookup_primitive_type_1 (la, gdbarch, name);
}
@@ -1059,9 +1045,9 @@ language_lookup_primitive_type (const struct language_defn *la,
/* See language.h. */
struct type *
-language_lookup_primitive_type (const struct language_defn *la,
- struct gdbarch *gdbarch,
- gdb::function_view<bool (struct type *)> filter)
+language_lookup_primitive_type (
+ const struct language_defn *la, struct gdbarch *gdbarch,
+ gdb::function_view<bool (struct type *)> filter)
{
return language_lookup_primitive_type_1 (la, gdbarch, filter);
}
@@ -1076,9 +1062,9 @@ language_lookup_primitive_type_as_symbol (const struct language_defn *la,
struct language_gdbarch *ld = get_language_gdbarch (gdbarch);
struct language_arch_info *lai = &ld->arch_info[la->la_language];
- symbol_lookup_debug_printf
- ("language = \"%s\", gdbarch @ %s, type = \"%s\")",
- la->name (), host_address_to_string (gdbarch), name);
+ symbol_lookup_debug_printf (
+ "language = \"%s\", gdbarch @ %s, type = \"%s\")", la->name (),
+ host_address_to_string (gdbarch), name);
struct symbol *sym
= lai->lookup_primitive_type_as_symbol (name, la->la_language);
@@ -1097,6 +1083,7 @@ language_lookup_primitive_type_as_symbol (const struct language_defn *la,
/* Initialize the language routines. */
void _initialize_language ();
+
void
_initialize_language ()
{
@@ -1110,10 +1097,10 @@ _initialize_language ()
set_show_commands setshow_check_cmds
= add_setshow_prefix_cmd ("check", no_class,
- _("Set the status of the type/range checker."),
- _("Show the status of the type/range checker."),
- &setchecklist, &showchecklist,
- &setlist, &showlist);
+ _ ("Set the status of the type/range checker."),
+ _ ("Show the status of the type/range checker."),
+ &setchecklist, &showchecklist, &setlist,
+ &showlist);
add_alias_cmd ("c", setshow_check_cmds.set, no_class, 1, &setlist);
add_alias_cmd ("ch", setshow_check_cmds.set, no_class, 1, &setlist);
add_alias_cmd ("c", setshow_check_cmds.show, no_class, 1, &showlist);
@@ -1121,24 +1108,23 @@ _initialize_language ()
range = type_or_range_names[3];
gdb_assert (strcmp (range, "auto") == 0);
- add_setshow_enum_cmd ("range", class_support, type_or_range_names,
- &range,
- _("Set range checking (on/warn/off/auto)."),
- _("Show range checking (on/warn/off/auto)."),
- NULL, set_range_command,
- show_range_command,
- &setchecklist, &showchecklist);
+ add_setshow_enum_cmd ("range", class_support, type_or_range_names, &range,
+ _ ("Set range checking (on/warn/off/auto)."),
+ _ ("Show range checking (on/warn/off/auto)."), NULL,
+ set_range_command, show_range_command, &setchecklist,
+ &showchecklist);
case_sensitive = case_sensitive_names[2];
gdb_assert (strcmp (case_sensitive, "auto") == 0);
add_setshow_enum_cmd ("case-sensitive", class_support, case_sensitive_names,
- &case_sensitive, _("\
-Set case sensitivity in name search (on/off/auto)."), _("\
-Show case sensitivity in name search (on/off/auto)."), _("\
+ &case_sensitive, _ ("\
+Set case sensitivity in name search (on/off/auto)."),
+ _ ("\
+Show case sensitivity in name search (on/off/auto)."),
+ _ ("\
For Fortran the default is off; for other languages the default is on."),
- set_case_command,
- show_case_command,
- &setlist, &showlist);
+ set_case_command, show_case_command, &setlist,
+ &showlist);
/* In order to call SET_LANGUAGE (below) we need to make sure that
CURRENT_LANGUAGE is not NULL. So first set the language to unknown,