[PATCHv2,17/18] gdb: Convert language_data::la_op_print_tab to a method

Message ID 5428efe0a9d7666ba6e3c63c37e2bbeebe6e1591.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_op_print_tab member variable to a virtual
method language_defn::opcode_print_table.  I changed the name in order
to make it clearer (I hope) what the method does.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* ada-lang.c (ada_language_data): Remove la_op_print_tab
	initializer.
	(ada_language::opcode_print_table): New member function.
	* c-lang.c (c_language_data): Remove la_op_print_tab initializer.
	(c_language::opcode_print_table): New member function.
	(cplus_language_data): Remove la_op_print_tab initializer.
	(cplus_language::opcode_print_table): New member function.
	(asm_language_data): Remove la_op_print_tab initializer.
	(asm_language::opcode_print_table): New member function.
	(minimal_language_data): Remove la_op_print_tab initializer.
	(minimal_language::opcode_print_table): New member function.
	* d-lang.c (d_language_data): Remove la_op_print_tab initializer.
	(d_language::opcode_print_table): New member function.
	* expprint.c (print_subexp_standard): Update call to
	opcode_print_table.
	(op_string): Likewise.
	* f-lang.c (f_language_data): Remove la_op_print_tab initializer.
	(f_language::opcode_print_table): New member function.
	* go-lang.c (go_language_data): Remove la_op_print_tab
	initializer.
	(go_language::opcode_print_table): New member function.
	* language.c (unknown_language_data): Remove la_op_print_tab
	initializer.
	(unknown_language::opcode_print_table): New member function.
	(auto_language_data): Remove la_op_print_tab initializer.
	(auto_language::opcode_print_table): New member function.
	* language.h (language_data): Remove la_op_print_tab field.
	(language_defn::opcode_print_table): Declare new member function.
	* m2-lang.c (m2_language_data): Remove la_op_print_tab
	initializer.
	(m2_language::opcode_print_table): New member function.
	* objc-lang.c (objc_language_data): Remove la_op_print_tab
	initializer.
	(objc_language::opcode_print_table): New member function.
	* opencl-lang.c (opencl_language_data): Remove la_op_print_tab
	initializer.
	(opencl_language::opcode_print_table): New member function.
	* p-lang.c (pascal_language_data): Remove la_op_print_tab
	initializer.
	(pascal_language::opcode_print_table): New member function.
	* rust-lang.c (rust_language_data): Remove la_op_print_tab
	initializer.
	(rust_language::opcode_print_table): New member function.
---
 gdb/ChangeLog     | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 gdb/ada-lang.c    |  6 +++++-
 gdb/c-lang.c      | 24 ++++++++++++++++++++----
 gdb/d-lang.c      |  6 +++++-
 gdb/expprint.c    |  4 ++--
 gdb/f-lang.c      |  6 +++++-
 gdb/go-lang.c     |  6 +++++-
 gdb/language.c    | 12 ++++++++++--
 gdb/language.h    |  7 ++++---
 gdb/m2-lang.c     |  6 +++++-
 gdb/objc-lang.c   |  6 +++++-
 gdb/opencl-lang.c |  6 +++++-
 gdb/p-lang.c      |  6 +++++-
 gdb/rust-lang.c   |  6 +++++-
 14 files changed, 127 insertions(+), 20 deletions(-)

-- 
2.25.4

Patch

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index b5c066f470c..dbfaebc66e2 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -13708,7 +13708,6 @@  ada_get_symbol_name_matcher (const lookup_name_info &lookup_name)
 
 extern const struct language_data ada_language_data =
 {
-  ada_op_print_tab,             /* expression operators for printing */
 };
 
 /* Class representing the Ada language.  */
@@ -14210,6 +14209,11 @@  class ada_language : public language_defn
   const struct exp_descriptor *expression_ops () const override
   { return &ada_exp_descriptor; }
 
+  /* See language.h.  */
+
+  const struct op_print *opcode_print_table () const override
+  { return ada_op_print_tab; }
+
 protected:
   /* See language.h.  */
 
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index f29f3407e16..73968ed20f4 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -875,7 +875,6 @@  const struct exp_descriptor exp_descriptor_c =
 
 extern const struct language_data c_language_data =
 {
-  c_op_print_tab,		/* expression operators for printing */
 };
 
 /* Class representing the C language.  */
@@ -951,6 +950,11 @@  class c_language : public language_defn
 
   const struct exp_descriptor *expression_ops () const override
   { return &exp_descriptor_c; }
+
+  /* See language.h.  */
+
+  const struct op_print *opcode_print_table () const override
+  { return c_op_print_tab; }
 };
 
 /* Single instance of the C language class.  */
