aboutsummaryrefslogtreecommitdiff
path: root/gdb/mips-tdep.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-10-04 20:47:06 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2021-10-25 14:51:44 -0400
commit50888e42dcd32b30e1144c0aa6d1c1490da45cd9 (patch)
tree72fad89d67057ecb53f26bac0464542829053e3e /gdb/mips-tdep.c
parentd9f82e931394efed68858eb7c7bb5832ad888482 (diff)
downloadgdb-50888e42dcd32b30e1144c0aa6d1c1490da45cd9.zip
gdb-50888e42dcd32b30e1144c0aa6d1c1490da45cd9.tar.gz
gdb-50888e42dcd32b30e1144c0aa6d1c1490da45cd9.tar.bz2
gdb: change functions returning value contents to use gdb::array_view
The bug fixed by this [1] patch was caused by an out-of-bounds access to a value's content. The code gets the value's content (just a pointer) and then indexes it with a non-sensical index. This made me think of changing functions that return value contents to return array_views instead of a plain pointer. This has the advantage that when GDB is built with _GLIBCXX_DEBUG, accesses to the array_view are checked, making bugs more apparent / easier to find. This patch changes the return types of these functions, and updates callers to call .data() on the result, meaning it's not changing anything in practice. Additional work will be needed (which can be done little by little) to make callers propagate the use of array_view and reap the benefits. [1] https://sourceware.org/pipermail/gdb-patches/2021-September/182306.html Change-Id: I5151f888f169e1c36abe2cbc57620110673816f3
Diffstat (limited to 'gdb/mips-tdep.c')
-rw-r--r--gdb/mips-tdep.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index f16cdaa..57295d6 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -4585,7 +4585,7 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
fprintf_unfiltered (gdb_stdlog, " push");
}
else
- val = value_contents (arg);
+ val = value_contents (arg).data ();
/* 32-bit ABIs always start floating point arguments in an
even-numbered floating point register. Round the FP register
@@ -4960,7 +4960,7 @@ mips_n32n64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
"mips_n32n64_push_dummy_call: %d len=%d type=%d",
argnum + 1, len, (int) typecode);
- val = value_contents (arg);
+ val = value_contents (arg).data ();
/* A 128-bit long double value requires an even-odd pair of
floating-point registers. */
@@ -5427,7 +5427,7 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
"mips_o32_push_dummy_call: %d len=%d type=%d",
argnum + 1, len, (int) typecode);
- val = value_contents (arg);
+ val = value_contents (arg).data ();
/* 32-bit ABIs always start floating point arguments in an
even-numbered floating point register. Round the FP register
@@ -5949,7 +5949,7 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
"mips_o64_push_dummy_call: %d len=%d type=%d",
argnum + 1, len, (int) typecode);
- val = value_contents (arg);
+ val = value_contents (arg).data ();
/* Floating point arguments passed in registers have to be
treated specially. On 32-bit architectures, doubles are
@@ -6556,7 +6556,7 @@ print_gp_register_row (struct ui_file *file, struct frame_info *frame,
col++;
continue;
}
- raw_buffer = value_contents_all (value);
+ raw_buffer = value_contents_all (value).data ();
/* pad small registers */
for (byte = 0;
byte < (mips_abi_regsize (gdbarch)