]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: Convert language la_sniff_from_mangled_name field to a method
authorAndrew Burgess <andrew.burgess@embecosm.com>
Wed, 13 May 2020 17:04:30 +0000 (18:04 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Tue, 2 Jun 2020 12:53:11 +0000 (13:53 +0100)
This commit changes the language_data::la_sniff_from_mangled_name
function pointer member variable into a member function of
language_defn.

Previously the la_sniff_from_mangled_name pointer was NULL for some
languages, however, all uses of this function pointer were through the
function language_sniff_from_mangled_name which provided a default
implementation.

This default implementation now becomes the implementation in the base
class language_defn, which is then overridden as required in various
language sub-classes.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_sniff_from_mangled_name): Delete function,
implementation moves to...
(ada_language::sniff_from_mangled_name): ...here.  Update return
type.
(ada_language_data): Delete la_sniff_from_mangled_name
initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(cplus_language::sniff_from_mangled_name): New member function,
implementation taken from gdb_sniff_from_mangled_name.
(asm_language_data): Delete la_sniff_from_mangled_name
initializer.
(minimal_language_data): Likewise.
* cp-support.c (gdb_sniff_from_mangled_name): Delete,
implementation moves to cplus_language::sniff_from_mangled_name.
* cp-support.h (gdb_sniff_from_mangled_name): Delete declaration.
* d-lang.c (d_sniff_from_mangled_name): Delete, implementation
moves to...
(d_language::sniff_from_mangled_name): ...here.
(d_language_data): Delete la_sniff_from_mangled_name initializer.
* f-lang.c (f_language_data): Likewise.
* go-lang.c (go_sniff_from_mangled_name): Delete, implementation
moves to...
(go_language::sniff_from_mangled_name): ...here.
(go_language_data): Delete la_sniff_from_mangled_name initializer.
* language.c (language_sniff_from_mangled_name): Delete.
(unknown_language_data): Delete la_sniff_from_mangled_name
initializer.
(auto_language_data): Likewise.
* language.h (language_data): Delete la_sniff_from_mangled_name
field.
(language_defn::sniff_from_mangled_name): New function.
(language_sniff_from_mangled_name): Delete declaration.
* m2-lang.c (m2_language_data): Delete la_sniff_from_mangled_name
field.
* objc-lang.c (objc_sniff_from_mangled_name): Delete,
implementation moves to...
(objc_language::sniff_from_mangled_name): ...here.
(objc_language_data): Delete la_sniff_from_mangled_name initializer.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_sniff_from_mangled_name): Delete,
implementation moves to...
(rust_language::sniff_from_mangled_name): ...here.
(rust_language_data): Delete la_sniff_from_mangled_name
initializer.
* symtab.c (symbol_find_demangled_name): Call
sniff_from_mangled_name member function.

16 files changed:
gdb/ChangeLog
gdb/ada-lang.c
gdb/c-lang.c
gdb/cp-support.c
gdb/cp-support.h
gdb/d-lang.c
gdb/f-lang.c
gdb/go-lang.c
gdb/language.c
gdb/language.h
gdb/m2-lang.c
gdb/objc-lang.c
gdb/opencl-lang.c
gdb/p-lang.c
gdb/rust-lang.c
gdb/symtab.c

