From: Matthieu Longo <matthieu.longo@arm.com>
To: <gdb-patches@sourceware.org>
Cc: Luis Machado <luis.machado@amd.com>,
Luis Machado <luis.machado.foss@gmail.com>,
Andrew Burgess <aburgess@redhat.com>,
"Matthieu Longo" <matthieu.longo@arm.com>
Subject: [PATCH v1 4/8] gdb support: add index_type to array_view for documentation purpose
Date: Fri, 3 Jul 2026 19:58:49 +0100 [thread overview]
Message-ID: <20260703185853.450440-5-matthieu.longo@arm.com> (raw)
In-Reply-To: <20260703185853.450440-1-matthieu.longo@arm.com>
The semantic of slice (size_type start, size_type size) might be
slightly ambiguous if the variable names are omitted. Making the
index type different from the size type removes this ambiguity.
This change is purely cosmetic.
---
gdbsupport/array-view.h | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/gdbsupport/array-view.h b/gdbsupport/array-view.h
index 8431d7f5add..e7baea728d4 100644
--- a/gdbsupport/array-view.h
+++ b/gdbsupport/array-view.h
@@ -87,6 +87,7 @@ class array_view
using value_type = T;
using reference = T &;
using const_reference = const T &;
+ using index_type = ptrdiff_t;
using size_type = size_t;
using const_iterator = const T *;
using iterator = T *;
@@ -165,14 +166,14 @@ class array_view
constexpr iterator end () const noexcept { return m_array + m_size; }
constexpr const_iterator cend () const noexcept { return m_array + m_size; }
- constexpr reference operator[] (size_t index) noexcept
+ constexpr reference operator[] (index_type index) noexcept
{
#if defined(_GLIBCXX_DEBUG)
gdb_assert (index < m_size);
#endif
return m_array[index];
}
- constexpr const_reference operator[] (size_t index) const noexcept
+ constexpr const_reference operator[] (index_type index) const noexcept
{
#if defined(_GLIBCXX_DEBUG)
gdb_assert (index < m_size);
@@ -187,7 +188,7 @@ class array_view
/* Return a new array view over SIZE elements starting at START. */
[[nodiscard]]
- constexpr array_view<T> slice (size_type start, size_type size) const noexcept
+ constexpr array_view<T> slice (index_type start, size_type size) const noexcept
{
#if defined(_GLIBCXX_DEBUG)
gdb_assert (start + size <= m_size);
@@ -198,7 +199,7 @@ class array_view
/* Return a new array view over all the elements after START,
inclusive. */
[[nodiscard]]
- constexpr array_view<T> slice (size_type start) const noexcept
+ constexpr array_view<T> slice (index_type start) const noexcept
{
#if defined(_GLIBCXX_DEBUG)
gdb_assert (start <= m_size);
@@ -216,7 +217,7 @@ class array_view
The two array views must have the same length. */
template <typename U, typename T>
-void copy (gdb::array_view<U> src, gdb::array_view<T> dest)
+void copy (array_view<U> src, array_view<T> dest)
{
gdb_assert (dest.size () == src.size ());
if (dest.data () < src.data ())
--
2.55.0
next prev parent reply other threads:[~2026-07-03 19:02 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-03 18:58 [PATCH v1 0/8] gdb: various refactoring in linux-tdep Matthieu Longo
2026-07-03 18:58 ` [PATCH v1 1/8] gdb/linux-tdep: use pid_t consistently for process IDs Matthieu Longo
2026-07-05 21:22 ` Tom Tromey
2026-07-06 9:30 ` Matthieu Longo
2026-07-03 18:58 ` [PATCH v1 2/8] gdb/linux-tdep: change linux_fill_prpsinfo to return bool Matthieu Longo
2026-07-03 18:58 ` [PATCH v1 3/8] target_fileio_read_stralloc: add an optional length parameter Matthieu Longo
2026-07-03 18:58 ` Matthieu Longo [this message]
2026-07-03 19:55 ` [PATCH v1 4/8] gdb support: add index_type to array_view for documentation purpose Pedro Alves
2026-07-06 10:51 ` Matthieu Longo
2026-07-03 18:58 ` [PATCH v1 5/8] gdb support: add gdb::replace algorithm for iterators and ranges Matthieu Longo
2026-07-03 18:58 ` [PATCH v1 6/8] gdb: introduce helper class file_reader_t Matthieu Longo
2026-07-03 18:58 ` [PATCH v1 7/8] gdb/linux-tdep: parse ProtectionKey in /proc/PID/smaps Matthieu Longo
2026-07-03 18:58 ` [PATCH v1 8/8] gdb/linux: add helpers to read AT_HWCAP3 Matthieu Longo
2026-07-07 10:39 ` Yury Khrustalev
2026-07-07 15:51 ` Matthieu Longo
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=20260703185853.450440-5-matthieu.longo@arm.com \
--to=matthieu.longo@arm.com \
--cc=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=luis.machado.foss@gmail.com \
--cc=luis.machado@amd.com \
/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