Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH v2 06/15] Qualify calls to gdb::copy
Date: Wed, 11 Nov 2026 08:58:54 -0700	[thread overview]
Message-ID: <20261111-span-part-1-v2-6-cd4e33a8a723@adacore.com> (raw)
In-Reply-To: <20261111-span-part-1-v2-0-cd4e33a8a723@adacore.com>

Some calls to gdb::copy are relying on Koenig lookup.  However, when
using the real C++20 std::span, this will not work.  This patch
changes these calls to fully qualify the name.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31422
---
 gdb/aarch64-tdep.c             |  6 +++---
 gdb/ada-lang.c                 |  5 +++--
 gdb/dwarf2/expr.c              |  4 ++--
 gdb/frame.c                    |  8 ++++----
 gdb/regcache.c                 | 18 +++++++++---------
 gdb/unittests/span-selftests.c | 14 +++++++-------
 gdb/valarith.c                 | 16 ++++++++--------
 gdb/valops.c                   | 22 +++++++++++-----------
 gdbserver/regcache.cc          |  4 ++--
 9 files changed, 49 insertions(+), 48 deletions(-)

diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index 7fc3a3aec31..9f40cb8f83f 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -3570,7 +3570,7 @@ aarch64_pseudo_write_1 (gdbarch *gdbarch, const frame_info_ptr &next_frame,
   static_assert (AARCH64_V0_REGNUM == AARCH64_SVE_Z0_REGNUM);
 
   gdb::span<gdb_byte> raw_view (raw_buf);
-  copy (buf, raw_view.subspan (0, buf.size ()));
+  gdb::copy (buf, raw_view.subspan (0, buf.size ()));
   put_frame_register (next_frame, raw_regnum, raw_view);
 }
 
@@ -3608,7 +3608,7 @@ aarch64_sme_pseudo_register_write (gdbarch *gdbarch, const frame_info_ptr &next_
 	  = data.subspan (chunks * offsets.chunk_size, offsets.chunk_size);
 	gdb::span<gdb_byte> dst
 	  = za_view.subspan (chunks * offsets.stride_size, offsets.chunk_size);
-	copy (src, dst);
+	gdb::copy (src, dst);
       }
   }
 
@@ -3683,7 +3683,7 @@ aarch64_pseudo_write (gdbarch *gdbarch, const frame_info_ptr &next_frame,
       /* First zero-out the contents of X.  */
       gdb_byte bytes[8] {};
       gdb::span<gdb_byte> bytes_view (bytes);
-      copy (buf, bytes_view.subspan (offset, 4));
+      gdb::copy (buf, bytes_view.subspan (offset, 4));
 
       /* Write to the bottom 4 bytes of X.  */
       put_frame_register (next_frame, x_regnum, bytes_view);
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index b1560fdb85d..80b49529b2a 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -4706,7 +4706,7 @@ ada_convert_actual (struct value *actual, struct type *formal_type0)
 
 	      actual_type = ada_check_typedef (actual->type ());
 	      val = value::allocate (actual_type);
-	      copy (actual->contents (), val->contents_raw ());
+	      gdb::copy (actual->contents (), val->contents_raw ());
 	      actual = ensure_lval (val);
 	    }
 	  result = value_addr (actual);
@@ -9212,7 +9212,8 @@ ada_promote_array_of_integrals (struct type *type, struct value *val)
       struct value *elt = value_cast (elt_type, value_subscript (val, lo + i));
       int elt_len = elt_type->length ();
 
-      copy (elt->contents_all (), res_contents.subspan (elt_len * i, elt_len));
+      gdb::copy (elt->contents_all (),
+		 res_contents.subspan (elt_len * i, elt_len));
     }
 
   return res;
diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c
index 8df2b8da28c..012f9bae369 100644
--- a/gdb/dwarf2/expr.c
+++ b/gdb/dwarf2/expr.c
@@ -1118,8 +1118,8 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type,
 	    if (gdbarch_byte_order (arch) == BFD_ENDIAN_BIG)
 	      subobj_offset += n - max;
 
-	    copy (val->contents_all ().subspan (subobj_offset, len),
-		  retval->contents_raw ());
+	    gdb::copy (val->contents_all ().subspan (subobj_offset, len),
+		       retval->contents_raw ());
 	  }
 	  break;
 
diff --git a/gdb/frame.c b/gdb/frame.c
index 3d20879f004..e24841bb8a1 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -1635,8 +1635,8 @@ get_frame_register_bytes (const frame_info_ptr &next_frame, int regnum,
 	      return false;
 	    }
 
-	  copy (value->contents_all ().subspan (offset, curr_len),
-		buffer.subspan (0, curr_len));
+	  gdb::copy (value->contents_all ().subspan (offset, curr_len),
+		     buffer.subspan (0, curr_len));
 	  release_value (value);
 	}
 
