gdb: Convert language la_demangle field to a method

This commit changes the language_data::la_demangle function pointer
member variable into a member function of language_defn.

The only slightly "weird" change in this commit is in f-lang.c, where
I have given the Fortran language a demangle method that is identical
to the default language_defn::demangle.  The only reason for this is
to give me somewhere to copy the comment that was previously embedded
within the f_language_data structure.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* ada-lang.c (ada_language_data): Delete la_demangle initializer.
	(ada_language::demangle): New member function.
	* c-lang.c (c_language_data): Delete la_demangle initializer.
	(cplus_language_data): Delete la_demangle initializer.
	(cplus_language::demangle): New member function.
	(asm_language_data): Delete la_demangle initializer.
	(minimal_language_data): Delete la_demangle initializer.
	* d-lang.c (d_language_data): Delete la_demangle initializer.
	(d_language::demangle): New member function.
	* f-lang.c (f_language_data): Delete la_demangle initializer.
	(f_language::demangle): New member function.
	* go-lang.c (go_language_data): Delete la_demangle initializer.
	(go_language::demangle): New member function.
	* language.c (language_demangle): Update.
	(unk_lang_demangle): Delete.
	(unknown_language_data): Delete la_demangle initializer.
	(unknown_language::demangle): New member function.
	(auto_language_data): Delete la_demangle initializer.
	(auto_language::demangle): New member function.
	* language.h (language_data): Delete la_demangle field.
	(language_defn::demangle): New function.
	* m2-lang.c (m2_language_data): Delete la_demangle initializer.
	* objc-lang.c (objc_language_data): Delete la_demangle
	initializer.
	(objc_language::demangle): New member function.
	* opencl-lang.c (opencl_language_data): Delete la_demangle
	initializer.
	* p-lang.c (pascal_language_data): Likewise.
	* rust-lang.c (rust_language_data): Likewise.
	(rust_language::demangle): New member functi
This commit is contained in:
Andrew Burgess 2020-05-14 19:03:45 +01:00
parent fbfb0a463f
commit 0a50df5dab
13 changed files with 111 additions and 32 deletions

View File

@ -1,3 +1,36 @@
2020-06-02 Andrew Burgess <andrew.burgess@embecosm.com>
* ada-lang.c (ada_language_data): Delete la_demangle initializer.
(ada_language::demangle): New member function.
* c-lang.c (c_language_data): Delete la_demangle initializer.
(cplus_language_data): Delete la_demangle initializer.
(cplus_language::demangle): New member function.
(asm_language_data): Delete la_demangle initializer.
(minimal_language_data): Delete la_demangle initializer.
* d-lang.c (d_language_data): Delete la_demangle initializer.
(d_language::demangle): New member function.
* f-lang.c (f_language_data): Delete la_demangle initializer.
(f_language::demangle): New member function.
* go-lang.c (go_language_data): Delete la_demangle initializer.
(go_language::demangle): New member function.
* language.c (language_demangle): Update.
(unk_lang_demangle): Delete.
(unknown_language_data): Delete la_demangle initializer.
(unknown_language::demangle): New member function.
(auto_language_data): Delete la_demangle initializer.
(auto_language::demangle): New member function.
* language.h (language_data): Delete la_demangle field.
(language_defn::demangle): New function.
* m2-lang.c (m2_language_data): Delete la_demangle initializer.
* objc-lang.c (objc_language_data): Delete la_demangle
initializer.
(objc_language::demangle): New member function.
* opencl-lang.c (opencl_language_data): Delete la_demangle
initializer.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.
(rust_language::demangle): New member function.
2020-06-02 Andrew Burgess <andrew.burgess@embecosm.com>
* ada-lang.c (ada_language_data): Delete la_print_type

View File

@ -13926,7 +13926,6 @@ extern const struct language_data ada_language_data =
NULL, /* name_of_this */
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 */
NULL, /* Language specific
class_name_from_physname */
ada_op_print_tab, /* expression operators for printing */
@ -14108,6 +14107,13 @@ class ada_language : public language_defn
/* See language.h. */
char *demangle (const char *mangled, int options) const override
{
return ada_la_decode (mangled, options);
}
/* See language.h. */
void print_type (struct type *type, const char *varstring,
struct ui_file *stream, int show, int level,
const struct type_print_options *flags) const override

View File