index b8ce9033cb83ec6c4865d0c48ff92e79cb4225f1..46ca01139261eb5112de2ffe6f5d449c440d9ad5 100644 (file)
@@ -1,3 +1,54 @@
+2020-06-02  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * ada-lang.c (ada_sniff_from_mangled_name): Delete function,
+       implementation moves to...
+       (ada_language::sniff_from_mangled_name): ...here.  Update return
+       type.
+       (ada_language_data): Delete la_sniff_from_mangled_name
+       initializer.
+       * c-lang.c (c_language_data): Likewise.
+       (cplus_language_data): Likewise.
+       (cplus_language::sniff_from_mangled_name): New member function,
+       implementation taken from gdb_sniff_from_mangled_name.
+       (asm_language_data): Delete la_sniff_from_mangled_name
+       initializer.
+       (minimal_language_data): Likewise.
+       * cp-support.c (gdb_sniff_from_mangled_name): Delete,
+       implementation moves to cplus_language::sniff_from_mangled_name.
+       * cp-support.h (gdb_sniff_from_mangled_name): Delete declaration.
+       * d-lang.c (d_sniff_from_mangled_name): Delete, implementation
+       moves to...
+       (d_language::sniff_from_mangled_name): ...here.
+       (d_language_data): Delete la_sniff_from_mangled_name initializer.
+       * f-lang.c (f_language_data): Likewise.
+       * go-lang.c (go_sniff_from_mangled_name): Delete, implementation
+       moves to...
+       (go_language::sniff_from_mangled_name): ...here.
+       (go_language_data): Delete la_sniff_from_mangled_name initializer.
+       * language.c (language_sniff_from_mangled_name): Delete.
+       (unknown_language_data): Delete la_sniff_from_mangled_name
+       initializer.
+       (auto_language_data): Likewise.
+       * language.h (language_data): Delete la_sniff_from_mangled_name
+       field.
+       (language_defn::sniff_from_mangled_name): New function.
+       (language_sniff_from_mangled_name): Delete declaration.
+       * m2-lang.c (m2_language_data): Delete la_sniff_from_mangled_name
+       field.
+       * objc-lang.c (objc_sniff_from_mangled_name): Delete,
+       implementation moves to...
+       (objc_language::sniff_from_mangled_name): ...here.
+       (objc_language_data): Delete la_sniff_from_mangled_name initializer.
+       * opencl-lang.c (opencl_language_data): Likewise.
+       * p-lang.c (pascal_language_data): Likewise.
+       * rust-lang.c (rust_sniff_from_mangled_name): Delete,
+       implementation moves to...
+       (rust_language::sniff_from_mangled_name): ...here.
+       (rust_language_data): Delete la_sniff_from_mangled_name
+       initializer.
+       * symtab.c (symbol_find_demangled_name): Call
+       sniff_from_mangled_name member function.
+
 2020-06-02  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * ada-lang.c (ada_language_data): Delete la_search_name_hash
index 0232f6b9485f8ee0130f892893efc0f48932f6ee..6bfc0256b66700d514ccbb9d4f7f0df1ea8c7d00 100644 (file)
@@ -1377,45 +1377,6 @@ ada_la_decode (const char *encoded, int options)
   return xstrdup (ada_decode (encoded).c_str ());
 }
 
-/* Implement la_sniff_from_mangled_name for Ada.  */
-
-static int
-ada_sniff_from_mangled_name (const char *mangled, char **out)
-{
-  std::string demangled = ada_decode (mangled);
-
-  *out = NULL;
-
-  if (demangled != mangled && demangled[0] != '<')
-    {
-      /* Set the gsymbol language to Ada, but still return 0.
-        Two reasons for that:
-
-        1. For Ada, we prefer computing the symbol's decoded name
-        on the fly rather than pre-compute it, in order to save
-        memory (Ada projects are typically very large).
-
-        2. There are some areas in the definition of the GNAT
-        encoding where, with a bit of bad luck, we might be able
-        to decode a non-Ada symbol, generating an incorrect
-        demangled name (Eg: names ending with "TB" for instance
-        are identified as task bodies and so stripped from
-        the decoded name returned).
-
-        Returning 1, here, but not setting *DEMANGLED, helps us get a
-        little bit of the best of both worlds.  Because we're last,
-        we should not affect any of the other languages that were
-        able to demangle the symbol before us; we get to correctly
-        tag Ada symbols as such; and even if we incorrectly tagged a
-        non-Ada symbol, which should be rare, any routing through the
-        Ada language should be transparent (Ada tries to behave much
-        like C/C++ with non-Ada symbols).  */
-      return 1;
-    }
-
-  return 0;
-}
-
 \f
 
                                 /* Arrays */
@@ -13967,7 +13928,6 @@ extern const struct language_data ada_language_data =
   true,                         /* la_store_sym_names_in_linkage_form_p */
   ada_lookup_symbol_nonlocal,   /* Looking up non-local symbols.  */
   ada_la_decode,                /* Language specific symbol demangler */
-  ada_sniff_from_mangled_name,
   NULL,                         /* Language specific
                                   class_name_from_physname */
   ada_op_print_tab,             /* expression operators for printing */
@@ -14108,6 +14068,44 @@ public:
 
     return true;
   }