@@ -989,7 +993,6 @@  enum cplus_primitive_types {
 
 extern const struct language_data cplus_language_data =
 {
-  c_op_print_tab,		/* expression operators for printing */
 };
 
 /* A class for the C++ language.  */
@@ -1187,6 +1190,11 @@  class cplus_language : public language_defn
   const struct exp_descriptor *expression_ops () const override
   { return &exp_descriptor_c; }
 
+  /* See language.h.  */
+
+  const struct op_print *opcode_print_table () const override
+  { return c_op_print_tab; }
+
 protected:
 
   /* See language.h.  */
@@ -1206,7 +1214,6 @@  static cplus_language cplus_language_defn;
 
 extern const struct language_data asm_language_data =
 {
-  c_op_print_tab,		/* expression operators for printing */
 };
 
 /* A class for the ASM language.  */
@@ -1269,6 +1276,11 @@  class asm_language : public language_defn
 
   const struct exp_descriptor *expression_ops () const override
   { return &exp_descriptor_c; }
+
+  /* See language.h.  */
+
+  const struct op_print *opcode_print_table () const override
+  { return c_op_print_tab; }
 };
 
 /* The single instance of the ASM language class.  */
@@ -1281,7 +1293,6 @@  static asm_language asm_language_defn;
 
 extern const struct language_data minimal_language_data =
 {
-  c_op_print_tab,		/* expression operators for printing */
 };
 
 /* A class for the minimal language.  */
@@ -1333,6 +1344,11 @@  class minimal_language : public language_defn
 
   const struct exp_descriptor *expression_ops () const override
   { return &exp_descriptor_c; }
+
+  /* See language.h.  */
+
+  const struct op_print *opcode_print_table () const override
+  { return c_op_print_tab; }
 };
 
 /* The single instance of the minimal language class.  */
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index 107ee4a4a70..f590d63d930 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -128,7 +128,6 @@  enum d_primitive_types {
 
 extern const struct language_data d_language_data =
 {
-  d_op_print_tab,		/* Expression operators for printing.  */
 };
 
 /* Class representing the D language.  */
@@ -280,6 +279,11 @@  class d_language : public language_defn
 
   const struct exp_descriptor *expression_ops () const override
   { return &exp_descriptor_c; }
+
+  /* See language.h.  */
+
+  const struct op_print *opcode_print_table () const override
+  { return d_op_print_tab; }
 };
 
 /* Single instance of the D language class.  */
diff --git a/gdb/expprint.c b/gdb/expprint.c
index 8cca5b4f92c..5bd9553a411 100644
--- a/gdb/expprint.c
+++ b/gdb/expprint.c
@@ -73,7 +73,7 @@  print_subexp_standard (struct expression *exp, int *pos,
   struct value *val;
   char *tempstr = NULL;
 
-  op_print_tab = exp->language_defn->la_op_print_tab;
+  op_print_tab = exp->language_defn->opcode_print_table ();
   pc = (*pos)++;
   opcode = exp->elts[pc].opcode;
   switch (opcode)
@@ -669,7 +669,7 @@  op_string (enum exp_opcode op)
   int tem;
   const struct op_print *op_print_tab;
 
-  op_print_tab = current_language->la_op_print_tab;
+  op_print_tab = current_language->opcode_print_table ();
   for (tem = 0; op_print_tab[tem].opcode != OP_NULL; tem++)
     if (op_print_tab[tem].opcode == op)
       return op_print_tab[tem].string;
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 8069fa4c17f..101f4dbc1e5 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -486,7 +486,6 @@  static const struct exp_descriptor exp_descriptor_f =
 
 extern const struct language_data f_language_data =
 {
-  f_op_print_tab,		/* expression operators for printing */
 };
 
 /* Class representing the Fortran language.  */
@@ -736,6 +735,11 @@  class f_language : public language_defn
   const struct exp_descriptor *expression_ops () const override
   { return &exp_descriptor_f; }
 
+  /* See language.h.  */
+
+  const struct op_print *opcode_print_table () const override
+  { return f_op_print_tab; }
+
 protected:
 
   /* See language.h.  */
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index eacc4debf42..2b9be93b2e5 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -508,7 +508,6 @@  enum go_primitive_types {
 
 extern const struct language_data go_language_data =
 {
-  go_op_print_tab,		/* Expression operators for printing.  */
 };
 
 /* Class representing the Go language.  */
@@ -641,6 +640,11 @@  class go_language : public language_defn
 
   const struct exp_descriptor *expression_ops () const override
   { return &exp_descriptor_c; }
+
+  /* See language.h.  */
+
+  const struct op_print *opcode_print_table () const override
+  { return go_op_print_tab; }
 };
 
 /* Single instance of the Go language class.  */
diff --git a/gdb/language.c b/gdb/language.c
index b467512e80d..37aef2cd73b 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -816,7 +816,6 @@  unknown_language_arch_info (struct gdbarch *gdbarch,
 
 extern const struct language_data unknown_language_data =
 {
-  unk_op_print_tab,		/* expression operators for printing */
 };
 
 /* Class representing the unknown language.  */
@@ -937,6 +936,11 @@  class unknown_language : public language_defn
 
   bool store_sym_names_in_linkage_form_p () const override
   { return true; }
+
+  /* See language.h.  */
+
+  const struct op_print *opcode_print_table () const override
+  { return unk_op_print_tab; }
 };
 
 /* Single instance of the unknown language class.  */
@@ -947,7 +951,6 @@  static unknown_language unknown_language_defn;
 
 extern const struct language_data auto_language_data =
 {
-  unk_op_print_tab,		/* expression operators for printing */
 };
 
 /* Class representing the fake "auto" language.  */
@@ -1063,6 +1066,11 @@  class auto_language : public language_defn
 
   const char *name_of_this () const override
   { return "this"; }
+
+  /* See language.h.  */
+
+  const struct op_print *opcode_print_table () const override
+  { return unk_op_print_tab; }
 };
 
 /* Single instance of the fake "auto" language.  */