@ -912,7 +912,6 @@ extern const struct language_data c_language_data =
NULL, /* name_of_this */
true, /* la_store_sym_names_in_linkage_form_p */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
NULL, /* Language specific symbol demangler */
NULL, /* Language specific
class_name_from_physname */
c_op_print_tab, /* expression operators for printing */
@ -1022,7 +1021,6 @@ extern const struct language_data cplus_language_data =
"this", /* name_of_this */
false, /* la_store_sym_names_in_linkage_form_p */
cp_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
gdb_demangle, /* Language specific symbol demangler */
cp_class_name_from_physname, /* Language specific
class_name_from_physname */
c_op_print_tab, /* expression operators for printing */
@ -1146,6 +1144,13 @@ class cplus_language : public language_defn
/* See language.h. */
char *demangle (const char *mangled, int options) const override
{
return gdb_demangle (mangled, options);
}
/* See language.h. */
void print_type (struct type *type, const char *varstring,
struct ui_file *stream, int show, int level,
const struct type_print_options *flags) const override
@ -1188,7 +1193,6 @@ extern const struct language_data asm_language_data =
NULL, /* name_of_this */
true, /* la_store_sym_names_in_linkage_form_p */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
NULL, /* Language specific symbol demangler */
NULL, /* Language specific
class_name_from_physname */
c_op_print_tab, /* expression operators for printing */
@ -1263,7 +1267,6 @@ extern const struct language_data minimal_language_data =
NULL, /* name_of_this */
true, /* la_store_sym_names_in_linkage_form_p */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
NULL, /* Language specific symbol demangler */
NULL, /* Language specific
class_name_from_physname */
c_op_print_tab, /* expression operators for printing */

View File

@ -155,7 +155,6 @@ extern const struct language_data d_language_data =
"this",
false, /* la_store_sym_names_in_linkage_form_p */
d_lookup_symbol_nonlocal,
d_demangle, /* Language specific symbol demangler. */
NULL, /* Language specific
class_name_from_physname. */
d_op_print_tab, /* Expression operators for printing. */
@ -254,6 +253,13 @@ class d_language : public language_defn
/* See language.h. */
char *demangle (const char *mangled, int options) const override
{
return d_demangle (mangled, options);
}
/* See language.h. */
void print_type (struct type *type, const char *varstring,
struct ui_file *stream, int show, int level,
const struct type_print_options *flags) const override

View File

@ -615,13 +615,6 @@ extern const struct language_data f_language_data =
NULL, /* name_of_this */
false, /* la_store_sym_names_in_linkage_form_p */
cp_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
/* We could support demangling here to provide module namespaces
also for inferiors with only minimal symbol table (ELF symbols).
Just the mangling standard is not standardized across compilers
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, /* Language specific
class_name_from_physname */
f_op_print_tab, /* expression operators for printing */
@ -692,6 +685,18 @@ class f_language : public language_defn
/* See language.h. */
char *demangle (const char *mangled, int options) const override
{
/* We could support demangling here to provide module namespaces
also for inferiors with only minimal symbol table (ELF symbols).
Just the mangling standard is not standardized across compilers
and there is no DW_AT_producer available for inferiors with only
the ELF symbols to check the mangling kind. */
return nullptr;
}
/* See language.h. */
void print_type (struct type *type, const char *varstring,
struct ui_file *stream, int show, int level,
const struct type_print_options *flags) const override

View File

@ -540,7 +540,6 @@ extern const struct language_data go_language_data =
NULL, /* name_of_this */
false, /* la_store_sym_names_in_linkage_form_p */
basic_lookup_symbol_nonlocal,
go_demangle, /* Language specific symbol demangler. */
NULL, /* Language specific
class_name_from_physname. */
go_op_print_tab, /* Expression operators for printing. */
@ -628,6 +627,13 @@ class go_language : public language_defn
/* See language.h. */
char *demangle (const char *mangled, int options) const override
{
return go_demangle (mangled, options);
}
/* See language.h. */
void print_type (struct type *type, const char *varstring,
struct ui_file *stream, int show, int level,
const struct type_print_options *flags) const override

View File

