public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 3/9] gdb: Convert language la_read_var_value field to a method
Date: Mon, 11 May 2020 23:35:48 +0100	[thread overview]
Message-ID: <1f2b61baf2d7a36845b5caf392e6682fb1474d36.1589235908.git.andrew.burgess@embecosm.com> (raw)
In-Reply-To: <cover.1589235908.git.andrew.burgess@embecosm.com>

This commit changes the language_data::la_read_var_value 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_read_var_value): Delete function, move
	implementation to...
	(ada_language::read_var_value): ...here.
	(ada_language_data): Delete la_read_var_value initializer.
	* c-lang.c (c_language_data): Likewise.
	(cplus_language_data): Likewise.
	(minimal_language_data): Likewise.
	* d-lang.c (d_language_data): Likewise.
	* f-lang.c (f_language_data): Likewise.
	* findvar.c (read_var_value): Update header comment, and change to
	call member function instead of function pointer.
	* go-lang.c (go_language_data): Likewise.
	* language.c (language_defn::read_var_value): New member function.
	(unknown_language_data): Delete la_read_var_value initializer.
	(auto_language_data): Likewise.
	* language.h (struct language_data): Delete la_read_var_value
	field.
	(language_defn::read_var_value): New member function.
	(default_read_var_value): Delete declaration.
	* m2-lang.c (m2_language_data): Delete la_read_var_value
	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     | 28 ++++++++++++++++++++++++++++
 gdb/ada-lang.c    | 41 ++++++++++++++++++++---------------------
 gdb/c-lang.c      |  4 ----
 gdb/d-lang.c      |  1 -
 gdb/f-lang.c      |  1 -
 gdb/findvar.c     |  5 ++---
 gdb/go-lang.c     |  1 -
 gdb/language.c    | 12 ++++++++++--
 gdb/language.h    | 30 +++++++++++++++---------------
 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, 75 insertions(+), 53 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 47007e52119..f39b4e0747c 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -14034,26 +14034,6 @@ ada_get_symbol_name_matcher (const lookup_name_info &lookup_name)
     }
 }
 
-/* Implement the "la_read_var_value" language_defn method for Ada.  */
-
-static struct value *
-ada_read_var_value (struct symbol *var, const struct block *var_block,
-		    struct frame_info *frame)
-{
-  /* The only case where default_read_var_value is not sufficient
-     is when VAR is a renaming...  */
-  if (frame != nullptr)
-    {
-      const struct block *frame_block = get_frame_block (frame, NULL);
-      if (frame_block != nullptr && ada_is_renaming_symbol (var))
-	return ada_read_renaming_var_value (var, frame_block);
-    }
-
-  /* This is a typical case where we expect the default_read_var_value
-     function to work.  */
-  return default_read_var_value (var, var_block, frame);
-}
-
 static const char *ada_extensions[] =
 {
   ".adb", ".ads", ".a", ".ada", ".dg", NULL
@@ -14082,7 +14062,6 @@ extern const struct language_data ada_language_data =
   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 */
-  ada_read_var_value,		/* la_read_var_value */
   NULL,                         /* Language specific skip_trampoline */
   NULL,                         /* name_of_this */
   true,                         /* la_store_sym_names_in_linkage_form_p */
@@ -14128,6 +14107,26 @@ class ada_language : public language_defn
     LA_VALUE_PRINT (index_value, stream, options);
     fprintf_filtered (stream, " => ");
   }
+
+  /* Implement the "read_var_value" language_defn method for Ada.  */
+
+  struct value *read_var_value (struct symbol *var,
+				const struct block *var_block,
+				struct frame_info *frame) const override
+  {
+    /* The only case where default_read_var_value is not sufficient
+       is when VAR is a renaming...  */
+    if (frame != nullptr)
+      {
+	const struct block *frame_block = get_frame_block (frame, NULL);
+	if (frame_block != nullptr && ada_is_renaming_symbol (var))
+	  return ada_read_renaming_var_value (var, frame_block);
+      }
+
+    /* This is a typical case where we expect the default_read_var_value
+       function to work.  */
+    return default_read_var_value (var, var_block, frame);
+  }
 };
 
 /* Single instance of the Ada language class.  */
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index af4b4d3cf02..8fbbf4b44d4 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -907,7 +907,6 @@ extern const struct language_data c_language_data =
   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 */