+
+  /* See language.h.  */
+  bool sniff_from_mangled_name (const char *mangled,
+                               char **out) const override
+  {
+    std::string demangled = ada_decode (mangled);
+
+    *out = NULL;
+
+    if (demangled != mangled && demangled[0] != '<')
+      {
+       /* Set the gsymbol language to Ada, but still return 0.
+          Two reasons for that:
+
+          1. For Ada, we prefer computing the symbol's decoded name
+          on the fly rather than pre-compute it, in order to save
+          memory (Ada projects are typically very large).
+
+          2. There are some areas in the definition of the GNAT
+          encoding where, with a bit of bad luck, we might be able
+          to decode a non-Ada symbol, generating an incorrect
+          demangled name (Eg: names ending with "TB" for instance
+          are identified as task bodies and so stripped from
+          the decoded name returned).
+
+          Returning true, here, but not setting *DEMANGLED, helps us get
+          a little bit of the best of both worlds.  Because we're last,
+          we should not affect any of the other languages that were
+          able to demangle the symbol before us; we get to correctly
+          tag Ada symbols as such; and even if we incorrectly tagged a
+          non-Ada symbol, which should be rare, any routing through the
+          Ada language should be transparent (Ada tries to behave much
+          like C/C++ with non-Ada symbols).  */
+       return true;
+      }
+
+    return false;
+  }
 };
 
 /* Single instance of the Ada language class.  */
index 8452760339c7bc3ac0e8993922f6d95b8e692181..a5f7d822866cc9ef4e89ae01923450845adbc81c 100644 (file)
@@ -914,7 +914,6 @@ extern const struct language_data c_language_data =
   true,                                /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
   NULL,                                /* Language specific symbol demangler */
-  NULL,
   NULL,                                /* Language specific
                                   class_name_from_physname */
   c_op_print_tab,              /* expression operators for printing */
@@ -1017,7 +1016,6 @@ extern const struct language_data cplus_language_data =
   false,                       /* la_store_sym_names_in_linkage_form_p */
   cp_lookup_symbol_nonlocal,   /* lookup_symbol_nonlocal */
   gdb_demangle,                        /* Language specific symbol demangler */
-  gdb_sniff_from_mangled_name,
   cp_class_name_from_physname,  /* Language specific
                                   class_name_from_physname */
   c_op_print_tab,              /* expression operators for printing */
@@ -1130,6 +1128,14 @@ public:
   {
     return cp_search_name_hash (name);
   }
+
+  /* See language.h.  */
+  bool sniff_from_mangled_name (const char *mangled,
+                               char **demangled) const override
+  {
+    *demangled = gdb_demangle (mangled, DMGL_PARAMS | DMGL_ANSI);
+    return *demangled != NULL;
+  }
 };
 
 /* The single instance of the C++ language class.  */
@@ -1168,7 +1174,6 @@ extern const struct language_data asm_language_data =
   true,                                /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
   NULL,                                /* Language specific symbol demangler */
-  NULL,
   NULL,                                /* Language specific
                                   class_name_from_physname */
   c_op_print_tab,              /* expression operators for printing */
@@ -1236,7 +1241,6 @@ extern const struct language_data minimal_language_data =
   true,                                /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
   NULL,                                /* Language specific symbol demangler */
-  NULL,
   NULL,                                /* Language specific
                                   class_name_from_physname */
   c_op_print_tab,              /* expression operators for printing */
index 11e54c272c57a2d55265d3213ef9dce54be3216f..3c3ede26a6067a2495742efa39a9900e0b68b0b3 100644 (file)
@@ -1676,15 +1676,6 @@ gdb_demangle (const char *name, int options)
 
 /* See cp-support.h.  */
 
-int
-gdb_sniff_from_mangled_name (const char *mangled, char **demangled)
-{
-  *demangled = gdb_demangle (mangled, DMGL_PARAMS | DMGL_ANSI);
-  return *demangled != NULL;
-}
-
-/* See cp-support.h.  */
-
 unsigned int
 cp_search_name_hash (const char *search_name)
 {
index 6ca898315bb1a8d4f9632e73680eab260167c622..7c948b212cbaeeb5453f2b64a5ee7b3cb6ca41c5 100644 (file)
@@ -191,8 +191,4 @@ extern struct cmd_list_element *maint_cplus_cmd_list;
 
 char *gdb_demangle (const char *name, int options);
 
-/* Like gdb_demangle, but suitable for use as la_sniff_from_mangled_name.  */
-
-int gdb_sniff_from_mangled_name (const char *mangled, char **demangled);
-
 #endif /* CP_SUPPORT_H */
index c6ee6a231e6ab37bd74cbe03d478a8d5981e1f51..23b9464cb58998bb96d6d1b629cb8ab49af6a526 100644 (file)
@@ -56,15 +56,6 @@ d_demangle (const char *symbol, int options)
   return gdb_demangle (symbol, options | DMGL_DLANG);
 }
 
