public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/9] Further Conversion of Language Class Hierarchy
@ 2020-06-02 13:32 Andrew Burgess
  2020-06-02 13:32 ` [PATCH 1/9] gdb: Convert language la_class_name_from_physname field to a method Andrew Burgess
                   ` (9 more replies)
  0 siblings, 10 replies; 12+ messages in thread
From: Andrew Burgess @ 2020-06-02 13:32 UTC (permalink / raw)
  To: gdb-patches

Continuing with the process of converting function pointers to member
functions within the class hierarchy of languages.

One interesting pattern that crops up a number of times, but which I
have not addressed in this series is for example in patch #8, in
f-lang.c, where I add this method:

     void value_print_inner
    	(struct value *val, struct ui_file *stream, int recurse,
         const struct value_print_options *options) const override
     {
       return f_value_print_inner (val, stream, recurse, options);
     }

The reason that the member function is just a wrapper around
f_value_print_inner, is that the f_language class is declared and
defined in f-lang.c, while f_value_print_inner is in f-valprint.c.  My
current thinking is that once all of the field conversion is done, I
will probably move some of the language classes out of their *-lang.c
files into a header file, at this point, in cases like the above,
f_value_print_inner would become f_language::value_print_inner, but
could still live in f-valprint.c.

I haven't done any of this code shuffling yet in order to keep these
patches more focused.

Everything else is pretty standard, except maybe patch #3, which is
slightly different, the commit message has more detail.

There will be more patches after this series, as a minimum to convert
the function pointers into methods.

All feedback welcome.

Thanks,
Andrew


---

Andrew Burgess (9):
  gdb: Convert language la_class_name_from_physname field to a method
  gdb: Convert language la_compute_program field to a method
  gdb: Convert language la_get_symbol_name_matcher field to a method
  gdb: Convert language la_word_break_characters field to a method
  gdb: Convert language la_collect_symbol_completion_matches field to a
    method
  gdb: Convert language la_watch_location_expression field to a method
  gdb: Convert language la_value_print field to a method
  gdb: Convert language la_value_print_inner field to a method
  gdb: Convert language la_lookup_symbol_nonlocal field to a method

 gdb/ChangeLog                   | 365 ++++++++++++++++++++++++++++
 gdb/ada-lang.c                  | 408 +++++++++++++++++---------------
 gdb/breakpoint.c                |   2 +-
 gdb/c-lang.c                    |  97 ++++----
 gdb/c-lang.h                    |   7 +-
 gdb/compile/compile-c-support.c |   4 +-
 gdb/compile/compile.c           |   4 +-
 gdb/completer.c                 |  12 +-
 gdb/cp-namespace.c              |   2 +-
 gdb/cp-support.h                |   3 +-
 gdb/d-lang.c                    |  28 ++-
 gdb/dictionary.c                |   6 +-
 gdb/dwarf2/read.c               |   9 +-
 gdb/f-lang.c                    | 118 +++++----
 gdb/f-lang.h                    |   2 +-
 gdb/f-valprint.c                |   2 +-
 gdb/go-lang.c                   |  19 +-
 gdb/language.c                  | 167 +++++++------
 gdb/language.h                  | 198 ++++++++--------
 gdb/linespec.c                  |   2 +-
 gdb/m2-lang.c                   |  19 +-
 gdb/minsyms.c                   |   6 +-
 gdb/objc-lang.c                 |  10 -
 gdb/opencl-lang.c               |  10 -
 gdb/p-lang.c                    |  26 +-
 gdb/psymtab.c                   |   2 +-
 gdb/rust-lang.c                 | 131 +++++-----
 gdb/symtab.c                    |  44 ++--
 gdb/symtab.h                    |  17 --
 gdb/valprint.c                  |   2 +-
 30 files changed, 1048 insertions(+), 674 deletions(-)

-- 
2.25.4


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/9] gdb: Convert language la_class_name_from_physname field to a method
  2020-06-02 13:32 [PATCH 0/9] Further Conversion of Language Class Hierarchy Andrew Burgess
@ 2020-06-02 13:32 ` Andrew Burgess
  2020-06-02 13:32 ` [PATCH 2/9] gdb: Convert language la_compute_program " Andrew Burgess
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Andrew Burgess @ 2020-06-02 13:32 UTC (permalink / raw)
  To: gdb-patches

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/ada-lang.c b/gdb/ada-lang.c
index b1c689beb0f..2fbd6e3764a 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -13925,8 +13925,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 364a672119a..4bdd70516f1 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 @@ class cplus_language : public language_defn
   {
     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 e6566f9649f..daf66725eb3 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -18831,8 +18831,8 @@ guess_partial_die_structure_name (struct partial_die_info *struct_pdi,
 	  && child_pdi->linkage_name != NULL)
 	{
 	  gdb::unique_xmalloc_ptr<char> 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;
@@ -21672,8 +21672,7 @@ guess_full_die_structure_name (struct die_info *die, struct dwarf2_cu *cu)
 	  if (linkage_name != NULL)
 	    {
 	      gdb::unique_xmalloc_ptr<char> 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 3975dfcb482..df08a5d5198 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 f174ad55823..60995d0b340 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 777f1ffe217..b97e7a1af47 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 0929daf0511..5344eacf03d 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.25.4


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 2/9] gdb: Convert language la_compute_program field to a method
  2020-06-02 13:32 [PATCH 0/9] Further Conversion of Language Class Hierarchy Andrew Burgess
  2020-06-02 13:32 ` [PATCH 1/9] gdb: Convert language la_class_name_from_physname field to a method Andrew Burgess
@ 2020-06-02 13:32 ` Andrew Burgess
  2020-06-02 13:32 ` [PATCH 3/9] gdb: Convert language la_get_symbol_name_matcher " Andrew Burgess
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Andrew Burgess @ 2020-06-02 13:32 UTC (permalink / raw)
  To: gdb-patches

This commit changes the language_data::la_compute_program 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_compute_program
	initializer.
	* c-lang.c (c_language_data): Likewise.
	(c_language::compute_program): New member function.
	(cplus_language_data): Delete la_compute_program initializer.
	(cplus_language::compute_program): New member function.
	(asm_language_data): Delete la_compute_program initializer.
	(minimal_language_data): Likewise.
	* c-lang.h (c_compute_program): Update comment.
	(cplus_compute_program): Likewise.
	* compile/compile-c-support.c (c_compute_program): Likewise.
	(cplus_compute_program): Likewise.
	* compile/compile.c (compile_to_object): Update call to
	la_compute_program.
	* d-lang.c (d_language_data): Delete la_compute_program
	initializer.
	* f-lang.c (f_language_data): Likewise.
	* go-lang.c (go_language_data): Likewise.
	* language.c (unknown_language_data): Likewise.
	(auto_language_data): Likewise.
	* language.h (language_data): Delete la_compute_program field.
	(language_defn::compute_program): New member function.
	* m2-lang.c (m2_language_data): Delete la_compute_program
	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                   | 31 ++++++++++++++++++++++++
 gdb/ada-lang.c                  |  1 -
 gdb/c-lang.c                    | 24 +++++++++++++++----
 gdb/c-lang.h                    |  4 ++--
 gdb/compile/compile-c-support.c |  4 ++--
 gdb/compile/compile.c           |  4 ++--
 gdb/d-lang.c                    |  1 -
 gdb/f-lang.c                    |  1 -
 gdb/go-lang.c                   |  1 -
 gdb/language.c                  |  2 --
 gdb/language.h                  | 42 +++++++++++++++++----------------
 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 -
 16 files changed, 79 insertions(+), 41 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 2fbd6e3764a..5f3af93d8e7 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -13933,7 +13933,6 @@ extern const struct language_data ada_language_data =
   ada_watch_location_expression,
   ada_get_symbol_name_matcher,	/* la_get_symbol_name_matcher */
   &ada_varobj_ops,
-  NULL,
   ada_is_string_type,
   "(...)"			/* la_struct_too_deep_ellipsis */
 };
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 4bdd70516f1..2fae50325eb 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -919,7 +919,6 @@ extern const struct language_data c_language_data =
   c_watch_location_expression,
   NULL,				/* la_get_symbol_name_matcher */
   &c_varobj_ops,
-  c_compute_program,
   c_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
 };
@@ -946,6 +945,16 @@ class c_language : public language_defn
     return c_get_compile_context ();
   }
 
+  /* See language.h.  */
+  std::string compute_program (compile_instance *inst,
+			       const char *input,
+			       struct gdbarch *gdbarch,
+			       const struct block *expr_block,
+			       CORE_ADDR expr_pc) const override
+  {
+    return c_compute_program (inst, input, gdbarch, expr_block, expr_pc);
+  }
+
   /* See language.h.  */
 
   void print_type (struct type *type, const char *varstring,
@@ -1025,7 +1034,6 @@ extern const struct language_data cplus_language_data =
   c_watch_location_expression,
   cp_get_symbol_name_matcher,
   &cplus_varobj_ops,
-  cplus_compute_program,
   c_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
 };
@@ -1122,6 +1130,16 @@ class cplus_language : public language_defn
     return cplus_get_compile_context ();
   }
 
+  /* See language.h.  */
+  std::string compute_program (compile_instance *inst,
+			       const char *input,
+			       struct gdbarch *gdbarch,
+			       const struct block *expr_block,
+			       CORE_ADDR expr_pc) const override
+  {
+    return cplus_compute_program (inst, input, gdbarch, expr_block, expr_pc);
+  }
+
   /* See language.h.  */
   unsigned int search_name_hash (const char *name) const override
   {
@@ -1209,7 +1227,6 @@ extern const struct language_data asm_language_data =
   c_watch_location_expression,
   NULL,				/* la_get_symbol_name_matcher */
   &default_varobj_ops,
-  NULL,
   c_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
 };
@@ -1280,7 +1297,6 @@ extern const struct language_data minimal_language_data =
   c_watch_location_expression,
   NULL,				/* la_get_symbol_name_matcher */
   &default_varobj_ops,
-  NULL,
   c_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
 };
diff --git a/gdb/c-lang.h b/gdb/c-lang.h
index 3e07dc9c88d..31ec6f2cf74 100644
--- a/gdb/c-lang.h
+++ b/gdb/c-lang.h
@@ -172,7 +172,7 @@ extern compile_instance *cplus_get_compile_context ();
 /* This takes the user-supplied text and returns a new bit of code to
    compile.
 
-   This is used as the la_compute_program language method; see that
+   This is used as the compute_program language method; see that
    for a description of the arguments.  */
 
 extern std::string c_compute_program (compile_instance *inst,
@@ -183,7 +183,7 @@ extern std::string c_compute_program (compile_instance *inst,
 
 /* This takes the user-supplied text and returns a new bit of code to compile.
 
-   This is used as the la_compute_program language method; see that
+   This is used as the compute_program language method; see that
    for a description of the arguments.  */
 
 extern std::string cplus_compute_program (compile_instance *inst,
diff --git a/gdb/compile/compile-c-support.c b/gdb/compile/compile-c-support.c
index 8499300179c..5e4da6703a6 100644
--- a/gdb/compile/compile-c-support.c
+++ b/gdb/compile/compile-c-support.c
@@ -660,7 +660,7 @@ typedef compile_program<compile_cplus_instance,
 			cplus_add_code_header, c_add_code_footer,
 			cplus_add_input> cplus_compile_program;
 
-/* The la_compute_program method for C.  */
+/* The compute_program method for C.  */
 
 std::string
 c_compute_program (compile_instance *inst,
@@ -675,7 +675,7 @@ c_compute_program (compile_instance *inst,
   return program.compute (input, expr_block, expr_pc);
 }
 
-/* The la_compute_program method for C++.  */
+/* The compute_program method for C++.  */
 
 std::string
 cplus_compute_program (compile_instance *inst,
diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c
index 3a3afa85736..0c29a0476e7 100644
--- a/gdb/compile/compile.c
+++ b/gdb/compile/compile.c
@@ -724,8 +724,8 @@ compile_to_object (struct command_line *cmd, const char *cmd_string,
     error (_("Neither a simple expression, or a multi-line specified."));
 
   std::string code
-    = current_language->la_compute_program (compiler.get (), input, gdbarch,
-					    expr_block, expr_pc);
+    = current_language->compute_program (compiler.get (), input, gdbarch,
+					 expr_block, expr_pc);
   if (compile_debug)
     fprintf_unfiltered (gdb_stdlog, "debug output:\n\n%s", code.c_str ());
 
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index 6dacf8ca4a4..ad16f991dd3 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -162,7 +162,6 @@ extern const struct language_data d_language_data =
   c_watch_location_expression,
   NULL,				/* la_get_symbol_name_matcher */
   &default_varobj_ops,
-  NULL,
   c_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
 };
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 07ee2c8e6c6..d748db82e4f 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -622,7 +622,6 @@ extern const struct language_data f_language_data =
   c_watch_location_expression,
   cp_get_symbol_name_matcher,	/* la_get_symbol_name_matcher */
   &default_varobj_ops,
-  NULL,
   f_is_string_type_p,
   "(...)"			/* la_struct_too_deep_ellipsis */
 };
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index df08a5d5198..831a3e2bf32 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -547,7 +547,6 @@ extern const struct language_data go_language_data =
   c_watch_location_expression,
   NULL,				/* la_get_symbol_name_matcher */
   &default_varobj_ops,
-  NULL,
   go_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
 };
diff --git a/gdb/language.c b/gdb/language.c
index ade5109c9dc..2b2584f4976 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -776,7 +776,6 @@ extern const struct language_data unknown_language_data =
   c_watch_location_expression,
   NULL,				/* la_get_symbol_name_matcher */
   &default_varobj_ops,
-  NULL,
   default_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
 };
@@ -851,7 +850,6 @@ extern const struct language_data auto_language_data =
   c_watch_location_expression,
   NULL,				/* la_get_symbol_name_matcher */
   &default_varobj_ops,
-  NULL,
   default_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
 };
diff --git a/gdb/language.h b/gdb/language.h
index 36fc2c55c58..523a7a923be 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -354,26 +354,6 @@ struct language_data
     /* Various operations on varobj.  */
     const struct lang_varobj_ops *la_varobj_ops;
 
-    /* This method must be defined if 'la_get_gcc_context' is defined.
-       If 'la_get_gcc_context' is not defined, then this method is
-       ignored.
-
-       This takes the user-supplied text and returns a new bit of code
-       to compile.
-
-       INST is the compiler instance being used.
-       INPUT is the user's input text.
-       GDBARCH is the architecture to use.
-       EXPR_BLOCK is the block in which the expression is being
-       parsed.
-       EXPR_PC is the PC at which the expression is being parsed.  */
-
-    std::string (*la_compute_program) (compile_instance *inst,
-				       const char *input,
-				       struct gdbarch *gdbarch,
-				       const struct block *expr_block,
-				       CORE_ADDR expr_pc);
-
     /* Return true if TYPE is a string type.  */
     bool (*la_is_string_type_p) (struct type *type);
 
@@ -476,6 +456,28 @@ struct language_defn : language_data
     return nullptr;
   }
 
+  /* This method must be overridden if 'get_compile_instance' is
+     overridden.
+
+     This takes the user-supplied text and returns a new bit of code
+     to compile.
+
+     INST is the compiler instance being used.
+     INPUT is the user's input text.
+     GDBARCH is the architecture to use.
+     EXPR_BLOCK is the block in which the expression is being
+     parsed.
+     EXPR_PC is the PC at which the expression is being parsed.  */
+
+  virtual std::string compute_program (compile_instance *inst,
+				       const char *input,
+				       struct gdbarch *gdbarch,
+				       const struct block *expr_block,
+				       CORE_ADDR expr_pc) const
+  {
+    gdb_assert_not_reached ("language_defn::compute_program");
+  }
+
   /* Hash the given symbol search name.  */
   virtual unsigned int search_name_hash (const char *name) const;
 
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index 60995d0b340..fe8739ef0dc 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -381,7 +381,6 @@ extern const struct language_data m2_language_data =
   c_watch_location_expression,
   NULL,				/* la_get_symbol_name_matcher */
   &default_varobj_ops,
-  NULL,
   m2_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
 };
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 631b2051f88..8b23c557984 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -356,7 +356,6 @@ extern const struct language_data objc_language_data =
   c_watch_location_expression,
   NULL,				/* la_get_symbol_name_matcher */
   &default_varobj_ops,
-  NULL,
   c_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
 };
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index ab19acfa4e4..00f88c60373 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -1035,7 +1035,6 @@ extern const struct language_data opencl_language_data =
   c_watch_location_expression,
   NULL,				/* la_get_symbol_name_matcher */
   &default_varobj_ops,
-  NULL,
   c_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
 };
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index b97e7a1af47..9a657e26c75 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -412,7 +412,6 @@ extern const struct language_data pascal_language_data =
   c_watch_location_expression,
   NULL,				/* la_compare_symbol_for_completion */
   &default_varobj_ops,
-  NULL,
   pascal_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
 };
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 5344eacf03d..73bc3d621b1 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -2067,7 +2067,6 @@ extern const struct language_data rust_language_data =
   rust_watch_location_expression,
   NULL,				/* la_get_symbol_name_matcher */
   &default_varobj_ops,
-  NULL,
   rust_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
 };
-- 
2.25.4


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 3/9] gdb: Convert language la_get_symbol_name_matcher field to a method
  2020-06-02 13:32 [PATCH 0/9] Further Conversion of Language Class Hierarchy Andrew Burgess
  2020-06-02 13:32 ` [PATCH 1/9] gdb: Convert language la_class_name_from_physname field to a method Andrew Burgess
  2020-06-02 13:32 ` [PATCH 2/9] gdb: Convert language la_compute_program " Andrew Burgess
@ 2020-06-02 13:32 ` Andrew Burgess
  2020-06-15 14:22   ` Tom Tromey
  2020-06-02 13:32 ` [PATCH 4/9] gdb: Convert language la_word_break_characters " Andrew Burgess
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 12+ messages in thread
From: Andrew Burgess @ 2020-06-02 13:32 UTC (permalink / raw)
  To: gdb-patches

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

There should be no user visible changes after this commit.

Before this commit access to the la_get_symbol_name_matcher function
pointer was through the get_symbol_name_matcher function, which looked
something like this (is pseudo-code):

  <return-type>
  get_symbol_name_matcher (language_defn *lang, <other args>)
  {
    if (current_language == ada)
      current_language->la_get_symbol_name_matcher (<other args>);
    else
      lang->la_get_symbol_name_matcher (<other args>);
  }

In this commit I moved the get_symbol_name_matcher as a non-virtual
function in the language_defn base class, I then add a new virtual
method that is only used from within get_symbol_name_matcher, this can
then be overridden by specific languages as needed.  So we now have:

  class language_defn
  {
    <return-type> get_symbol_name_matcher (<args>)
    {
      if (current_language == ada)
        return current_language->get_symbol_name_matcher_inner (<args>);
      else
        return this->get_symbol_name_matcher_inner (<args>);
    }

    virtual <return-type> get_symbol_name_matcher_inner (<args>)
    {
        ....
    }
  }

gdb/ChangeLog:

	* ada-lang.c (ada_get_symbol_name_matcher): Update header comment.
	(ada_language_data): Delete la_get_symbol_name_matcher
	initializer.
	(language_defn::get_symbol_name_matcher_inner): New member
	function.
	* c-lang.c (c_language_data): Delete la_get_symbol_name_matcher
	initializer.
	(cplus_language_data): Likewise.
	(cplus_language::get_symbol_name_matcher_inner): New member
	function.
	(asm_language_data): Delete la_get_symbol_name_matcher initializer.
	(minimal_language_data): Likewise.
	* cp-support.h (cp_get_symbol_name_matcher): Update header comment.
	* d-lang.c (d_language_data): Delete la_get_symbol_name_matcher
	initializer.
	* dictionary.c (iter_match_first_hashed): Update call to
	get_symbol_name_matcher.
	(iter_match_next_hashed): Likewise.
	(iter_match_next_linear): Likewise.
	* dwarf2/read.c (dw2_expand_symtabs_matching_symbol): Likewise.
	* f-lang.c (f_language_data): Delete la_get_symbol_name_matcher
	initializer.
	(f_language::get_symbol_name_matcher_inner): New member function.
	* go-lang.c (go_language_data): Delete la_get_symbol_name_matcher
	initializer.
	* language.c (default_symbol_name_matcher): Update header comment,
	make static.
	(language_defn::get_symbol_name_matcher): New definition.
	(language_defn::get_symbol_name_matcher_inner): Likewise.
	(get_symbol_name_matcher): Delete.
	(unknown_language_data): Delete la_get_symbol_name_matcher
	initializer.
	(auto_language_data): Likewise.
	* language.h (language_data): Delete la_get_symbol_name_matcher
	field.
	(language_defn::get_symbol_name_matcher): New member function.
	(language_defn::get_symbol_name_matcher_inner): Likewise.
	(default_symbol_name_matcher): Delete declaration.
	* linespec.c (find_methods): Update call to
	get_symbol_name_matcher.
	* m2-lang.c (m2_language_data): Delete la_get_symbol_name_matcher
	initializer.
	* minsyms.c (lookup_minimal_symbol): Update call to
	get_symbol_name_matcher.
	(iterate_over_minimal_symbols): Likewise.
	* objc-lang.c (objc_language_data): Delete
	la_get_symbol_name_matcher initializer.
	* opencl-lang.c (opencl_language_data): Likewise.
	* p-lang.c (pascal_language_data): Likewise.
	* psymtab.c (psymbol_name_matches): Update call to
	get_symbol_name_matcher.
	* rust-lang.c (rust_language_data): Delete
	la_get_symbol_name_matcher initializer.
	* symtab.c (symbol_matches_search_name): Update call to
	get_symbol_name_matcher.
	(compare_symbol_name): Likewise.
---
 gdb/ChangeLog     | 59 +++++++++++++++++++++++++++++++++++++++++++++++
 gdb/ada-lang.c    | 12 ++++++++--
 gdb/c-lang.c      | 14 +++++++----
 gdb/cp-support.h  |  3 +--
 gdb/d-lang.c      |  1 -
 gdb/dictionary.c  |  6 ++---
 gdb/dwarf2/read.c |  2 +-
 gdb/f-lang.c      | 11 ++++++++-
 gdb/go-lang.c     |  1 -
 gdb/language.c    | 50 +++++++++++++++++++++------------------
 gdb/language.h    | 42 +++++++++++++++++----------------
 gdb/linespec.c    |  2 +-
 gdb/m2-lang.c     |  1 -
 gdb/minsyms.c     |  6 ++---
 gdb/objc-lang.c   |  1 -
 gdb/opencl-lang.c |  1 -
 gdb/p-lang.c      |  1 -
 gdb/psymtab.c     |  2 +-
 gdb/rust-lang.c   |  1 -
 gdb/symtab.c      |  4 ++--
 20 files changed, 151 insertions(+), 69 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 5f3af93d8e7..8747501fa17 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -13873,7 +13873,7 @@ literal_symbol_name_matcher (const char *symbol_search_name,
     return false;
 }
 
-/* Implement the "la_get_symbol_name_matcher" language_defn method for
+/* Implement the "get_symbol_name_matcher" language_defn method for
    Ada.  */
 
 static symbol_name_matcher_ftype *
@@ -13931,7 +13931,6 @@ extern const struct language_data ada_language_data =
   ada_get_gdb_completer_word_break_characters,
   ada_collect_symbol_completion_matches,
   ada_watch_location_expression,
-  ada_get_symbol_name_matcher,	/* la_get_symbol_name_matcher */
   &ada_varobj_ops,
   ada_is_string_type,
   "(...)"			/* la_struct_too_deep_ellipsis */
@@ -14116,6 +14115,15 @@ class ada_language : public language_defn
   {
     ada_print_type (type, varstring, stream, show, level, flags);
   }
+
+protected:
+  /* See language.h.  */
+
+  symbol_name_matcher_ftype *get_symbol_name_matcher_inner
+	(const lookup_name_info &lookup_name) const override
+  {
+    return ada_get_symbol_name_matcher (lookup_name);
+  }
 };
 
 /* Single instance of the Ada language class.  */
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 2fae50325eb..3a0bb209535 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -917,7 +917,6 @@ extern const struct language_data c_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
-  NULL,				/* la_get_symbol_name_matcher */
   &c_varobj_ops,
   c_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
@@ -1032,7 +1031,6 @@ extern const struct language_data cplus_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
-  cp_get_symbol_name_matcher,
   &cplus_varobj_ops,
   c_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
@@ -1184,6 +1182,16 @@ class cplus_language : public language_defn
   {
     return cp_class_name_from_physname (physname);
   }
+
+protected:
+
+  /* See language.h.  */
+
+  symbol_name_matcher_ftype *get_symbol_name_matcher_inner
+	(const lookup_name_info &lookup_name) const override
+  {
+    return cp_get_symbol_name_matcher (lookup_name);
+  }
 };
 
 /* The single instance of the C++ language class.  */