@@ -1678,8 +1678,8 @@ put_frame_register_bytes (const frame_info_ptr &next_frame, int regnum,
 	  value *value = frame_unwind_register_value (next_frame, regnum);
 	  gdb_assert (value != nullptr);
 
-	  copy (buffer.subspan (0, curr_len),
-		value->contents_writeable ().subspan (offset, curr_len));
+	  gdb::copy (buffer.subspan (0, curr_len),
+		     value->contents_writeable ().subspan (offset, curr_len));
 	  put_frame_register (next_frame, regnum, value->contents_raw ());
 	  release_value (value);
 	}
diff --git a/gdb/regcache.c b/gdb/regcache.c
index e706ccd8faa..0e7e6a85284 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -622,7 +622,7 @@ readable_regcache::raw_read (int regnum, gdb::span<gdb_byte> dst)
   if (m_register_status[regnum] != REG_VALID)
     memset (dst.data (), 0, dst.size ());
   else
-    copy (register_buffer (regnum), dst);
+    gdb::copy (register_buffer (regnum), dst);
 
   return m_register_status[regnum];
 }
@@ -726,7 +726,7 @@ readable_regcache::cooked_read (int regnum, gdb::span<gdb_byte> dst)
   if (m_has_pseudo && m_register_status[regnum] != REG_UNKNOWN)
     {
       if (m_register_status[regnum] == REG_VALID)
-	copy (register_buffer (regnum), dst);
+	gdb::copy (register_buffer (regnum), dst);
       else
 	memset (dst.data (), 0, dst.size ());
 
@@ -741,7 +741,7 @@ readable_regcache::cooked_read (int regnum, gdb::span<gdb_byte> dst)
 	 regnum);
 
       if (computed->entirely_available ())
-	copy (computed->contents_raw (), dst);
+	gdb::copy (computed->contents_raw (), dst);
       else
 	{
 	  memset (dst.data (), 0, dst.size ());
@@ -975,7 +975,7 @@ readable_regcache::read_part (int regnum, int offset,
     return status;
 
   /* Copy out.  */
-  copy (reg.subspan (offset, dst.size ()), dst);
+  gdb::copy (reg.subspan (offset, dst.size ()), dst);
   return REG_VALID;
 }
 
@@ -1006,7 +1006,7 @@ reg_buffer::raw_collect_part (int regnum, int offset,
   gdb_byte *reg_buf = (gdb_byte *) alloca (reg_size);
   auto reg = gdb::make_span (reg_buf, reg_size);
   raw_collect (regnum, reg);
-  copy (reg.subspan (offset, dst.size ()), dst);
+  gdb::copy (reg.subspan (offset, dst.size ()), dst);
 }
 
 /* See regcache.h.  */
@@ -1051,7 +1051,7 @@ regcache::write_part (int regnum, int offset,
     return status;
 
   /* Update buffer, then write back to regcache.  */
-  copy (src, reg.subspan (offset, src.size ()));
+  gdb::copy (src, reg.subspan (offset, src.size ()));
 
   if (is_raw)
     raw_write (regnum, reg);
@@ -1090,7 +1090,7 @@ reg_buffer::raw_supply_part (int regnum, int offset,
   raw_collect (regnum, reg);
 
   /* Write to buffer, then write out.  */
-  copy (src, reg.subspan (offset, src.size ()));
+  gdb::copy (src, reg.subspan (offset, src.size ()));
   raw_supply (regnum, reg);
 }
 
@@ -1141,7 +1141,7 @@ reg_buffer::raw_supply (int regnum, gdb::span<const gdb_byte> src)
 
   if (src.data () != nullptr)
     {
-      copy (src, dst);
+      gdb::copy (src, dst);
       m_register_status[regnum] = REG_VALID;
     }
   else
@@ -1205,7 +1205,7 @@ void
 reg_buffer::raw_collect (int regnum, gdb::span<gdb_byte> dst) const
 {
   gdb::span<const gdb_byte> src = register_buffer (regnum);
-  copy (src, dst);
+  gdb::copy (src, dst);
 }
 
 /* See regcache.h.  */
diff --git a/gdb/unittests/span-selftests.c b/gdb/unittests/span-selftests.c
index 8beb1b033ad..0012d3600d4 100644
--- a/gdb/unittests/span-selftests.c
+++ b/gdb/unittests/span-selftests.c
@@ -600,7 +600,7 @@ run_copy_test ()
     std::vector<T> dest_v (4, -1);
 
     SELF_CHECK (dest_v != src_v);
-    copy (gdb::span<const T> (src_v), gdb::span<T> (dest_v));
+    gdb::copy (gdb::span<const T> (src_v), gdb::span<T> (dest_v));
     SELF_CHECK (dest_v == src_v);
   }
 
@@ -609,8 +609,8 @@ run_copy_test ()
     std::vector<T> vec = {1, 2, 3, 4, 5, 6, 7, 8};
     gdb::span<T> v = vec;
 
-    copy (v.subspan (1, 4),
-	  v.subspan (2, 4));
+    gdb::copy (v.subspan (1, 4),
+	       v.subspan (2, 4));
 
     std::vector<T> expected = {1, 2, 2, 3, 4, 5, 7, 8};
     SELF_CHECK (vec == expected);
@@ -621,8 +621,8 @@ run_copy_test ()
     std::vector<T> vec = {1, 2, 3, 4, 5, 6, 7, 8};
     gdb::span<T> v = vec;
 
-    copy (v.subspan (2, 4),
-	  v.subspan (1, 4));
+    gdb::copy (v.subspan (2, 4),
+	       v.subspan (1, 4));
 
     std::vector<T> expected = {1, 3, 4, 5, 6, 6, 7, 8};
     SELF_CHECK (vec == expected);
@@ -633,8 +633,8 @@ run_copy_test ()
     std::vector<T> vec = {1, 2, 3, 4, 5, 6, 7, 8};
     gdb::span<T> v = vec;
 
-    copy (v.subspan (2, 4),
-	  v.subspan (2, 4));
+    gdb::copy (v.subspan (2, 4),
+	       v.subspan (2, 4));
 
     std::vector<T> expected = {1, 2, 3, 4, 5, 6, 7, 8};
     SELF_CHECK (vec == expected);
diff --git a/gdb/valarith.c b/gdb/valarith.c
index aeb0ce195cc..1918050aa6f 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -1420,8 +1420,8 @@ value_vector_widen (struct value *scalar_value, struct type *vector_type)
 
   for (i = 0; i < high_bound - low_bound + 1; i++)
     /* Duplicate the contents of elval into the destination vector.  */
-    copy (elval->contents_all (),
-	  val_contents.subspan (i * elt_len, elt_len));
+    gdb::copy (elval->contents_all (),
+	       val_contents.subspan (i * elt_len, elt_len));
 
   return val;
 }