-  default_read_var_value,	/* la_read_var_value */
   NULL,				/* Language specific skip_trampoline */
   NULL,				/* name_of_this */
   true,				/* la_store_sym_names_in_linkage_form_p */
@@ -1067,7 +1066,6 @@ extern const struct language_data cplus_language_data =
   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 */
-  default_read_var_value,	/* la_read_var_value */
   cplus_skip_trampoline,	/* Language specific skip_trampoline */
   "this",                       /* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
@@ -1136,7 +1134,6 @@ extern const struct language_data asm_language_data =
   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 */
-  default_read_var_value,	/* la_read_var_value */
   NULL,				/* Language specific skip_trampoline */
   NULL,				/* name_of_this */
   true,				/* la_store_sym_names_in_linkage_form_p */
@@ -1202,7 +1199,6 @@ extern const struct language_data minimal_language_data =
   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 */
-  default_read_var_value,	/* la_read_var_value */
   NULL,				/* Language specific skip_trampoline */
   NULL,				/* name_of_this */
   true,				/* la_store_sym_names_in_linkage_form_p */
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index af8143b9b13..e55d82e08be 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -228,7 +228,6 @@ extern const struct language_data d_language_data =
 				   syntax.  */
   d_value_print_inner,		/* la_value_print_inner */
   c_value_print,		/* Print a top-level value.  */
-  default_read_var_value,	/* la_read_var_value */
   NULL,				/* Language specific skip_trampoline.  */
   "this",
   false,			/* la_store_sym_names_in_linkage_form_p */
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 1b79485f61d..310eb999f45 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -650,7 +650,6 @@ extern const struct language_data f_language_data =
   f_print_typedef,		/* Print a typedef using appropriate syntax */
   f_value_print_innner,		/* la_value_print_inner */
   c_value_print,		/* FIXME */
