From bdec2917b1e94c7198ba39919f45060067952f43 Mon Sep 17 00:00:00 2001 From: Luis Machado Date: Fri, 15 Jan 2021 13:16:04 -0300 Subject: Convert some frame functions to use gdb::array_view. 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 2021-01-19 Luis Machado * 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/ChangeLog | 42 ++++++++++++++++++++++++++++++++++++++++++ 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 ++++++------ 27 files changed, 147 insertions(+), 84 deletions(-) (limited to 'gdb') diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e31ed43..aeb0894 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,47 @@ 2021-01-19 Luis Machado + * 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. + +2021-01-19 Luis Machado + * aarch64-linux-tdep.c (aarch64_linux_restore_vreg): Pass in an array_view. * trad-frame.c (trad_frame_set_value_bytes): Use gdb::array_view diff --git a/gdb/amd64-fbsd-tdep.c b/gdb/amd64-fbsd-tdep.c index 6a7000e..2894313 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)) return 0; if (memcmp (buf, amd64fbsd_sigtramp_code, sizeof amd64fbsd_sigtramp_code) != 0) diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c index f65ac4e..00d19be 100644 --- a/gdb/amd64-linux-tdep.c +++ b/gdb/amd64-linux-tdep.c @@ -146,7 +146,7 @@ amd64_linux_sigtramp_start (struct frame_info *this_frame) PC is not at the start of the instruction sequence, there will be a few trailing readable bytes on the stack. */ - if (!safe_frame_unwind_memory (this_frame, pc, buf, sizeof buf)) + if (!safe_frame_unwind_memory (this_frame, pc, buf)) return 0; if (buf[0] != LINUX_SIGTRAMP_INSN0) @@ -155,7 +155,7 @@ amd64_linux_sigtramp_start (struct frame_info *this_frame) return 0; pc -= LINUX_SIGTRAMP_OFFSET1; - if (!safe_frame_unwind_memory (this_frame, pc, buf, sizeof buf)) + if (!safe_frame_unwind_memory (this_frame, pc, buf)) return 0; } diff --git a/gdb/amd64-obsd-tdep.c b/gdb/amd64-obsd-tdep.c index 5a7e6ae..cdb09d0 100644 --- a/gdb/amd64-obsd-tdep.c +++ b/gdb/amd64-obsd-tdep.c @@ -78,7 +78,7 @@ amd64obsd_sigtramp_p (struct frame_info *this_frame) /* If we can't read the instructions at START_PC, return zero. */ buf = (gdb_byte *) alloca ((sizeof sigreturn) + 1); - if (!safe_frame_unwind_memory (this_frame, start_pc + 6, buf, buflen)) + if (!safe_frame_unwind_memory (this_frame, start_pc + 6, {buf, buflen})) return 0; /* Check for sigreturn(2). Depending on how the assembler encoded diff --git a/gdb/arc-linux-tdep.c b/gdb/arc-linux-tdep.c index f41cb20..c9fbd7d 100644 --- a/gdb/arc-linux-tdep.c +++ b/gdb/arc-linux-tdep.c @@ -204,7 +204,7 @@ arc_linux_is_sigtramp (struct frame_info *this_frame) /* Read the memory at the PC. Since we are stopped, any breakpoint must have been removed. */ - if (!safe_frame_unwind_memory (this_frame, pc, buf, insns_sz)) + if (!safe_frame_unwind_memory (this_frame, pc, {buf, insns_sz})) { /* Failed to unwind frame. */ return FALSE; @@ -215,7 +215,7 @@ arc_linux_is_sigtramp (struct frame_info *this_frame) return TRUE; /* No - look one instruction earlier in the code... */ - if (!safe_frame_unwind_memory (this_frame, pc - 4, buf, insns_sz)) + if (!safe_frame_unwind_memory (this_frame, pc - 4, {buf, insns_sz})) { /* Failed to unwind frame. */ return FALSE; diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c index 63ce803..a33fdc1 100644 --- a/gdb/cris-tdep.c +++ b/gdb/cris-tdep.c @@ -198,7 +198,7 @@ cris_sigtramp_start (struct frame_info *this_frame) CORE_ADDR pc = get_frame_pc (this_frame); gdb_byte buf[SIGTRAMP_LEN]; - if (!safe_frame_unwind_memory (this_frame, pc, buf, SIGTRAMP_LEN)) + if (!safe_frame_unwind_memory (this_frame, pc, buf)) return 0; if (((buf[1] << 8) + buf[0]) != SIGTRAMP_INSN0) @@ -207,7 +207,7 @@ cris_sigtramp_start (struct frame_info *this_frame) return 0; pc -= SIGTRAMP_OFFSET1; - if (!safe_frame_unwind_memory (this_frame, pc, buf, SIGTRAMP_LEN)) + if (!safe_frame_unwind_memory (this_frame, pc, buf)) return 0; } @@ -226,7 +226,7 @@ cris_rt_sigtramp_start (struct frame_info *this_frame) CORE_ADDR pc = get_frame_pc (this_frame); gdb_byte buf[SIGTRAMP_LEN]; - if (!safe_frame_unwind_memory (this_frame, pc, buf, SIGTRAMP_LEN)) + if (!safe_frame_unwind_memory (this_frame, pc, buf)) return 0; if (((buf[1] << 8) + buf[0]) != SIGTRAMP_INSN0) @@ -235,7 +235,7 @@ cris_rt_sigtramp_start (struct frame_info *this_frame) return 0; pc -= SIGTRAMP_OFFSET1; - if (!safe_frame_unwind_memory (this_frame, pc, buf, SIGTRAMP_LEN)) + if (!safe_frame_unwind_memory (this_frame, pc, buf)) return 0; } diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 33c4056..580e5b0 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -1748,7 +1748,7 @@ rw_pieced_value (struct value *v, struct value *from) /* Read mode. */ if (!get_frame_register_bytes (frame, gdb_regnum, bits_to_skip / 8, - this_size, buffer.data (), + buffer, &optim, &unavail)) { if (optim) @@ -1773,7 +1773,7 @@ rw_pieced_value (struct value *v, struct value *from) Need some bits from original register value. */ get_frame_register_bytes (frame, gdb_regnum, bits_to_skip / 8, - this_size, buffer.data (), + buffer, &optim, &unavail); if (optim) throw_error (OPTIMIZED_OUT_ERROR, @@ -1792,7 +1792,7 @@ rw_pieced_value (struct value *v, struct value *from) this_size_bits, bits_big_endian); put_frame_register_bytes (frame, gdb_regnum, bits_to_skip / 8, - this_size, buffer.data ()); + buffer); } } break; diff --git a/gdb/frame.c b/gdb/frame.c index fed5871..4578b1a 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -1469,7 +1469,8 @@ deprecated_frame_register_read (frame_info *frame, int regnum, bool get_frame_register_bytes (frame_info *frame, int regnum, - CORE_ADDR offset, int len, gdb_byte *myaddr, + CORE_ADDR offset, + gdb::array_view buffer, int *optimizedp, int *unavailablep) { struct gdbarch *gdbarch = get_frame_arch (frame); @@ -1496,6 +1497,8 @@ get_frame_register_bytes (frame_info *frame, int regnum, break; /* This register is not available on this architecture. */ maxsize += thissize; } + + int len = buffer.size (); if (len > maxsize) error (_("Bad debug information detected: " "Attempt to read %d bytes from registers."), len); @@ -1508,6 +1511,8 @@ get_frame_register_bytes (frame_info *frame, int regnum, if (curr_len > len) curr_len = len; + gdb_byte *myaddr = buffer.data (); + if (curr_len == register_size (gdbarch, regnum)) { enum lval_type lval; @@ -1551,7 +1556,8 @@ get_frame_register_bytes (frame_info *frame, int regnum, void put_frame_register_bytes (struct frame_info *frame, int regnum, - CORE_ADDR offset, int len, const gdb_byte *myaddr) + CORE_ADDR offset, + gdb::array_view buffer) { struct gdbarch *gdbarch = get_frame_arch (frame); @@ -1562,6 +1568,7 @@ put_frame_register_bytes (struct frame_info *frame, int regnum, regnum++; } + int len = buffer.size (); /* Copy the data. */ while (len > 0) { @@ -1570,6 +1577,7 @@ put_frame_register_bytes (struct frame_info *frame, int regnum, if (curr_len > len) curr_len = len; + const gdb_byte *myaddr = buffer.data (); if (curr_len == register_size (gdbarch, regnum)) { put_frame_register (frame, regnum, myaddr); @@ -2891,9 +2899,9 @@ get_frame_address_space (struct frame_info *frame) void get_frame_memory (struct frame_info *this_frame, CORE_ADDR addr, - gdb_byte *buf, int len) + gdb::array_view buffer) { - read_memory (addr, buf, len); + read_memory (addr, buffer.data (), buffer.size ()); } LONGEST @@ -2918,10 +2926,10 @@ get_frame_memory_unsigned (struct frame_info *this_frame, CORE_ADDR addr, bool safe_frame_unwind_memory (struct frame_info *this_frame, - CORE_ADDR addr, gdb_byte *buf, int len) + CORE_ADDR addr, gdb::array_view buffer) { /* NOTE: target_read_memory returns zero on success! */ - return target_read_memory (addr, buf, len) == 0; + return target_read_memory (addr, buffer.data (), buffer.size ()) == 0; } /* Architecture methods. */ diff --git a/gdb/frame.h b/gdb/frame.h index 7028b26..597a459 100644 --- a/gdb/frame.h +++ b/gdb/frame.h @@ -653,15 +653,15 @@ extern void put_frame_register (struct frame_info *frame, int regnum, contents are optimized out or unavailable, set *OPTIMIZEDP, *UNAVAILABLEP accordingly. */ extern bool get_frame_register_bytes (frame_info *frame, int regnum, - CORE_ADDR offset, int len, - gdb_byte *myaddr, + CORE_ADDR offset, + gdb::array_view buffer, int *optimizedp, int *unavailablep); -/* Write LEN bytes to one or multiple registers starting with REGNUM - in frame FRAME, starting at OFFSET, into BUF. */ +/* Write bytes from BUFFER to one or multiple registers starting with REGNUM + in frame FRAME, starting at OFFSET. */ extern void put_frame_register_bytes (struct frame_info *frame, int regnum, - CORE_ADDR offset, int len, - const gdb_byte *myaddr); + CORE_ADDR offset, + gdb::array_view buffer); /* Unwind the PC. Strictly speaking return the resume address of the calling frame. For GDB, `pc' is the resume address and not a @@ -687,7 +687,7 @@ extern void frame_pop (struct frame_info *frame); adaptor frames this should be ok. */ extern void get_frame_memory (struct frame_info *this_frame, CORE_ADDR addr, - gdb_byte *buf, int len); + gdb::array_view buffer); extern LONGEST get_frame_memory_signed (struct frame_info *this_frame, CORE_ADDR memaddr, int len); extern ULONGEST get_frame_memory_unsigned (struct frame_info *this_frame, @@ -696,7 +696,7 @@ extern ULONGEST get_frame_memory_unsigned (struct frame_info *this_frame, /* Same as above, but return true zero when the entire memory read succeeds, false otherwise. */ extern bool safe_frame_unwind_memory (frame_info *this_frame, CORE_ADDR addr, - gdb_byte *buf, int len); + gdb::array_view buffer); /* Return this frame's architecture. */ extern struct gdbarch *get_frame_arch (struct frame_info *this_frame); diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c index 4f72565..786dda6 100644 --- a/gdb/hppa-tdep.c +++ b/gdb/hppa-tdep.c @@ -1990,7 +1990,7 @@ hppa_frame_cache (struct frame_info *this_frame, void **this_cache) gdb_byte buf4[4]; long inst; - if (!safe_frame_unwind_memory (this_frame, pc, buf4, sizeof buf4)) + if (!safe_frame_unwind_memory (this_frame, pc, buf4)) { error (_("Cannot read instruction at %s."), paddress (gdbarch, pc)); diff --git a/gdb/i386-fbsd-tdep.c b/gdb/i386-fbsd-tdep.c index bb0c622..1039724 100644 --- a/gdb/i386-fbsd-tdep.c +++ b/gdb/i386-fbsd-tdep.c @@ -135,8 +135,8 @@ i386fbsd_sigtramp_p (struct frame_info *this_frame) const gdb_byte *middle, *end; /* Look for a matching start. */ - if (!safe_frame_unwind_memory (this_frame, pc, buf, - sizeof i386fbsd_sigtramp_start)) + if (!safe_frame_unwind_memory (this_frame, pc, + {buf, sizeof i386fbsd_sigtramp_start})) return 0; if (memcmp (buf, i386fbsd_sigtramp_start, sizeof i386fbsd_sigtramp_start) == 0) @@ -162,23 +162,23 @@ i386fbsd_sigtramp_p (struct frame_info *this_frame) /* Since the end is shorter than the middle, check for a matching end next. */ pc += sizeof i386fbsd_sigtramp_start; - if (!safe_frame_unwind_memory (this_frame, pc, buf, - sizeof i386fbsd_sigtramp_end)) + if (!safe_frame_unwind_memory (this_frame, pc, + {buf, sizeof i386fbsd_sigtramp_end})) return 0; if (memcmp (buf, end, sizeof i386fbsd_sigtramp_end) == 0) return 1; /* If the end didn't match, check for a matching middle. */ - if (!safe_frame_unwind_memory (this_frame, pc, buf, - sizeof i386fbsd_sigtramp_middle)) + if (!safe_frame_unwind_memory (this_frame, pc, + {buf, sizeof i386fbsd_sigtramp_middle})) return 0; if (memcmp (buf, middle, sizeof i386fbsd_sigtramp_middle) != 0) return 0; /* The middle matched, check for a matching end. */ pc += sizeof i386fbsd_sigtramp_middle; - if (!safe_frame_unwind_memory (this_frame, pc, buf, - sizeof i386fbsd_sigtramp_end)) + if (!safe_frame_unwind_memory (this_frame, pc, + {buf, sizeof i386fbsd_sigtramp_end})) return 0; if (memcmp (buf, end, sizeof i386fbsd_sigtramp_end) != 0) return 0; diff --git a/gdb/i386-gnu-tdep.c b/gdb/i386-gnu-tdep.c index 6033b98..33ccd3b 100644 --- a/gdb/i386-gnu-tdep.c +++ b/gdb/i386-gnu-tdep.c @@ -63,7 +63,7 @@ i386_gnu_sigtramp_start (struct frame_info *this_frame) if (!safe_frame_unwind_memory (this_frame, pc + GNU_SIGTRAMP_TAIL - GNU_SIGTRAMP_LEN, - buf, GNU_SIGTRAMP_LEN)) + buf)) return 0; if (memcmp (buf, gnu_sigtramp_code, GNU_SIGTRAMP_LEN) != 0) diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c index 3ec29e3..c0df916 100644 --- a/gdb/i386-linux-tdep.c +++ b/gdb/i386-linux-tdep.c @@ -134,7 +134,7 @@ i386_linux_sigtramp_start (struct frame_info *this_frame) PC is not at the start of the instruction sequence, there will be a few trailing readable bytes on the stack. */ - if (!safe_frame_unwind_memory (this_frame, pc, buf, LINUX_SIGTRAMP_LEN)) + if (!safe_frame_unwind_memory (this_frame, pc, buf)) return 0; if (buf[0] != LINUX_SIGTRAMP_INSN0) @@ -155,7 +155,7 @@ i386_linux_sigtramp_start (struct frame_info *this_frame) pc -= adjust; - if (!safe_frame_unwind_memory (this_frame, pc, buf, LINUX_SIGTRAMP_LEN)) + if (!safe_frame_unwind_memory (this_frame, pc, buf)) return 0; } @@ -202,7 +202,7 @@ i386_linux_rt_sigtramp_start (struct frame_info *this_frame) PC is not at the start of the instruction sequence, there will be a few trailing readable bytes on the stack. */ - if (!safe_frame_unwind_memory (this_frame, pc, buf, LINUX_RT_SIGTRAMP_LEN)) + if (!safe_frame_unwind_memory (this_frame, pc, buf)) return 0; if (buf[0] != LINUX_RT_SIGTRAMP_INSN0) @@ -212,8 +212,8 @@ i386_linux_rt_sigtramp_start (struct frame_info *this_frame) pc -= LINUX_RT_SIGTRAMP_OFFSET1; - if (!safe_frame_unwind_memory (this_frame, pc, buf, - LINUX_RT_SIGTRAMP_LEN)) + if (!safe_frame_unwind_memory (this_frame, pc, + buf)) return 0; } diff --git a/gdb/i386-obsd-tdep.c b/gdb/i386-obsd-tdep.c index d4d12ff..387863f 100644 --- a/gdb/i386-obsd-tdep.c +++ b/gdb/i386-obsd-tdep.c @@ -99,7 +99,7 @@ i386obsd_sigtramp_p (struct frame_info *this_frame) { /* If we can't read the instructions, return zero. */ if (!safe_frame_unwind_memory (this_frame, start_pc + *offset, - buf, buflen)) + {buf, buflen})) return 0; /* Check for sigreturn(2). */ diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 1a30172..991218d 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -3781,8 +3781,10 @@ i386_register_to_value (struct frame_info *frame, int regnum, gdb_assert (register_size (gdbarch, regnum) == 4); if (!get_frame_register_bytes (frame, regnum, 0, - register_size (gdbarch, regnum), - to, optimizedp, unavailablep)) + gdb::make_array_view (to, + register_size (gdbarch, + regnum)), + optimizedp, unavailablep)) return 0; regnum = i386_next_regnum (regnum); diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c index 118f983..c17c0f3 100644 --- a/gdb/i387-tdep.c +++ b/gdb/i387-tdep.c @@ -365,8 +365,10 @@ i387_register_to_value (struct frame_info *frame, int regnum, /* Convert to TYPE. */ if (!get_frame_register_bytes (frame, regnum, 0, - register_size (gdbarch, regnum), - from, optimizedp, unavailablep)) + gdb::make_array_view (from, + register_size (gdbarch, + regnum)), + optimizedp, unavailablep)) return 0; target_float_convert (from, i387_ext_type (gdbarch), to, type); diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c index 71f1581..35eeffe 100644 --- a/gdb/ia64-tdep.c +++ b/gdb/ia64-tdep.c @@ -1226,8 +1226,10 @@ ia64_register_to_value (struct frame_info *frame, int regnum, /* Convert to TYPE. */ if (!get_frame_register_bytes (frame, regnum, 0, - register_size (gdbarch, regnum), - in, optimizedp, unavailablep)) + gdb::make_array_view (in, + register_size (gdbarch, + regnum)), + optimizedp, unavailablep)) return 0; target_float_convert (in, ia64_ext_type (gdbarch), out, valtype); diff --git a/gdb/m32r-linux-tdep.c b/gdb/m32r-linux-tdep.c index bed14ed..1d42a0a 100644 --- a/gdb/m32r-linux-tdep.c +++ b/gdb/m32r-linux-tdep.c @@ -99,7 +99,7 @@ m32r_linux_sigtramp_start (CORE_ADDR pc, struct frame_info *this_frame) if (pc % 2 != 0) { - if (!safe_frame_unwind_memory (this_frame, pc, buf, 2)) + if (!safe_frame_unwind_memory (this_frame, pc, {buf, 2})) return 0; if (memcmp (buf, linux_sigtramp_code, 2) == 0) @@ -108,7 +108,7 @@ m32r_linux_sigtramp_start (CORE_ADDR pc, struct frame_info *this_frame) return 0; } - if (!safe_frame_unwind_memory (this_frame, pc, buf, 4)) + if (!safe_frame_unwind_memory (this_frame, pc, {buf, 4})) return 0; if (memcmp (buf, linux_sigtramp_code, 4) != 0) @@ -148,12 +148,12 @@ m32r_linux_rt_sigtramp_start (CORE_ADDR pc, struct frame_info *this_frame) if (pc % 2 != 0) return 0; - if (!safe_frame_unwind_memory (this_frame, pc, buf, 4)) + if (!safe_frame_unwind_memory (this_frame, pc, {buf, 4})) return 0; if (memcmp (buf, linux_rt_sigtramp_code, 4) == 0) { - if (!safe_frame_unwind_memory (this_frame, pc + 4, buf, 4)) + if (!safe_frame_unwind_memory (this_frame, pc + 4, {buf, 4})) return 0; if (memcmp (buf, linux_rt_sigtramp_code + 4, 4) == 0) @@ -161,7 +161,7 @@ m32r_linux_rt_sigtramp_start (CORE_ADDR pc, struct frame_info *this_frame) } else if (memcmp (buf, linux_rt_sigtramp_code + 4, 4) == 0) { - if (!safe_frame_unwind_memory (this_frame, pc - 4, buf, 4)) + if (!safe_frame_unwind_memory (this_frame, pc - 4, {buf, 4})) return 0; if (memcmp (buf, linux_rt_sigtramp_code, 4) == 0) diff --git a/gdb/m68k-linux-tdep.c b/gdb/m68k-linux-tdep.c index b83636c..7b3cd5f 100644 --- a/gdb/m68k-linux-tdep.c +++ b/gdb/m68k-linux-tdep.c @@ -69,7 +69,7 @@ m68k_linux_pc_in_sigtramp (struct frame_info *this_frame) unsigned long insn0, insn1, insn2; CORE_ADDR pc = get_frame_pc (this_frame); - if (!safe_frame_unwind_memory (this_frame, pc - 4, buf, sizeof (buf))) + if (!safe_frame_unwind_memory (this_frame, pc - 4, {buf, sizeof (buf)})) return 0; insn1 = extract_unsigned_integer (buf + 4, 4, byte_order); insn2 = extract_unsigned_integer (buf + 8, 4, byte_order); diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c index ae3be2b..76cc38b 100644 --- a/gdb/m68k-tdep.c +++ b/gdb/m68k-tdep.c @@ -213,8 +213,10 @@ m68k_register_to_value (struct frame_info *frame, int regnum, /* Convert to TYPE. */ if (!get_frame_register_bytes (frame, regnum, 0, - register_size (gdbarch, regnum), - from, optimizedp, unavailablep)) + gdb::make_array_view (from, + register_size (gdbarch, + regnum)), + optimizedp, unavailablep)) return 0; target_float_convert (from, fpreg_type, to, type); diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index f0c343d..e12dffb 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -926,11 +926,11 @@ mips_register_to_value (struct frame_info *frame, int regnum, get_frame_register (frame, regnum + 0, to + 4); get_frame_register (frame, regnum + 1, to + 0); - if (!get_frame_register_bytes (frame, regnum + 0, 0, 4, to + 4, + if (!get_frame_register_bytes (frame, regnum + 0, 0, {to + 4, 4}, optimizedp, unavailablep)) return 0; - if (!get_frame_register_bytes (frame, regnum + 1, 0, 4, to + 0, + if (!get_frame_register_bytes (frame, regnum + 1, 0, {to + 0, 4}, optimizedp, unavailablep)) return 0; *optimizedp = *unavailablep = 0; @@ -938,11 +938,11 @@ mips_register_to_value (struct frame_info *frame, int regnum, } else if (mips_convert_register_gpreg_case_p (gdbarch, regnum, type)) { - int len = TYPE_LENGTH (type); + size_t len = TYPE_LENGTH (type); CORE_ADDR offset; offset = gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG ? 8 - len : 0; - if (!get_frame_register_bytes (frame, regnum, offset, len, to, + if (!get_frame_register_bytes (frame, regnum, offset, {to, len}, optimizedp, unavailablep)) return 0; @@ -970,7 +970,7 @@ mips_value_to_register (struct frame_info *frame, int regnum, else if (mips_convert_register_gpreg_case_p (gdbarch, regnum, type)) { gdb_byte fill[8]; - int len = TYPE_LENGTH (type); + size_t len = TYPE_LENGTH (type); /* Sign extend values, irrespective of type, that are stored to a 64-bit general purpose register. (32-bit unsigned values @@ -984,8 +984,8 @@ mips_value_to_register (struct frame_info *frame, int regnum, store_signed_integer (fill, 8, BFD_ENDIAN_BIG, -1); else store_signed_integer (fill, 8, BFD_ENDIAN_BIG, 0); - put_frame_register_bytes (frame, regnum, 0, 8 - len, fill); - put_frame_register_bytes (frame, regnum, 8 - len, len, from); + put_frame_register_bytes (frame, regnum, 0, {fill, 8 - len}); + put_frame_register_bytes (frame, regnum, 8 - len, {from, len}); } else { @@ -993,8 +993,8 @@ mips_value_to_register (struct frame_info *frame, int regnum, store_signed_integer (fill, 8, BFD_ENDIAN_LITTLE, -1); else store_signed_integer (fill, 8, BFD_ENDIAN_LITTLE, 0); - put_frame_register_bytes (frame, regnum, 0, len, from); - put_frame_register_bytes (frame, regnum, len, 8 - len, fill); + put_frame_register_bytes (frame, regnum, 0, {from, len}); + put_frame_register_bytes (frame, regnum, len, {fill, 8 - len}); } } else diff --git a/gdb/ppc-fbsd-tdep.c b/gdb/ppc-fbsd-tdep.c index e59ef4b..d03df96 100644 --- a/gdb/ppc-fbsd-tdep.c +++ b/gdb/ppc-fbsd-tdep.c @@ -176,7 +176,7 @@ ppcfbsd_sigtramp_frame_sniffer (const struct frame_unwind *self, unsigned long insn; if (!safe_frame_unwind_memory (this_frame, start_pc + *offset, - buf, sizeof buf)) + {buf, sizeof buf})) continue; /* Check for "li r0,SYS_sigreturn". */ @@ -214,7 +214,7 @@ ppcfbsd_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache) func = get_frame_pc (this_frame); func &= ~(ppcfbsd_page_size - 1); - if (!safe_frame_unwind_memory (this_frame, func, buf, sizeof buf)) + if (!safe_frame_unwind_memory (this_frame, func, {buf, sizeof buf})) return cache; base = get_frame_register_unsigned (this_frame, gdbarch_sp_regnum (gdbarch)); diff --git a/gdb/ppc-obsd-tdep.c b/gdb/ppc-obsd-tdep.c index f1c6094..b92f11c 100644 --- a/gdb/ppc-obsd-tdep.c +++ b/gdb/ppc-obsd-tdep.c @@ -137,7 +137,7 @@ ppcobsd_sigtramp_frame_sniffer (const struct frame_unwind *self, unsigned long insn; if (!safe_frame_unwind_memory (this_frame, start_pc + *offset, - buf, sizeof buf)) + {buf, sizeof buf})) continue; /* Check for "li r0,SYS_sigreturn". */ @@ -177,7 +177,7 @@ ppcobsd_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache) func = get_frame_pc (this_frame); func &= ~(ppcobsd_page_size - 1); - if (!safe_frame_unwind_memory (this_frame, func, buf, sizeof buf)) + if (!safe_frame_unwind_memory (this_frame, func, {buf, sizeof buf})) return cache; /* Calculate the offset where we can find `struct sigcontext'. We diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index 2dbc2a2..62848a0 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -777,7 +777,8 @@ rs6000_in_function_epilogue_frame_p (struct frame_info *curfrm, for (scan_pc = pc; scan_pc < epilogue_end; scan_pc += PPC_INSN_SIZE) { - if (!safe_frame_unwind_memory (curfrm, scan_pc, insn_buf, PPC_INSN_SIZE)) + if (!safe_frame_unwind_memory (curfrm, scan_pc, + {insn_buf, PPC_INSN_SIZE})) return 0; insn = extract_unsigned_integer (insn_buf, PPC_INSN_SIZE, byte_order); if (insn == 0x4e800020) @@ -803,7 +804,8 @@ rs6000_in_function_epilogue_frame_p (struct frame_info *curfrm, scan_pc >= epilogue_start; scan_pc -= PPC_INSN_SIZE) { - if (!safe_frame_unwind_memory (curfrm, scan_pc, insn_buf, PPC_INSN_SIZE)) + if (!safe_frame_unwind_memory (curfrm, scan_pc, + {insn_buf, PPC_INSN_SIZE})) return 0; insn = extract_unsigned_integer (insn_buf, PPC_INSN_SIZE, byte_order); if (insn_changes_sp_or_jumps (insn)) @@ -2607,8 +2609,10 @@ rs6000_register_to_value (struct frame_info *frame, gdb_assert (type->code () == TYPE_CODE_FLT); if (!get_frame_register_bytes (frame, regnum, 0, - register_size (gdbarch, regnum), - from, optimizedp, unavailablep)) + gdb::make_array_view (from, + register_size (gdbarch, + regnum)), + optimizedp, unavailablep)) return 0; target_float_convert (from, builtin_type (gdbarch)->builtin_double, diff --git a/gdb/tilegx-tdep.c b/gdb/tilegx-tdep.c index 0030fed..7ff8794 100644 --- a/gdb/tilegx-tdep.c +++ b/gdb/tilegx-tdep.c @@ -429,7 +429,7 @@ tilegx_analyze_prologue (struct gdbarch* gdbarch, instbuf_start = next_addr; status = safe_frame_unwind_memory (next_frame, instbuf_start, - instbuf, instbuf_size); + {instbuf, instbuf_size}); if (status == 0) memory_error (TARGET_XFER_E_IO, next_addr); } diff --git a/gdb/tramp-frame.c b/gdb/tramp-frame.c index 5f5d1b4..b13ca51 100644 --- a/gdb/tramp-frame.c +++ b/gdb/tramp-frame.c @@ -102,14 +102,15 @@ tramp_frame_start (const struct tramp_frame *tramp, { gdb_byte buf[sizeof (tramp->insn[0])]; ULONGEST insn; + size_t insn_size = tramp->insn_size; if (tramp->insn[i].bytes == TRAMP_SENTINEL_INSN) return func; if (!safe_frame_unwind_memory (this_frame, - func + i * tramp->insn_size, - buf, tramp->insn_size)) + func + i * insn_size, + {buf, insn_size})) break; - insn = extract_unsigned_integer (buf, tramp->insn_size, byte_order); + insn = extract_unsigned_integer (buf, insn_size, byte_order); if (tramp->insn[i].bytes != (insn & tramp->insn[i].mask)) break; } diff --git a/gdb/valops.c b/gdb/valops.c index 6a9cbdc..882f6e7 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1200,7 +1200,7 @@ value_assign (struct value *toval, struct value *fromval) { struct value *parent = value_parent (toval); LONGEST offset = value_offset (parent) + value_offset (toval); - int changed_len; + size_t changed_len; gdb_byte buffer[sizeof (LONGEST)]; int optim, unavail; @@ -1209,13 +1209,13 @@ value_assign (struct value *toval, struct value *fromval) + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT; - if (changed_len > (int) sizeof (LONGEST)) + if (changed_len > sizeof (LONGEST)) error (_("Can't handle bitfields which " "don't fit in a %d bit word."), (int) sizeof (LONGEST) * HOST_CHAR_BIT); if (!get_frame_register_bytes (frame, value_reg, offset, - changed_len, buffer, + {buffer, changed_len}, &optim, &unavail)) { if (optim) @@ -1230,7 +1230,7 @@ value_assign (struct value *toval, struct value *fromval) value_bitpos (toval), value_bitsize (toval)); put_frame_register_bytes (frame, value_reg, offset, - changed_len, buffer); + {buffer, changed_len}); } else { @@ -1248,8 +1248,8 @@ value_assign (struct value *toval, struct value *fromval) { put_frame_register_bytes (frame, value_reg, value_offset (toval), - TYPE_LENGTH (type), - value_contents (fromval)); + {value_contents (fromval), + TYPE_LENGTH (type)}); } } -- cgit v1.1