[PATCHv2,03/18] gdb: Convert la_name and la_natural_name to methods

Message ID 252854446e51fbba8c9c7911ed7e712b8e1456ba.1596638295.git.andrew.burgess@embecosm.com
State New
Headers show
Series
  • Further updates for the language class structure
Related show

Commit Message

Andrew Burgess Aug. 5, 2020, 2:45 p.m.
Convert the two language_data member variables la_name and
la_natural_name to virtual methods in language_defn struct called name
and natural_name respectively.

The virtual methods in the language_defn base class are pure virtual,
as every language must implement these, and as every language has a
unique name there's no sensible default here.

Given that every language must implement these methods I did wonder
about making this data passed into the base class constructor, but in
the end I went with the virtual method approach.  I'm open to changing
this approach if people prefer the constructor approach.

During updating the calls to language_defn::name I found in
add_set_language_command a place where we took la_name and then
capitalised the first letter to create a language name that could be
used in the documentation string.  I replaced this with a use of
natural_name instead as this seemed a better choice, in most cases
this will make no difference, as for most languages the natural_name
is just the name with the first character in upper case, but for some
languages, for example 'Open-CL' and 'Objective-C' this is not the
case.

In the case of asm_language the name is 'asm', while the natural_name
was previously 'assembly'.  I changed the natural name to 'Assembly',
this makes the documentation string case above cleaner, however, this
will change the MI output for -var-info-expression, where the 'lang'
field will change from 'assembly' to 'Assembly'.  It is possible this
could be a breaking change if a front-end is relying on the existing
name.

gdb/ChangeLog:

	* 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.
---
 gdb/ChangeLog         | 86 +++++++++++++++++++++++++++++++++++++++++++
 gdb/ada-lang.c        | 12 +++++-
 gdb/c-lang.c          | 48 ++++++++++++++++++++----
 gdb/compile/compile.c |  2 +-
 gdb/d-lang.c          | 12 +++++-
 gdb/expprint.c        |  6 +--
 gdb/f-lang.c          | 12 +++++-
 gdb/go-lang.c         | 12 +++++-
 gdb/language.c        | 52 ++++++++++++++++----------
 gdb/language.h        | 16 ++++----
 gdb/m2-lang.c         | 12 +++++-
 gdb/mi/mi-cmd-var.c   |  2 +-
 gdb/objc-lang.c       | 12 +++++-
 gdb/opencl-lang.c     | 12 +++++-
 gdb/p-lang.c          | 13 ++++++-
 gdb/rust-lang.c       | 12 +++++-
 gdb/symtab.c          |  2 +-
 17 files changed, 263 insertions(+), 60 deletions(-)

-- 
2.25.4

Patch

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 3c40eca03f2..019abceb0c5 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -13713,8 +13713,6 @@  static const char *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 @@  class ada_language : public language_defn
     : 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 484ac814b56..04e9eae8912 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -880,8 +880,6 @@  static const char *c_extensions[] =
 
 extern const struct language_data c_language_data =
 {
-  "c",				/* Language name */
-  "C",
   language_c,
   range_check_off,
   case_sensitive_on,
@@ -905,6 +903,16 @@  class c_language : public language_defn
     : language_defn (language_c, c_language_data)
   { /* 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 *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 @@  class cplus_language : public language_defn
 
   /* 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 *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 @@  class asm_language : public language_defn
     : 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,
@@ -1259,6 +1281,16 @@  class minimal_language : public language_defn
     : language_defn (language_minimal, minimal_language_data)
   { /* 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 0c29a0476e7..8d8c2b14eba 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 c60e0702b22..0985f535743 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -133,8 +133,6 @@  static const char *d_extensions[] =
 
 extern const struct language_data d_language_data =
 {
-  "d",
-  "D",
   language_d,
   range_check_off,
   case_sensitive_on,
@@ -158,6 +156,16 @@  class d_language : public language_defn
     : language_defn (language_d, d_language_data)
   { /* 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 24d647e006c..36e18ea1a9f 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 a27f2157b42..a31f863cc09 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,
@@ -518,6 +516,16 @@  class f_language : public language_defn
     : language_defn (language_fortran, f_language_data)
   { /* 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 df7cbc79b19..6e9b4875696 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,
@@ -533,6 +531,16 @@  class go_language : public language_defn
     : language_defn (language_go, go_language_data)
   { /* 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 7ccd0ac2b8e..0b1b4882038 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,
@@ -808,6 +802,16 @@  class unknown_language : public language_defn
     : language_defn (language_unknown, unknown_language_data)
   { /* 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,
@@ -937,6 +939,16 @@  class auto_language : public language_defn
     : language_defn (language_auto, auto_language_data)
   { /* 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 4c9453f33cb..980e3647af9 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 3ba5026b2bc..9806caf6103 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,
@@ -224,6 +222,16 @@  class m2_language : public language_defn
     : language_defn (language_m2, m2_language_data)
   { /* 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 da5bf2d7fac..65a2ba146dd 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 f18a7761532..99306a6c9c3 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -328,8 +328,6 @@  static const char *objc_extensions[] =
 
 extern const struct language_data objc_language_data =
 {
-  "objective-c",		/* Language name */
-  "Objective-C",
   language_objc,
   range_check_off,
   case_sensitive_on,
@@ -353,6 +351,16 @@  class objc_language : public language_defn
     : language_defn (language_objc, objc_language_data)
   { /* 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 37ac1386b2d..08fc05b2310 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -1007,8 +1007,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 @@  class opencl_language : public language_defn
     : language_defn (language_opencl, opencl_language_data)
   { /* 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 ab24d48bf8f..9fa6cf7e15c 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -257,8 +257,6 @@  static const char *p_extensions[] =
 
 extern const struct language_data pascal_language_data =
 {
-  "pascal",			/* Language name */
-  "Pascal",
   language_pascal,
   range_check_on,
   case_sensitive_on,
@@ -282,6 +280,17 @@  class pascal_language : public language_defn
     : language_defn (language_pascal, pascal_language_data)
   { /* 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 94515ed17e2..dd330a74eb4 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -1911,8 +1911,6 @@  static const char *rust_extensions[] =
 
 extern const struct language_data rust_language_data =
 {
-  "rust",
-  "Rust",
   language_rust,
   range_check_on,
   case_sensitive_on,
@@ -1936,6 +1934,16 @@  class rust_language : public language_defn
     : language_defn (language_rust, rust_language_data)
   { /* 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 ff88adfe020..61f96b2ab8c 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));
     }