public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Make gdb property batons type-safe
@ 2023-03-01 22:37 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2023-03-01 22:37 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=802dace16f8c6dfa3200381669015a7dccbd5e28

commit 802dace16f8c6dfa3200381669015a7dccbd5e28
Author: Tom Tromey <tromey@adacore.com>
Date:   Wed Mar 1 07:59:44 2023 -0700

    Make gdb property batons type-safe
    
    gdbtypes treats dynamic property batons as 'void *', but in actuality
    the only users all use dwarf2_property_baton.  This patch changes this
    code to be type-safe.  If a new type is needed here, it seems like
    that too could be done in a type-safe way.
    
    Approved-By: Simon Marchi <simon.marchi@efficios.com>

Diff:
---
 gdb/dwarf2/loc.c | 12 ++++--------
 gdb/gdbtypes.h   | 11 ++++++-----
 2 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 4727651027b..bf582bcfeff 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -1649,8 +1649,7 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop,
     {
     case PROP_LOCEXPR:
       {
-	const struct dwarf2_property_baton *baton
-	  = (const struct dwarf2_property_baton *) prop->baton ();
+	const struct dwarf2_property_baton *baton = prop->baton ();
 	gdb_assert (baton->property_type != NULL);
 
 	bool is_reference = baton->locexpr.is_reference;
@@ -1692,8 +1691,7 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop,
 
     case PROP_LOCLIST:
       {
-	struct dwarf2_property_baton *baton
-	  = (struct dwarf2_property_baton *) prop->baton ();
+	struct dwarf2_property_baton *baton = prop->baton ();
 	CORE_ADDR pc;
 	const gdb_byte *data;
 	struct value *val;
@@ -1724,8 +1722,7 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop,
 
     case PROP_ADDR_OFFSET:
       {
-	struct dwarf2_property_baton *baton
-	  = (struct dwarf2_property_baton *) prop->baton ();
+	struct dwarf2_property_baton *baton = prop->baton ();
 	const struct property_addr_info *pinfo;
 	struct value *val;
 
@@ -1775,8 +1772,7 @@ dwarf2_compile_property_to_c (string_file *stream,
 			      CORE_ADDR pc,
 			      struct symbol *sym)
 {
-  struct dwarf2_property_baton *baton
-    = (struct dwarf2_property_baton *) prop->baton ();
+  struct dwarf2_property_baton *baton = prop->baton ();
   const gdb_byte *data;
   size_t size;
   dwarf2_per_cu_data *per_cu;
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index c2253310666..701a64d457a 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -64,6 +64,7 @@ struct value_print_options;
 struct language_defn;
 struct dwarf2_per_cu_data;
 struct dwarf2_per_objfile;
+struct dwarf2_property_baton;
 
 /* Some macros for char-based bitfields.  */
 
@@ -289,7 +290,7 @@ union dynamic_prop_data
 
   /* Storage for dynamic property.  */
 
-  void *baton;
+  dwarf2_property_baton *baton;
 
   /* Storage of variant parts for a type.  A type with variant parts
      has all its fields "linearized" -- stored in a single field
@@ -339,7 +340,7 @@ struct dynamic_prop
     m_data.const_val = const_val;
   }
 
-  void *baton () const
+  dwarf2_property_baton *baton () const
   {
     gdb_assert (m_kind == PROP_LOCEXPR
 		|| m_kind == PROP_LOCLIST
@@ -348,19 +349,19 @@ struct dynamic_prop
     return m_data.baton;
   }
 
-  void set_locexpr (void *baton)
+  void set_locexpr (dwarf2_property_baton *baton)
   {
     m_kind = PROP_LOCEXPR;
     m_data.baton = baton;
   }
 
-  void set_loclist (void *baton)
+  void set_loclist (dwarf2_property_baton *baton)
   {
     m_kind = PROP_LOCLIST;
     m_data.baton = baton;
   }
 
-  void set_addr_offset (void *baton)
+  void set_addr_offset (dwarf2_property_baton *baton)
   {
     m_kind = PROP_ADDR_OFFSET;
     m_data.baton = baton;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-01 22:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-01 22:37 [binutils-gdb] Make gdb property batons type-safe Tom Tromey

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).