@@ -1225,7 +1233,6 @@ extern const struct language_data asm_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
-  NULL,				/* la_get_symbol_name_matcher */
   &default_varobj_ops,
   c_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
@@ -1295,7 +1302,6 @@ extern const struct language_data minimal_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
-  NULL,				/* la_get_symbol_name_matcher */
   &default_varobj_ops,
   c_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
diff --git a/gdb/cp-support.h b/gdb/cp-support.h
index 7c948b212cb..d031ad9a096 100644
--- a/gdb/cp-support.h
+++ b/gdb/cp-support.h
@@ -127,8 +127,7 @@ extern struct type *cp_lookup_rtti_type (const char *name,
    "function" or "bar::function" in all namespaces is possible.  */
 extern unsigned int cp_search_name_hash (const char *search_name);
 
-/* Implement the "la_get_symbol_name_matcher" language_defn method for
-   C++.  */
+/* Implement the "get_symbol_name_matcher" language_defn method for C++.  */
 extern symbol_name_matcher_ftype *cp_get_symbol_name_matcher
   (const lookup_name_info &lookup_name);
 
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index ad16f991dd3..4842d4b9d69 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -160,7 +160,6 @@ extern const struct language_data d_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
-  NULL,				/* la_get_symbol_name_matcher */
   &default_varobj_ops,
   c_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
diff --git a/gdb/dictionary.c b/gdb/dictionary.c
index da44946a98c..c94a49ee373 100644
--- a/gdb/dictionary.c
+++ b/gdb/dictionary.c
@@ -584,7 +584,7 @@ iter_match_first_hashed (const struct dictionary *dict,
   unsigned int hash_index = (name.search_name_hash (lang->la_language)
 			     % DICT_HASHED_NBUCKETS (dict));
   symbol_name_matcher_ftype *matches_name
-    = get_symbol_name_matcher (lang, name);
+    = lang->get_symbol_name_matcher (name);
   struct symbol *sym;
 
   DICT_ITERATOR_DICT (iterator) = dict;
@@ -612,7 +612,7 @@ iter_match_next_hashed (const lookup_name_info &name,
 {
   const language_defn *lang = DICT_LANGUAGE (DICT_ITERATOR_DICT (iterator));
   symbol_name_matcher_ftype *matches_name
-    = get_symbol_name_matcher (lang, name);
+    = lang->get_symbol_name_matcher (name);
   struct symbol *next;
 
   for (next = DICT_ITERATOR_CURRENT (iterator)->hash_next;
@@ -828,7 +828,7 @@ iter_match_next_linear (const lookup_name_info &name,
   const struct dictionary *dict = DICT_ITERATOR_DICT (iterator);
   const language_defn *lang = DICT_LANGUAGE (dict);
   symbol_name_matcher_ftype *matches_name
-    = get_symbol_name_matcher (lang, name);
+    = lang->get_symbol_name_matcher (name);
 
   int i, nsyms = DICT_LINEAR_NSYMS (dict);
   struct symbol *sym, *retval = NULL;
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index daf66725eb3..30d62b2c436 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -4062,7 +4062,7 @@ dw2_expand_symtabs_matching_symbol
 
       const language_defn *lang = language_def (lang_e);
       symbol_name_matcher_ftype *name_matcher
-	= get_symbol_name_matcher (lang, lookup_name_without_params);
+	= lang->get_symbol_name_matcher (lookup_name_without_params);
 
       name_and_matcher key {
          name_matcher,
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index d748db82e4f..42e6c988f3d 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -620,7 +620,6 @@ extern const struct language_data f_language_data =
   f_word_break_characters,
   f_collect_symbol_completion_matches,
   c_watch_location_expression,
-  cp_get_symbol_name_matcher,	/* la_get_symbol_name_matcher */
   &default_varobj_ops,
   f_is_string_type_p,
   "(...)"			/* la_struct_too_deep_ellipsis */
@@ -699,6 +698,16 @@ class f_language : public language_defn
   {
     f_print_type (type, varstring, stream, show, level, flags);
   }
+
+protected:
+
+  /* See language.h.  */
+
+  symbol_name_matcher_ftype *get_symbol_name_matcher_inner
+	(const lookup_name_info &lookup_name) const override
+  {
+    return cp_get_symbol_name_matcher (lookup_name);
+  }
 };
 
 /* Single instance of the Fortran language class.  */
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index 831a3e2bf32..d49d9e5fb17 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -545,7 +545,6 @@ extern const struct language_data go_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
-  NULL,				/* la_get_symbol_name_matcher */
   &default_varobj_ops,
   go_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
diff --git a/gdb/language.c b/gdb/language.c
index 2b2584f4976..363481bc9d5 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -622,9 +622,10 @@ language_defn::print_array_index (struct type *index_type, LONGEST index,
   fprintf_filtered (stream, "] = ");
 }
 
-/* See language.h.  */
+/* The default implementation of the get_symbol_name_matcher_inner method
+   from the language_defn class.  Matches with strncmp_iw.  */
 
-bool
+static bool
 default_symbol_name_matcher (const char *symbol_search_name,
 			     const lookup_name_info &lookup_name,
 			     completion_match_result *comp_match_res)
@@ -649,6 +650,31 @@ default_symbol_name_matcher (const char *symbol_search_name,
 
 /* See language.h.  */
 
+symbol_name_matcher_ftype *
+language_defn::get_symbol_name_matcher
+	(const lookup_name_info &lookup_name) const
+{
+  /* If currently in Ada mode, and the lookup name is wrapped in
+     '<...>', hijack all symbol name comparisons using the Ada
+     matcher, which handles the verbatim matching.  */
+  if (current_language->la_language == language_ada
+      && lookup_name.ada ().verbatim_p ())
+    return current_language->get_symbol_name_matcher_inner (lookup_name);
+
+  return this->get_symbol_name_matcher_inner (lookup_name);
+}
+
+/* See language.h.  */
+
+symbol_name_matcher_ftype *
+language_defn::get_symbol_name_matcher_inner
+	(const lookup_name_info &lookup_name) const
+{
+  return default_symbol_name_matcher;
+}
+
+/* See language.h.  */
+
 bool
 default_is_string_type_p (struct type *type)
 {
@@ -661,24 +687,6 @@ default_is_string_type_p (struct type *type)
   return (type->code ()  == TYPE_CODE_STRING);
 }
 
-/* See language.h.  */
-
-symbol_name_matcher_ftype *
-get_symbol_name_matcher (const language_defn *lang,
-			 const lookup_name_info &lookup_name)
-{
-  /* If currently in Ada mode, and the lookup name is wrapped in
-     '<...>', hijack all symbol name comparisons using the Ada
-     matcher, which handles the verbatim matching.  */
-  if (current_language->la_language == language_ada
-      && lookup_name.ada ().verbatim_p ())
-    return current_language->la_get_symbol_name_matcher (lookup_name);
-
-  if (lang->la_get_symbol_name_matcher != nullptr)
-    return lang->la_get_symbol_name_matcher (lookup_name);
-  return default_symbol_name_matcher;
-}
-
 /* Define the language that is no language.  */
 
 static int
@@ -774,7 +782,6 @@ extern const struct language_data unknown_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
-  NULL,				/* la_get_symbol_name_matcher */
   &default_varobj_ops,
   default_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
@@ -848,7 +855,6 @@ extern const struct language_data auto_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
-  NULL,				/* la_get_symbol_name_matcher */
   &default_varobj_ops,
   default_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
diff --git a/gdb/language.h b/gdb/language.h
index 523a7a923be..7e5837fdef3 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -338,19 +338,6 @@ struct language_data
     gdb::unique_xmalloc_ptr<char> (*la_watch_location_expression)
          (struct type *type, CORE_ADDR addr);
 
-    /* Return a pointer to the function that should be used to match a
-       symbol name against LOOKUP_NAME, according to this language's
-       rules.  The matching algorithm depends on LOOKUP_NAME.  For
-       example, on Ada, the matching algorithm depends on the symbol
-       name (wild/full/verbatim matching), and on whether we're doing
-       a normal lookup or a completion match lookup.
-
-       This field may be NULL, in which case
-       default_symbol_name_matcher is used to perform the
-       matching.  */
-    symbol_name_matcher_ftype *(*la_get_symbol_name_matcher)
-      (const lookup_name_info &);
-
     /* Various operations on varobj.  */
     const struct lang_varobj_ops *la_varobj_ops;
 
@@ -443,6 +430,20 @@ struct language_defn : language_data
     return ::iterate_over_symbols (block, name, domain, callback);
   }
 
+  /* Return a pointer to the function that should be used to match a
+     symbol name against LOOKUP_NAME, according to this language's
+     rules.  The matching algorithm depends on LOOKUP_NAME.  For
+     example, on Ada, the matching algorithm depends on the symbol
+     name (wild/full/verbatim matching), and on whether we're doing
+     a normal lookup or a completion match lookup.
+
+     As Ada wants to capture symbol matching for all languages in some
+     cases, then this method is a non-overridable interface.  Languages
+     should override GET_SYMBOL_NAME_MATCHER_INNER if they need to.  */
+
+  symbol_name_matcher_ftype *get_symbol_name_matcher
+	(const lookup_name_info &lookup_name) const;
+
   /* If this language allows compilation from the gdb command line, then
      this method will return an instance of struct gcc_context appropriate
      to the language.  If compilation for this language is generally
@@ -530,6 +531,14 @@ struct language_defn : language_data
 
   /* List of all known languages.  */
   static const struct language_defn *languages[nr_languages];
+
+protected:
+
+  /* This is the overridable part of the GET_SYMBOL_NAME_MATCHER method.
+     See that method for a description of the arguments.  */
+
+  virtual symbol_name_matcher_ftype *get_symbol_name_matcher_inner
+	  (const lookup_name_info &lookup_name) const;
 };
 
 /* Pointer to the language_defn for our current language.  This pointer
@@ -698,13 +707,6 @@ void c_get_string (struct value *value,
 		   int *length, struct type **char_type,
 		   const char **charset);
 
-/* The default implementation of la_symbol_name_matcher.  Matches with
-   strncmp_iw.  */
-extern bool default_symbol_name_matcher
-  (const char *symbol_search_name,
-   const lookup_name_info &lookup_name,
-   completion_match_result *comp_match_res);
-
 /* Get LANG's symbol_name_matcher method for LOOKUP_NAME.  Returns
    default_symbol_name_matcher if not set.  LANG is used as a hint;
    the function may ignore it depending on the current language and
diff --git a/gdb/linespec.c b/gdb/linespec.c
index ddca05b3dbf..4a634e3aff9 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -1232,7 +1232,7 @@ find_methods (struct type *t, enum language t_lang, const char *name,
       int method_counter;
       lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
       symbol_name_matcher_ftype *symbol_name_compare
-	= get_symbol_name_matcher (language_def (t_lang), lookup_name);
+	= language_def (t_lang)->get_symbol_name_matcher (lookup_name);
 
       t = check_typedef (t);
 
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index fe8739ef0dc..bffe6c96d57 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -379,7 +379,6 @@ extern const struct language_data m2_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
-  NULL,				/* la_get_symbol_name_matcher */
   &default_varobj_ops,
   m2_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 47c6f0bc0cd..f4a2544eb19 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -363,8 +363,8 @@ lookup_minimal_symbol (const char *name, const char *sfile,
 		       % MINIMAL_SYMBOL_HASH_SIZE);
 
 		  symbol_name_matcher_ftype *match
-		    = get_symbol_name_matcher (language_def (lang),
-					       lookup_name);
+		    = language_def (lang)->get_symbol_name_matcher
+							(lookup_name);
 		  struct minimal_symbol **msymbol_demangled_hash
 		    = objfile->per_bfd->msymbol_demangled_hash;
 
@@ -507,7 +507,7 @@ iterate_over_minimal_symbols
       enum language lang = (enum language) liter;
       const language_defn *lang_def = language_def (lang);
       symbol_name_matcher_ftype *name_match
-	= get_symbol_name_matcher (lang_def, lookup_name);
+	= lang_def->get_symbol_name_matcher (lookup_name);
 
       unsigned int hash
 	= lookup_name.search_name_hash (lang) % MINIMAL_SYMBOL_HASH_SIZE;
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 8b23c557984..9a77f6cb96d 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -354,7 +354,6 @@ extern const struct language_data objc_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
-  NULL,				/* la_get_symbol_name_matcher */
   &default_varobj_ops,
   c_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index 00f88c60373..377c550d5a6 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -1033,7 +1033,6 @@ extern const struct language_data opencl_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
-  NULL,				/* la_get_symbol_name_matcher */
   &default_varobj_ops,
   c_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index 9a657e26c75..61089bd1399 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -410,7 +410,6 @@ extern const struct language_data pascal_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
-  NULL,				/* la_compare_symbol_for_completion */
   &default_varobj_ops,
   pascal_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 5960c593fcf..47e31aab61e 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -557,7 +557,7 @@ psymbol_name_matches (partial_symbol *psym,
 {
   const language_defn *lang = language_def (psym->ginfo.language ());
   symbol_name_matcher_ftype *name_match
-    = get_symbol_name_matcher (lang, lookup_name);
+    = lang->get_symbol_name_matcher (lookup_name);
   return name_match (psym->ginfo.search_name (), lookup_name, NULL);
 }
 
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 73bc3d621b1..74ddcc17095 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -2065,7 +2065,6 @@ extern const struct language_data rust_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   rust_watch_location_expression,
-  NULL,				/* la_get_symbol_name_matcher */
   &default_varobj_ops,
   rust_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 791ce11a737..be349911995 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -1016,7 +1016,7 @@ symbol_matches_search_name (const struct general_symbol_info *gsymbol,
 			    const lookup_name_info &name)
 {
   symbol_name_matcher_ftype *name_match
-    = get_symbol_name_matcher (language_def (gsymbol->language ()), name);
+    = language_def (gsymbol->language ())->get_symbol_name_matcher (name);
   return name_match (gsymbol->search_name (), name, NULL);
 }
 
@@ -5253,7 +5253,7 @@ compare_symbol_name (const char *symbol_name, language symbol_language,
   const language_defn *lang = language_def (symbol_language);
 
   symbol_name_matcher_ftype *name_match
-    = get_symbol_name_matcher (lang, lookup_name);
+    = lang->get_symbol_name_matcher (lookup_name);
 
   return name_match (symbol_name, lookup_name, &match_res);
 }
-- 
2.25.4


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 4/9] gdb: Convert language la_word_break_characters field to a method
  2020-06-02 13:32 [PATCH 0/9] Further Conversion of Language Class Hierarchy Andrew Burgess
                   ` (2 preceding siblings ...)
  2020-06-02 13:32 ` [PATCH 3/9] gdb: Convert language la_get_symbol_name_matcher " Andrew Burgess
@ 2020-06-02 13:32 ` Andrew Burgess
  2020-06-02 13:32 ` [PATCH 5/9] gdb: Convert language la_collect_symbol_completion_matches " Andrew Burgess
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Andrew Burgess @ 2020-06-02 13:32 UTC (permalink / raw)
  To: gdb-patches

This commit changes the language_data::la_word_break_characters
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_get_gdb_completer_word_break_characters): Delete.
	(ada_language_data): Delete la_word_break_characters initializer.
	(ada_language::word_break_characters): New member function.
	* c-lang.c (c_language_data): Delete la_word_break_characters
	initializer.
	(cplus_language_data): Likewise.
	(asm_language_data): Likewise.
	(minimal_language_data): Likewise.
	* completer.c: Update global comment.
	(advance_to_expression_complete_word_point): Update call to
	word_break_characters.
	(complete_files_symbols): Likewise.
	(complete_line_internal_1): Likewise.
	(default_completer_handle_brkchars): Likewise.
	(skip_quoted_chars): Likewise.
	* d-lang.c (d_language_data): Delete la_word_break_characters
	initializer.
	* f-lang.c (f_word_break_characters): Delete.
	(f_language_data): Delete la_word_break_characters initializer.
	(f_language::word_break_characters): New member function.
	* go-lang.c (go_language_data): Delete la_word_break_characters
	initializer.
	* language.c (unknown_language_data): Likewise.
	(auto_language_data): Likewise.
	* language.h (default_word_break_characters): Move declaration to
	earlier in the file.
	(language_data): Delete la_word_break_characters field.
	(language_defn::word_break_characters): New member function.
	* m2-lang.c (m2_language_data): Delete la_word_break_characters
	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     | 37 +++++++++++++++++++++++++++++++++++
 gdb/ada-lang.c    | 14 +++++++-------
 gdb/c-lang.c      |  4 ----
 gdb/completer.c   | 12 ++++++------
 gdb/d-lang.c      |  1 -
 gdb/f-lang.c      | 49 +++++++++++++++++++++++------------------------
 gdb/go-lang.c     |  1 -
 gdb/language.c    |  2 --
 gdb/language.h    | 15 +++++++++------
 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 -
 14 files changed, 83 insertions(+), 57 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 8747501fa17..abb95a22375 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -488,12 +488,6 @@ add_angle_brackets (const char *str)
   return string_printf ("<%s>", str);
 }
 
-static const char *
-ada_get_gdb_completer_word_break_characters (void)
-{
-  return ada_completer_word_break_characters;
-}
-
 /* la_watch_location_expression for Ada.  */
 
 static gdb::unique_xmalloc_ptr<char>
@@ -13928,7 +13922,6 @@ extern const struct language_data ada_language_data =
   ada_op_print_tab,             /* expression operators for printing */
   0,                            /* c-style arrays */
   1,                            /* String lower bound */
-  ada_get_gdb_completer_word_break_characters,
   ada_collect_symbol_completion_matches,
   ada_watch_location_expression,
   &ada_varobj_ops,
@@ -14116,6 +14109,13 @@ class ada_language : public language_defn
     ada_print_type (type, varstring, stream, show, level, flags);
   }
 
+  /* See language.h.  */
+
+  const char *word_break_characters (void) const override
+  {
+    return ada_completer_word_break_characters;
+  }
+
 protected:
   /* See language.h.  */
 
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 3a0bb209535..44aa544337a 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -914,7 +914,6 @@ extern const struct language_data c_language_data =
   c_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
-  default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &c_varobj_ops,
@@ -1028,7 +1027,6 @@ extern const struct language_data cplus_language_data =
   c_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
-  default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &cplus_varobj_ops,
@@ -1230,7 +1228,6 @@ extern const struct language_data asm_language_data =
   c_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
-  default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
@@ -1299,7 +1296,6 @@ extern const struct language_data minimal_language_data =
   c_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
-  default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
diff --git a/gdb/completer.c b/gdb/completer.c
index ad33b98c696..a2c2f7ea549 100644
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -155,7 +155,7 @@ enum explicit_location_match_type
    but it does affect how much stuff M-? lists.
    (2) If one of the matches contains a word break character, readline
    will quote it.  That's why we switch between
-   current_language->la_word_break_characters() and
+   current_language->word_break_characters () and
    gdb_completer_command_word_break_characters.  I'm not sure when
    we need this behavior (perhaps for funky characters in C++ 
    symbols?).  */
@@ -448,7 +448,7 @@ const char *
 advance_to_expression_complete_word_point (completion_tracker &tracker,
 					   const char *text)
 {
-  const char *brk_chars = current_language->la_word_break_characters ();
+  const char *brk_chars = current_language->word_break_characters ();
   return advance_to_completion_word (tracker, brk_chars, text);
 }
 
@@ -573,7 +573,7 @@ complete_files_symbols (completion_tracker &tracker,
 	  colon = p;
 	  symbol_start = p + 1;
 	}
-      else if (strchr (current_language->la_word_break_characters(), *p))
+      else if (strchr (current_language->word_break_characters (), *p))
 	symbol_start = p + 1;
     }
 
@@ -1348,7 +1348,7 @@ complete_line_internal_1 (completion_tracker &tracker,
      strings, which leaves out the '-' and '.' character used in some
      commands.  */
   set_rl_completer_word_break_characters
-    (current_language->la_word_break_characters());
+    (current_language->word_break_characters ());
 
   /* Decide whether to complete on a list of gdb commands or on
      symbols.  */
@@ -1964,7 +1964,7 @@ default_completer_handle_brkchars (struct cmd_list_element *ignore,
 				   const char *text, const char *word)
 {
   set_rl_completer_word_break_characters
-    (current_language->la_word_break_characters ());
+    (current_language->word_break_characters ());
 }
 
 /* See definition in completer.h.  */
@@ -2473,7 +2473,7 @@ skip_quoted_chars (const char *str, const char *quotechars,
     quotechars = gdb_completer_quote_characters;
 
   if (breakchars == NULL)
-    breakchars = current_language->la_word_break_characters();
+    breakchars = current_language->word_break_characters ();
 
   for (scan = str; *scan != '\0'; scan++)
     {
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index 4842d4b9d69..56feda1268f 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -157,7 +157,6 @@ extern const struct language_data d_language_data =
   d_op_print_tab,		/* Expression operators for printing.  */
   1,				/* C-style arrays.  */
   0,				/* String lower bound.  */
-  default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 42e6c988f3d..27495cf63f1 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -165,30 +165,6 @@ enum f_primitive_types {
   nr_f_primitive_types
 };
 
-/* Remove the modules separator :: from the default break list.  */
-
-static const char *
-f_word_break_characters (void)
-{
-  static char *retval;
-
-  if (!retval)
-    {
-      char *s;
-
-      retval = xstrdup (default_word_break_characters ());
-      s = strchr (retval, ':');
-      if (s)
-	{
-	  char *last_char = &s[strlen (s) - 1];
-
-	  *s = *last_char;
-	  *last_char = 0;
-	}
-    }
-  return retval;
-}
-
 /* Consider the modules separator :: as a valid symbol name character
    class.  */
 
@@ -617,7 +593,6 @@ extern const struct language_data f_language_data =
   f_op_print_tab,		/* expression operators for printing */
   0,				/* arrays are first-class (not c-style) */
   1,				/* String lower bound */
-  f_word_break_characters,
   f_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
@@ -699,6 +674,30 @@ class f_language : public language_defn
     f_print_type (type, varstring, stream, show, level, flags);
   }
 
+  /* See language.h.  This just returns default set of word break
+     characters but with the modules separator `::' removed.  */
+
+  const char *word_break_characters (void) const override
+  {
+    static char *retval;
+
+    if (!retval)
+      {
+	char *s;
+
+	retval = xstrdup (language_defn::word_break_characters ());
+	s = strchr (retval, ':');
+	if (s)
+	  {
+	    char *last_char = &s[strlen (s) - 1];
+
+	    *s = *last_char;
+	    *last_char = 0;
+	  }
+      }
+    return retval;
+  }
+
 protected:
 
   /* See language.h.  */
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index d49d9e5fb17..7ea1d6165a6 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -542,7 +542,6 @@ extern const struct language_data go_language_data =
   go_op_print_tab,		/* Expression operators for printing.  */
   1,				/* C-style arrays.  */
   0,				/* String lower bound.  */
-  default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
diff --git a/gdb/language.c b/gdb/language.c
index 363481bc9d5..167a68c9203 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -779,7 +779,6 @@ extern const struct language_data unknown_language_data =
   unk_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
-  default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
@@ -852,7 +851,6 @@ extern const struct language_data auto_language_data =
   unk_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
-  default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
diff --git a/gdb/language.h b/gdb/language.h
index 7e5837fdef3..8c6f7e3fb13 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -169,6 +169,9 @@ struct language_pass_by_ref_info
   bool destructible = true;
 };
 
+/* Splitting strings into words.  */
+extern const char *default_word_break_characters (void);
+
 /* Structure tying together assorted information about a language.
 
    As we move over from the old structure based languages to a class
@@ -316,9 +319,6 @@ struct language_data
     /* Index to use for extracting the first element of a string.  */
     char string_lower_bound;
 
-    /* The list of characters forming word boundaries.  */
-    const char *(*la_word_break_characters) (void);
-
     /* Add to the completion tracker all symbols which are possible
        completions for TEXT.  WORD is the entire command on which the
        completion is being made.  If CODE is TYPE_CODE_UNDEF, then all
@@ -529,6 +529,12 @@ struct language_defn : language_data
     return nullptr;
   }
 
+  /* The list of characters forming word boundaries.  */
+  virtual const char *word_break_characters (void) const
+  {
+    return default_word_break_characters ();
+  }
+
   /* List of all known languages.  */
   static const struct language_defn *languages[nr_languages];
 
@@ -691,9 +697,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);
 
-/* Splitting strings into words.  */
-extern const char *default_word_break_characters (void);
-
 /* Return information about whether TYPE should be passed
    (and returned) by reference at the language level.  */
 struct language_pass_by_ref_info language_pass_by_reference (struct type *type);
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index bffe6c96d57..f9ed4897a1d 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -376,7 +376,6 @@ extern const struct language_data m2_language_data =
   m2_op_print_tab,		/* expression operators for printing */
   0,				/* arrays are first-class (not c-style) */
   0,				/* String lower bound */
-  default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 9a77f6cb96d..3bd71896aef 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -351,7 +351,6 @@ extern const struct language_data objc_language_data =
   objc_op_print_tab,		/* Expression operators for printing */
   1,				/* C-style arrays */
   0,				/* String lower bound */
-  default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index 377c550d5a6..3f0fb1fa948 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -1030,7 +1030,6 @@ extern const struct language_data opencl_language_data =
   c_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
-  default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index 61089bd1399..cc49f5bef0c 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -407,7 +407,6 @@ extern const struct language_data pascal_language_data =
   pascal_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
-  default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 74ddcc17095..b33740b9620 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -2062,7 +2062,6 @@ extern const struct language_data rust_language_data =
   c_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
-  default_word_break_characters,
   default_collect_symbol_completion_matches,
   rust_watch_location_expression,
   &default_varobj_ops,
-- 
2.25.4


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 5/9] gdb: Convert language la_collect_symbol_completion_matches field to a method
  2020-06-02 13:32 [PATCH 0/9] Further Conversion of Language Class Hierarchy Andrew Burgess
                   ` (3 preceding siblings ...)
  2020-06-02 13:32 ` [PATCH 4/9] gdb: Convert language la_word_break_characters " Andrew Burgess
