From b63a3f3fc4e998b4efd5fd49aa0eb044e9cee261 Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Tue, 4 Aug 2020 15:59:52 +0100 Subject: [PATCH] gdb: Convert language_data::la_varobj_ops to a method Convert language_data::la_varobj_ops member variable to a virtual method language_defn::varobj_ops. There should be no user visible changes after this commit. gdb/ChangeLog: * ada-lang.c (ada_language_data): Remove la_varobj_ops initializer. (ada_language::varobj_ops): New member function. * c-lang.c (c_language_data): Remove la_varobj_ops initializer. (cplus_language_data): Likewise. (cplus_language::varobj_ops): New member function. (asm_language_data): Remove la_varobj_ops initializer. (minimal_language_data): Likewise. * d-lang.c (d_language_data): Likewise. * f-lang.c (f_language_data): Likewise. * go-lang.c (go_language_data): Likewise. * language.c (language_defn::varobj_ops): New function. (unknown_language_data): Remove la_varobj_ops initializer. (auto_language_data): Likewise. * language.h (language_data): Remove la_varobj_ops field. (language_defn::varobj_ops): Declare new member function. * m2-lang.c (m2_language_data): Remove la_varobj_ops 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. * varobj.c (varobj_create): Update call to varobj_ops. * varobj.h (default_varobj_ops): Delete define. --- gdb/ChangeLog | 28 ++++++++++++++++++++++++++++ gdb/ada-lang.c | 6 +++++- gdb/c-lang.c | 9 +++++---- gdb/d-lang.c | 1 - gdb/f-lang.c | 1 - gdb/go-lang.c | 1 - gdb/language.c | 12 ++++++++++-- gdb/language.h | 8 +++++--- gdb/m2-lang.c | 1 - gdb/objc-lang.c | 1 - gdb/opencl-lang.c | 1 - gdb/p-lang.c | 1 - gdb/rust-lang.c | 1 - gdb/varobj.c | 2 +- gdb/varobj.h | 2 -- 15 files changed, 54 insertions(+), 21 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 44786285082..666dd1a4289 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,31 @@ +2020-09-16 Andrew Burgess + + * ada-lang.c (ada_language_data): Remove la_varobj_ops + initializer. + (ada_language::varobj_ops): New member function. + * c-lang.c (c_language_data): Remove la_varobj_ops + initializer. + (cplus_language_data): Likewise. + (cplus_language::varobj_ops): New member function. + (asm_language_data): Remove la_varobj_ops initializer. + (minimal_language_data): Likewise. + * d-lang.c (d_language_data): Likewise. + * f-lang.c (f_language_data): Likewise. + * go-lang.c (go_language_data): Likewise. + * language.c (language_defn::varobj_ops): New function. + (unknown_language_data): Remove la_varobj_ops + initializer. + (auto_language_data): Likewise. + * language.h (language_data): Remove la_varobj_ops field. + (language_defn::varobj_ops): Declare new member function. + * m2-lang.c (m2_language_data): Remove la_varobj_ops 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. + * varobj.c (varobj_create): Update call to varobj_ops. + * varobj.h (default_varobj_ops): Delete define. + 2020-09-16 Andrew Burgess * ada-lang.c (ada_language_data): Remove la_macro_expansion diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 43b3af1f04f..20fbf33af71 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -13710,7 +13710,6 @@ extern const struct language_data ada_language_data = { &ada_exp_descriptor, ada_op_print_tab, /* expression operators for printing */ - &ada_varobj_ops, }; /* Class representing the Ada language. */ @@ -14202,6 +14201,11 @@ public: bool store_sym_names_in_linkage_form_p () const override { return true; } + /* See language.h. */ + + const struct lang_varobj_ops *varobj_ops () const override + { return &ada_varobj_ops; } + protected: /* See language.h. */ diff --git a/gdb/c-lang.c b/gdb/c-lang.c index a478dd81b23..9b21da15044 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -877,7 +877,6 @@ extern const struct language_data c_language_data = { &exp_descriptor_c, c_op_print_tab, /* expression operators for printing */ - &c_varobj_ops, }; /* Class representing the C language. */ @@ -988,7 +987,6 @@ extern const struct language_data cplus_language_data = { &exp_descriptor_c, c_op_print_tab, /* expression operators for printing */ - &cplus_varobj_ops, }; /* A class for the C++ language. */ @@ -1176,6 +1174,11 @@ public: enum macro_expansion macro_expansion () const override { return macro_expansion_c; } + /* See language.h. */ + + const struct lang_varobj_ops *varobj_ops () const override + { return &cplus_varobj_ops; } + protected: /* See language.h. */ @@ -1197,7 +1200,6 @@ extern const struct language_data asm_language_data = { &exp_descriptor_c, c_op_print_tab, /* expression operators for printing */ - &default_varobj_ops, }; /* A class for the ASM language. */ @@ -1269,7 +1271,6 @@ extern const struct language_data minimal_language_data = { &exp_descriptor_c, c_op_print_tab, /* expression operators for printing */ - &default_varobj_ops, }; /* A class for the minimal language. */ diff --git a/gdb/d-lang.c b/gdb/d-lang.c index 348702276e6..95175af4074 100644 --- a/gdb/d-lang.c +++ b/gdb/d-lang.c @@ -130,7 +130,6 @@ extern const struct language_data d_language_data = { &exp_descriptor_c, d_op_print_tab, /* Expression operators for printing. */ - &default_varobj_ops, }; /* Class representing the D language. */ diff --git a/gdb/f-lang.c b/gdb/f-lang.c index cd596b5df47..d333055510f 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -488,7 +488,6 @@ extern const struct language_data f_language_data = { &exp_descriptor_f, f_op_print_tab, /* expression operators for printing */ - &default_varobj_ops, }; /* Class representing the Fortran language. */ diff --git a/gdb/go-lang.c b/gdb/go-lang.c index 92d2819ac4a..c37e918e42a 100644 --- a/gdb/go-lang.c +++ b/gdb/go-lang.c @@ -510,7 +510,6 @@ extern const struct language_data go_language_data = { &exp_descriptor_c, go_op_print_tab, /* Expression operators for printing. */ - &default_varobj_ops, }; /* Class representing the Go language. */ diff --git a/gdb/language.c b/gdb/language.c index d255035495b..bcffd3e1338 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -764,6 +764,16 @@ language_defn::get_symbol_name_matcher_inner return default_symbol_name_matcher; } +/* See language.h. */ + +const struct lang_varobj_ops * +language_defn::varobj_ops () const +{ + /* The ops for the C language are suitable for the vast majority of the + supported languages. */ + return &c_varobj_ops; +} + /* Return true if TYPE is a string type, otherwise return false. This default implementation only detects TYPE_CODE_STRING. */ @@ -800,7 +810,6 @@ extern const struct language_data unknown_language_data = { &exp_descriptor_standard, unk_op_print_tab, /* expression operators for printing */ - &default_varobj_ops, }; /* Class representing the unknown language. */ @@ -933,7 +942,6 @@ extern const struct language_data auto_language_data = { &exp_descriptor_standard, unk_op_print_tab, /* expression operators for printing */ - &default_varobj_ops, }; /* Class representing the fake "auto" language. */ diff --git a/gdb/language.h b/gdb/language.h index a2a970e192b..414488ddfbd 100644 --- a/gdb/language.h +++ b/gdb/language.h @@ -176,9 +176,6 @@ struct language_data /* Table for printing expressions. */ const struct op_print *la_op_print_tab; - - /* Various operations on varobj. */ - const struct lang_varobj_ops *la_varobj_ops; }; /* Base class from which all other language classes derive. */ @@ -565,6 +562,11 @@ struct language_defn : language_data virtual enum macro_expansion macro_expansion () const { return macro_expansion_no; } + /* Return a structure containing various operations on varobj specific + for this language. */ + + virtual const struct lang_varobj_ops *varobj_ops () const; + protected: /* This is the overridable part of the GET_SYMBOL_NAME_MATCHER method. diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c index ac251af24e8..c5206bbf901 100644 --- a/gdb/m2-lang.c +++ b/gdb/m2-lang.c @@ -201,7 +201,6 @@ extern const struct language_data m2_language_data = { &exp_descriptor_modula2, m2_op_print_tab, /* expression operators for printing */ - &default_varobj_ops, }; /* Class representing the M2 language. */ diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c index 2246e125fc3..523902a0774 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -325,7 +325,6 @@ extern const struct language_data objc_language_data = { &exp_descriptor_standard, objc_op_print_tab, /* Expression operators for printing */ - &default_varobj_ops, }; /* Class representing the Objective-C language. */ diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index 8f19f253cc9..38dc73d1f22 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -1008,7 +1008,6 @@ extern const struct language_data opencl_language_data = { &exp_descriptor_opencl, c_op_print_tab, /* expression operators for printing */ - &default_varobj_ops, }; /* Class representing the OpenCL language. */ diff --git a/gdb/p-lang.c b/gdb/p-lang.c index aa2b9fcb8ca..6dd0b988a54 100644 --- a/gdb/p-lang.c +++ b/gdb/p-lang.c @@ -254,7 +254,6 @@ extern const struct language_data pascal_language_data = { &exp_descriptor_standard, pascal_op_print_tab, /* expression operators for printing */ - &default_varobj_ops, }; /* Class representing the Pascal language. */ diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 2c82ddb7abc..96abca18241 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -1903,7 +1903,6 @@ extern const struct language_data rust_language_data = { &exp_descriptor_rust, c_op_print_tab, /* expression operators for printing */ - &default_varobj_ops, }; /* Class representing the Rust language. */ diff --git a/gdb/varobj.c b/gdb/varobj.c index 3358be4e77b..85530e3f3cf 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -386,7 +386,7 @@ varobj_create (const char *objname, } /* Set language info */ - var->root->lang_ops = var->root->exp->language_defn->la_varobj_ops; + var->root->lang_ops = var->root->exp->language_defn->varobj_ops (); install_new_value (var.get (), value, 1 /* Initial assignment */); diff --git a/gdb/varobj.h b/gdb/varobj.h index 3e6abaa709f..7831e76b973 100644 --- a/gdb/varobj.h +++ b/gdb/varobj.h @@ -233,8 +233,6 @@ extern const struct lang_varobj_ops c_varobj_ops; extern const struct lang_varobj_ops cplus_varobj_ops; extern const struct lang_varobj_ops ada_varobj_ops; -#define default_varobj_ops c_varobj_ops - /* Non-zero if we want to see trace of varobj level stuff. */ extern unsigned int varobjdebug; -- 2.30.2