[PATCH] Convert some frame functions to use gdb::array_view.
Simon Marchi
simon.marchi@polymtl.ca
Tue Jan 19 15:17:28 GMT 2021
On 2021-01-19 8:31 a.m., Luis Machado via Gdb-patches wrote:
> This patch converts the most obvious functions from gdb/frame.h to use
> the gdb::array_view abstraction. I've converted the ones that used buffer +
> length.
>
> There are others using only the buffer, with an implicit size. I did not
> touch those for now. But it would be nice to pass the size for safety.
>
> Tested with --enable-targets=all on Ubuntu 18.04/20.04 aarch64-linux.
>
> gdb/ChangeLog
>
> YYYY-MM-DD Luis Machado <luis.machado@linaro.org>
>
> * frame.h (get_frame_register_bytes): Pass a gdb::array_view instead
> of buffer + length.
> (put_frame_register_bytes): Likewise.
> Adjust documentation.
> (get_frame_memory): Pass a gdb::array_view instead of buffer + length.
> (safe_frame_unwind_memory): Likewise.
> * frame.c (get_frame_register_bytes, put_frame_register_bytes)
> (get_frame_memory, safe_frame_unwind_memory): Adjust to use
> gdb::array_view.
> * amd64-fbsd-tdep.c (amd64fbsd_sigtramp_p): Likewise.
> * amd64-linux-tdep.c (amd64_linux_sigtramp_start): Likewise.
> * amd64-obsd-tdep.c (amd64obsd_sigtramp_p): Likewise.
> * arc-linux-tdep.c (arc_linux_is_sigtramp): Likewise.
> * cris-tdep.c (cris_sigtramp_start, cris_rt_sigtramp_start): Likewise.
> * dwarf2/loc.c (rw_pieced_value): Likewise.
> * hppa-tdep.c (hppa_frame_cache): Likewise.
> * i386-fbsd-tdep.c (i386fbsd_sigtramp_p): Likewise.
> * i386-gnu-tdep.c (i386_gnu_sigtramp_start): Likewise.
> * i386-linux-tdep.c (i386_linux_sigtramp_start)
> (i386_linux_rt_sigtramp_start): Likewise.
> * i386-obsd-tdep.c (i386obsd_sigtramp_p): Likewise.
> * i386-tdep.c (i386_register_to_value): Likewise.
> * i387-tdep.c (i387_register_to_value): Likewise.
> * ia64-tdep.c (ia64_register_to_value): Likewise.
> * m32r-linux-tdep.c (m32r_linux_sigtramp_start)
> (m32r_linux_rt_sigtramp_start): Likewise.
> * m68k-linux-tdep.c (m68k_linux_pc_in_sigtramp): Likewise.
> * m68k-tdep.c (m68k_register_to_value): Likewise.
> * mips-tdep.c (mips_register_to_value)
> (mips_value_to_register): Likewise.
> * ppc-fbsd-tdep.c (ppcfbsd_sigtramp_frame_sniffer)
> (ppcfbsd_sigtramp_frame_cache): Likewise.
> * ppc-obsd-tdep.c (ppcobsd_sigtramp_frame_sniffer)
> (ppcobsd_sigtramp_frame_cache): Likewise.
> * rs6000-tdep.c (rs6000_in_function_epilogue_frame_p)
> (rs6000_register_to_value): Likewise.
> * tilegx-tdep.c (tilegx_analyze_prologue): Likewise.
> * tramp-frame.c (tramp_frame_start): Likewise.
> * valops.c (value_assign): Likewise.
> ---
> gdb/amd64-fbsd-tdep.c | 2 +-
> gdb/amd64-linux-tdep.c | 4 ++--
> gdb/amd64-obsd-tdep.c | 2 +-
> gdb/arc-linux-tdep.c | 4 ++--
> gdb/cris-tdep.c | 8 ++++----
> gdb/dwarf2/loc.c | 6 +++---
> gdb/frame.c | 20 ++++++++++++++------
> gdb/frame.h | 16 ++++++++--------
> gdb/hppa-tdep.c | 2 +-
> gdb/i386-fbsd-tdep.c | 16 ++++++++--------
> gdb/i386-gnu-tdep.c | 2 +-
> gdb/i386-linux-tdep.c | 10 +++++-----
> gdb/i386-obsd-tdep.c | 2 +-
> gdb/i386-tdep.c | 6 ++++--
> gdb/i387-tdep.c | 6 ++++--
> gdb/ia64-tdep.c | 6 ++++--
> gdb/m32r-linux-tdep.c | 10 +++++-----
> gdb/m68k-linux-tdep.c | 2 +-
> gdb/m68k-tdep.c | 6 ++++--
> gdb/mips-tdep.c | 18 +++++++++---------
> gdb/ppc-fbsd-tdep.c | 4 ++--
> gdb/ppc-obsd-tdep.c | 4 ++--
> gdb/rs6000-tdep.c | 12 ++++++++----
> gdb/tilegx-tdep.c | 2 +-
> gdb/tramp-frame.c | 7 ++++---
> gdb/valops.c | 12 ++++++------
> 26 files changed, 105 insertions(+), 84 deletions(-)
>
> diff --git a/gdb/amd64-fbsd-tdep.c b/gdb/amd64-fbsd-tdep.c
> index 6a7000e7530..c0da5434537 100644
> --- a/gdb/amd64-fbsd-tdep.c
> +++ b/gdb/amd64-fbsd-tdep.c
> @@ -52,7 +52,7 @@ amd64fbsd_sigtramp_p (struct frame_info *this_frame)
> CORE_ADDR pc = get_frame_pc (this_frame);
> gdb_byte buf[sizeof amd64fbsd_sigtramp_code];
>
> - if (!safe_frame_unwind_memory (this_frame, pc, buf, sizeof buf))
> + if (!safe_frame_unwind_memory (this_frame, pc, {buf, sizeof buf}))
When passing a static array, you can just pass it directly (just buf). The array
view will get the size information from the array's type.
Otherwise, LGTM.
Simon
More information about the Gdb-patches
mailing list