@ 2020-06-02 13:32 ` Andrew Burgess
  2020-06-02 13:32 ` [PATCH 6/9] gdb: Convert language la_watch_location_expression " Andrew Burgess
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Andrew Burgess @ 2020-06-02 13:32 UTC (permalink / raw)
  To: gdb-patches

This commit changes the
language_data::la_collect_symbol_completion_matches 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_collect_symbol_completion_matches): Rename to
	ada_language::collect_symbol_completion_matches.
	(ada_language_data): Delete la_collect_symbol_completion_matches
	initializer.
	(ada_language::collect_symbol_completion_matches): New member
	function, implementation from
	ada_collect_symbol_completion_matches.
	* c-lang.c (c_language_data): Delete
	la_collect_symbol_completion_matches initializer.
	(cplus_language_data): Likewise.
	(asm_language_data): Likewise.
	(minimal_language_data): Likewise.
	* d-lang.c (d_language_data): Likewise.
	* f-lang.c (f_collect_symbol_completion_matches): Rename to
	f_language::collect_symbol_completion_matches.
	(f_language_data): Delete la_collect_symbol_completion_matches
	initializer.
	(f_language::collect_symbol_completion_matches) New member
	function, implementation from f_collect_symbol_completion_matches.
	* go-lang.c (go_language_data): Delete
	la_collect_symbol_completion_matches initializer.
	* language.c (unknown_language_data): Likewise.
	(auto_language_data): Likewise.
	* language.h (language_data): Delete
	la_collect_symbol_completion_matches field.
	(language_defn::collect_symbol_completion_matches): New member
	function.
	* m2-lang.c (m2_language_data): Delete
	la_collect_symbol_completion_matches 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.
	* symtab.c (default_collect_symbol_completion_matches): Delete.
	(collect_symbol_completion_matches): Update call to
	collect_symbol_completion_matches.
	(collect_symbol_completion_matches_type): Likewise.
	* symtab.h (default_collect_symbol_completion_matches): Delete
	declaration.
