aboutsummaryrefslogtreecommitdiff
path: root/gdb/fbsd-tdep.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-10-25 23:29:34 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2021-12-03 16:41:38 -0500
commit2a50938ab740296a1d6df67feea9401e57e4d90e (patch)
treec0a570783faab4b4e5225e14a434739fa0264536 /gdb/fbsd-tdep.c
parent4bce7cdaf481901edbc5ee47d953ea7e8efb56ca (diff)
downloadfsf-binutils-gdb-2a50938ab740296a1d6df67feea9401e57e4d90e.zip
fsf-binutils-gdb-2a50938ab740296a1d6df67feea9401e57e4d90e.tar.gz
fsf-binutils-gdb-2a50938ab740296a1d6df67feea9401e57e4d90e.tar.bz2
gdb: make extract_integer take an array_view
I think it would make sense for extract_integer, extract_signed_integer and extract_unsigned_integer to take an array_view. This way, when we extract an integer, we can validate that we don't overflow the buffer passed by the caller (e.g. ask to extract a 4-byte integer but pass a 2-byte buffer). - Change extract_integer to take an array_view - Add overloads of extract_signed_integer and extract_unsigned_integer that take array_views. Keep the existing versions so we don't need to change all callers, but make them call the array_view versions. This shortens some places like: result = extract_unsigned_integer (value_contents (result_val).data (), TYPE_LENGTH (value_type (result_val)), byte_order); into result = extract_unsigned_integer (value_contents (result_val), byte_order); value_contents returns an array view that is of length `TYPE_LENGTH (value_type (result_val))` already, so the length is implicitly communicated through the array view. Change-Id: Ic1c1f98c88d5c17a8486393af316f982604d6c95
Diffstat (limited to 'gdb/fbsd-tdep.c')
-rw-r--r--gdb/fbsd-tdep.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c
index 07cd844..4da7798 100644
--- a/gdb/fbsd-tdep.c
+++ b/gdb/fbsd-tdep.c
@@ -611,7 +611,7 @@ fbsd_core_xfer_siginfo (struct gdbarch *gdbarch, gdb_byte *readbuf,
LWPINFO_OFFSET + LWPINFO_PL_FLAGS, 4))
return -1;
- int pl_flags = extract_signed_integer (buf, 4, gdbarch_byte_order (gdbarch));
+ int pl_flags = extract_signed_integer (buf, gdbarch_byte_order (gdbarch));
if (!(pl_flags & PL_FLAG_SI))
return -1;
@@ -1933,7 +1933,7 @@ fbsd_read_integer_by_name (struct gdbarch *gdbarch, const char *name)
if (target_read_memory (BMSYMBOL_VALUE_ADDRESS (ms), buf, sizeof buf) != 0)
error (_("Unable to read value of '%s'"), name);
- return extract_signed_integer (buf, sizeof buf, gdbarch_byte_order (gdbarch));
+ return extract_signed_integer (buf, gdbarch_byte_order (gdbarch));
}
/* Lookup offsets of fields in the runtime linker's 'Obj_Entry'
@@ -2004,7 +2004,7 @@ fbsd_get_tls_index (struct gdbarch *gdbarch, CORE_ADDR lm_addr)
throw_error (TLS_GENERIC_ERROR,
_("Cannot find thread-local variables on this target"));
- return extract_signed_integer (buf, sizeof buf, gdbarch_byte_order (gdbarch));
+ return extract_signed_integer (buf, gdbarch_byte_order (gdbarch));
}
/* See fbsd-tdep.h. */