diff --git a/gdb/language.h b/gdb/language.h
index cfb3461a8cd..2d13cfa9db9 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -168,9 +168,6 @@  extern const char *default_word_break_characters (void);
 
 struct language_data
   {
-    /* Table for printing expressions.  */
-
-    const struct op_print *la_op_print_tab;
   };
 
 /* Base class from which all other language classes derive.  */
@@ -567,6 +564,10 @@  struct language_defn : language_data
 
   virtual const struct exp_descriptor *expression_ops () const;
 
+  /* Table for printing expressions.  */
+
+  virtual const struct op_print *opcode_print_table () const = 0;
+
 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 b41d0b48d6e..1f9c8a878e4 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -199,7 +199,6 @@  const struct exp_descriptor exp_descriptor_modula2 =
 
 extern const struct language_data m2_language_data =
 {
-  m2_op_print_tab,		/* expression operators for printing */
 };
 
 /* Class representing the M2 language.  */
@@ -448,6 +447,11 @@  class m2_language : public language_defn
 
   const struct exp_descriptor *expression_ops () const override
   { return &exp_descriptor_modula2; }
+
+  /* See language.h.  */
+
+  const struct op_print *opcode_print_table () const override
+  { return m2_op_print_tab; }
 };
 
 /* Single instance of the M2 language.  */
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index e78e0871aa9..b59a45b49be 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -323,7 +323,6 @@  static const struct op_print objc_op_print_tab[] =
 
 extern const struct language_data objc_language_data =
 {
-  objc_op_print_tab,		/* Expression operators for printing */
 };
 
 /* Class representing the Objective-C language.  */
@@ -427,6 +426,11 @@  class objc_language : public language_defn
 
   enum macro_expansion macro_expansion () const override
   { return macro_expansion_c; }
+
+  /* See language.h.  */
+
+  const struct op_print *opcode_print_table () const override
+  { return c_op_print_tab; }
 };
 
 /* Single instance of the class representing the Objective-C language.  */
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index 8b77b875469..9bc5f5698c6 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -1007,7 +1007,6 @@  const struct exp_descriptor exp_descriptor_opencl =
 /* Constant data representing the OpenCL language.  */
 extern const struct language_data opencl_language_data =
 {
-  c_op_print_tab,		/* expression operators for printing */
 };
 
 /* Class representing the OpenCL language.  */
@@ -1075,6 +1074,11 @@  class opencl_language : public language_defn
 
   const struct exp_descriptor *expression_ops () const override
   { return &exp_descriptor_opencl; }
+
+  /* See language.h.  */
+
+  const struct op_print *opcode_print_table () const override
+  { return c_op_print_tab; }
 };
 
 /* Single instance of the OpenCL language class.  */
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index 1acd591d41c..6a9811d869c 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -252,7 +252,6 @@  enum pascal_primitive_types {
 
 extern const struct language_data pascal_language_data =
 {
-  pascal_op_print_tab,		/* expression operators for printing */
 };
 
 /* Class representing the Pascal language.  */
@@ -507,6 +506,11 @@  class pascal_language : public language_defn
 
   bool range_checking_on_by_default () const override
   { return true; }
+
+  /* See language.h.  */
+
+  const struct op_print *opcode_print_table () const override
+  { return pascal_op_print_tab; }
 };
 
 /* Single instance of the Pascal language class.  */
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index d676f91da7d..23508af96dc 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -1906,7 +1906,6 @@  static const struct exp_descriptor exp_descriptor_rust =
 
 extern const struct language_data rust_language_data =
 {
-  c_op_print_tab,		/* expression operators for printing */
 };
 
 /* Class representing the Rust language.  */
@@ -2158,6 +2157,11 @@  class rust_language : public language_defn
 
   const struct exp_descriptor *expression_ops () const override
   { return &exp_descriptor_rust; }
+
+  /* See language.h.  */
+
+  const struct op_print *opcode_print_table () const override
+  { return c_op_print_tab; }
 };
 
 /* Single instance of the Rust language class.  */