---
 gdb/ChangeLog     |  42 ++++++++
 gdb/ada-lang.c    | 255 +++++++++++++++++++++++-----------------------
 gdb/c-lang.c      |   4 -
 gdb/d-lang.c      |   1 -
 gdb/f-lang.c      |  33 +++---
 gdb/go-lang.c     |   1 -
 gdb/language.c    |   2 -
 gdb/language.h    |  31 +++---
 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/symtab.c      |  27 ++---
 gdb/symtab.h      |   7 --
 15 files changed, 210 insertions(+), 198 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index abb95a22375..08421c3fbf2 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -6280,134 +6280,6 @@ ada_lookup_name_info::matches
   return true;
 }
 
-/* Add the list of possible symbol names completing TEXT to TRACKER.
-   WORD is the entire command on which completion is made.  */
-
-static void
-ada_collect_symbol_completion_matches (completion_tracker &tracker,
-				       complete_symbol_mode mode,
-				       symbol_name_match_type name_match_type,
-				       const char *text, const char *word,
-				       enum type_code code)
-{
-  struct symbol *sym;
-  const struct block *b, *surrounding_static_block = 0;
-  struct block_iterator iter;
-
-  gdb_assert (code == TYPE_CODE_UNDEF);
-
-  lookup_name_info lookup_name (text, name_match_type, true);
-
-  /* First, look at the partial symtab symbols.  */
-  expand_symtabs_matching (NULL,
-			   lookup_name,
-			   NULL,
-			   NULL,
-			   ALL_DOMAIN);
-
-  /* At this point scan through the misc symbol vectors and add each
-     symbol you find to the list.  Eventually we want to ignore
-     anything that isn't a text symbol (everything else will be
-     handled by the psymtab code above).  */
-
-  for (objfile *objfile : current_program_space->objfiles ())
-    {
-      for (minimal_symbol *msymbol : objfile->msymbols ())
-	{
-	  QUIT;
-
-	  if (completion_skip_symbol (mode, msymbol))
-	    continue;
-
-	  language symbol_language = msymbol->language ();
-
-	  /* Ada minimal symbols won't have their language set to Ada.  If
-	     we let completion_list_add_name compare using the
-	     default/C-like matcher, then when completing e.g., symbols in a
-	     package named "pck", we'd match internal Ada symbols like
-	     "pckS", which are invalid in an Ada expression, unless you wrap
-	     them in '<' '>' to request a verbatim match.
-
-	     Unfortunately, some Ada encoded names successfully demangle as
-	     C++ symbols (using an old mangling scheme), such as "name__2Xn"
-	     -> "Xn::name(void)" and thus some Ada minimal symbols end up
-	     with the wrong language set.  Paper over that issue here.  */
-	  if (symbol_language == language_auto
-	      || symbol_language == language_cplus)
-	    symbol_language = language_ada;
-
-	  completion_list_add_name (tracker,
-				    symbol_language,
-				    msymbol->linkage_name (),
-				    lookup_name, text, word);
-	}
-    }
-
-  /* Search upwards from currently selected frame (so that we can
-     complete on local vars.  */
-
-  for (b = get_selected_block (0); b != NULL; b = BLOCK_SUPERBLOCK (b))
-    {
-      if (!BLOCK_SUPERBLOCK (b))
-        surrounding_static_block = b;   /* For elmin of dups */
-
-      ALL_BLOCK_SYMBOLS (b, iter, sym)
-      {
-	if (completion_skip_symbol (mode, sym))
-	  continue;
-
-	completion_list_add_name (tracker,
-				  sym->language (),
-				  sym->linkage_name (),
-				  lookup_name, text, word);
-      }
-    }
-
-  /* Go through the symtabs and check the externs and statics for
-     symbols which match.  */
-
-  for (objfile *objfile : current_program_space->objfiles ())
-    {
-      for (compunit_symtab *s : objfile->compunits ())
-	{
-	  QUIT;
-	  b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (s), GLOBAL_BLOCK);
-	  ALL_BLOCK_SYMBOLS (b, iter, sym)
-	    {
-	      if (completion_skip_symbol (mode, sym))
-		continue;
-
-	      completion_list_add_name (tracker,
-					sym->language (),
-					sym->linkage_name (),
-					lookup_name, text, word);
-	    }
-	}
-    }
-
-  for (objfile *objfile : current_program_space->objfiles ())
-    {
-      for (compunit_symtab *s : objfile->compunits ())
-	{
-	  QUIT;
-	  b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (s), STATIC_BLOCK);
-	  /* Don't do this block twice.  */
-	  if (b == surrounding_static_block)
-	    continue;
-	  ALL_BLOCK_SYMBOLS (b, iter, sym)
-	    {
-	      if (completion_skip_symbol (mode, sym))
-		continue;
-
-	      completion_list_add_name (tracker,
-					sym->language (),
-					sym->linkage_name (),
-					lookup_name, text, word);
-	    }
-	}
-    }
-}
-
                                 /* Field Access */
 
 /* Return non-zero if TYPE is a pointer to the GNAT dispatch table used
@@ -13922,7 +13794,6 @@ extern const struct language_data ada_language_data =
   ada_op_print_tab,             /* expression operators for printing */
   0,                            /* c-style arrays */
   1,                            /* String lower bound */
-  ada_collect_symbol_completion_matches,
   ada_watch_location_expression,
   &ada_varobj_ops,
   ada_is_string_type,
@@ -14116,6 +13987,132 @@ class ada_language : public language_defn
     return ada_completer_word_break_characters;
   }
 
+  /* See language.h.  */
+
+  void collect_symbol_completion_matches (completion_tracker &tracker,
+					  complete_symbol_mode mode,
+					  symbol_name_match_type name_match_type,
+					  const char *text, const char *word,
+					  enum type_code code) const override
+  {
+    struct symbol *sym;
+    const struct block *b, *surrounding_static_block = 0;
+    struct block_iterator iter;
+
+    gdb_assert (code == TYPE_CODE_UNDEF);
+
+    lookup_name_info lookup_name (text, name_match_type, true);
+
+    /* First, look at the partial symtab symbols.  */
+    expand_symtabs_matching (NULL,
+			     lookup_name,
+			     NULL,
+			     NULL,
+			     ALL_DOMAIN);
+
+    /* At this point scan through the misc symbol vectors and add each
+       symbol you find to the list.  Eventually we want to ignore
+       anything that isn't a text symbol (everything else will be
+       handled by the psymtab code above).  */
+
+    for (objfile *objfile : current_program_space->objfiles ())
+      {
+	for (minimal_symbol *msymbol : objfile->msymbols ())
+	  {
+	    QUIT;
+
+	    if (completion_skip_symbol (mode, msymbol))
+	      continue;
+
+	    language symbol_language = msymbol->language ();
+
+	    /* Ada minimal symbols won't have their language set to Ada.  If
+	       we let completion_list_add_name compare using the
+	       default/C-like matcher, then when completing e.g., symbols in a
+	       package named "pck", we'd match internal Ada symbols like
+	       "pckS", which are invalid in an Ada expression, unless you wrap
+	       them in '<' '>' to request a verbatim match.
+
+	       Unfortunately, some Ada encoded names successfully demangle as
+	       C++ symbols (using an old mangling scheme), such as "name__2Xn"
+	       -> "Xn::name(void)" and thus some Ada minimal symbols end up
+	       with the wrong language set.  Paper over that issue here.  */
+	    if (symbol_language == language_auto
+		|| symbol_language == language_cplus)
+	      symbol_language = language_ada;
+
+	    completion_list_add_name (tracker,
+				      symbol_language,
+				      msymbol->linkage_name (),
+				      lookup_name, text, word);
+	  }
+      }
+
+    /* Search upwards from currently selected frame (so that we can
+       complete on local vars.  */
+
+    for (b = get_selected_block (0); b != NULL; b = BLOCK_SUPERBLOCK (b))
+      {
+	if (!BLOCK_SUPERBLOCK (b))
+	  surrounding_static_block = b;   /* For elmin of dups */
+
+	ALL_BLOCK_SYMBOLS (b, iter, sym)
+	  {
+	    if (completion_skip_symbol (mode, sym))
+	      continue;
+
+	    completion_list_add_name (tracker,
+				      sym->language (),
+				      sym->linkage_name (),
+				      lookup_name, text, word);
+	  }
+      }
+
+    /* Go through the symtabs and check the externs and statics for
+       symbols which match.  */
+
+    for (objfile *objfile : current_program_space->objfiles ())
+      {
+	for (compunit_symtab *s : objfile->compunits ())
+	  {
+	    QUIT;
+	    b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (s), GLOBAL_BLOCK);
+	    ALL_BLOCK_SYMBOLS (b, iter, sym)
+	      {
+		if (completion_skip_symbol (mode, sym))
+		  continue;
+
+		completion_list_add_name (tracker,
+					  sym->language (),
+					  sym->linkage_name (),
+					  lookup_name, text, word);
+	      }
+	  }
+      }
+
+    for (objfile *objfile : current_program_space->objfiles ())
+      {
+	for (compunit_symtab *s : objfile->compunits ())
+	  {
+	    QUIT;
+	    b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (s), STATIC_BLOCK);
+	    /* Don't do this block twice.  */
+	    if (b == surrounding_static_block)
+	      continue;
+	    ALL_BLOCK_SYMBOLS (b, iter, sym)
+	      {
+		if (completion_skip_symbol (mode, sym))
+		  continue;
+
+		completion_list_add_name (tracker,
+					  sym->language (),
+					  sym->linkage_name (),
+					  lookup_name, text, word);
+	      }
+	  }
+      }
+  }
+
 protected:
   /* See language.h.  */
 
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 44aa544337a..d6b32eef175 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -914,7 +914,6 @@ extern const struct language_data c_language_data =
   c_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
-  default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &c_varobj_ops,
   c_is_string_type_p,
@@ -1027,7 +1026,6 @@ extern const struct language_data cplus_language_data =
   c_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
-  default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &cplus_varobj_ops,
   c_is_string_type_p,
@@ -1228,7 +1226,6 @@ extern const struct language_data asm_language_data =
   c_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
-  default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
   c_is_string_type_p,
@@ -1296,7 +1293,6 @@ extern const struct language_data minimal_language_data =
   c_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
-  default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
   c_is_string_type_p,
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index 56feda1268f..67c82e4215e 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -157,7 +157,6 @@ extern const struct language_data d_language_data =
   d_op_print_tab,		/* Expression operators for printing.  */
   1,				/* C-style arrays.  */
   0,				/* String lower bound.  */
-  default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
   c_is_string_type_p,
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 27495cf63f1..0540ab233db 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -165,21 +165,6 @@ enum f_primitive_types {
   nr_f_primitive_types
 };
 
-/* Consider the modules separator :: as a valid symbol name character
-   class.  */
-
-static void
-f_collect_symbol_completion_matches (completion_tracker &tracker,
-				     complete_symbol_mode mode,
-				     symbol_name_match_type compare_name,
-				     const char *text, const char *word,
-				     enum type_code code)
-{
-  default_collect_symbol_completion_matches_break_on (tracker, mode,
-						      compare_name,
-						      text, word, ":", code);
-}
-
 /* Special expression evaluation cases for Fortran.  */
 
 static struct value *
@@ -593,7 +578,6 @@ extern const struct language_data f_language_data =
   f_op_print_tab,		/* expression operators for printing */
   0,				/* arrays are first-class (not c-style) */
   1,				/* String lower bound */
-  f_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
   f_is_string_type_p,
@@ -698,6 +682,23 @@ class f_language : public language_defn
     return retval;
   }
 
+
+  /* See language.h.  */
+
+  void collect_symbol_completion_matches (completion_tracker &tracker,
+					  complete_symbol_mode mode,
+					  symbol_name_match_type name_match_type,
+					  const char *text, const char *word,
+					  enum type_code code) const override
+  {
+    /* Consider the modules separator :: as a valid symbol name character
+       class.  */
+    default_collect_symbol_completion_matches_break_on (tracker, mode,
+							name_match_type,
+							text, word, ":",
+							code);
+  }
+
 protected:
 
   /* See language.h.  */
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index 7ea1d6165a6..a1af67deaae 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -542,7 +542,6 @@ extern const struct language_data go_language_data =
   go_op_print_tab,		/* Expression operators for printing.  */
   1,				/* C-style arrays.  */
   0,				/* String lower bound.  */
-  default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
   go_is_string_type_p,
diff --git a/gdb/language.c b/gdb/language.c
index 167a68c9203..f4e99fc392f 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -779,7 +779,6 @@ extern const struct language_data unknown_language_data =
   unk_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
-  default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
   default_is_string_type_p,
@@ -851,7 +850,6 @@ extern const struct language_data auto_language_data =
   unk_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
-  default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
   default_is_string_type_p,
diff --git a/gdb/language.h b/gdb/language.h
index 8c6f7e3fb13..5872db39dbb 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -319,19 +319,6 @@ struct language_data
     /* Index to use for extracting the first element of a string.  */
     char string_lower_bound;
 
-    /* Add to the completion tracker all symbols which are possible
-       completions for TEXT.  WORD is the entire command on which the
-       completion is being made.  If CODE is TYPE_CODE_UNDEF, then all
-       symbols should be examined; otherwise, only STRUCT_DOMAIN
-       symbols whose type has a code of CODE should be matched.  */
-    void (*la_collect_symbol_completion_matches)
-      (completion_tracker &tracker,
-       complete_symbol_mode mode,
-       symbol_name_match_type match_type,
-       const char *text,
-       const char *word,
-       enum type_code code);
-
     /* Return an expression that can be used for a location
        watchpoint.  TYPE is a pointer type that points to the memory
        to watch, and ADDR is the address of the watched memory.  */
@@ -535,6 +522,24 @@ struct language_defn : language_data
     return default_word_break_characters ();
   }
 
+  /* Add to the completion tracker all symbols which are possible
+     completions for TEXT.  WORD is the entire command on which the
+     completion is being made.  If CODE is TYPE_CODE_UNDEF, then all
+     symbols should be examined; otherwise, only STRUCT_DOMAIN symbols
+     whose type has a code of CODE should be matched.  */
+
+  virtual void collect_symbol_completion_matches
+	(completion_tracker &tracker,
+	 complete_symbol_mode mode,
+	 symbol_name_match_type name_match_type,
+	 const char *text,
+	 const char *word,
+	 enum type_code code) const
+  {
+    return default_collect_symbol_completion_matches_break_on
+      (tracker, mode, name_match_type, text, word, "", code);
+  }
+
   /* List of all known languages.  */
   static const struct language_defn *languages[nr_languages];
 
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index f9ed4897a1d..a028a2f2e22 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -376,7 +376,6 @@ extern const struct language_data m2_language_data =
   m2_op_print_tab,		/* expression operators for printing */
   0,				/* arrays are first-class (not c-style) */
   0,				/* String lower bound */
-  default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
   m2_is_string_type_p,
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 3bd71896aef..5f9e9710366 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -351,7 +351,6 @@ extern const struct language_data objc_language_data =
   objc_op_print_tab,		/* Expression operators for printing */
   1,				/* C-style arrays */
   0,				/* String lower bound */
-  default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
   c_is_string_type_p,
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index 3f0fb1fa948..d93ce0bc478 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -1030,7 +1030,6 @@ extern const struct language_data opencl_language_data =
   c_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
-  default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
   c_is_string_type_p,
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index cc49f5bef0c..cdcf726ce9c 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -407,7 +407,6 @@ extern const struct language_data pascal_language_data =
   pascal_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
-  default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
   pascal_is_string_type_p,
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index b33740b9620..a4e473d2f6f 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -2062,7 +2062,6 @@ extern const struct language_data rust_language_data =
   c_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
-  default_collect_symbol_completion_matches,
   rust_watch_location_expression,
   &default_varobj_ops,
   rust_is_string_type_p,
diff --git a/gdb/symtab.c b/gdb/symtab.c
index be349911995..3cb1382a6a8 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -5801,19 +5801,6 @@ default_collect_symbol_completion_matches_break_on
     }
 }
 
