From 50888e42dcd32b30e1144c0aa6d1c1490da45cd9 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 4 Oct 2021 20:47:06 -0400 Subject: 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 --- gdb/lm32-tdep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gdb/lm32-tdep.c') diff --git a/gdb/lm32-tdep.c b/gdb/lm32-tdep.c index 123a1a9..9c5dda3 100644 --- a/gdb/lm32-tdep.c +++ b/gdb/lm32-tdep.c @@ -271,7 +271,7 @@ lm32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* FIXME: Handle structures. */ - contents = (gdb_byte *) value_contents (arg); + contents = (gdb_byte *) value_contents (arg).data (); val = extract_unsigned_integer (contents, TYPE_LENGTH (arg_type), byte_order); -- cgit v1.1