[PATCHv2,15/18] gdb: Convert language_data::la_varobj_ops to a method

Message ID 90098e1c46859f784849e51632d40c56f66c336c.1596638296.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 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(-)

-- 
2.25.4

Patch

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 9da6625830e..7b8676959cf 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 @@  class ada_language : public language_defn
   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 @@  class cplus_language : public language_defn
   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 785440024d0..5630610536e 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 eb7b70cdecc..b9651412efc 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 6365d622fae..235ee2dc47e 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -1009,7 +1009,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 f099024d4e2..4b5b9b08bdf 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -1908,7 +1908,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;