aboutsummaryrefslogtreecommitdiff
path: root/gdb/stack.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/stack.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/stack.c')
-rw-r--r--gdb/stack.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/gdb/stack.c b/gdb/stack.c
index bedadb0..66517cf 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -1716,8 +1716,8 @@ info_frame_command_core (struct frame_info *fi, bool selected_frame_p)
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int sp_size = register_size (gdbarch, sp_regnum);
- sp = extract_unsigned_integer (value_contents_all (value),
- sp_size, byte_order);
+ sp = extract_unsigned_integer
+ (value_contents_all (value).data (), sp_size, byte_order);
printf_filtered (" Previous frame's sp is ");
fputs_filtered (paddress (gdbarch, sp), gdb_stdout);
@@ -2842,7 +2842,7 @@ return_command (const char *retval_exp, int from_tty)
&& rv_conv != RETURN_VALUE_ABI_RETURNS_ADDRESS);
gdbarch_return_value (cache_arch, function, return_type,
get_current_regcache (), NULL /*read*/,
- value_contents (return_value) /*write*/);
+ value_contents (return_value).data () /*write*/);
}
/* If we are at the end of a call dummy now, pop the dummy frame