-void
-default_collect_symbol_completion_matches (completion_tracker &tracker,
-					   complete_symbol_mode mode,
-					   symbol_name_match_type name_match_type,
-					   const char *text, const char *word,
-					   enum type_code code)
-{
-  return default_collect_symbol_completion_matches_break_on (tracker, mode,
-							     name_match_type,
-							     text, word, "",
-							     code);
-}
-
 /* Collect all symbols (regardless of class) which begin by matching
    TEXT.  */
 
@@ -5823,10 +5810,10 @@ collect_symbol_completion_matches (completion_tracker &tracker,
 				   symbol_name_match_type name_match_type,
 				   const char *text, const char *word)
 {
-  current_language->la_collect_symbol_completion_matches (tracker, mode,
-							  name_match_type,
-							  text, word,
-							  TYPE_CODE_UNDEF);
+  current_language->collect_symbol_completion_matches (tracker, mode,
+						       name_match_type,
+						       text, word,
+						       TYPE_CODE_UNDEF);
 }
 
 /* Like collect_symbol_completion_matches, but only collect
@@ -5843,9 +5830,9 @@ collect_symbol_completion_matches_type (completion_tracker &tracker,
   gdb_assert (code == TYPE_CODE_UNION
 	      || code == TYPE_CODE_STRUCT
 	      || code == TYPE_CODE_ENUM);
-  current_language->la_collect_symbol_completion_matches (tracker, mode,
-							  name_match_type,
-							  text, word, code);
+  current_language->collect_symbol_completion_matches (tracker, mode,
+						       name_match_type,
+						       text, word, code);
 }
 
 /* Like collect_symbol_completion_matches, but collects a list of
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 9972e8125ba..bf02828d12c 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1952,13 +1952,6 @@ extern void default_collect_symbol_completion_matches_break_on
    symbol_name_match_type name_match_type,
    const char *text, const char *word, const char *break_on,
    enum type_code code);
-extern void default_collect_symbol_completion_matches
-  (completion_tracker &tracker,
-   complete_symbol_mode,
-   symbol_name_match_type name_match_type,
-   const char *,
-   const char *,
-   enum type_code);
 extern void collect_symbol_completion_matches
   (completion_tracker &tracker,
    complete_symbol_mode mode,
-- 
2.25.4


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 6/9] gdb: Convert language la_watch_location_expression field to a method
  2020-06-02 13:32 [PATCH 0/9] Further Conversion of Language Class Hierarchy Andrew Burgess
                   ` (4 preceding siblings ...)
  2020-06-02 13:32 ` [PATCH 5/9] gdb: Convert language la_collect_symbol_completion_matches " Andrew Burgess
@ 2020-06-02 13:32 ` Andrew Burgess
  2020-06-02 13:32 ` [PATCH 7/9] gdb: Convert language la_value_print " Andrew Burgess
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Andrew Burgess @ 2020-06-02 13:32 UTC (permalink / raw)
  To: gdb-patches

This commit changes the language_data::la_watch_location_expression
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_watch_location_expression): Rename to
	ada_language::watch_location_expression.
	(ada_language_data): Delete la_watch_location_expression
	initializer.
	(ada_language::watch_location_expression): New member function,
	implementation from ada_watch_location_expression.
	* breakpoint.c (watch_command_1): Update call to
	watch_location_expression.
	* c-lang.c (c_watch_location_expression): Rename to
	language_defn::watch_location_expression.
	(c_language_data): Delete la_watch_location_expression
	initializer.
	(cplus_language_data): Likewise.
	(asm_language_data): Likewise.
	(minimal_language_data): Likewise.
	* c-lang.h (c_watch_location_expression): Delete declaration.
	* d-lang.c (d_language_data): Delete la_watch_location_expression
	initializer.
	* f-lang.c (f_language_data): Likewise.
	* go-lang.c (go_language_data): Likewise.
	* language.c (language_defn::watch_location_expression): Member
	function implementation from c_watch_location_expression.
	(unknown_language_data): Delete la_watch_location_expression
	initializer.
	(auto_language_data): Likewise.
	* language.h (language_data): Delete la_watch_location_expression
	field.
	(language_defn::watch_location_expression): Declare new member
	function.
	* m2-lang.c (m2_language_data): Delete
	la_watch_location_expression 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_watch_location_expression): Rename to
	rust_language::watch_location_expression.
	(rust_language_data): Delete la_watch_location_expression
	initializer.
	(rust_language::watch_location_expression): New member function,
	implementation from rust_watch_location_expression.
---
 gdb/ChangeLog     | 43 +++++++++++++++++++++++++++++++++++++++++++
 gdb/ada-lang.c    | 23 +++++++++++------------
 gdb/breakpoint.c  |  2 +-
 gdb/c-lang.c      | 15 ---------------
 gdb/c-lang.h      |  3 ---
 gdb/d-lang.c      |  1 -
 gdb/f-lang.c      |  1 -
 gdb/go-lang.c     |  1 -
 gdb/language.c    | 15 +++++++++++++--
 gdb/language.h    | 12 ++++++------
 gdb/m2-lang.c     |  1 -
 gdb/objc-lang.c   |  1 -
 gdb/opencl-lang.c |  1 -
 gdb/p-lang.c      |  1 -
 gdb/rust-lang.c   | 27 ++++++++++++---------------
 15 files changed, 86 insertions(+), 61 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 08421c3fbf2..6c95d20162d 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -488,17 +488,6 @@ add_angle_brackets (const char *str)
   return string_printf ("<%s>", str);
 }
 
-/* la_watch_location_expression for Ada.  */
-
-static gdb::unique_xmalloc_ptr<char>
-ada_watch_location_expression (struct type *type, CORE_ADDR addr)
-{
-  type = check_typedef (TYPE_TARGET_TYPE (check_typedef (type)));
-  std::string name = type_to_string (type);
-  return gdb::unique_xmalloc_ptr<char>
-    (xstrprintf ("{%s} %s", name.c_str (), core_addr_to_string (addr)));
-}
-
 /* Assuming V points to an array of S objects,  make sure that it contains at
    least M objects, updating V and S as necessary.  */
 
@@ -13794,7 +13783,6 @@ extern const struct language_data ada_language_data =
   ada_op_print_tab,             /* expression operators for printing */
   0,                            /* c-style arrays */
   1,                            /* String lower bound */
-  ada_watch_location_expression,
   &ada_varobj_ops,
   ada_is_string_type,
   "(...)"			/* la_struct_too_deep_ellipsis */
@@ -14113,6 +14101,17 @@ class ada_language : public language_defn
       }
   }
 
+  /* See language.h.  */
+
+  gdb::unique_xmalloc_ptr<char> watch_location_expression
+	(struct type *type, CORE_ADDR addr) const override
+  {
+    type = check_typedef (TYPE_TARGET_TYPE (check_typedef (type)));
+    std::string name = type_to_string (type);
+    return gdb::unique_xmalloc_ptr<char>
+      (xstrprintf ("{%s} %s", name.c_str (), core_addr_to_string (addr)));
+  }
+
 protected:
   /* See language.h.  */
 
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index aead882acd8..6d81323dd92 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -10738,7 +10738,7 @@ watch_command_1 (const char *arg, int accessflag, int from_tty,
       CORE_ADDR addr = value_as_address (val.get ());
 
       w->exp_string_reparse
-	= current_language->la_watch_location_expression (t, addr).release ();
+	= current_language->watch_location_expression (t, addr).release ();
 
       w->exp_string = xstrprintf ("-location %.*s",
 				  (int) (exp_end - exp_start), exp_start);
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index d6b32eef175..13d13435fe4 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -727,17 +727,6 @@ evaluate_subexp_c (struct type *expect_type, struct expression *exp,
   return evaluate_subexp_standard (expect_type, exp, pos, noside);
 }
 \f
-/* la_watch_location_expression for C.  */
-
-gdb::unique_xmalloc_ptr<char>
-c_watch_location_expression (struct type *type, CORE_ADDR addr)
-{
-  type = check_typedef (TYPE_TARGET_TYPE (check_typedef (type)));
-  std::string name = type_to_string (type);
-  return gdb::unique_xmalloc_ptr<char>
-    (xstrprintf ("* (%s *) %s", name.c_str (), core_addr_to_string (addr)));
-}
-
 /* See c-lang.h.  */
 
 bool
@@ -914,7 +903,6 @@ extern const struct language_data c_language_data =
   c_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
-  c_watch_location_expression,
   &c_varobj_ops,
   c_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
@@ -1026,7 +1014,6 @@ extern const struct language_data cplus_language_data =
   c_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
-  c_watch_location_expression,
   &cplus_varobj_ops,
   c_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
@@ -1226,7 +1213,6 @@ extern const struct language_data asm_language_data =
   c_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
-  c_watch_location_expression,
   &default_varobj_ops,
   c_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
@@ -1293,7 +1279,6 @@ extern const struct language_data minimal_language_data =
   c_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
-  c_watch_location_expression,
   &default_varobj_ops,
   c_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
diff --git a/gdb/c-lang.h b/gdb/c-lang.h
index 31ec6f2cf74..6c5d0d814c4 100644
--- a/gdb/c-lang.h
+++ b/gdb/c-lang.h
@@ -116,9 +116,6 @@ extern void c_emit_char (int c, struct type *type,
 
 extern const struct op_print c_op_print_tab[];
 
-extern gdb::unique_xmalloc_ptr<char> c_watch_location_expression
-     (struct type *type, CORE_ADDR addr);
-
 /* These are in c-typeprint.c: */
 
 extern void c_type_print_base (struct type *, struct ui_file *,
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index 67c82e4215e..001af06a82a 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -157,7 +157,6 @@ extern const struct language_data d_language_data =
   d_op_print_tab,		/* Expression operators for printing.  */
   1,				/* C-style arrays.  */
   0,				/* String lower bound.  */
-  c_watch_location_expression,
   &default_varobj_ops,
   c_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 0540ab233db..e421e5f9645 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -578,7 +578,6 @@ extern const struct language_data f_language_data =
   f_op_print_tab,		/* expression operators for printing */
   0,				/* arrays are first-class (not c-style) */
   1,				/* String lower bound */
-  c_watch_location_expression,
   &default_varobj_ops,
   f_is_string_type_p,
   "(...)"			/* la_struct_too_deep_ellipsis */
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index a1af67deaae..92eeae4d0a8 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -542,7 +542,6 @@ extern const struct language_data go_language_data =
   go_op_print_tab,		/* Expression operators for printing.  */
   1,				/* C-style arrays.  */
   0,				/* String lower bound.  */
-  c_watch_location_expression,
   &default_varobj_ops,
   go_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
diff --git a/gdb/language.c b/gdb/language.c
index f4e99fc392f..6320577addf 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -622,6 +622,19 @@ language_defn::print_array_index (struct type *index_type, LONGEST index,
   fprintf_filtered (stream, "] = ");
 }
 
+/* See language.h.  */
+
+gdb::unique_xmalloc_ptr<char>
+language_defn::watch_location_expression (struct type *type,
+					  CORE_ADDR addr) const
+{
+  /* Generates an expression that assumes a C like syntax is valid.  */
+  type = check_typedef (TYPE_TARGET_TYPE (check_typedef (type)));
+  std::string name = type_to_string (type);
+  return gdb::unique_xmalloc_ptr<char>
+    (xstrprintf ("* (%s *) %s", name.c_str (), core_addr_to_string (addr)));
+}
+
 /* The default implementation of the get_symbol_name_matcher_inner method
    from the language_defn class.  Matches with strncmp_iw.  */
 
@@ -779,7 +792,6 @@ extern const struct language_data unknown_language_data =
   unk_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
-  c_watch_location_expression,
   &default_varobj_ops,
   default_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
@@ -850,7 +862,6 @@ extern const struct language_data auto_language_data =
   unk_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
-  c_watch_location_expression,
   &default_varobj_ops,
   default_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
diff --git a/gdb/language.h b/gdb/language.h
index 5872db39dbb..1cd3785ab0b 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -319,12 +319,6 @@ struct language_data
     /* Index to use for extracting the first element of a string.  */
     char string_lower_bound;
 
-    /* Return an expression that can be used for a location
-       watchpoint.  TYPE is a pointer type that points to the memory
-       to watch, and ADDR is the address of the watched memory.  */
-    gdb::unique_xmalloc_ptr<char> (*la_watch_location_expression)
-         (struct type *type, CORE_ADDR addr);
-
     /* Various operations on varobj.  */
     const struct lang_varobj_ops *la_varobj_ops;
 
@@ -540,6 +534,12 @@ struct language_defn : language_data
       (tracker, mode, name_match_type, text, word, "", code);
   }
 
+  /* Return an expression that can be used for a location
+     watchpoint.  TYPE is a pointer type that points to the memory
+     to watch, and ADDR is the address of the watched memory.  */
+  virtual gdb::unique_xmalloc_ptr<char> watch_location_expression
+	(struct type *type, CORE_ADDR addr) const;
+
   /* List of all known languages.  */
   static const struct language_defn *languages[nr_languages];
 
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index a028a2f2e22..e4c783964ce 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -376,7 +376,6 @@ extern const struct language_data m2_language_data =
   m2_op_print_tab,		/* expression operators for printing */
   0,				/* arrays are first-class (not c-style) */
   0,				/* String lower bound */
-  c_watch_location_expression,
   &default_varobj_ops,
   m2_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 5f9e9710366..fa5aa9bc06e 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -351,7 +351,6 @@ extern const struct language_data objc_language_data =
   objc_op_print_tab,		/* Expression operators for printing */
   1,				/* C-style arrays */
   0,				/* String lower bound */
-  c_watch_location_expression,
   &default_varobj_ops,
   c_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index d93ce0bc478..4cdfc045e04 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -1030,7 +1030,6 @@ extern const struct language_data opencl_language_data =
   c_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
-  c_watch_location_expression,
   &default_varobj_ops,
   c_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index cdcf726ce9c..72c484a88cb 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -407,7 +407,6 @@ extern const struct language_data pascal_language_data =
   pascal_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
-  c_watch_location_expression,
   &default_varobj_ops,
   pascal_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index a4e473d2f6f..373d6101018 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -2006,20 +2006,6 @@ rust_lookup_symbol_nonlocal (const struct language_defn *langdef,
 
 \f
 
-/* la_watch_location_expression for Rust.  */
-
-static gdb::unique_xmalloc_ptr<char>
-rust_watch_location_expression (struct type *type, CORE_ADDR addr)
-{
-  type = check_typedef (TYPE_TARGET_TYPE (check_typedef (type)));
-  std::string name = type_to_string (type);
-  return gdb::unique_xmalloc_ptr<char>
-    (xstrprintf ("*(%s as *mut %s)", core_addr_to_string (addr),
-		 name.c_str ()));
-}
-
-\f
-
 static const struct exp_descriptor exp_descriptor_rust = 
 {
   rust_print_subexp,
@@ -2062,7 +2048,6 @@ extern const struct language_data rust_language_data =
   c_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
-  rust_watch_location_expression,
   &default_varobj_ops,
   rust_is_string_type_p,
   "{...}"			/* la_struct_too_deep_ellipsis */
@@ -2143,6 +2128,18 @@ class rust_language : public language_defn
     rust_internal_print_type (type, varstring, stream, show, level,
 			      flags, false, &podata);
   }
+
+  /* See language.h.  */
+
+  gdb::unique_xmalloc_ptr<char> watch_location_expression
+	(struct type *type, CORE_ADDR addr) const override
+  {
+    type = check_typedef (TYPE_TARGET_TYPE (check_typedef (type)));
+    std::string name = type_to_string (type);
+    return gdb::unique_xmalloc_ptr<char>
+      (xstrprintf ("*(%s as *mut %s)", core_addr_to_string (addr),
+		   name.c_str ()));
+  }
 };
 
 /* Single instance of the Rust language class.  */
-- 
2.25.4


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 7/9] gdb: Convert language la_value_print field to a method
  2020-06-02 13:32 [PATCH 0/9] Further Conversion of Language Class Hierarchy Andrew Burgess
                   ` (5 preceding siblings ...)
  2020-06-02 13:32 ` [PATCH 6/9] gdb: Convert language la_watch_location_expression " Andrew Burgess
@ 2020-06-02 13:32 ` Andrew Burgess
  2020-06-02 13:32 ` [PATCH 8/9] gdb: Convert language la_value_print_inner " Andrew Burgess
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Andrew Burgess @ 2020-06-02 13:32 UTC (permalink / raw)
  To: gdb-patches

This commit changes the language_data::la_value_print 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_value_print
	initializer.
	(ada_language::value_print): New member function.
	* c-lang.c (c_language_data): Delete la_value_print initializer.
	(cplus_language_data): Likewise.
	(asm_language_data): Likewise.
	(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 (unk_lang_value_print): Delete.
	(language_defn::value_print): Define new member function.
	(unknown_language_data): Delete la_value_print initializer.
	(unknown_language::value_print): New member function.
	(auto_language_data): Delete la_value_print initializer.
	(auto_language::value_print): New member function.
	* language.h (language_data): Delete la_value_print field.
	(language_defn::value_print): Declare new member function.
	(LA_VALUE_PRINT): Update call to value_print.
	* m2-lang.c (m2_language_data): Delete la_value_print initializer.
	* objc-lang.c (objc_language_data): Likewise.
	* opencl-lang.c (opencl_language_data): Likewise.
	* p-lang.c (pascal_language_data): Likewise.
	(pascal_language::value_print): New member function.
	* rust-lang.c (rust_language_data): Delete la_value_print
	initializer.
---
 gdb/ChangeLog     | 29 +++++++++++++++++++++++++++++
 gdb/ada-lang.c    |  9 ++++++++-
 gdb/c-lang.c      |  4 ----
 gdb/d-lang.c      |  1 -
 gdb/f-lang.c      |  1 -
 gdb/go-lang.c     |  1 -
 gdb/language.c    | 38 +++++++++++++++++++++++++-------------
 gdb/language.h    | 11 +++++------
 gdb/m2-lang.c     |  1 -
 gdb/objc-lang.c   |  1 -
 gdb/opencl-lang.c |  1 -
 gdb/p-lang.c      |  9 ++++++++-
 gdb/rust-lang.c   |  1 -
 13 files changed, 75 insertions(+), 32 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 6c95d20162d..af08f023aca 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -13776,7 +13776,6 @@ extern const struct language_data ada_language_data =
   emit_char,                    /* Function to print single char (not used) */
   ada_print_typedef,            /* Print a typedef using appropriate syntax */
   ada_value_print_inner,	/* la_value_print_inner */
-  ada_value_print,              /* Print a top-level value */
   NULL,                         /* name_of_this */
   true,                         /* la_store_sym_names_in_linkage_form_p */
   ada_lookup_symbol_nonlocal,   /* Looking up non-local symbols.  */
@@ -14112,6 +14111,14 @@ class ada_language : public language_defn
       (xstrprintf ("{%s} %s", name.c_str (), core_addr_to_string (addr)));
   }
 
+  /* See language.h.  */
+
+  void value_print (struct value *val, struct ui_file *stream,
+		    const struct value_print_options *options) const override
+  {
+    return ada_value_print (val, stream, options);
+  }
+
 protected:
   /* See language.h.  */
 
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 13d13435fe4..9096e7b15eb 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -896,7 +896,6 @@ extern const struct language_data c_language_data =
   c_emit_char,			/* Print a single char */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
   c_value_print_inner,		/* la_value_print_inner */
-  c_value_print,		/* Print a top-level value */
   NULL,				/* name_of_this */
   true,				/* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
@@ -1007,7 +1006,6 @@ extern const struct language_data cplus_language_data =
   c_emit_char,			/* Print a single char */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
   c_value_print_inner,		/* la_value_print_inner */
-  c_value_print,		/* Print a top-level value */
   "this",                       /* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
   cp_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
@@ -1206,7 +1204,6 @@ extern const struct language_data asm_language_data =
   c_emit_char,			/* Print a single char */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
   c_value_print_inner,		/* la_value_print_inner */
-  c_value_print,		/* Print a top-level value */
   NULL,				/* name_of_this */
   true,				/* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
@@ -1272,7 +1269,6 @@ extern const struct language_data minimal_language_data =
   c_emit_char,			/* Print a single char */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
   c_value_print_inner,		/* la_value_print_inner */
-  c_value_print,		/* Print a top-level value */
   NULL,				/* name_of_this */
   true,				/* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index 001af06a82a..553b38de81e 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -150,7 +150,6 @@ extern const struct language_data d_language_data =
   c_print_typedef,		/* Print a typedef using appropriate
 				   syntax.  */
   d_value_print_inner,		/* la_value_print_inner */
-  c_value_print,		/* Print a top-level value.  */
   "this",
   false,			/* la_store_sym_names_in_linkage_form_p */
   d_lookup_symbol_nonlocal,
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index e421e5f9645..3e2c97c0619 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -571,7 +571,6 @@ extern const struct language_data f_language_data =
   f_emit_char,			/* Function to print a single character */
   f_print_typedef,		/* Print a typedef using appropriate syntax */
   f_value_print_innner,		/* la_value_print_inner */
-  c_value_print,		/* FIXME */
   NULL,                    	/* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
   cp_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index 92eeae4d0a8..e38156d7096 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -535,7 +535,6 @@ extern const struct language_data go_language_data =
   c_print_typedef,		/* Print a typedef using appropriate
 				   syntax.  */
   go_value_print_inner,		/* la_value_print_inner */
-  c_value_print,		/* Print a top-level value.  */
   NULL,				/* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal, 
diff --git a/gdb/language.c b/gdb/language.c
index 6320577addf..5b47a4956ed 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -57,9 +57,6 @@ static void unk_lang_emit_char (int c, struct type *type,
 static void unk_lang_printchar (int c, struct type *type,
 				struct ui_file *stream);
 
-static void unk_lang_value_print (struct value *, struct ui_file *,
-				  const struct value_print_options *);
-
 /* The current (default at startup) state of type and range checking.
    (If the modes are set to "auto", though, these are changed based
    on the default language at startup, and then again based on the
@@ -635,6 +632,15 @@ language_defn::watch_location_expression (struct type *type,
     (xstrprintf ("* (%s *) %s", name.c_str (), core_addr_to_string (addr)));
 }
 
+/* See language.h.  */
+
+void
+language_defn::value_print (struct value *val, struct ui_file *stream,
+	       const struct value_print_options *options) const
+{
+  return c_value_print (val, stream, options);
+}
+
 /* The default implementation of the get_symbol_name_matcher_inner method
    from the language_defn class.  Matches with strncmp_iw.  */
 
@@ -742,14 +748,6 @@ unk_lang_value_print_inner (struct value *val,
 	   "function unk_lang_value_print_inner called."));
 }
 
