aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog86
-rw-r--r--gdb/ada-lang.c12
-rw-r--r--gdb/c-lang.c48
-rw-r--r--gdb/compile/compile.c2
-rw-r--r--gdb/d-lang.c12
-rw-r--r--gdb/expprint.c6
-rw-r--r--gdb/f-lang.c12
-rw-r--r--gdb/go-lang.c12
-rw-r--r--gdb/language.c52
-rw-r--r--gdb/language.h16
-rw-r--r--gdb/m2-lang.c12
-rw-r--r--gdb/mi/mi-cmd-var.c2
-rw-r--r--gdb/objc-lang.c12
-rw-r--r--gdb/opencl-lang.c12
-rw-r--r--gdb/p-lang.c13
-rw-r--r--gdb/rust-lang.c12
-rw-r--r--gdb/symtab.c2
17 files changed, 263 insertions, 60 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a5d9d3b..a58c490 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,91 @@
2020-09-16 Andrew Burgess <andrew.burgess@embecosm.com>
+ * ada-lang.c (ada_language_data): Remove la_name and
+ la_natural_name initializers.
+ (ada_language::name): New member function.
+ (ada_language::natural_name): New member function.
+ * c-lang.c (c_language_data): Remove la_name and
+ la_natural_name initializers.
+ (c_language::name): New member function.
+ (c_language::natural_name): New member function.
+ (cplus_language_data): Remove la_name and
+ la_natural_name initializers.
+ (cplus_language::name): New member function.
+ (cplus_language::natural_name): New member function.
+ (asm_language_data): Remove la_name and
+ la_natural_name initializers.
+ (asm_language::name): New member function.
+ (asm_language::natural_name): New member function.
+ (minimal_language_data): Remove la_name and
+ la_natural_name initializers.
+ (minimal_language::name): New member function.
+ (minimal_language::natural_name): New member function.
+ * compile/compile.c (compile_to_object): Update call to
+ lanugage_defn::name.
+ * d-lang.c (d_language_data): Remove la_name and
+ la_natural_name initializers.
+ (d_language::name): New member function.
+ (d_language::natural_name): New member function.
+ * expprint.c (print_subexp_standard): Update call to
+ language_defn::name.
+ (dump_raw_expression): Likewise
+ (dump_prefix_expression): Likewise.
+ * f-lang.c (f_language_data): Remove la_name and
+ la_natural_name initializers.
+ (f_language::name): New member function.
+ (f_language::natural_name): New member function.
+ * go-lang.c (go_language_data): Remove la_name and
+ la_natural_name initializers.
+ (go_language::name): New member function.
+ (go_language::natural_name): New member function.
+ * language.c (show_language_command): Update call to
+ language_defn::name.
+ (set_language_command): Likewise.
+ (language_enum): Likewise.
+ (language_str): Likewise.
+ (add_set_language_command): Likewise, use
+ language_defn::natural_name in the doc string.
+ (unknown_language_data): Remove la_name and
+ la_natural_name initializers.
+ (unknown_language::name): New member function.
+ (unknown_language::natural_name): New member function.
+ (auto_language_data): Remove la_name and
+ la_natural_name initializers.
+ (auto_language::name): New member function.
+ (auto_language::natural_name): New member function.
+ (language_lookup_primitive_type_as_symbol): Update call to
+ language_defn::name.
+ * language.h (language_data): Remove la_name and la_natural_name
+ member variables.
+ (language_defn::name): New member function.
+ (language_defn::natural_name): New member function.
+ * m2-lang.c (m2_language_data): Remove la_name and
+ la_natural_name initializers.
+ (m2_language::name): New member function.
+ (m2_language::natural_name): New member function.
+ * mi/mi-cmd-var.c (mi_cmd_var_info_expression): Update call to
+ language_defn::natural_name.
+ * objc-lang.c (objc_language_data): Remove la_name and
+ la_natural_name initializers.
+ (objc_language::name): New member function.
+ (objc_language::natural_name): New member function.
+ * opencl-lang.c (opencl_language_data): Remove la_name and
+ la_natural_name initializers.
+ (opencl_language::name): New member function.
+ (opencl_language::natural_name): New member function.
+ * p-lang.c (pascal_language_data): Remove la_name and
+ la_natural_name initializers.
+ (pascal_language::name): New member function.
+ (pascal_language::natural_name): New member function.
+ * rust-lang.c (rust_language_data): Remove la_name and
+ la_natural_name initializers.
+ (rust_language::name): New member function.
+ (rust_language::natural_name): New member function.
+ * symtab.c (lookup_language_this): Update call to
+ language_defn::name.
+
+2020-09-16 Andrew Burgess <andrew.burgess@embecosm.com>
+
* ada-lang.c (ada_language_data): Remove la_name_of_this
initializer.
* ax-gdb.c (gen_expr): Update call to name_of_this.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index b028ccb..fd9e6d3 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -13713,8 +13713,6 @@ static const char * const ada_extensions[] =
extern const struct language_data ada_language_data =
{
- "ada", /* Language name */
- "Ada",
language_ada,
range_check_off,
case_sensitive_on, /* Yes, Ada is case-insensitive, but
@@ -13739,6 +13737,16 @@ public:
: language_defn (language_ada, ada_language_data)
{ /* Nothing. */ }
+ /* See language.h. */
+
+ const char *name () const override
+ { return "ada"; }
+
+ /* See language.h. */
+
+ const char *natural_name () const override
+ { return "Ada"; }
+
/* Print an array element index using the Ada syntax. */
void print_array_index (struct type *index_type,
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 2e4cf07..eb987f4 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -880,8 +880,6 @@ static const char * const c_extensions[] =
extern const struct language_data c_language_data =
{
- "c", /* Language name */
- "C",
language_c,
range_check_off,
case_sensitive_on,
@@ -906,6 +904,16 @@ public:
{ /* Nothing. */ }
/* See language.h. */
+
+ const char *name () const override
+ { return "c"; }
+
+ /* See language.h. */
+
+ const char *natural_name () const override
+ { return "C"; }
+
+ /* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
{
@@ -979,8 +987,6 @@ static const char * const cplus_extensions[] =
extern const struct language_data cplus_language_data =
{
- "c++", /* Language name */
- "C++",
language_cplus,
range_check_off,
case_sensitive_on,
@@ -1006,6 +1012,16 @@ public:
/* See language.h. */
+ const char *name () const override
+ { return "c++"; }
+
+ /* See language.h. */
+
+ const char *natural_name () const override
+ { return "C++"; }
+
+ /* See language.h. */
+
struct language_pass_by_ref_info pass_by_reference_info
(struct type *type) const override
{
@@ -1180,8 +1196,6 @@ static const char * const asm_extensions[] =
extern const struct language_data asm_language_data =
{
- "asm", /* Language name */
- "assembly",
language_asm,
range_check_off,
case_sensitive_on,
@@ -1205,6 +1219,16 @@ public:
: language_defn (language_asm, asm_language_data)
{ /* Nothing. */ }
+ /* See language.h. */
+
+ const char *name () const override
+ { return "asm"; }
+
+ /* See language.h. */
+
+ const char *natural_name () const override
+ { return "Assembly"; }
+
/* See language.h.
FIXME: Should this have its own arch info method? */
@@ -1234,8 +1258,6 @@ static asm_language asm_language_defn;
extern const struct language_data minimal_language_data =
{
- "minimal", /* Language name */
- "Minimal",
language_minimal,
range_check_off,
case_sensitive_on,
@@ -1260,6 +1282,16 @@ public:
{ /* Nothing. */ }
/* See language.h. */
+
+ const char *name () const override
+ { return "minimal"; }
+
+ /* See language.h. */
+
+ const char *natural_name () const override
+ { return "Minimal"; }
+
+ /* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
{
diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c
index 0c29a04..8d8c2b1 100644
--- a/gdb/compile/compile.c
+++ b/gdb/compile/compile.c
@@ -695,7 +695,7 @@ compile_to_object (struct command_line *cmd, const char *cmd_string,
(current_language->get_compile_instance ());
if (compiler == nullptr)
error (_("No compiler support for language %s."),
- current_language->la_name);
+ current_language->name ());
compiler->set_print_callback (print_callback, NULL);
compiler->set_scope (scope);
compiler->set_block (expr_block);
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index 82d5615..ff2bdf0 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -133,8 +133,6 @@ static const char * const d_extensions[] =
extern const struct language_data d_language_data =
{
- "d",
- "D",
language_d,
range_check_off,
case_sensitive_on,
@@ -159,6 +157,16 @@ public:
{ /* Nothing. */ }
/* See language.h. */
+
+ const char *name () const override
+ { return "d"; }
+
+ /* See language.h. */
+
+ const char *natural_name () const override
+ { return "D"; }
+
+ /* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
{
diff --git a/gdb/expprint.c b/gdb/expprint.c
index 24d647e..36e18ea 100644
--- a/gdb/expprint.c
+++ b/gdb/expprint.c
@@ -509,7 +509,7 @@ print_subexp_standard (struct expression *exp, int *pos,
else
fprintf_styled (stream, metadata_style.style (),
_("<language %s has no 'this'>"),
- exp->language_defn->la_name);
+ exp->language_defn->name ());
return;
/* Modula-2 ops */
@@ -734,7 +734,7 @@ dump_raw_expression (struct expression *exp, struct ui_file *stream,
if (note)
fprintf_filtered (stream, ", %s:", note);
fprintf_filtered (stream, "\n\tLanguage %s, %d elements, %ld bytes each.\n",
- exp->language_defn->la_name, exp->nelts,
+ exp->language_defn->name (), exp->nelts,
(long) sizeof (union exp_element));
fprintf_filtered (stream, "\t%5s %20s %16s %s\n", "Index", "Opcode",
"Hex Value", "String Value");
@@ -1159,7 +1159,7 @@ dump_prefix_expression (struct expression *exp, struct ui_file *stream)
fputs_filtered (", after conversion to prefix form:\nExpression: `", stream);
print_expression (exp, stream);
fprintf_filtered (stream, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",
- exp->language_defn->la_name, exp->nelts,
+ exp->language_defn->name (), exp->nelts,
(long) sizeof (union exp_element));
fputs_filtered ("\n", stream);
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 76f5fb5..ace0c56 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -493,8 +493,6 @@ static const struct exp_descriptor exp_descriptor_f =
extern const struct language_data f_language_data =
{
- "fortran",
- "Fortran",
language_fortran,
range_check_on,
case_sensitive_off,
@@ -519,6 +517,16 @@ public:
{ /* Nothing. */ }
/* See language.h. */
+
+ const char *name () const override
+ { return "fortran"; }
+
+ /* See language.h. */
+
+ const char *natural_name () const override
+ { return "Fortran"; }
+
+ /* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
{
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index df7cbc7..6e9b487 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -508,8 +508,6 @@ enum go_primitive_types {
extern const struct language_data go_language_data =
{
- "go",
- "Go",
language_go,
range_check_off,
case_sensitive_on,
@@ -534,6 +532,16 @@ public:
{ /* Nothing. */ }
/* See language.h. */
+
+ const char *name () const override
+ { return "go"; }
+
+ /* See language.h. */
+
+ const char *natural_name () const override
+ { return "Go"; }
+
+ /* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
{
diff --git a/gdb/language.c b/gdb/language.c
index 7ccd0ac..0b1b488 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -98,11 +98,11 @@ show_language_command (struct ui_file *file, int from_tty,
fprintf_filtered (gdb_stdout,
_("The current source language is "
"\"auto; currently %s\".\n"),
- current_language->la_name);
+ current_language->name ());
else
fprintf_filtered (gdb_stdout,
_("The current source language is \"%s\".\n"),
- current_language->la_name);
+ current_language->name ());
if (has_stack_frames ())
{
@@ -131,7 +131,7 @@ set_language_command (const char *ignore,
/* Search the list of languages for a match. */
for (const auto &lang : language_defn::languages)
{
- if (strcmp (lang->la_name, language) == 0)
+ if (strcmp (lang->name (), language) == 0)
{
/* Found it! Go into manual mode, and use this language. */
if (lang->la_language == language_auto)
@@ -442,7 +442,7 @@ enum language
language_enum (const char *str)
{
for (const auto &lang : language_defn::languages)
- if (strcmp (lang->la_name, str) == 0)
+ if (strcmp (lang->name (), str) == 0)
return lang->la_language;
if (strcmp (str, "local") == 0)
@@ -466,7 +466,7 @@ language_def (enum language lang)
const char *
language_str (enum language lang)
{
- return language_def (lang)->la_name;
+ return language_def (lang)->name ();
}
@@ -486,9 +486,9 @@ add_set_language_command ()
/* Display "auto", "local" and "unknown" first, and then the rest,
alpha sorted. */
const char **language_names_p = language_names;
- *language_names_p++ = language_def (language_auto)->la_name;
+ *language_names_p++ = language_def (language_auto)->name ();
*language_names_p++ = "local";
- *language_names_p++ = language_def (language_unknown)->la_name;
+ *language_names_p++ = language_def (language_unknown)->name ();
const char **sort_begin = language_names_p;
for (const auto &lang : language_defn::languages)
{
@@ -496,7 +496,7 @@ add_set_language_command ()
if (lang->la_language == language_auto
|| lang->la_language == language_unknown)
continue;
- *language_names_p++ = lang->la_name;
+ *language_names_p++ = lang->name ();
}
*language_names_p = NULL;
std::sort (sort_begin, language_names_p, compare_cstrings);
@@ -524,15 +524,11 @@ add_set_language_command ()
|| lang->la_language == language_auto)
continue;
- /* FIXME: i18n: for now assume that the human-readable name is
- just a capitalization of the internal name. */
/* 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 %c%s language",
- lang->la_name,
- /* Capitalize first letter of language name. */
- toupper (lang->la_name[0]),
- lang->la_name + 1);
+ doc.printf ("\n%-16s Use the %s language",
+ lang->name (),
+ lang->natural_name ());
}
add_setshow_enum_cmd ("language", class_support,
@@ -783,8 +779,6 @@ unknown_language_arch_info (struct gdbarch *gdbarch,
extern const struct language_data unknown_language_data =
{
- "unknown",
- "Unknown",
language_unknown,
range_check_off,
case_sensitive_on,
@@ -809,6 +803,16 @@ public:
{ /* Nothing. */ }
/* See language.h. */
+
+ const char *name () const override
+ { return "unknown"; }
+
+ /* See language.h. */
+
+ const char *natural_name () const override
+ { return "Unknown"; }
+
+ /* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
{
@@ -912,8 +916,6 @@ static unknown_language unknown_language_defn;
extern const struct language_data auto_language_data =
{
- "auto",
- "Auto",
language_auto,
range_check_off,
case_sensitive_on,
@@ -938,6 +940,16 @@ public:
{ /* Nothing. */ }
/* See language.h. */
+
+ const char *name () const override
+ { return "auto"; }
+
+ /* See language.h. */
+
+ const char *natural_name () const override
+ { return "Auto"; }
+
+ /* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
{
@@ -1209,7 +1221,7 @@ language_lookup_primitive_type_as_symbol (const struct language_defn *la,
fprintf_unfiltered (gdb_stdlog,
"language_lookup_primitive_type_as_symbol"
" (%s, %s, %s)",
- la->la_name, host_address_to_string (gdbarch), name);
+ la->name (), host_address_to_string (gdbarch), name);
}
typep = language_lookup_primitive_type_1 (lai, name);
diff --git a/gdb/language.h b/gdb/language.h
index 4c9453f..980e364 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -188,14 +188,6 @@ extern const char *default_word_break_characters (void);
struct language_data
{
- /* Name of the language. */
-
- const char *la_name;
-
- /* Natural or official name of the language. */
-
- const char *la_natural_name;
-
/* its symtab language-enum (defs.h). */
enum language la_language;
@@ -275,6 +267,14 @@ struct language_defn : language_data
languages[lang] = this;
}
+ /* Name of the language. */
+
+ virtual const char *name () const = 0;
+
+ /* Natural or official name of the language. */
+
+ virtual const char *natural_name () const = 0;
+
/* Print the index of an element of an array. This default
implementation prints using C99 syntax. */
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index 3ba5026..9806caf 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -199,8 +199,6 @@ const struct exp_descriptor exp_descriptor_modula2 =
extern const struct language_data m2_language_data =
{
- "modula-2",
- "Modula-2",
language_m2,
range_check_on,
case_sensitive_on,
@@ -225,6 +223,16 @@ public:
{ /* Nothing. */ }
/* See language.h. */
+
+ const char *name () const override
+ { return "modula-2"; }
+
+ /* See language.h. */
+
+ const char *natural_name () const override
+ { return "Modula-2"; }
+
+ /* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
{
diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c
index da5bf2d..65a2ba1 100644
--- a/gdb/mi/mi-cmd-var.c
+++ b/gdb/mi/mi-cmd-var.c
@@ -458,7 +458,7 @@ mi_cmd_var_info_expression (const char *command, char **argv, int argc)
lang = varobj_get_language (var);
- uiout->field_string ("lang", lang->la_natural_name);
+ uiout->field_string ("lang", lang->natural_name ());
std::string exp = varobj_get_expression (var);
uiout->field_string ("exp", exp.c_str ());
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index e8d846e..e63b992 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -328,8 +328,6 @@ static const char * const objc_extensions[] =
extern const struct language_data objc_language_data =
{
- "objective-c", /* Language name */
- "Objective-C",
language_objc,
range_check_off,
case_sensitive_on,
@@ -354,6 +352,16 @@ public:
{ /* Nothing. */ }
/* See language.h. */
+
+ const char *name () const override
+ { return "objective-c"; }
+
+ /* See language.h. */
+
+ const char *natural_name () const override
+ { return "Objective-C"; }
+
+ /* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
{
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index 2806bee..9a311c1 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -1006,8 +1006,6 @@ const struct exp_descriptor exp_descriptor_opencl =
/* Constant data representing the OpenCL language. */
extern const struct language_data opencl_language_data =
{
- "opencl", /* Language name */
- "OpenCL C",
language_opencl,
range_check_off,
case_sensitive_on,
@@ -1032,6 +1030,16 @@ public:
{ /* Nothing. */ }
/* See language.h. */
+
+ const char *name () const override
+ { return "opencl"; }
+
+ /* See language.h. */
+
+ const char *natural_name () const override
+ { return "OpenCL C"; }
+
+ /* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
{
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index 2c55139..486e906 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -257,8 +257,6 @@ static const char * const p_extensions[] =
extern const struct language_data pascal_language_data =
{
- "pascal", /* Language name */
- "Pascal",
language_pascal,
range_check_on,
case_sensitive_on,
@@ -283,6 +281,17 @@ public:
{ /* Nothing. */ }
/* See language.h. */
+
+ const char *name () const override
+ { return "pascal"; }
+
+ /* See language.h. */
+
+ const char *natural_name () const override
+ { return "Pascal"; }
+
+
+ /* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
{
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index aec430e..971d60b 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -1906,8 +1906,6 @@ static const char * const rust_extensions[] =
extern const struct language_data rust_language_data =
{
- "rust",
- "Rust",
language_rust,
range_check_on,
case_sensitive_on,
@@ -1932,6 +1930,16 @@ public:
{ /* Nothing. */ }
/* See language.h. */
+
+ const char *name () const override
+ { return "rust"; }
+
+ /* See language.h. */
+
+ const char *natural_name () const override
+ { return "Rust"; }
+
+ /* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
{
diff --git a/gdb/symtab.c b/gdb/symtab.c
index ff88adf..61f96b2 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -1921,7 +1921,7 @@ lookup_language_this (const struct language_defn *lang,
fprintf_unfiltered (gdb_stdlog,
"lookup_language_this (%s, %s (objfile %s))",
- lang->la_name, host_address_to_string (block),
+ lang->name (), host_address_to_string (block),
objfile_debug_name (objfile));
}