@@ -1468,8 +1468,8 @@ vector_binop (struct value *val1, struct value *val2, enum exp_opcode op)
     {
       value *tmp = value_binop (value_subscript (val1, i),
 				value_subscript (val2, i), op);
-      copy (tmp->contents_all (),
-	    val_contents.subspan (i * elsize, elsize));
+      gdb::copy (tmp->contents_all (),
+		 val_contents.subspan (i * elsize, elsize));
      }
 
   return val;
@@ -1763,8 +1763,8 @@ value_neg (struct value *arg1)
       for (i = 0; i < high_bound - low_bound + 1; i++)
 	{
 	  value *tmp = value_neg (value_subscript (arg1, i));
-	  copy (tmp->contents_all (),
-		val_contents.subspan (i * elt_len, elt_len));
+	  gdb::copy (tmp->contents_all (),
+		     val_contents.subspan (i * elt_len, elt_len));
 	}
       return val;
     }
@@ -1814,8 +1814,8 @@ value_complement (struct value *arg1)
       for (i = 0; i < high_bound - low_bound + 1; i++)
 	{
 	  value *tmp = value_complement (value_subscript (arg1, i));
-	  copy (tmp->contents_all (),
-		val_contents.subspan (i * elt_len, elt_len));
+	  gdb::copy (tmp->contents_all (),
+		     val_contents.subspan (i * elt_len, elt_len));
 	}
     }
   else if (type->code () == TYPE_CODE_COMPLEX)
diff --git a/gdb/valops.c b/gdb/valops.c
index 53af4554f34..4109c8ff498 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -983,8 +983,8 @@ value_one (struct type *type)
       for (i = 0; i < high_bound - low_bound + 1; i++)
 	{
 	  value *tmp = value_one (eltype);
-	  copy (tmp->contents_all (),
-		val_contents.subspan (i * elt_len, elt_len));
+	  gdb::copy (tmp->contents_all (),
+		     val_contents.subspan (i * elt_len, elt_len));
 	}
     }
   else
@@ -1353,7 +1353,7 @@ value_assign (struct value *toval, struct value *fromval)
      implies the returned value is not lazy, even if TOVAL was.  */
   val = toval->copy ();
   val->set_lazy (false);
