aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2023-12-01 11:27:16 -0500
committerSimon Marchi <simon.marchi@efficios.com>2023-12-14 16:04:49 +0000
commitf06b75776428f524d91d860aecbbe2734cf5580c (patch)
tree3d8a6f2a0a344887df9bc9c3e0759a4095a4f362
parente4e20d45110d919a5a2da2db84806f315ab59d90 (diff)
downloadgdb-f06b75776428f524d91d860aecbbe2734cf5580c.zip
gdb-f06b75776428f524d91d860aecbbe2734cf5580c.tar.gz
gdb-f06b75776428f524d91d860aecbbe2734cf5580c.tar.bz2
gdb: make store_integer take an array_view
Change store_integer, store_signed_integer and store_unsigned_integer to accept an array_view. Add some backwards compatibility overloads to avoid changing all callers at once. Change-Id: Ibb1381228ab1cb65fc7e2e4b92cf9ab1047cdc03 Reviewed-By: John Baldwin <jhb@FreeBSD.org>
-rw-r--r--gdb/defs.h39
-rw-r--r--gdb/findvar.c16
2 files changed, 38 insertions, 17 deletions
diff --git a/gdb/defs.h b/gdb/defs.h
index bcce4f4..e20143b 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -495,21 +495,44 @@ extern CORE_ADDR extract_typed_address (const gdb_byte *buf,
target-format integer at ADDR which is LEN bytes long. */
template<typename T, typename = RequireLongest<T>>
-extern void store_integer (gdb_byte *addr, int len, enum bfd_endian byte_order,
- T val);
+extern void store_integer (gdb::array_view<gdb_byte> dst,
+ bfd_endian byte_order, T val);
+
+template<typename T>
+static inline void
+store_integer (gdb_byte *addr, int len, bfd_endian byte_order, T val)
+{
+ return store_integer (gdb::make_array_view (addr, len), byte_order, val);
+}
+
+static inline void
+store_signed_integer (gdb::array_view<gdb_byte> dst, bfd_endian byte_order,
+ LONGEST val)
+{
+ return store_integer (dst, byte_order, val);
+}
+
+static inline void
+store_signed_integer (gdb_byte *addr, int len, bfd_endian byte_order,
+ LONGEST val)
+{
+ return store_signed_integer (gdb::make_array_view (addr, len), byte_order,
+ val);
+}
static inline void
-store_signed_integer (gdb_byte *addr, int len,
- enum bfd_endian byte_order, LONGEST val)
+store_unsigned_integer (gdb::array_view<gdb_byte> dst, bfd_endian byte_order,
+ ULONGEST val)
{
- return store_integer (addr, len, byte_order, val);
+ return store_integer (dst, byte_order, val);
}
static inline void
-store_unsigned_integer (gdb_byte *addr, int len,
- enum bfd_endian byte_order, ULONGEST val)
+store_unsigned_integer (gdb_byte *addr, int len, bfd_endian byte_order,
+ ULONGEST val)
{
- return store_integer (addr, len, byte_order, val);
+ return store_unsigned_integer (gdb::make_array_view (addr, len), byte_order,
+ val);
}
extern void store_typed_address (gdb_byte *buf, struct type *type,
diff --git a/gdb/findvar.c b/gdb/findvar.c
index 02b4a12..8f016f5 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -159,12 +159,12 @@ extract_typed_address (const gdb_byte *buf, struct type *type)
target-format integer at ADDR which is LEN bytes long. */
template<typename T, typename>
void
-store_integer (gdb_byte *addr, int len, enum bfd_endian byte_order,
+store_integer (gdb::array_view<gdb_byte> dst, enum bfd_endian byte_order,
T val)
{
gdb_byte *p;
- gdb_byte *startaddr = addr;
- gdb_byte *endaddr = startaddr + len;
+ gdb_byte *startaddr = dst.data ();
+ gdb_byte *endaddr = startaddr + dst.size ();
/* Start at the least significant end of the integer, and work towards
the most significant. */
@@ -187,13 +187,11 @@ store_integer (gdb_byte *addr, int len, enum bfd_endian byte_order,
}
/* Explicit instantiations. */
-template void store_integer (gdb_byte *addr, int len,
- enum bfd_endian byte_order,
- LONGEST val);
+template void store_integer (gdb::array_view<gdb_byte> dst,
+ bfd_endian byte_order, LONGEST val);
-template void store_integer (gdb_byte *addr, int len,
- enum bfd_endian byte_order,
- ULONGEST val);
+template void store_integer (gdb::array_view<gdb_byte> dst,
+ bfd_endian byte_order, ULONGEST val);
/* Store the address ADDR as a pointer of type TYPE at BUF, in target
form. */