-  default_read_var_value,	/* la_read_var_value */
   NULL,				/* Language specific skip_trampoline */
   NULL,                    	/* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
diff --git a/gdb/findvar.c b/gdb/findvar.c
index ac4f5c3997d..3bed2706502 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -801,7 +801,7 @@ default_read_var_value (struct symbol *var, const struct block *var_block,
   return v;
 }
 
-/* Calls VAR's language la_read_var_value hook with the given arguments.  */
+/* Calls VAR's language read_var_value hook with the given arguments.  */
 
 struct value *
 read_var_value (struct symbol *var, const struct block *var_block,
@@ -810,9 +810,8 @@ read_var_value (struct symbol *var, const struct block *var_block,
   const struct language_defn *lang = language_def (var->language ());
 
   gdb_assert (lang != NULL);
-  gdb_assert (lang->la_read_var_value != NULL);
 
-  return lang->la_read_var_value (var, var_block, frame);
+  return lang->read_var_value (var, var_block, frame);
 }
 
 /* Install default attributes for register values.  */
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index a69091bb631..cd960961400 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -599,7 +599,6 @@ extern const struct language_data go_language_data =
 				   syntax.  */
   go_value_print_inner,		/* la_value_print_inner */
   c_value_print,		/* Print a top-level value.  */
-  default_read_var_value,	/* la_read_var_value */
   NULL,				/* Language specific skip_trampoline.  */
   NULL,				/* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
diff --git a/gdb/language.c b/gdb/language.c
index 4b2a405c725..8917099d8fe 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -664,6 +664,16 @@ language_defn::print_array_index (struct value *index_value,
 
 /* See language.h.  */
 
+struct value *
+language_defn::read_var_value (struct symbol *var,
+					const struct block *var_block,
+					struct frame_info *frame) const
+{
+  return default_read_var_value (var, var_block, frame);
+}
+
+/* See language.h.  */
+
 bool
 default_symbol_name_matcher (const char *symbol_search_name,
 			     const lookup_name_info &lookup_name,
@@ -831,7 +841,6 @@ extern const struct language_data unknown_language_data =
   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 */
-  default_read_var_value,	/* la_read_var_value */
   unk_lang_trampoline,		/* Language specific skip_trampoline */
   "this",        	    	/* name_of_this */
   true,				/* store_sym_names_in_linkage_form_p */
@@ -895,7 +904,6 @@ extern const struct language_data auto_language_data =
   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 */
-  default_read_var_value,	/* la_read_var_value */
   unk_lang_trampoline,		/* Language specific skip_trampoline */
   "this",		        /* name_of_this */
   false,			/* store_sym_names_in_linkage_form_p */
diff --git a/gdb/language.h b/gdb/language.h
index 307a08c13cd..2219bcf3869 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -272,21 +272,6 @@ struct language_data
     void (*la_value_print) (struct value *, struct ui_file *,
 			    const struct value_print_options *);
 
-    /* Given a symbol VAR, the corresponding block VAR_BLOCK (if any) and a
-       stack frame id FRAME, read the value of the variable and return (pointer
-       to a) struct value containing the value.
-
-       VAR_BLOCK is needed if there's a possibility for VAR to be outside
-       FRAME.  This is what happens if FRAME correspond to a nested function
-       and VAR is defined in the outer function.  If callers know that VAR is
-       located in FRAME or is global/static, NULL can be passed as VAR_BLOCK.
-
-       Throw an error if the variable cannot be found.  */
-
-    struct value *(*la_read_var_value) (struct symbol *var,
-					const struct block *var_block,
-					struct frame_info *frame);
-
     /* PC is possibly an unknown languages trampoline.
        If that PC falls in a trampoline belonging to this language,
        return the address of the first pc in the real function, or 0
@@ -496,6 +481,21 @@ struct language_defn : language_data
 				  struct ui_file *stream,
 				  const value_print_options *options) const;
 
+  /* Given a symbol VAR, the corresponding block VAR_BLOCK (if any) and a
+     stack frame id FRAME, read the value of the variable and return (pointer
+     to a) struct value containing the value.
+
+     VAR_BLOCK is needed if there's a possibility for VAR to be outside
+     FRAME.  This is what happens if FRAME correspond to a nested function
+     and VAR is defined in the outer function.  If callers know that VAR is
+     located in FRAME or is global/static, NULL can be passed as VAR_BLOCK.
+
+     Throw an error if the variable cannot be found.  */
+
+  virtual struct value *read_var_value (struct symbol *var,
+					const struct block *var_block,
+					struct frame_info *frame) 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 4d4f5493938..a6be7c3a889 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -397,7 +397,6 @@ extern const struct language_data m2_language_data =
   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 */
-  default_read_var_value,	/* la_read_var_value */
   NULL,				/* Language specific skip_trampoline */
   NULL,		                /* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 47d75620dcb..2ac484c7bcd 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -386,7 +386,6 @@ extern const struct language_data objc_language_data =
   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 */
-  default_read_var_value,	/* la_read_var_value */
   objc_skip_trampoline, 	/* Language specific skip_trampoline */
   "self",		        /* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index ebd13d68381..c1dc325e29c 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -1063,7 +1063,6 @@ extern const struct language_data opencl_language_data =
   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 */
-  default_read_var_value,	/* la_read_var_value */
   NULL,				/* Language specific skip_trampoline */
   NULL,                         /* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index 34063232da6..8d64c30376a 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -451,7 +451,6 @@ extern const struct language_data pascal_language_data =
   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 */
-  default_read_var_value,	/* la_read_var_value */
   NULL,				/* Language specific skip_trampoline */
   "this",		        /* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 41bb47189eb..7f3ed2bb3ec 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -2123,7 +2123,6 @@ extern const struct language_data rust_language_data =
   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 */
-  default_read_var_value,	/* la_read_var_value */
   NULL,				/* Language specific skip_trampoline */
   NULL,				/* name_of_this */
   false,			/* la_store_sym_names_in_linkage_form_p */
-- 
2.25.3


  parent reply	other threads:[~2020-05-11 22:36 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-11 22:35 [PATCH 0/9] Starting to convert languages to separate classes Andrew Burgess
2020-05-11 22:35 ` [PATCH 1/9] gdb: Represent all languages as sub-classes of language_defn Andrew Burgess
2020-05-11 22:35 ` [PATCH 2/9] gdb: Convert language la_print_array_index field to a method Andrew Burgess
2020-05-11 22:35 ` Andrew Burgess [this message]
2020-05-14 19:43   ` [PATCH 3/9] gdb: Convert language la_read_var_value " Tom Tromey
2020-05-11 22:35 ` [PATCH 4/9] gdb: Convert language la_pass_by_reference " Andrew Burgess
2020-05-14 11:00   ` Aktemur, Tankut Baris
2020-05-14 19:49     ` Tom Tromey
2020-05-14 19:48   ` Tom Tromey
2020-05-11 22:35 ` [PATCH 5/9] gdb: Convert language la_language_arch_info " Andrew Burgess
2020-05-11 22:35 ` [PATCH 6/9] gdb: Convert language la_lookup_transparent_type " Andrew Burgess
2020-05-11 22:35 ` [PATCH 7/9] gdb: Convert language la_iterate_over_symbols " Andrew Burgess
2020-05-12 23:21   ` Christian Biesinger
2020-05-11 22:35 ` [PATCH 8/9] gdb: Convert language la_get_compile_instance " Andrew Burgess
2020-05-12 21:11   ` Christian Biesinger
2020-05-11 22:35 ` [PATCH 9/9] gdb: Convert language la_search_name_hash " Andrew Burgess
2020-05-12 21:10   ` Christian Biesinger
2020-05-12 23:17 ` [PATCH 0/9] Starting to convert languages to separate classes Christian Biesinger
2020-05-13  1:33 ` Simon Marchi
2020-05-14 19:57 ` Tom Tromey
2020-05-15 15:06 ` [PATCHv2 00/13] " Andrew Burgess
2020-05-15 15:06   ` [PATCHv2 01/13] gdb: Represent all languages as sub-classes of language_defn Andrew Burgess
2020-05-15 15:06   ` [PATCHv2 02/13] gdb: Convert language la_print_array_index field to a method Andrew Burgess
2020-05-15 15:06   ` [PATCHv2 03/13] gdb: Convert language la_read_var_value " Andrew Burgess
2020-05-15 15:06   ` [PATCHv2 04/13] gdb: Convert language la_pass_by_reference " Andrew Burgess
2020-05-15 15:06   ` [PATCHv2 05/13] gdb: Convert language la_language_arch_info " Andrew Burgess
2020-05-15 15:06   ` [PATCHv2 06/13] gdb: Convert language la_lookup_transparent_type " Andrew Burgess
2020-05-15 15:06   ` [PATCHv2 07/13] gdb: Convert language la_iterate_over_symbols " Andrew Burgess
2020-05-15 15:06   ` [PATCHv2 08/13] gdb: Convert language la_get_compile_instance " Andrew Burgess
2020-05-15 15:06   ` [PATCHv2 09/13] gdb: Convert language la_search_name_hash " Andrew Burgess
2020-05-15 17:47     ` Christian Biesinger
2020-05-15 15:06   ` [PATCHv2 10/13] gdb: Convert language la_sniff_from_mangled_name " Andrew Burgess
2020-05-15 15:06   ` [PATCHv2 11/13] gdb: Convert language la_print_type " Andrew Burgess
2020-05-15 15:06   ` [PATCHv2 12/13] gdb: Convert language la_demangle " Andrew Burgess
2020-05-15 15:06   ` [PATCHv2 13/13] gdb: Convert language skip_trampoline " Andrew Burgess
2020-05-15 17:06   ` [PATCHv2 00/13] Starting to convert languages to separate classes Tom Tromey
2020-06-01 16:02   ` Andrew Burgess

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1f2b61baf2d7a36845b5caf392e6682fb1474d36.1589235908.git.andrew.burgess@embecosm.com \
    --to=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).