-  copy (fromval->contents (), val->contents_raw ());
+  gdb::copy (fromval->contents (), val->contents_raw ());
 
   /* We copy over the enclosing type and pointed-to offset from FROMVAL
      in the case of pointer types.  For object types, the enclosing type
@@ -4109,10 +4109,10 @@ value_literal_complex (struct value *arg1,
 
   int len = real_type->length ();
 
-  copy (arg1->contents (),
-	val->contents_raw ().subspan (0, len));
-  copy (arg2->contents (),
-	val->contents_raw ().subspan (len, len));
+  gdb::copy (arg1->contents (),
+	     val->contents_raw ().subspan (0, len));
+  gdb::copy (arg2->contents (),
+	     val->contents_raw ().subspan (len, len));
 
   return val;
 }
@@ -4156,10 +4156,10 @@ cast_into_complex (struct type *type, struct value *val)
       struct value *im_val = value::allocate (val_real_type);
       int len = val_real_type->length ();
 
-      copy (val->contents ().subspan (0, len),
-	    re_val->contents_raw ());
-      copy (val->contents ().subspan (len, len),
-	    im_val->contents_raw ());
+      gdb::copy (val->contents ().subspan (0, len),
+		 re_val->contents_raw ());
+      gdb::copy (val->contents ().subspan (len, len),
+		 im_val->contents_raw ());
 
       return value_literal_complex (re_val, im_val, type);
     }
diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc
index 796181ded65..8b45b6fd71f 100644
--- a/gdbserver/regcache.cc
+++ b/gdbserver/regcache.cc
@@ -303,7 +303,7 @@ regcache::raw_supply (int n, gdb::span<const gdb_byte> src)
 
   if (src.data () != nullptr)
     {
-      copy (src, dst);
+      gdb::copy (src, dst);
 #ifndef IN_PROCESS_AGENT
       set_register_status (n, REG_VALID);
 #endif
@@ -393,7 +393,7 @@ void
 regcache::raw_collect (int n, gdb::span<gdb_byte> dst) const
 {
   auto src = register_data (this, n);
-  copy (src, dst);
+  gdb::copy (src, dst);
 }
 
 enum register_status

-- 
2.56.0


  parent reply	other threads:[~2026-11-11 16:00 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-11 15:58 [PATCH v2 00/15] Rename gdb::array_view to gdb::span Tom Tromey
2026-11-11 15:58 ` [PATCH v2 01/15] Rename array_view files Tom Tromey
2026-11-15  4:09   ` Simon Marchi
2026-11-16 15:55     ` Tom Tromey
2026-11-11 15:58 ` [PATCH v2 02/15] Rename gdb::array_view to gdb::span Tom Tromey
2026-11-15  4:18   ` Simon Marchi
2026-11-11 15:58 ` [PATCH v2 03/15] Rename gdb::make_array_view to gdb::make_span Tom Tromey
2026-11-11 15:58 ` [PATCH v2 04/15] Remove operator== and operator!= from gdb::span Tom Tromey
2026-11-11 15:58 ` [PATCH v2 05/15] Rename span::slice to span::subspan Tom Tromey
2026-11-11 15:58 ` Tom Tromey [this message]
2026-11-11 15:58 ` [PATCH v2 07/15] Add single-argument overloads of process_options et al Tom Tromey
2026-11-11 15:58 ` [PATCH v2 08/15] Remove span from cli-option.c:build_help_option Tom Tromey
2026-11-15  3:40   ` Simon Marchi
2026-11-11 15:58 ` [PATCH v2 09/15] Add gdb::make_span overload and add necessary calls Tom Tromey
2026-11-15  3:53   ` Simon Marchi
2026-11-15  4:35     ` Simon Marchi
2026-11-16 16:55       ` Tom Tromey
2026-11-11 15:58 ` [PATCH v2 10/15] Don't turn rvalue reference into a span Tom Tromey
2026-11-11 15:58 ` [PATCH v2 11/15] Change span-selftests.c for C++20 Tom Tromey
2026-11-15  4:01   ` Simon Marchi
2026-11-15  5:15     ` Simon Marchi
2026-11-11 15:59 ` [PATCH v2 12/15] Make gdb::span conform more closely to C++20 Tom Tromey
2026-11-11 15:59 ` [PATCH v2 13/15] Allow the use of C++20 std::ranges in gdbsupport/ranges.h Tom Tromey
2026-11-15  5:18   ` Simon Marchi
2026-11-11 15:59 ` [PATCH v2 14/15] Allow the use of C++20 std::span in gdbsupport/span.h Tom Tromey
2026-11-15  4:05   ` Simon Marchi
2026-11-11 15:59 ` [PATCH v2 15/15] Move gdb::ranges::equal to gdbsupport/ranges.h Tom Tromey
2026-11-15  5:21 ` [PATCH v2 00/15] Rename gdb::array_view to gdb::span Simon Marchi
2026-11-17 21:42   ` Tom Tromey

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=20261111-span-part-1-v2-6-cd4e33a8a723@adacore.com \
    --to=tromey@adacore.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