-static void
-unk_lang_value_print (struct value *val, struct ui_file *stream,
-		      const struct value_print_options *options)
-{
-  error (_("internal error - unimplemented "
-	   "function unk_lang_value_print called."));
-}
-
 static const struct op_print unk_op_print_tab[] =
 {
   {NULL, OP_NULL, PREC_NULL, 0}
@@ -785,7 +783,6 @@ extern const struct language_data unknown_language_data =
   unk_lang_emit_char,
   default_print_typedef,	/* Print a typedef using appropriate syntax */
   unk_lang_value_print_inner,	/* la_value_print_inner */
-  unk_lang_value_print,		/* Print a top-level value */
   "this",        	    	/* name_of_this */
   true,				/* store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
@@ -829,6 +826,14 @@ class unknown_language : public language_defn
     /* The unknown language just uses the C++ demangler.  */
     return gdb_demangle (mangled, options);
   }
+
+  /* See language.h.  */
+
+  void value_print (struct value *val, struct ui_file *stream,
+		    const struct value_print_options *options) const override
+  {
+    error (_("unimplemented unknown_language::value_print called"));
+  }
 };
 
 /* Single instance of the unknown language class.  */
@@ -855,7 +860,6 @@ extern const struct language_data auto_language_data =
   unk_lang_emit_char,
   default_print_typedef,	/* Print a typedef using appropriate syntax */
   unk_lang_value_print_inner,	/* la_value_print_inner */
-  unk_lang_value_print,		/* Print a top-level value */
   "this",		        /* name_of_this */
   false,			/* store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
@@ -899,6 +903,14 @@ class auto_language : public language_defn
     /* The auto language just uses the C++ demangler.  */
     return gdb_demangle (mangled, options);
   }
+
+  /* See language.h.  */
+
+  void value_print (struct value *val, struct ui_file *stream,
+		    const struct value_print_options *options) const override
+  {
+    error (_("unimplemented auto_language::value_print called"));
+  }
 };
 
 /* Single instance of the fake "auto" language.  */
diff --git a/gdb/language.h b/gdb/language.h
index 1cd3785ab0b..4b27c010b0e 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -265,11 +265,6 @@ struct language_data
 				  int recurse,
 				  const struct value_print_options *);
 
-    /* Print a top-level value using syntax appropriate for this language.  */
-
-    void (*la_value_print) (struct value *, struct ui_file *,
-			    const struct value_print_options *);
-
     /* Now come some hooks for lookup_symbol.  */
 
     /* If this is non-NULL, specifies the name that of the implicit
@@ -543,6 +538,10 @@ struct language_defn : language_data
   /* List of all known languages.  */
   static const struct language_defn *languages[nr_languages];
 
+  /* Print a top-level value using syntax appropriate for this language.  */
+  virtual void value_print (struct value *val, struct ui_file *stream,
+			    const struct value_print_options *options) const;
+
 protected:
 
   /* This is the overridable part of the GET_SYMBOL_NAME_MATCHER method.
@@ -642,7 +641,7 @@ extern enum language set_language (enum language);
   (current_language->la_print_typedef(type,new_symbol,stream))
 
 #define LA_VALUE_PRINT(val,stream,options) \
-  (current_language->la_value_print(val,stream,options))
+  (current_language->value_print (val,stream,options))
 
 #define LA_PRINT_CHAR(ch, type, stream) \
   (current_language->la_printchar(ch, type, stream))
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index e4c783964ce..9bb4af18b29 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -369,7 +369,6 @@ extern const struct language_data m2_language_data =
   m2_emit_char,			/* Function to print a single character */
   m2_print_typedef,		/* Print a typedef using appropriate syntax */
   m2_value_print_inner,		/* la_value_print_inner */
-  c_value_print,		/* Print a top-level value */
   NULL,		                /* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index fa5aa9bc06e..aa9d1a9312c 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -344,7 +344,6 @@ extern const struct language_data objc_language_data =
   c_emit_char,
   c_print_typedef,		/* Print a typedef using appropriate syntax */
   c_value_print_inner,		/* la_value_print_inner */
-  c_value_print,		/* Print a top-level value */
   "self",		        /* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index 4cdfc045e04..1b7553dde6e 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -1023,7 +1023,6 @@ extern const struct language_data opencl_language_data =
   c_emit_char,			/* Print a single char */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
   c_value_print_inner,		/* la_value_print_inner */
-  c_value_print,		/* Print a top-level value */
   NULL,                         /* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index 72c484a88cb..d7ddb7b9069 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -400,7 +400,6 @@ extern const struct language_data pascal_language_data =
   pascal_emit_char,		/* Print a single char */
   pascal_print_typedef,		/* Print a typedef using appropriate syntax */
   pascal_value_print_inner,	/* la_value_print_inner */
-  pascal_value_print,		/* Print a top-level value */
   "this",		        /* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
@@ -478,6 +477,14 @@ class pascal_language : public language_defn
   {
     pascal_print_type (type, varstring, stream, show, level, flags);
   }
+
+  /* See language.h.  */
+
+  void value_print (struct value *val, struct ui_file *stream,
+		    const struct value_print_options *options) const override
+  {
+    return pascal_value_print (val, stream, options);
+  }
 };
 
 /* Single instance of the Pascal language class.  */
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 373d6101018..7b03c3898d2 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -2041,7 +2041,6 @@ extern const struct language_data rust_language_data =
   rust_emitchar,		/* Print a single char */
   rust_print_typedef,		/* Print a typedef using appropriate syntax */
   rust_value_print_inner,	/* la_value_print_inner */
-  c_value_print,		/* Print a top-level value */
   NULL,				/* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
   rust_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
-- 
2.25.4


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 8/9] gdb: Convert language la_value_print_inner field to a method
  2020-06-02 13:32 [PATCH 0/9] Further Conversion of Language Class Hierarchy Andrew Burgess
                   ` (6 preceding siblings ...)
  2020-06-02 13:32 ` [PATCH 7/9] gdb: Convert language la_value_print " Andrew Burgess
@ 2020-06-02 13:32 ` Andrew Burgess
  2020-06-02 13:32 ` [PATCH 9/9] gdb: Convert language la_lookup_symbol_nonlocal " Andrew Burgess
  2020-06-10  2:54 ` [PATCH 0/9] Further Conversion of Language Class Hierarchy Simon Marchi
  9 siblings, 0 replies; 12+ messages in thread
From: Andrew Burgess @ 2020-06-02 13:32 UTC (permalink / raw)
  To: gdb-patches

This commit changes the language_data::la_value_print_inner 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_value_print_inner
	initializer.
	(ada_language::value_print_inner): New member function.
	* c-lang.c (c_language_data): Delete la_value_print_inner
	initializer.
	(cplus_language_data): Likewise.
	(asm_language_data): Likewise.
	(minimal_language_data): Likewise.
	* d-lang.c (d_language_data): Likewise.
	(d_language::value_print_inner): New member function.
	* f-lang.c (f_language_data): Delete la_value_print_inner
	initializer.
	(f_language::value_print_inner): New member function.
	* f-lang.h (f_value_print_innner): Rename to...
	(f_value_print_inner): ...this (note spelling of 'inner').
	* f-valprint.c (f_value_print_innner): Rename to...
	(f_value_print_inner): ...this (note spelling of 'inner').
	* go-lang.c (go_language_data): Delete la_value_print_inner
	initializer.
	(go_language::value_print_inner): New member function.
	* language.c (language_defn::value_print_inner): Define new member
	function.
	(unk_lang_value_print_inner): Delete.
	(unknown_language_data): Delete la_value_print_inner initializer.
	(unknown_language::value_print_inner): New member function.
	(auto_language_data): Delete la_value_print_inner initializer.
	(auto_language::value_print_inner): New member function.
	* language.h (language_data): Delete la_value_print_inner field.
	(language_defn::value_print_inner): Delcare new member function.
	* m2-lang.c (m2_language_data): Delete la_value_print_inner
	initializer.
	(m2_language::value_print_inner): New member function.
	* objc-lang.c (objc_language_data): Delete la_value_print_inner
	initializer.
	* opencl-lang.c (opencl_language_data): Likewise.
	* p-lang.c (pascal_language_data): Likewise.
	(pascal_language::value_print_inner): New member function.
	* rust-lang.c (rust_language_data): Delete la_value_print_inner
	initializer.
	(rust_language::value_print_inner): New member function.
	* valprint.c (do_val_print): Update call to value_print_inner.
---
 gdb/ChangeLog     | 44 ++++++++++++++++++++++++++++++++++++++++++++
 gdb/ada-lang.c    | 10 +++++++++-
 gdb/c-lang.c      |  4 ----
 gdb/d-lang.c      | 10 +++++++++-
 gdb/f-lang.c      | 11 ++++++++++-
 gdb/f-lang.h      |  2 +-
 gdb/f-valprint.c  |  2 +-
 gdb/go-lang.c     | 10 +++++++++-
 gdb/language.c    | 39 ++++++++++++++++++++++++++++-----------
 gdb/language.h    | 13 ++++++-------
 gdb/m2-lang.c     | 10 +++++++++-
 gdb/objc-lang.c   |  1 -
 gdb/opencl-lang.c |  1 -
 gdb/p-lang.c      | 10 +++++++++-
 gdb/rust-lang.c   | 10 +++++++++-
 gdb/valprint.c    |  2 +-
 16 files changed, 145 insertions(+), 34 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index af08f023aca..90a444b6064 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -13775,7 +13775,6 @@ extern const struct language_data ada_language_data =
   ada_printstr,                 /* Function to print string constant */
   emit_char,                    /* Function to print single char (not used) */
   ada_print_typedef,            /* Print a typedef using appropriate syntax */
-  ada_value_print_inner,	/* la_value_print_inner */
   NULL,                         /* name_of_this */
   true,                         /* la_store_sym_names_in_linkage_form_p */
   ada_lookup_symbol_nonlocal,   /* Looking up non-local symbols.  */
@@ -14119,6 +14118,15 @@ class ada_language : public language_defn
     return ada_value_print (val, stream, options);
   }
 
+  /* See language.h.  */
+
+  void value_print_inner
+	(struct value *val, struct ui_file *stream, int recurse,
+	 const struct value_print_options *options) const override
+  {
+    return ada_value_print_inner (val, stream, recurse, options);
+  }
+
 protected:
   /* See language.h.  */
 
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 9096e7b15eb..3ba9c7dffce 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -895,7 +895,6 @@ extern const struct language_data c_language_data =
   c_printstr,			/* Function to print string constant */
   c_emit_char,			/* Print a single char */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
-  c_value_print_inner,		/* la_value_print_inner */
   NULL,				/* name_of_this */
   true,				/* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
@@ -1005,7 +1004,6 @@ extern const struct language_data cplus_language_data =
   c_printstr,			/* Function to print string constant */
   c_emit_char,			/* Print a single char */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
-  c_value_print_inner,		/* la_value_print_inner */
   "this",                       /* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
   cp_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
@@ -1203,7 +1201,6 @@ extern const struct language_data asm_language_data =
   c_printstr,			/* Function to print string constant */
   c_emit_char,			/* Print a single char */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
-  c_value_print_inner,		/* la_value_print_inner */
   NULL,				/* name_of_this */
   true,				/* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
@@ -1268,7 +1265,6 @@ extern const struct language_data minimal_language_data =
   c_printstr,			/* Function to print string constant */
   c_emit_char,			/* Print a single char */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
-  c_value_print_inner,		/* la_value_print_inner */
   NULL,				/* name_of_this */
   true,				/* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index 553b38de81e..dff9d470bc9 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -149,7 +149,6 @@ extern const struct language_data d_language_data =
   c_emit_char,			/* Print a single char.  */
   c_print_typedef,		/* Print a typedef using appropriate
 				   syntax.  */