-/* la_sniff_from_mangled_name implementation for D.  */
-
-static int
-d_sniff_from_mangled_name (const char *mangled, char **demangled)
-{
-  *demangled = d_demangle (mangled, 0);
-  return *demangled != NULL;
-}
-
 /* Table mapping opcodes into strings for printing operators
    and precedences of the operators.  */
 static const struct op_print d_op_print_tab[] =
@@ -166,7 +157,6 @@ extern const struct language_data d_language_data =
   false,                       /* la_store_sym_names_in_linkage_form_p */
   d_lookup_symbol_nonlocal,
   d_demangle,                  /* Language specific symbol demangler.  */
-  d_sniff_from_mangled_name,
   NULL,                                /* Language specific
                                   class_name_from_physname.  */
   d_op_print_tab,              /* Expression operators for printing.  */
@@ -254,6 +244,14 @@ public:
     lai->bool_type_symbol = "bool";
     lai->bool_type_default = builtin->builtin_bool;
   }
+
+  /* See language.h.  */
+  bool sniff_from_mangled_name (const char *mangled,
+                               char **demangled) const override
+  {
+    *demangled = d_demangle (mangled, 0);
+    return *demangled != NULL;
+  }
 };
 
 /* Single instance of the D language class.  */
index a2df46a8b4a8c516dd7a921ee6ec6b89a3cf11f5..804b2823f31e907cd163461bb0e61ebdcd75dbd9 100644 (file)
@@ -623,7 +623,6 @@ extern const struct language_data f_language_data =
      and there is no DW_AT_producer available for inferiors with only
      the ELF symbols to check the mangling kind.  */
   NULL,                                /* Language specific symbol demangler */
-  NULL,
   NULL,                                /* Language specific
                                   class_name_from_physname */
   f_op_print_tab,              /* expression operators for printing */
index 8491c97f5e9e6daf545052dcdb519078199daa34..dce7e6ab76968f6b13cf2447470868ee85790f85 100644 (file)
@@ -396,15 +396,6 @@ go_demangle (const char *mangled_name, int options)
   return result;
 }
 
-/* la_sniff_from_mangled_name for Go.  */
-
-static int
-go_sniff_from_mangled_name (const char *mangled, char **demangled)
-{
-  *demangled = go_demangle (mangled, 0);
-  return *demangled != NULL;
-}
-
 /* Given a Go symbol, return its package or NULL if unknown.
    Space for the result is malloc'd, caller must free.  */
 
@@ -551,7 +542,6 @@ extern const struct language_data go_language_data =
   false,                       /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal, 
   go_demangle,                 /* Language specific symbol demangler.  */
-  go_sniff_from_mangled_name,
   NULL,                                /* Language specific
                                   class_name_from_physname.  */
   go_op_print_tab,             /* Expression operators for printing.  */
@@ -628,6 +618,14 @@ public:
     lai->bool_type_symbol = "bool";
     lai->bool_type_default = builtin->builtin_bool;
   }
+
+  /* See language.h.  */
+  bool sniff_from_mangled_name (const char *mangled,
+                               char **demangled) const override
+  {
+    *demangled = go_demangle (mangled, 0);
+    return *demangled != NULL;
+  }
 };
 
 /* Single instance of the Go language class.  */
index 7a871348d43d8fbd6f47131731a4df8bffe40388..2a66f1fd6eaf8ff9c1aa4cde9a1616e2f6f46061 100644 (file)
@@ -594,23 +594,6 @@ language_demangle (const struct language_defn *current_language,
   return NULL;
 }
 
