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>
This commit is contained in:
Simon Marchi
2023-12-01 11:27:16 -05:00
parent e4e20d4511
commit f06b757764
2 changed files with 38 additions and 17 deletions

View File

@@ -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. */