-  d_value_print_inner,		/* la_value_print_inner */
   "this",
   false,			/* la_store_sym_names_in_linkage_form_p */
   d_lookup_symbol_nonlocal,
@@ -257,6 +256,15 @@ class d_language : public language_defn
   {
     c_print_type (type, varstring, stream, show, level, flags);
   }
+
+  /* See language.h.  */
+
+  void value_print_inner
+	(struct value *val, struct ui_file *stream, int recurse,
+	 const struct value_print_options *options) const override
+  {
+    return d_value_print_inner (val, stream, recurse, options);
+  }
 };
 
 /* Single instance of the D language class.  */
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 3e2c97c0619..d5b2bf286da 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -570,7 +570,6 @@ extern const struct language_data f_language_data =
   f_printstr,			/* function to print string constant */
   f_emit_char,			/* Function to print a single character */
   f_print_typedef,		/* Print a typedef using appropriate syntax */
-  f_value_print_innner,		/* la_value_print_inner */
   NULL,                    	/* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
   cp_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
@@ -697,6 +696,16 @@ class f_language : public language_defn
 							code);
   }
 
+  /* See language.h.  */
+
+  void value_print_inner
+	(struct value *val, struct ui_file *stream, int recurse,
+	 const struct value_print_options *options) const override
+  {
+    return f_value_print_inner (val, stream, recurse, options);
+  }
+
+
 protected:
 
   /* See language.h.  */
diff --git a/gdb/f-lang.h b/gdb/f-lang.h
index 84a63a8a410..4710b14aa62 100644
--- a/gdb/f-lang.h
+++ b/gdb/f-lang.h
@@ -38,7 +38,7 @@ extern void f_print_type (struct type *, const char *, struct ui_file *, int,
 
 /* Implement la_value_print_inner for Fortran.  */
 
-extern void f_value_print_innner (struct value *val, struct ui_file *stream,
+extern void f_value_print_inner (struct value *val, struct ui_file *stream,
 				  int recurse,
 				  const struct value_print_options *options);
 
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index bd16a4348d3..387d8c19d5b 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -211,7 +211,7 @@ static const struct generic_val_print_decorations f_decorations =
 /* See f-lang.h.  */
 
 void
-f_value_print_innner (struct value *val, struct ui_file *stream, int recurse,
+f_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
 		      const struct value_print_options *options)
 {
   struct type *type = check_typedef (value_type (val));
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index e38156d7096..fabe1309314 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -534,7 +534,6 @@ extern const struct language_data go_language_data =
   c_emit_char,			/* Print a single char.  */
   c_print_typedef,		/* Print a typedef using appropriate
 				   syntax.  */
-  go_value_print_inner,		/* la_value_print_inner */
   NULL,				/* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal, 
@@ -631,6 +630,15 @@ class go_language : public language_defn
   {
     go_print_type (type, varstring, stream, show, level, flags);
   }
+
+  /* See language.h.  */
+
+  void value_print_inner
+	(struct value *val, struct ui_file *stream, int recurse,
+	 const struct value_print_options *options) const override
+  {
+    return go_value_print_inner (val, stream, recurse, options);
+  }
 };
 
 /* Single instance of the Go language class.  */
diff --git a/gdb/language.c b/gdb/language.c
index 5b47a4956ed..d93b4756707 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -641,6 +641,16 @@ language_defn::value_print (struct value *val, struct ui_file *stream,
   return c_value_print (val, stream, options);
 }
 
+/* See language.h.  */
+
+void
+language_defn::value_print_inner
+	(struct value *val, struct ui_file *stream, int recurse,
+	 const struct value_print_options *options) const
+{
+  return c_value_print_inner (val, stream, recurse, options);
+}
+
 /* The default implementation of the get_symbol_name_matcher_inner method
    from the language_defn class.  Matches with strncmp_iw.  */
 
@@ -739,15 +749,6 @@ unk_lang_printstr (struct ui_file *stream, struct type *type,
 	   "function unk_lang_printstr called."));
 }
 
-static void
-unk_lang_value_print_inner (struct value *val,
-			    struct ui_file *stream, int recurse,
-			    const struct value_print_options *options)
-{
-  error (_("internal error - unimplemented "
-	   "function unk_lang_value_print_inner called."));
-}
-
 static const struct op_print unk_op_print_tab[] =
 {
   {NULL, OP_NULL, PREC_NULL, 0}
@@ -782,7 +783,6 @@ extern const struct language_data unknown_language_data =
   unk_lang_printstr,
   unk_lang_emit_char,
   default_print_typedef,	/* Print a typedef using appropriate syntax */
-  unk_lang_value_print_inner,	/* la_value_print_inner */
   "this",        	    	/* name_of_this */
   true,				/* store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
@@ -834,6 +834,15 @@ class unknown_language : public language_defn
   {
     error (_("unimplemented unknown_language::value_print called"));
   }
+
+  /* See language.h.  */
+
+  void value_print_inner
+	(struct value *val, struct ui_file *stream, int recurse,
+	 const struct value_print_options *options) const override
+  {
+    error (_("unimplemented unknown_language::value_print_inner called"));
+  }
 };
 
 /* Single instance of the unknown language class.  */
@@ -859,7 +868,6 @@ extern const struct language_data auto_language_data =
   unk_lang_printstr,
   unk_lang_emit_char,
   default_print_typedef,	/* Print a typedef using appropriate syntax */
-  unk_lang_value_print_inner,	/* la_value_print_inner */
   "this",		        /* name_of_this */
   false,			/* store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
@@ -911,6 +919,15 @@ class auto_language : public language_defn
   {
     error (_("unimplemented auto_language::value_print called"));
   }
+
+  /* See language.h.  */
+
+  void value_print_inner
+	(struct value *val, struct ui_file *stream, int recurse,
+	 const struct value_print_options *options) const override
+  {
+    error (_("unimplemented auto_language::value_print_inner called"));
+  }
 };
 
 /* Single instance of the fake "auto" language.  */
diff --git a/gdb/language.h b/gdb/language.h
index 4b27c010b0e..06978d7067f 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -258,13 +258,6 @@ struct language_data
     void (*la_print_typedef) (struct type *type, struct symbol *new_symbol,
 			      struct ui_file *stream);
 
-    /* Print a value using syntax appropriate for this language.
-       RECURSE is the recursion depth.  It is zero-based.  */
-
-    void (*la_value_print_inner) (struct value *, struct ui_file *,
-				  int recurse,
-				  const struct value_print_options *);
-
     /* Now come some hooks for lookup_symbol.  */
 
     /* If this is non-NULL, specifies the name that of the implicit
@@ -542,6 +535,12 @@ struct language_defn : language_data
   virtual void value_print (struct value *val, struct ui_file *stream,
 			    const struct value_print_options *options) const;
 
+  /* Print a value using syntax appropriate for this language.  RECURSE is
+     the recursion depth.  It is zero-based.  */
+  virtual void value_print_inner
+	(struct value *val, struct ui_file *stream, int recurse,
+	 const struct value_print_options *options) 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 9bb4af18b29..cc565fc5610 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -368,7 +368,6 @@ extern const struct language_data m2_language_data =
   m2_printstr,			/* function to print string constant */
   m2_emit_char,			/* Function to print a single character */
   m2_print_typedef,		/* Print a typedef using appropriate syntax */
-  m2_value_print_inner,		/* la_value_print_inner */
   NULL,		                /* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
@@ -423,6 +422,15 @@ class m2_language : public language_defn
   {
     m2_print_type (type, varstring, stream, show, level, flags);
   }
+
+  /* See language.h.  */
+
+  void value_print_inner
+	(struct value *val, struct ui_file *stream, int recurse,
+	 const struct value_print_options *options) const override
+  {
+    return m2_value_print_inner (val, stream, recurse, options);
+  }
 };
 
 /* Single instance of the M2 language.  */
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index aa9d1a9312c..387c6ba7e11 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -343,7 +343,6 @@ extern const struct language_data objc_language_data =
   c_printstr,		       /* Function to print string constant */
   c_emit_char,
   c_print_typedef,		/* Print a typedef using appropriate syntax */
-  c_value_print_inner,		/* la_value_print_inner */
   "self",		        /* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index 1b7553dde6e..5cb98390009 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -1022,7 +1022,6 @@ extern const struct language_data opencl_language_data =
   c_printstr,			/* Function to print string constant */
   c_emit_char,			/* Print a single char */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
-  c_value_print_inner,		/* la_value_print_inner */
   NULL,                         /* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index d7ddb7b9069..db8d81b0bf6 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -399,7 +399,6 @@ extern const struct language_data pascal_language_data =
   pascal_printstr,		/* Function to print string constant */
   pascal_emit_char,		/* Print a single char */
   pascal_print_typedef,		/* Print a typedef using appropriate syntax */
-  pascal_value_print_inner,	/* la_value_print_inner */
   "this",		        /* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
@@ -485,6 +484,15 @@ class pascal_language : public language_defn
   {
     return pascal_value_print (val, stream, options);
   }
+
+  /* See language.h.  */
+
+  void value_print_inner
+	(struct value *val, struct ui_file *stream, int recurse,
+	 const struct value_print_options *options) const override
+  {
+    return pascal_value_print_inner (val, stream, recurse, options);
+  }
 };
 
 /* Single instance of the Pascal language class.  */
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 7b03c3898d2..92ff1bdfdfe 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -2040,7 +2040,6 @@ extern const struct language_data rust_language_data =
   rust_printstr,		/* Function to print string constant */
   rust_emitchar,		/* Print a single char */
   rust_print_typedef,		/* Print a typedef using appropriate syntax */
-  rust_value_print_inner,	/* la_value_print_inner */
   NULL,				/* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
   rust_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
@@ -2139,6 +2138,15 @@ class rust_language : public language_defn
       (xstrprintf ("*(%s as *mut %s)", core_addr_to_string (addr),
 		   name.c_str ()));
   }
+
+  /* See language.h.  */
+
+  void value_print_inner
+	(struct value *val, struct ui_file *stream, int recurse,
+	 const struct value_print_options *options) const override
+  {
+    return rust_value_print_inner (val, stream, recurse, options);
+  }
 };
 
 /* Single instance of the Rust language class.  */
