From eff93b4d48eb0e79b7879475bb47eec55dbb41be Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Mon, 1 Jun 2020 10:53:05 +0100 Subject: [PATCH] gdb: Convert language la_class_name_from_physname field to a method This commit changes the language_data::la_class_name_from_physname function pointer member variable into a member function of language_defn. There should be no user visible changes after this commit. gdb/ChangeLog: * ada-lang.c (ada_language_data) Delete la_class_name_from_physname initializer. * c-lang.c (c_language_data): Likewise. (cplus_language_data): Likewise. (cplus_language::class_name_from_physname): New member function. (asm_language_data): Delete la_class_name_from_physname initializer. (minimal_language_data): Likewise. * d-lang.c (d_language_data): Likewise. * dwarf2/read.c (guess_partial_die_structure_name): Update to call method on language_defn class. (guess_full_die_structure_name): Likewise. * f-lang.c (f_language_data): Delete la_class_name_from_physname initializer. * go-lang.c (go_language_data): Likewise. * language.c (language_class_name_from_physname): Delete. (unk_lang_class_name): Delete. (unknown_language_data): Delete la_class_name_from_physname initializer. (auto_language_data): Likewise. * language.h (language_data): Delete la_class_name_from_physname field. (language_defn::class_name_from_physname): New function. (language_class_name_from_physname): Delete declaration. * m2-lang.c (m2_language_data): Delete la_class_name_from_physname initializer. * objc-lang.c (objc_language_data): Likewise. * opencl-lang.c (opencl_language_data): Likewise. * p-lang.c (pascal_language_data): Likewise. * rust-lang.c (rust_language_data): Likewise. --- gdb/ChangeLog | 33 +++++++++++++++++++++++++++++++++ gdb/ada-lang.c | 2 -- gdb/c-lang.c | 15 +++++++-------- gdb/d-lang.c | 2 -- gdb/dwarf2/read.c | 7 +++---- gdb/f-lang.c | 2 -- gdb/go-lang.c | 2 -- gdb/language.c | 19 ------------------- gdb/language.h | 13 ++++++------- gdb/m2-lang.c | 2 -- gdb/objc-lang.c | 2 -- gdb/opencl-lang.c | 2 -- gdb/p-lang.c | 1 - gdb/rust-lang.c | 2 -- 14 files changed, 49 insertions(+), 55 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f9d989d2444..2aafc0ad8d9 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,36 @@ +2020-06-17 Andrew Burgess + + * ada-lang.c (ada_language_data) Delete + la_class_name_from_physname initializer. + * c-lang.c (c_language_data): Likewise. + (cplus_language_data): Likewise. + (cplus_language::class_name_from_physname): New member function. + (asm_language_data): Delete la_class_name_from_physname + initializer. + (minimal_language_data): Likewise. + * d-lang.c (d_language_data): Likewise. + * dwarf2/read.c (guess_partial_die_structure_name): Update to call + method on language_defn class. + (guess_full_die_structure_name): Likewise. + * f-lang.c (f_language_data): Delete la_class_name_from_physname + initializer. + * go-lang.c (go_language_data): Likewise. + * language.c (language_class_name_from_physname): Delete. + (unk_lang_class_name): Delete. + (unknown_language_data): Delete la_class_name_from_physname + initializer. + (auto_language_data): Likewise. + * language.h (language_data): Delete la_class_name_from_physname + field. + (language_defn::class_name_from_physname): New function. + (language_class_name_from_physname): Delete declaration. + * m2-lang.c (m2_language_data): Delete la_class_name_from_physname + initializer. + * objc-lang.c (objc_language_data): Likewise. + * opencl-lang.c (opencl_language_data): Likewise. + * p-lang.c (pascal_language_data): Likewise. + * rust-lang.c (rust_language_data): Likewise. + 2020-06-16 Tom Tromey * tui/tui-data.h (STATUS_NAME): New macro. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index c5e28c5b669..96cb8653d59 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -13914,8 +13914,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. */ - NULL, /* Language specific - class_name_from_physname */ ada_op_print_tab, /* expression operators for printing */ 0, /* c-style arrays */ 1, /* String lower bound */ diff --git a/gdb/c-lang.c b/gdb/c-lang.c index 53137e89b85..bb4970628d1 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -911,8 +911,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 - class_name_from_physname */ c_op_print_tab, /* expression operators for printing */ 1, /* c-style arrays */ 0, /* String lower bound */ @@ -1019,8 +1017,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 */ - cp_class_name_from_physname, /* Language specific - class_name_from_physname */ c_op_print_tab, /* expression operators for printing */ 1, /* c-style arrays */ 0, /* String lower bound */ @@ -1163,6 +1159,13 @@ public: { return cplus_skip_trampoline (fi, pc); } + + /* See language.h. */ + + char *class_name_from_physname (const char *physname) const override + { + return cp_class_name_from_physname (physname); + } }; /* The single instance of the C++ language class. */ @@ -1198,8 +1201,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 - class_name_from_physname */ c_op_print_tab, /* expression operators for printing */ 1, /* c-style arrays */ 0, /* String lower bound */ @@ -1271,8 +1272,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 - class_name_from_physname */ c_op_print_tab, /* expression operators for printing */ 1, /* c-style arrays */ 0, /* String lower bound */ diff --git a/gdb/d-lang.c b/gdb/d-lang.c index 81e3aac87ba..6dacf8ca4a4 100644 --- a/gdb/d-lang.c +++ b/gdb/d-lang.c @@ -154,8 +154,6 @@ extern const struct language_data d_language_data = "this", false, /* la_store_sym_names_in_linkage_form_p */ d_lookup_symbol_nonlocal, - NULL, /* Language specific - class_name_from_physname. */ d_op_print_tab, /* Expression operators for printing. */ 1, /* C-style arrays. */ 0, /* String lower bound. */ diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index e3073fe43ce..d15eba9462c 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -18874,8 +18874,8 @@ guess_partial_die_structure_name (struct partial_die_info *struct_pdi, && child_pdi->linkage_name != NULL) { gdb::unique_xmalloc_ptr actual_class_name - (language_class_name_from_physname (cu->language_defn, - child_pdi->linkage_name)); + (cu->language_defn->class_name_from_physname + (child_pdi->linkage_name)); if (actual_class_name != NULL) { struct objfile *objfile = cu->per_objfile->objfile; @@ -21715,8 +21715,7 @@ guess_full_die_structure_name (struct die_info *die, struct dwarf2_cu *cu) if (linkage_name != NULL) { gdb::unique_xmalloc_ptr actual_name - (language_class_name_from_physname (cu->language_defn, - linkage_name)); + (cu->language_defn->class_name_from_physname (linkage_name)); const char *name = NULL; if (actual_name != NULL) diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 90a794ef4ba..07ee2c8e6c6 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -614,8 +614,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 */ - NULL, /* Language specific - class_name_from_physname */ f_op_print_tab, /* expression operators for printing */ 0, /* arrays are first-class (not c-style) */ 1, /* String lower bound */ diff --git a/gdb/go-lang.c b/gdb/go-lang.c index 6a60e1864d9..7b8d4a5e6ee 100644 --- a/gdb/go-lang.c +++ b/gdb/go-lang.c @@ -539,8 +539,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, - NULL, /* Language specific - class_name_from_physname. */ go_op_print_tab, /* Expression operators for printing. */ 1, /* C-style arrays. */ 0, /* String lower bound. */ diff --git a/gdb/language.c b/gdb/language.c index ba4d96cf89b..ade5109c9dc 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -589,16 +589,6 @@ language_demangle (const struct language_defn *current_language, return NULL; } -/* Return class name from physname or NULL. */ -char * -language_class_name_from_physname (const struct language_defn *lang, - const char *physname) -{ - if (lang != NULL && lang->la_class_name_from_physname) - return lang->la_class_name_from_physname (physname); - return NULL; -} - /* Return information about whether TYPE should be passed (and returned) by reference at the language level. */ @@ -739,11 +729,6 @@ unk_lang_value_print (struct value *val, struct ui_file *stream, "function unk_lang_value_print called.")); } -static char *unk_lang_class_name (const char *mangled) -{ - return NULL; -} - static const struct op_print unk_op_print_tab[] = { {NULL, OP_NULL, PREC_NULL, 0} @@ -783,8 +768,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_class_name, /* Language specific - class_name_from_physname */ unk_op_print_tab, /* expression operators for printing */ 1, /* c-style arrays */ 0, /* String lower bound */ @@ -860,8 +843,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_class_name, /* Language specific - class_name_from_physname */ unk_op_print_tab, /* expression operators for printing */ 1, /* c-style arrays */ 0, /* String lower bound */ diff --git a/gdb/language.h b/gdb/language.h index 05ad132d01b..36fc2c55c58 100644 --- a/gdb/language.h +++ b/gdb/language.h @@ -304,9 +304,6 @@ struct language_data const struct block *, const domain_enum); - /* Return class name of a mangled method name or NULL. */ - char *(*la_class_name_from_physname) (const char *physname); - /* Table for printing expressions. */ const struct op_print *la_op_print_tab; @@ -523,6 +520,12 @@ struct language_defn : language_data return (CORE_ADDR) 0; } + /* Return class name of a mangled method name or NULL. */ + virtual char *class_name_from_physname (const char *physname) const + { + return nullptr; + } + /* List of all known languages. */ static const struct language_defn *languages[nr_languages]; }; @@ -677,10 +680,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); -/* Return class name from physname, or NULL. */ -extern char *language_class_name_from_physname (const struct language_defn *, - const char *physname); - /* Splitting strings into words. */ extern const char *default_word_break_characters (void); diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c index 3e1b74e3b15..6cb3f7ddf61 100644 --- a/gdb/m2-lang.c +++ b/gdb/m2-lang.c @@ -373,8 +373,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 - class_name_from_physname */ m2_op_print_tab, /* expression operators for printing */ 0, /* arrays are first-class (not c-style) */ 0, /* String lower bound */ diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c index ff028fc012a..631b2051f88 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -348,8 +348,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 */ - NULL, /* Language specific - class_name_from_physname */ objc_op_print_tab, /* Expression operators for printing */ 1, /* C-style arrays */ 0, /* String lower bound */ diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index eaf61c3fc1a..ab19acfa4e4 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -1027,8 +1027,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 - class_name_from_physname */ c_op_print_tab, /* expression operators for printing */ 1, /* c-style arrays */ 0, /* String lower bound */ diff --git a/gdb/p-lang.c b/gdb/p-lang.c index f3d10d0ec6e..2f77d7ae0ea 100644 --- a/gdb/p-lang.c +++ b/gdb/p-lang.c @@ -404,7 +404,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 class_name_from_physname */ pascal_op_print_tab, /* expression operators for printing */ 1, /* c-style arrays */ 0, /* String lower bound */ diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 449dfca59e9..ada721f5327 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -2059,8 +2059,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 */ - NULL, /* Language specific - class_name_from_physname */ c_op_print_tab, /* expression operators for printing */ 1, /* c-style arrays */ 0, /* String lower bound */ -- 2.30.2