-/* See language.h.  */
-
-int
-language_sniff_from_mangled_name (const struct language_defn *lang,
-                                 const char *mangled, char **demangled)
-{
-  gdb_assert (lang != NULL);
-
-  if (lang->la_sniff_from_mangled_name == NULL)
-    {
-      *demangled = NULL;
-      return 0;
-    }
-
-  return lang->la_sniff_from_mangled_name (mangled, demangled);
-}
-
 /* Return class name from physname or NULL.  */
 char *
 language_class_name_from_physname (const struct language_defn *lang,
@@ -828,7 +811,6 @@ extern const struct language_data unknown_language_data =
   true,                                /* store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
   unk_lang_demangle,           /* Language specific symbol demangler */
-  NULL,
   unk_lang_class_name,         /* Language specific
                                   class_name_from_physname */
   unk_op_print_tab,            /* expression operators for printing */
@@ -892,7 +874,6 @@ extern const struct language_data auto_language_data =
   false,                       /* store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
   unk_lang_demangle,           /* Language specific symbol demangler */
-  NULL,
   unk_lang_class_name,         /* Language specific
                                   class_name_from_physname */
   unk_op_print_tab,            /* expression operators for printing */
index 5233c0f10c58133a2c5e34dfc851ebd873cd9490..d5013bf83244bc8d443384b680092fb4aca74f6c 100644 (file)
@@ -318,22 +318,6 @@ struct language_data
     /* Return demangled language symbol, or NULL.  */
     char *(*la_demangle) (const char *mangled, int options);
 
-    /* Demangle a symbol according to this language's rules.  Unlike
-       la_demangle, this does not take any options.
-
-       *DEMANGLED will be set by this function.
-       
-       If this function returns 0, then *DEMANGLED must always be set
-       to NULL.
-
-       If this function returns 1, the implementation may set this to
-       a xmalloc'd string holding the demangled form.  However, it is
-       not required to.  The string, if any, is owned by the caller.
-
-       The resulting string should be of the form that will be
-       installed into a symbol.  */
-    int (*la_sniff_from_mangled_name) (const char *mangled, char **demangled);
-
     /* Return class name of a mangled method name or NULL.  */
     char *(*la_class_name_from_physname) (const char *physname);
 
@@ -512,6 +496,27 @@ struct language_defn : language_data
   /* Hash the given symbol search name.  */
   virtual unsigned int search_name_hash (const char *name) const;
 
+  /* Demangle a symbol according to this language's rules.  Unlike
+     la_demangle, this does not take any options.
+
+     *DEMANGLED will be set by this function.
+
+     If this function returns false, then *DEMANGLED must always be set
+     to NULL.
+
+     If this function returns true, the implementation may set this to
+     a xmalloc'd string holding the demangled form.  However, it is
+     not required to.  The string, if any, is owned by the caller.
+
+     The resulting string should be of the form that will be
+     installed into a symbol.  */
+  virtual bool sniff_from_mangled_name (const char *mangled,
+                                       char **demangled) const
+  {
+    *demangled = nullptr;
+    return false;
+  }
+
   /* List of all known languages.  */
   static const struct language_defn *languages[nr_languages];
 };
@@ -666,13 +671,6 @@ extern CORE_ADDR skip_language_trampoline (struct frame_info *, CORE_ADDR pc);
 extern char *language_demangle (const struct language_defn *current_language, 
                                const char *mangled, int options);
 
-/* A wrapper for la_sniff_from_mangled_name.  The arguments and result
-   are as for the method.  */
-
-extern int language_sniff_from_mangled_name (const struct language_defn *lang,
-                                            const char *mangled,
-                                            char **demangled);
-
 /* Return class name from physname, or NULL.  */
 extern char *language_class_name_from_physname (const struct language_defn *,
                                                const char *physname);
index 2166470467c8724e129c4c6db3e53c950b73fc92..fbfdcff71f38bb80706bd0793a6d6f63b5d10d10 100644 (file)
@@ -376,7 +376,6 @@ extern const struct language_data m2_language_data =
   false,                       /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
   NULL,                                /* Language specific symbol demangler */
-  NULL,
   NULL,                                /* Language specific
                                   class_name_from_physname */
   m2_op_print_tab,             /* expression operators for printing */
index afbb1fbed73b60508c39d3e2ea389f6cd297ae97..3082a5d058a0c6b3f1e2f313fd0de49ff55e93e5 100644 (file)
@@ -281,15 +281,6 @@ objc_demangle (const char *mangled, int options)
     return NULL;       /* Not an objc mangled name.  */
 }
 
-/* la_sniff_from_mangled_name for ObjC.  */
-
-static int
-objc_sniff_from_mangled_name (const char *mangled, char **demangled)
-{
-  *demangled = objc_demangle (mangled, 0);
-  return *demangled != NULL;
-}
-
 /* Determine if we are currently in the Objective-C dispatch function.
    If so, get the address of the method function that the dispatcher
    would call and use that as the function to step into instead.  Also
@@ -391,7 +382,6 @@ extern const struct language_data objc_language_data =
   false,                       /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
   objc_demangle,               /* Language specific symbol demangler */