diff --git a/gdb/valprint.c b/gdb/valprint.c
index d678ad3091a..fd053d623cd 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -984,7 +984,7 @@ do_val_print (struct value *value, struct ui_file *stream, int recurse,
 
   try
     {
-      language->la_value_print_inner (value, stream, recurse, &local_opts);
+      language->value_print_inner (value, stream, recurse, &local_opts);
     }
   catch (const gdb_exception_error &except)
     {
-- 
2.25.4


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 9/9] gdb: Convert language la_lookup_symbol_nonlocal field to a method
  2020-06-02 13:32 [PATCH 0/9] Further Conversion of Language Class Hierarchy Andrew Burgess
                   ` (7 preceding siblings ...)
  2020-06-02 13:32 ` [PATCH 8/9] gdb: Convert language la_value_print_inner " Andrew Burgess
@ 2020-06-02 13:32 ` Andrew Burgess
  2020-06-10  2:54 ` [PATCH 0/9] Further Conversion of Language Class Hierarchy Simon Marchi
  9 siblings, 0 replies; 12+ messages in thread
From: Andrew Burgess @ 2020-06-02 13:32 UTC (permalink / raw)
  To: gdb-patches

This commit changes the language_data::la_lookup_symbol_nonlocal
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_lookup_symbol_nonlocal): Rename to
	ada_language::lookup_symbol_nonlocal.
	(ada_language_data): Delete la_lookup_symbol_nonlocal initializer.
	(ada_language::lookup_symbol_nonlocal): New member function,
	implementation from ada_lookup_symbol_nonlocal.
	* c-lang.c (c_language_data): Delete la_lookup_symbol_nonlocal
	initializer.
	(cplus_language_data): Delete la_lookup_symbol_nonlocal
	initializer.
	(cplus_language::lookup_symbol_nonlocal): New member function.
	(asm_language_data): Delete la_lookup_symbol_nonlocal initializer.
	(minimal_language_data) Likewise.
	* cp-namespace.c (cp_lookup_nested_symbol): Update comment.
	* d-lang.c (d_language_data): Delete la_lookup_symbol_nonlocal
	initializer.
	(d_language::lookup_symbol_nonlocal): New member function.
	* f-lang.c (f_language_data): Delete la_lookup_symbol_nonlocal
	initializer.
	(f_language::lookup_symbol_nonlocal): New member function.
	* go-lang.c (go_language_data): Delete la_lookup_symbol_nonlocal
	initializer.
	* language.c (unknown_language_data): Likewise.
	(auto_language_data): Likewise.
	* language.h (language_data): Delete la_lookup_symbol_nonlocal
	field.
	(language_defn::lookup_symbol_nonlocal): New member function.
	* m2-lang.c (m2_language_data): Delete la_lookup_symbol_nonlocal
	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_lookup_symbol_nonlocal): Rename to
	rust_language::lookup_symbol_nonlocal.
	(rust_language_data): Delete la_lookup_symbol_nonlocal
	initializer.
	(rust_language::lookup_symbol_nonlocal): New member function,
	implementation from rust_lookup_symbol_nonlocal.
	* symtab.c (lookup_symbol_aux): Update call to
	lookup_symbol_nonlocal.
	(basic_lookup_symbol_nonlocal): Rename to...
	(language_defn::lookup_symbol_nonlocal): ...this, and update
	header comment.  Remove language_defn parameter, and replace with
	uses of `this'.
	* symtab.h (basic_lookup_symbol_nonlocal): Delete declaration.
---
 gdb/ChangeLog      | 47 +++++++++++++++++++++++++
 gdb/ada-lang.c     | 82 +++++++++++++++++++++----------------------
 gdb/c-lang.c       | 13 ++++---
 gdb/cp-namespace.c |  2 +-
 gdb/d-lang.c       | 10 +++++-
 gdb/f-lang.c       |  9 ++++-
 gdb/go-lang.c      |  1 -
 gdb/language.c     |  2 --
 gdb/language.h     | 19 +++++-----
 gdb/m2-lang.c      |  1 -
 gdb/objc-lang.c    |  1 -
 gdb/opencl-lang.c  |  1 -
 gdb/p-lang.c       |  1 -
 gdb/rust-lang.c    | 87 ++++++++++++++++++++++------------------------
 gdb/symtab.c       | 13 ++++---
 gdb/symtab.h       | 10 ------
 16 files changed, 171 insertions(+), 128 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 90a444b6064..4ef919bdc06 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -5772,46 +5772,6 @@ ada_lookup_symbol (const char *name, const struct block *block0,
   return info;
 }
 
-static struct block_symbol
-ada_lookup_symbol_nonlocal (const struct language_defn *langdef,
-			    const char *name,
-                            const struct block *block,
-                            const domain_enum domain)
-{
-  struct block_symbol sym;
-
-  sym = ada_lookup_symbol (name, block_static_block (block), domain);
-  if (sym.symbol != NULL)
-    return sym;
-
-  /* If we haven't found a match at this point, try the primitive
-     types.  In other languages, this search is performed before
-     searching for global symbols in order to short-circuit that
-     global-symbol search if it happens that the name corresponds
-     to a primitive type.  But we cannot do the same in Ada, because
-     it is perfectly legitimate for a program to declare a type which
-     has the same name as a standard type.  If looking up a type in
-     that situation, we have traditionally ignored the primitive type
-     in favor of user-defined types.  This is why, unlike most other
-     languages, we search the primitive types this late and only after
-     having searched the global symbols without success.  */
-
-  if (domain == VAR_DOMAIN)
-    {
-      struct gdbarch *gdbarch;
-
-      if (block == NULL)
-	gdbarch = target_gdbarch ();
-      else
-	gdbarch = block_gdbarch (block);
-      sym.symbol = language_lookup_primitive_type_as_symbol (langdef, gdbarch, name);
-      if (sym.symbol != NULL)
-	return sym;
-    }
-
-  return {};
-}
-
 
 /* True iff STR is a possible encoded suffix of a normal Ada name
    that is to be ignored for matching purposes.  Suffixes of parallel
@@ -13777,7 +13737,6 @@ extern const struct language_data ada_language_data =
   ada_print_typedef,            /* Print a typedef using appropriate syntax */
   NULL,                         /* name_of_this */
   true,                         /* la_store_sym_names_in_linkage_form_p */
-  ada_lookup_symbol_nonlocal,   /* Looking up non-local symbols.  */
   ada_op_print_tab,             /* expression operators for printing */
   0,                            /* c-style arrays */
   1,                            /* String lower bound */
@@ -14127,6 +14086,47 @@ class ada_language : public language_defn
     return ada_value_print_inner (val, stream, recurse, options);
   }
 
+  /* See language.h.  */
+
+  struct block_symbol lookup_symbol_nonlocal
+	(const char *name, const struct block *block,
+	 const domain_enum domain) const override
+  {
+    struct block_symbol sym;
+
+    sym = ada_lookup_symbol (name, block_static_block (block), domain);
+    if (sym.symbol != NULL)
+      return sym;
+
+    /* If we haven't found a match at this point, try the primitive
+       types.  In other languages, this search is performed before
+       searching for global symbols in order to short-circuit that
+       global-symbol search if it happens that the name corresponds
+       to a primitive type.  But we cannot do the same in Ada, because
+       it is perfectly legitimate for a program to declare a type which
+       has the same name as a standard type.  If looking up a type in
+       that situation, we have traditionally ignored the primitive type
+       in favor of user-defined types.  This is why, unlike most other
+       languages, we search the primitive types this late and only after
+       having searched the global symbols without success.  */
+
+    if (domain == VAR_DOMAIN)
+      {
+	struct gdbarch *gdbarch;
+
+	if (block == NULL)
+	  gdbarch = target_gdbarch ();
+	else
+	  gdbarch = block_gdbarch (block);
+	sym.symbol
+	  = language_lookup_primitive_type_as_symbol (this, gdbarch, name);
+	if (sym.symbol != NULL)
+	  return sym;
+      }
+
+    return {};
+  }
+
 protected:
   /* See language.h.  */
 
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 3ba9c7dffce..0c17b0ebce3 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -897,7 +897,6 @@ extern const struct language_data c_language_data =
   c_print_typedef,		/* Print a typedef using appropriate syntax */
   NULL,				/* name_of_this */
   true,				/* la_store_sym_names_in_linkage_form_p */
-  basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
   c_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
@@ -1006,7 +1005,6 @@ extern const struct language_data cplus_language_data =
   c_print_typedef,		/* Print a typedef using appropriate syntax */
   "this",                       /* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
-  cp_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
   c_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
@@ -1162,6 +1160,15 @@ class cplus_language : public language_defn
     return cp_class_name_from_physname (physname);
   }
 
+  /* See language.h.  */
+
+  struct block_symbol lookup_symbol_nonlocal
+	(const char *name, const struct block *block,
+	 const domain_enum domain) const override
+  {
+    return cp_lookup_symbol_nonlocal (this, name, block, domain);
+  }
+
 protected:
 
   /* See language.h.  */
@@ -1203,7 +1210,6 @@ extern const struct language_data asm_language_data =
   c_print_typedef,		/* Print a typedef using appropriate syntax */
   NULL,				/* name_of_this */
   true,				/* la_store_sym_names_in_linkage_form_p */
-  basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
   c_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
@@ -1267,7 +1273,6 @@ extern const struct language_data minimal_language_data =
   c_print_typedef,		/* Print a typedef using appropriate syntax */
   NULL,				/* name_of_this */
   true,				/* la_store_sym_names_in_linkage_form_p */
-  basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
   c_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index 81fb2ef67c4..bf57e703d43 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -935,7 +935,7 @@ cp_lookup_nested_symbol (struct type *parent_type,
     case TYPE_CODE_ENUM:
     /* NOTE: Handle modules here as well, because Fortran is re-using the C++
        specific code to lookup nested symbols in modules, by calling the
-       function pointer la_lookup_symbol_nonlocal, which ends up here.  */
+       method lookup_symbol_nonlocal, which ends up here.  */
     case TYPE_CODE_MODULE:
       {
 	int size;
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index dff9d470bc9..5689b6ceafc 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -151,7 +151,6 @@ extern const struct language_data d_language_data =
 				   syntax.  */
   "this",
   false,			/* la_store_sym_names_in_linkage_form_p */
-  d_lookup_symbol_nonlocal,
   d_op_print_tab,		/* Expression operators for printing.  */
   1,				/* C-style arrays.  */
   0,				/* String lower bound.  */
@@ -265,6 +264,15 @@ class d_language : public language_defn
   {
     return d_value_print_inner (val, stream, recurse, options);
   }
+
+  /* See language.h.  */
+
+  struct block_symbol lookup_symbol_nonlocal
+	(const char *name, const struct block *block,
+	 const domain_enum domain) const override
+  {
+    return d_lookup_symbol_nonlocal (this, name, block, domain);
+  }
 };
 
 /* Single instance of the D language class.  */
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index d5b2bf286da..db337be26bb 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -572,7 +572,6 @@ extern const struct language_data f_language_data =
   f_print_typedef,		/* Print a typedef using appropriate syntax */
   NULL,                    	/* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
-  cp_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
   f_op_print_tab,		/* expression operators for printing */
   0,				/* arrays are first-class (not c-style) */
   1,				/* String lower bound */
@@ -705,6 +704,14 @@ class f_language : public language_defn
     return f_value_print_inner (val, stream, recurse, options);
   }
 
+  /* See language.h.  */
+
+  struct block_symbol lookup_symbol_nonlocal
+	(const char *name, const struct block *block,
+	 const domain_enum domain) const override
+  {
+    return cp_lookup_symbol_nonlocal (this, name, block, domain);
+  }
 
 protected:
 
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index fabe1309314..76d489d233a 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -536,7 +536,6 @@ extern const struct language_data go_language_data =
 				   syntax.  */
   NULL,				/* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
-  basic_lookup_symbol_nonlocal, 
   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 d93b4756707..0cbc7f05402 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -785,7 +785,6 @@ extern const struct language_data unknown_language_data =
   default_print_typedef,	/* Print a typedef using appropriate syntax */
   "this",        	    	/* name_of_this */
   true,				/* store_sym_names_in_linkage_form_p */
-  basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
   unk_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
@@ -870,7 +869,6 @@ extern const struct language_data auto_language_data =
   default_print_typedef,	/* Print a typedef using appropriate syntax */
   "this",		        /* name_of_this */
   false,			/* store_sym_names_in_linkage_form_p */
-  basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
   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 06978d7067f..2149487dd74 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -285,16 +285,6 @@ struct language_data
 
     const bool la_store_sym_names_in_linkage_form_p;
 
-    /* This is a function that lookup_symbol will call when it gets to
-       the part of symbol lookup where C looks up static and global
-       variables.  */
-
-    struct block_symbol (*la_lookup_symbol_nonlocal)
-      (const struct language_defn *,
-       const char *,
-       const struct block *,
-       const domain_enum);
-
     /* Table for printing expressions.  */
 
     const struct op_print *la_op_print_tab;
@@ -522,6 +512,15 @@ struct language_defn : language_data
       (tracker, mode, name_match_type, text, word, "", code);
   }
 
+  /* This is a function that lookup_symbol will call when it gets to
+     the part of symbol lookup where C looks up static and global
+     variables.  This default implements the basic C lookup rules.  */
+
+  virtual struct block_symbol lookup_symbol_nonlocal
+	(const char *name,
+	 const struct block *block,
+	 const domain_enum domain) const;
+
   /* Return an expression that can be used for a location
      watchpoint.  TYPE is a pointer type that points to the memory
      to watch, and ADDR is the address of the watched memory.  */
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index cc565fc5610..7e996364a8c 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -370,7 +370,6 @@ extern const struct language_data m2_language_data =
   m2_print_typedef,		/* Print a typedef using appropriate syntax */
   NULL,		                /* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
-  basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
   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 387c6ba7e11..1e4862fe3fe 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -345,7 +345,6 @@ extern const struct language_data objc_language_data =
   c_print_typedef,		/* Print a typedef using appropriate syntax */
   "self",		        /* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
-  basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
   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 5cb98390009..2a83f51f5c7 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -1024,7 +1024,6 @@ extern const struct language_data opencl_language_data =
   c_print_typedef,		/* Print a typedef using appropriate syntax */
   NULL,                         /* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
-  basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
   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 db8d81b0bf6..bfc08d11996 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -401,7 +401,6 @@ extern const struct language_data pascal_language_data =
   pascal_print_typedef,		/* Print a typedef using appropriate syntax */
   "this",		        /* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
-  basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
   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 92ff1bdfdfe..a8c28dd955e 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -1961,51 +1961,6 @@ rust_operator_check (struct expression *exp, int pos,
 
 \f
 
-/* Implementation of la_lookup_symbol_nonlocal for Rust.  */
-
-static struct block_symbol
-rust_lookup_symbol_nonlocal (const struct language_defn *langdef,
-			     const char *name,
-			     const struct block *block,
-			     const domain_enum domain)
-{
-  struct block_symbol result = {};
-
-  if (symbol_lookup_debug)
-    {
-      fprintf_unfiltered (gdb_stdlog,
-			  "rust_lookup_symbol_non_local"
-			  " (%s, %s (scope %s), %s)\n",
-			  name, host_address_to_string (block),
-			  block_scope (block), domain_name (domain));
-    }
-
-  /* Look up bare names in the block's scope.  */
-  std::string scopedname;
-  if (name[cp_find_first_component (name)] == '\0')
-    {
-      const char *scope = block_scope (block);
-
-      if (scope[0] != '\0')
-	{
-	  scopedname = std::string (scope) + "::" + name;
-	  name = scopedname.c_str ();
-	}
-      else
-	name = NULL;
-    }
-
-  if (name != NULL)
-    {
-      result = lookup_symbol_in_static_block (name, block, domain);
-      if (result.symbol == NULL)
-	result = lookup_global_symbol (name, block, domain);
-    }
-  return result;
-}
-
-\f
-
 static const struct exp_descriptor exp_descriptor_rust = 
 {
   rust_print_subexp,
@@ -2042,7 +1997,6 @@ extern const struct language_data rust_language_data =
   rust_print_typedef,		/* Print a typedef using appropriate syntax */
   NULL,				/* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
-  rust_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
   c_op_print_tab,		/* expression operators for printing */
   1,				/* c-style arrays */
   0,				/* String lower bound */
@@ -2147,6 +2101,47 @@ class rust_language : public language_defn
   {
     return rust_value_print_inner (val, stream, recurse, options);
   }
+
+  /* See language.h.  */
+
+  struct block_symbol lookup_symbol_nonlocal
+	(const char *name, const struct block *block,
+	 const domain_enum domain) const override
+  {
+    struct block_symbol result = {};
+
+    if (symbol_lookup_debug)
+      {
+	fprintf_unfiltered (gdb_stdlog,
+			    "rust_lookup_symbol_non_local"
+			    " (%s, %s (scope %s), %s)\n",
+			    name, host_address_to_string (block),
+			    block_scope (block), domain_name (domain));
+      }
+
+    /* Look up bare names in the block's scope.  */
+    std::string scopedname;
+    if (name[cp_find_first_component (name)] == '\0')
+      {
+	const char *scope = block_scope (block);
+
+	if (scope[0] != '\0')
+	  {
+	    scopedname = std::string (scope) + "::" + name;
+	    name = scopedname.c_str ();
+	  }
+	else
+	  name = NULL;
+      }
+
+    if (name != NULL)
+      {
+	result = lookup_symbol_in_static_block (name, block, domain);
+	if (result.symbol == NULL)
+	  result = lookup_global_symbol (name, block, domain);
+      }
+    return result;
+  }
 };
 
 /* Single instance of the Rust language class.  */
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 3cb1382a6a8..34ac29e81dc 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -2086,7 +2086,7 @@ lookup_symbol_aux (const char *name, symbol_name_match_type match_type,
   /* Now do whatever is appropriate for LANGUAGE to look
      up static and global variables.  */
 
-  result = langdef->la_lookup_symbol_nonlocal (langdef, name, block, domain);
+  result = langdef->lookup_symbol_nonlocal (name, block, domain);
   if (result.symbol != NULL)
     {
       if (symbol_lookup_debug)
@@ -2401,13 +2401,12 @@ lookup_symbol_via_quick_fns (struct objfile *objfile,
   return result;
 }
 
-/* See symtab.h.  */
+/* See language.h.  */
 
 struct block_symbol
-basic_lookup_symbol_nonlocal (const struct language_defn *langdef,
-			      const char *name,
-			      const struct block *block,
-			      const domain_enum domain)
+language_defn::lookup_symbol_nonlocal (const char *name,
+				       const struct block *block,
+				       const domain_enum domain) const
 {
   struct block_symbol result;
 
@@ -2433,7 +2432,7 @@ basic_lookup_symbol_nonlocal (const struct language_defn *langdef,
 	gdbarch = target_gdbarch ();
       else
 	gdbarch = block_gdbarch (block);
-      result.symbol = language_lookup_primitive_type_as_symbol (langdef,
+      result.symbol = language_lookup_primitive_type_as_symbol (this,
 								gdbarch, name);
       result.block = NULL;
       if (result.symbol != NULL)
diff --git a/gdb/symtab.h b/gdb/symtab.h
index bf02828d12c..0b186554ea1 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1644,16 +1644,6 @@ extern struct block_symbol lookup_symbol_search_name (const char *search_name,
 						      const struct block *block,
 						      domain_enum domain);
 
-/* A default version of lookup_symbol_nonlocal for use by languages
-   that can't think of anything better to do.
-   This implements the C lookup rules.  */
-
-extern struct block_symbol
-  basic_lookup_symbol_nonlocal (const struct language_defn *langdef,
-				const char *,
-				const struct block *,
-				const domain_enum);
-
 /* Some helper functions for languages that need to write their own
    lookup_symbol_nonlocal functions.  */
 
-- 
2.25.4


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/9] Further Conversion of Language Class Hierarchy
  2020-06-02 13:32 [PATCH 0/9] Further Conversion of Language Class Hierarchy Andrew Burgess
                   ` (8 preceding siblings ...)
  2020-06-02 13:32 ` [PATCH 9/9] gdb: Convert language la_lookup_symbol_nonlocal " Andrew Burgess
@ 2020-06-10  2:54 ` Simon Marchi
  9 siblings, 0 replies; 12+ messages in thread
From: Simon Marchi @ 2020-06-10  2:54 UTC (permalink / raw)
  To: Andrew Burgess, gdb-patches

On 2020-06-02 9:32 a.m., Andrew Burgess wrote:
> Continuing with the process of converting function pointers to member
> functions within the class hierarchy of languages.
> 
> One interesting pattern that crops up a number of times, but which I
> have not addressed in this series is for example in patch #8, in
> f-lang.c, where I add this method:
> 
>      void value_print_inner
>     	(struct value *val, struct ui_file *stream, int recurse,
>          const struct value_print_options *options) const override
>      {
>        return f_value_print_inner (val, stream, recurse, options);
>      }
> 
> The reason that the member function is just a wrapper around
> f_value_print_inner, is that the f_language class is declared and
> defined in f-lang.c, while f_value_print_inner is in f-valprint.c.  My
> current thinking is that once all of the field conversion is done, I
> will probably move some of the language classes out of their *-lang.c
> files into a header file, at this point, in cases like the above,
> f_value_print_inner would become f_language::value_print_inner, but
> could still live in f-valprint.c.
> 
> I haven't done any of this code shuffling yet in order to keep these
> patches more focused.
> 
> Everything else is pretty standard, except maybe patch #3, which is
> slightly different, the commit message has more detail.

I spot-checked this, it all LGTM, including patch #3.

Thanks,

Simon


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/9] gdb: Convert language la_get_symbol_name_matcher field to a method
  2020-06-02 13:32 ` [PATCH 3/9] gdb: Convert language la_get_symbol_name_matcher " Andrew Burgess
@ 2020-06-15 14:22   ` Tom Tromey
  0 siblings, 0 replies; 12+ messages in thread
From: Tom Tromey @ 2020-06-15 14:22 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: gdb-patches

>>>>> "Andrew" == Andrew Burgess <andrew.burgess@embecosm.com> writes:

Andrew> In this commit I moved the get_symbol_name_matcher as a non-virtual
Andrew> function in the language_defn base class, I then add a new virtual
Andrew> method that is only used from within get_symbol_name_matcher, this can
Andrew> then be overridden by specific languages as needed.  So we now have:

Seems reasonable.

Andrew> +symbol_name_matcher_ftype *
Andrew> +language_defn::get_symbol_name_matcher
Andrew> +	(const lookup_name_info &lookup_name) const
Andrew> +{
Andrew> +  /* If currently in Ada mode, and the lookup name is wrapped in
Andrew> +     '<...>', hijack all symbol name comparisons using the Ada
Andrew> +     matcher, which handles the verbatim matching.  */

FWIW I hope to get rid of this someday.  I know I've looked into it
before, but I don't recall now what the difficulty was.

Tom

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-06-15 14:22 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-02 13:32 [PATCH 0/9] Further Conversion of Language Class Hierarchy Andrew Burgess
2020-06-02 13:32 ` [PATCH 1/9] gdb: Convert language la_class_name_from_physname field to a method Andrew Burgess
2020-06-02 13:32 ` [PATCH 2/9] gdb: Convert language la_compute_program " Andrew Burgess
2020-06-02 13:32 ` [PATCH 3/9] gdb: Convert language la_get_symbol_name_matcher " Andrew Burgess
2020-06-15 14:22   ` Tom Tromey
2020-06-02 13:32 ` [PATCH 4/9] gdb: Convert language la_word_break_characters " Andrew Burgess
2020-06-02 13:32 ` [PATCH 5/9] gdb: Convert language la_collect_symbol_completion_matches " Andrew Burgess
2020-06-02 13:32 ` [PATCH 6/9] gdb: Convert language la_watch_location_expression " Andrew Burgess
2020-06-02 13:32 ` [PATCH 7/9] gdb: Convert language la_value_print " Andrew Burgess
2020-06-02 13:32 ` [PATCH 8/9] gdb: Convert language la_value_print_inner " Andrew Burgess
2020-06-02 13:32 ` [PATCH 9/9] gdb: Convert language la_lookup_symbol_nonlocal " Andrew Burgess
2020-06-10  2:54 ` [PATCH 0/9] Further Conversion of Language Class Hierarchy Simon Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).