public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Turn value_arch into method
@ 2023-02-13 22:27 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2023-02-13 22:27 UTC (permalink / raw)
  To: gdb-cvs

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

commit f9ee742cd7f9ea4f6050599a4784cb162dcc49b5
Author: Tom Tromey <tom@tromey.com>
Date:   Tue Jan 31 08:31:48 2023 -0700

    Turn value_arch into method
    
    This changes value_arch to be a method of value.  Much of this patch
    was written by script.
    
    Approved-By: Simon Marchi <simon.marchi@efficios.com>

Diff:
---
 gdb/valops.c |  2 +-
 gdb/value.c  | 12 ++++++------
 gdb/value.h  |  7 +++----
 3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/gdb/valops.c b/gdb/valops.c
index 1cac2496183..ae876b795d0 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -1045,7 +1045,7 @@ read_value_memory (struct value *val, LONGEST bit_offset,
 		   gdb_byte *buffer, size_t length)
 {
   ULONGEST xfered_total = 0;
-  struct gdbarch *arch = get_value_arch (val);
+  struct gdbarch *arch = val->arch ();
   int unit_size = gdbarch_addressable_memory_unit_size (arch);
   enum target_object object;
 
diff --git a/gdb/value.c b/gdb/value.c
index 9347acd09ce..8eb3cb20379 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -163,9 +163,9 @@ value::~value ()
 /* See value.h.  */
 
 struct gdbarch *
-get_value_arch (const struct value *value)
+value::arch () const
 {
-  return value->type ()->arch ();
+  return type ()->arch ();
 }
 
 int
@@ -1074,7 +1074,7 @@ set_value_parent (struct value *value, struct value *parent)
 gdb::array_view<gdb_byte>
 value_contents_raw (struct value *value)
 {
-  struct gdbarch *arch = get_value_arch (value);
+  struct gdbarch *arch = value->arch ();
   int unit_size = gdbarch_addressable_memory_unit_size (arch);
 
   allocate_value_contents (value, true);
@@ -1251,7 +1251,7 @@ value_contents_copy_raw (struct value *dst, LONGEST dst_offset,
 			 struct value *src, LONGEST src_offset, LONGEST length)
 {
   LONGEST src_bit_offset, dst_bit_offset, bit_length;
-  struct gdbarch *arch = get_value_arch (src);
+  struct gdbarch *arch = src->arch ();
   int unit_size = gdbarch_addressable_memory_unit_size (arch);
 
   /* A lazy DST would make that this copy operation useless, since as
@@ -2324,7 +2324,7 @@ set_internalvar_component (struct internalvar *var,
     {
     case INTERNALVAR_VALUE:
       addr = value_contents_writeable (var->u.value).data ();
-      arch = get_value_arch (var->u.value);
+      arch = var->u.value->arch ();
       unit_size = gdbarch_addressable_memory_unit_size (arch);
 
       if (bitsize)
@@ -3048,7 +3048,7 @@ value_primitive_field (struct value *arg1, LONGEST offset,
 {
   struct value *v;
   struct type *type;
-  struct gdbarch *arch = get_value_arch (arg1);
+  struct gdbarch *arch = arg1->arch ();
   int unit_size = gdbarch_addressable_memory_unit_size (arch);
 
   arg_type = check_typedef (arg_type);
diff --git a/gdb/value.h b/gdb/value.h
index 2b626adbb29..66297e455b9 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -170,6 +170,9 @@ struct value
   void deprecated_set_type (struct type *type)
   { m_type = type; }
 
+  /* Return the gdbarch associated with the value. */
+  struct gdbarch *arch () const;
+
 
   /* Type of value; either not an lval, or one of the various
      different possible kinds of lval.  */
@@ -348,10 +351,6 @@ struct value
   ULONGEST m_limited_length = 0;
 };
 
-/* Return the gdbarch associated with the value. */
-
-extern struct gdbarch *get_value_arch (const struct value *value);
-
 /* Only used for bitfields; number of bits contained in them.  */
 
 extern LONGEST value_bitsize (const struct value *);

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

only message in thread, other threads:[~2023-02-13 22:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-13 22:27 [binutils-gdb] Turn value_arch into method 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).