-  objc_sniff_from_mangled_name,
   NULL,                                /* Language specific
                                   class_name_from_physname */
   objc_op_print_tab,           /* Expression operators for printing */
@@ -422,6 +412,14 @@ public:
   {
     c_language_arch_info (gdbarch, lai);
   }
+
+  /* See language.h.  */
+  bool sniff_from_mangled_name (const char *mangled,
+                               char **demangled) const override
+  {
+    *demangled = objc_demangle (mangled, 0);
+    return *demangled != NULL;
+  }
 };
 
 /* Single instance of the class representing the Objective-C language.  */
index a3a51a5809556b6428239fb5adaac9195f150c55..4080c51854f722f957a3885afbd98a655c983dfd 100644 (file)
@@ -1051,7 +1051,6 @@ extern const struct language_data opencl_language_data =
   false,                       /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
   NULL,                                /* Language specific symbol demangler */
-  NULL,
   NULL,                                /* Language specific
                                   class_name_from_physname */
   c_op_print_tab,              /* expression operators for printing */
index 5d8c8167da284ed91884fc9f8c31ecc6c6aeba50..8d96dd15832608433febd68afba4b1e96e6db04d 100644 (file)
@@ -407,7 +407,6 @@ extern const struct language_data pascal_language_data =
   false,                       /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
   NULL,                                /* Language specific symbol demangler */
-  NULL,
   NULL,                                /* Language specific class_name_from_physname */
   pascal_op_print_tab,         /* expression operators for printing */
   1,                           /* c-style arrays */
index 26e2ad5ce25265d5b02114d9ee50ebe12199f2e1..d75f34d0d9a4c39019540086046be4bbe7507703 100644 (file)
@@ -2016,17 +2016,6 @@ rust_lookup_symbol_nonlocal (const struct language_defn *langdef,
 
 \f
 
-/* la_sniff_from_mangled_name for Rust.  */
-
-static int
-rust_sniff_from_mangled_name (const char *mangled, char **demangled)
-{
-  *demangled = gdb_demangle (mangled, DMGL_PARAMS | DMGL_ANSI);
-  return *demangled != NULL;
-}
-
-\f
-
 /* la_watch_location_expression for Rust.  */
 
 static gdb::unique_xmalloc_ptr<char>
@@ -2083,7 +2072,6 @@ extern const struct language_data rust_language_data =
   false,                       /* la_store_sym_names_in_linkage_form_p */
   rust_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
   gdb_demangle,                        /* Language specific symbol demangler */
-  rust_sniff_from_mangled_name,
   NULL,                                /* Language specific
                                   class_name_from_physname */
   c_op_print_tab,              /* expression operators for printing */
@@ -2148,6 +2136,14 @@ public:
     lai->bool_type_default = types[rust_primitive_bool];
     lai->string_char_type = types[rust_primitive_u8];
   }
+
+  /* See language.h.  */
+  bool sniff_from_mangled_name (const char *mangled,
+                               char **demangled) const override
+  {
+    *demangled = gdb_demangle (mangled, DMGL_PARAMS | DMGL_ANSI);
+    return *demangled != NULL;
+  }
 };
 
 /* Single instance of the Rust language class.  */
index aa3d84a62d5f7ce2b12de4245b5c779192dbaae4..791ce11a7372c11583eec384b5d44bf13d4366ea 100644 (file)
@@ -807,7 +807,7 @@ symbol_find_demangled_name (struct general_symbol_info *gsymbol,
     {
       const struct language_defn *lang = language_def (gsymbol->language ());
 
-      language_sniff_from_mangled_name (lang, mangled, &demangled);
+      lang->sniff_from_mangled_name (mangled, &demangled);
       return demangled;
     }
 
@@ -816,7 +816,7 @@ symbol_find_demangled_name (struct general_symbol_info *gsymbol,
       enum language l = (enum language) i;
       const struct language_defn *lang = language_def (l);
 
-      if (language_sniff_from_mangled_name (lang, mangled, &demangled))
+      if (lang->sniff_from_mangled_name (mangled, &demangled))
        {
          gsymbol->m_language = l;
          return demangled;