@ -589,8 +589,8 @@ char *
language_demangle (const struct language_defn *current_language,
const char *mangled, int options)
{
if (current_language != NULL && current_language->la_demangle)
return current_language->la_demangle (mangled, options);
if (current_language != NULL)
return current_language->demangle (mangled, options);
return NULL;
}
@ -749,12 +749,6 @@ static CORE_ADDR unk_lang_trampoline (struct frame_info *frame, CORE_ADDR pc)
return 0;
}
/* Unknown languages just use the cplus demangler. */
static char *unk_lang_demangle (const char *mangled, int options)
{
return gdb_demangle (mangled, options);
}
static char *unk_lang_class_name (const char *mangled)
{
return NULL;
@ -800,7 +794,6 @@ extern const struct language_data unknown_language_data =
"this", /* name_of_this */
true, /* store_sym_names_in_linkage_form_p */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
unk_lang_demangle, /* Language specific symbol demangler */
unk_lang_class_name, /* Language specific
class_name_from_physname */
unk_op_print_tab, /* expression operators for printing */
@ -840,6 +833,14 @@ class unknown_language : public language_defn
{
error (_("unimplemented unknown_language::print_type called"));
}
/* See language.h. */
char *demangle (const char *mangled, int options) const override
{
/* The unknown language just uses the C++ demangler. */
return gdb_demangle (mangled, options);
}
};
/* Single instance of the unknown language class. */
@ -871,7 +872,6 @@ extern const struct language_data auto_language_data =
"this", /* name_of_this */
false, /* store_sym_names_in_linkage_form_p */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
unk_lang_demangle, /* Language specific symbol demangler */
unk_lang_class_name, /* Language specific
class_name_from_physname */
unk_op_print_tab, /* expression operators for printing */
@ -911,6 +911,14 @@ class auto_language : public language_defn
{
error (_("unimplemented auto_language::print_type called"));
}
/* See language.h. */
char *demangle (const char *mangled, int options) const override
{
/* The auto language just uses the C++ demangler. */
return gdb_demangle (mangled, options);
}
};
/* Single instance of the fake "auto" language. */

View File

@ -310,9 +310,6 @@ struct language_data
const struct block *,
const domain_enum);
/* Return demangled language symbol, or NULL. */
char *(*la_demangle) (const char *mangled, int options);
/* Return class name of a mangled method name or NULL. */
char *(*la_class_name_from_physname) (const char *physname);
@ -512,6 +509,12 @@ struct language_defn : language_data
return false;
}
/* Return demangled language symbol version of MANGLED, or NULL. */
virtual char *demangle (const char *mangled, int options) const
{
return nullptr;
}
/* Print a type using syntax appropriate for this language. */
virtual void print_type (struct type *, const char *, struct ui_file *, int,

View File

@ -374,7 +374,6 @@ extern const struct language_data m2_language_data =
NULL, /* name_of_this */
false, /* la_store_sym_names_in_linkage_form_p */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
NULL, /* Language specific symbol demangler */
NULL, /* Language specific
class_name_from_physname */
m2_op_print_tab, /* expression operators for printing */

View File

@ -380,7 +380,6 @@ extern const struct language_data objc_language_data =
"self", /* name_of_this */
false, /* la_store_sym_names_in_linkage_form_p */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
objc_demangle, /* Language specific symbol demangler */
NULL, /* Language specific
class_name_from_physname */
objc_op_print_tab, /* Expression operators for printing */
@ -422,6 +421,13 @@ class objc_language : public language_defn
/* See language.h. */
char *demangle (const char *mangled, int options) const override
{
return objc_demangle (mangled, options);
}
/* See language.h. */
void print_type (struct type *type, const char *varstring,
struct ui_file *stream, int show, int level,
const struct type_print_options *flags) const override

View File

@ -1028,7 +1028,6 @@ extern const struct language_data opencl_language_data =
NULL, /* name_of_this */
false, /* la_store_sym_names_in_linkage_form_p */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
NULL, /* Language specific symbol demangler */
NULL, /* Language specific
class_name_from_physname */
c_op_print_tab, /* expression operators for printing */

View File

@ -405,7 +405,6 @@ extern const struct language_data pascal_language_data =
"this", /* name_of_this */
false, /* la_store_sym_names_in_linkage_form_p */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
NULL, /* Language specific symbol demangler */
NULL, /* Language specific class_name_from_physname */
pascal_op_print_tab, /* expression operators for printing */
1, /* c-style arrays */

View File

@ -2060,7 +2060,6 @@ extern const struct language_data rust_language_data =
NULL, /* name_of_this */
false, /* la_store_sym_names_in_linkage_form_p */
rust_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
gdb_demangle, /* Language specific symbol demangler */
NULL, /* Language specific
class_name_from_physname */
c_op_print_tab, /* expression operators for printing */
@ -2136,6 +2135,13 @@ class rust_language : public language_defn
/* See language.h. */
char *demangle (const char *mangled, int options) const override
{
return gdb_demangle (mangled, options);
}
/* See language.h. */
void print_type (struct type *type, const char *varstring,
struct ui_file *stream, int show, int level,
const struct type_print_options *flags) const override