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
This commit is contained in:
parent
d9f82e9313
commit
50888e42dc
96 changed files with 453 additions and 417 deletions
|
@ -2229,7 +2229,7 @@ push_large_arguments (CORE_ADDR sp, int argc, struct value **argv,
|
|||
/* Reserve space for the copy, and then round the SP down, to
|
||||
make sure it's all aligned properly. */
|
||||
sp = (sp - arg_len) & -4;
|
||||
write_memory (sp, value_contents (argv[i]), arg_len);
|
||||
write_memory (sp, value_contents (argv[i]).data (), arg_len);
|
||||
copy[i] = sp;
|
||||
}
|
||||
}
|
||||
|
@ -2283,7 +2283,7 @@ mep_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
|
|||
|
||||
/* Arguments that fit in a GPR get expanded to fill the GPR. */
|
||||
if (TYPE_LENGTH (value_type (argv[i])) <= MEP_GPR_SIZE)
|
||||
value = extract_unsigned_integer (value_contents (argv[i]),
|
||||
value = extract_unsigned_integer (value_contents (argv[i]).data (),
|
||||
TYPE_LENGTH (value_type (argv[i])),
|
||||
byte_order);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue