[00/24] Fix reading and writing pseudo registers in non-current frames

Message ID 20231201162751.741751-1-simon.marchi@efficios.com
Headers
Series Fix reading and writing pseudo registers in non-current frames |

Message

Simon Marchi Dec. 1, 2023, 4:27 p.m. UTC
  Hi,

This is version 3 of:

  https://inbox.sourceware.org/gdb-patches/20231124212656.96801-1-simon.marchi@efficios.com/

There are two functional changes in this version:

 - fixed the raw_compare behavior in patch 5 ("gdb: change regcache
   interface to use array_view"), added a selftest that would have
   caught my mistake
 - changed a LONGEST for ULONGEST in patch 3 ("gdb: make store_integer
   take an array_view")

The rest of the changes should all be cosmetic.

Simon Marchi (24):
  gdb: don't handle i386 k registers as pseudo registers
  gdb: use reg_buffer_common throughout gdbsupport/common-regcache.h
  gdb: make store_integer take an array_view
  gdb: simplify conditions in
    regcache::{read,write,raw_collect,raw_supply}_part
  gdb: change regcache interface to use array_view
  gdb: fix bugs in {get,put}_frame_register_bytes
  gdb: make put_frame_register take an array_view
  gdb: change value_of_register and value_of_register_lazy to take the
    next frame
  gdb: remove frame_register
  gdb: make put_frame_register take the next frame
  gdb: make put_frame_register_bytes take the next frame
  gdb: make get_frame_register_bytes take the next frame
  gdb: add value::allocate_register
  gdb: read pseudo register through frame
  gdb: change parameter name in frame_unwind_register_unsigned
    declaration
  gdb: rename gdbarch_pseudo_register_write to
    gdbarch_deprecated_pseudo_register_write
  gdb: add gdbarch_pseudo_register_write that takes a frame
  gdb: migrate i386 and amd64 to the new gdbarch_pseudo_register_write
  gdb: make aarch64_za_offsets_from_regnum return za_offsets
  gdb: add missing raw register read in
    aarch64_sme_pseudo_register_write
  gdb: migrate aarch64 to new gdbarch_pseudo_register_write
  gdb: migrate arm to gdbarch_pseudo_register_read_value
  gdb: migrate arm to new gdbarch_pseudo_register_write
  gdb/testsuite: add tests for unwinding of pseudo registers

 gdb/aarch64-tdep.c                            | 293 +++++----
 gdb/alpha-tdep.c                              |  11 +-
 gdb/amd64-tdep.c                              |  82 +--
 gdb/arch/arm-get-next-pcs.c                   |   8 +-
 gdb/arch/arm-get-next-pcs.h                   |   5 +-
 gdb/arch/arm.c                                |   2 +-
 gdb/arch/arm.h                                |   4 +-
 gdb/arm-linux-tdep.c                          |  11 +-
 gdb/arm-tdep.c                                | 145 +++--
 gdb/avr-tdep.c                                |   3 +-
 gdb/bfin-tdep.c                               |   3 +-
 gdb/csky-tdep.c                               |   4 +-
 gdb/defs.h                                    |  39 +-
 gdb/dwarf2/expr.c                             |  22 +-
 gdb/dwarf2/frame.c                            |   5 +-
 gdb/eval.c                                    |   3 +-
 gdb/findvar.c                                 |  50 +-
 gdb/frame-unwind.c                            |   3 +-
 gdb/frame.c                                   | 174 +++---
 gdb/frame.h                                   |  28 +-
 gdb/frv-tdep.c                                |   3 +-
 gdb/gdbarch-gen.h                             |  28 +-
 gdb/gdbarch.c                                 |  40 +-
 gdb/gdbarch_components.py                     |  29 +-
 gdb/guile/scm-frame.c                         |   3 +-
 gdb/h8300-tdep.c                              |   3 +-
 gdb/i386-tdep.c                               | 380 ++++--------
 gdb/i386-tdep.h                               |  15 +-
 gdb/i387-tdep.c                               |  16 +-
 gdb/ia64-tdep.c                               |  18 +-
 gdb/infcmd.c                                  |   6 +-
 gdb/loongarch-tdep.c                          |   3 +-
 gdb/m32c-tdep.c                               |   3 +-
 gdb/m68hc11-tdep.c                            |   3 +-
 gdb/m68k-tdep.c                               |  17 +-
 gdb/mep-tdep.c                                |   3 +-
 gdb/mi/mi-main.c                              |   3 +-
 gdb/mips-tdep.c                               |  29 +-
 gdb/msp430-tdep.c                             |   3 +-
 gdb/nat/aarch64-hw-point.c                    |   3 +-
 gdb/nat/aarch64-scalable-linux-ptrace.c       |  20 +-
 gdb/nat/linux-btrace.c                        |   3 +-
 gdb/nds32-tdep.c                              |   8 +-
 gdb/python/py-frame.c                         |   3 +-
 gdb/python/py-unwind.c                        |   4 +-
 gdb/regcache.c                                | 563 +++++++++++-------
 gdb/regcache.h                                | 110 +++-
 gdb/riscv-tdep.c                              |  13 +-
 gdb/rl78-tdep.c                               |   3 +-
 gdb/rs6000-tdep.c                             |  21 +-
 gdb/s12z-tdep.c                               |   2 +-
 gdb/s390-tdep.c                               |   3 +-
 gdb/sh-tdep.c                                 |   9 +-
 gdb/sparc-tdep.c                              |   3 +-
 gdb/sparc64-tdep.c                            |   3 +-
 gdb/std-regs.c                                |  11 +-
 .../gdb.arch/aarch64-pseudo-unwind-asm.S      |  82 +++
 .../gdb.arch/aarch64-pseudo-unwind.c          |  33 +
 .../gdb.arch/aarch64-pseudo-unwind.exp        |  88 +++
 .../gdb.arch/amd64-pseudo-unwind-asm.S        |  66 ++
 gdb/testsuite/gdb.arch/amd64-pseudo-unwind.c  |  33 +
 .../gdb.arch/amd64-pseudo-unwind.exp          |  91 +++
 .../gdb.arch/arm-pseudo-unwind-asm.S          |  79 +++
 .../gdb.arch/arm-pseudo-unwind-legacy-asm.S   |  84 +++
 .../gdb.arch/arm-pseudo-unwind-legacy.c       |  33 +
 .../gdb.arch/arm-pseudo-unwind-legacy.exp     |  86 +++
 gdb/testsuite/gdb.arch/arm-pseudo-unwind.c    |  33 +
 gdb/testsuite/gdb.arch/arm-pseudo-unwind.exp  |  88 +++
 gdb/valops.c                                  |  31 +-
 gdb/value.c                                   | 153 +++++
 gdb/value.h                                   |  64 +-
 gdb/xtensa-tdep.c                             |   3 +-
 gdbserver/linux-arm-low.cc                    |   4 +-
 gdbserver/regcache.cc                         |  66 +-
 gdbserver/regcache.h                          |   4 +-
 gdbsupport/common-regcache.cc                 |   2 +-
 gdbsupport/common-regcache.h                  |  55 +-
 gdbsupport/rsp-low.cc                         |   8 +
 gdbsupport/rsp-low.h                          |   2 +
 79 files changed, 2329 insertions(+), 1141 deletions(-)
 create mode 100644 gdb/testsuite/gdb.arch/aarch64-pseudo-unwind-asm.S
 create mode 100644 gdb/testsuite/gdb.arch/aarch64-pseudo-unwind.c
 create mode 100644 gdb/testsuite/gdb.arch/aarch64-pseudo-unwind.exp
 create mode 100644 gdb/testsuite/gdb.arch/amd64-pseudo-unwind-asm.S
 create mode 100644 gdb/testsuite/gdb.arch/amd64-pseudo-unwind.c
 create mode 100644 gdb/testsuite/gdb.arch/amd64-pseudo-unwind.exp
 create mode 100644 gdb/testsuite/gdb.arch/arm-pseudo-unwind-asm.S
 create mode 100644 gdb/testsuite/gdb.arch/arm-pseudo-unwind-legacy-asm.S
 create mode 100644 gdb/testsuite/gdb.arch/arm-pseudo-unwind-legacy.c
 create mode 100644 gdb/testsuite/gdb.arch/arm-pseudo-unwind-legacy.exp
 create mode 100644 gdb/testsuite/gdb.arch/arm-pseudo-unwind.c
 create mode 100644 gdb/testsuite/gdb.arch/arm-pseudo-unwind.exp


base-commit: 9d8fc40eb0e611162844eb7b89f1c76875153fbe
  

Comments

Simon Marchi Dec. 1, 2023, 4:56 p.m. UTC | #1
On 12/1/23 11:27, Simon Marchi wrote:
> Hi,
> 
> This is version 3 of:
> 
>   https://inbox.sourceware.org/gdb-patches/20231124212656.96801-1-simon.marchi@efficios.com/
> 
> There are two functional changes in this version:
> 
>  - fixed the raw_compare behavior in patch 5 ("gdb: change regcache
>    interface to use array_view"), added a selftest that would have
>    caught my mistake
>  - changed a LONGEST for ULONGEST in patch 3 ("gdb: make store_integer
>    take an array_view")
> 
> The rest of the changes should all be cosmetic.
> 

Sorry, I messed up putting "v3" in the subjects.  I sent this by doing a
"git format-patch" followed by a "git send-email", but I only passed
"-v3" to "git send-email".  I should have passed it to "git
format-patch".

Simon
  
Luis Machado Dec. 14, 2023, 2:51 p.m. UTC | #2
Hi Simon,

I re-tested this on aarch64 and arm, and the result with the changes are still clean.

On 12/1/23 16:27, Simon Marchi wrote:
> Hi,
> 
> This is version 3 of:
> 
>   https://inbox.sourceware.org/gdb-patches/20231124212656.96801-1-simon.marchi@efficios.com/
> 
> There are two functional changes in this version:
> 
>  - fixed the raw_compare behavior in patch 5 ("gdb: change regcache
>    interface to use array_view"), added a selftest that would have
>    caught my mistake
>  - changed a LONGEST for ULONGEST in patch 3 ("gdb: make store_integer
>    take an array_view")
> 
> The rest of the changes should all be cosmetic.
> 
> Simon Marchi (24):
>   gdb: don't handle i386 k registers as pseudo registers
>   gdb: use reg_buffer_common throughout gdbsupport/common-regcache.h
>   gdb: make store_integer take an array_view
>   gdb: simplify conditions in
>     regcache::{read,write,raw_collect,raw_supply}_part
>   gdb: change regcache interface to use array_view
>   gdb: fix bugs in {get,put}_frame_register_bytes
>   gdb: make put_frame_register take an array_view
>   gdb: change value_of_register and value_of_register_lazy to take the
>     next frame
>   gdb: remove frame_register
>   gdb: make put_frame_register take the next frame
>   gdb: make put_frame_register_bytes take the next frame
>   gdb: make get_frame_register_bytes take the next frame
>   gdb: add value::allocate_register
>   gdb: read pseudo register through frame
>   gdb: change parameter name in frame_unwind_register_unsigned
>     declaration
>   gdb: rename gdbarch_pseudo_register_write to
>     gdbarch_deprecated_pseudo_register_write
>   gdb: add gdbarch_pseudo_register_write that takes a frame
>   gdb: migrate i386 and amd64 to the new gdbarch_pseudo_register_write
>   gdb: make aarch64_za_offsets_from_regnum return za_offsets
>   gdb: add missing raw register read in
>     aarch64_sme_pseudo_register_write
>   gdb: migrate aarch64 to new gdbarch_pseudo_register_write
>   gdb: migrate arm to gdbarch_pseudo_register_read_value
>   gdb: migrate arm to new gdbarch_pseudo_register_write
>   gdb/testsuite: add tests for unwinding of pseudo registers
> 
>  gdb/aarch64-tdep.c                            | 293 +++++----
>  gdb/alpha-tdep.c                              |  11 +-
>  gdb/amd64-tdep.c                              |  82 +--
>  gdb/arch/arm-get-next-pcs.c                   |   8 +-
>  gdb/arch/arm-get-next-pcs.h                   |   5 +-
>  gdb/arch/arm.c                                |   2 +-
>  gdb/arch/arm.h                                |   4 +-
>  gdb/arm-linux-tdep.c                          |  11 +-
>  gdb/arm-tdep.c                                | 145 +++--
>  gdb/avr-tdep.c                                |   3 +-
>  gdb/bfin-tdep.c                               |   3 +-
>  gdb/csky-tdep.c                               |   4 +-
>  gdb/defs.h                                    |  39 +-
>  gdb/dwarf2/expr.c                             |  22 +-
>  gdb/dwarf2/frame.c                            |   5 +-
>  gdb/eval.c                                    |   3 +-
>  gdb/findvar.c                                 |  50 +-
>  gdb/frame-unwind.c                            |   3 +-
>  gdb/frame.c                                   | 174 +++---
>  gdb/frame.h                                   |  28 +-
>  gdb/frv-tdep.c                                |   3 +-
>  gdb/gdbarch-gen.h                             |  28 +-
>  gdb/gdbarch.c                                 |  40 +-
>  gdb/gdbarch_components.py                     |  29 +-
>  gdb/guile/scm-frame.c                         |   3 +-
>  gdb/h8300-tdep.c                              |   3 +-
>  gdb/i386-tdep.c                               | 380 ++++--------
>  gdb/i386-tdep.h                               |  15 +-
>  gdb/i387-tdep.c                               |  16 +-
>  gdb/ia64-tdep.c                               |  18 +-
>  gdb/infcmd.c                                  |   6 +-
>  gdb/loongarch-tdep.c                          |   3 +-
>  gdb/m32c-tdep.c                               |   3 +-
>  gdb/m68hc11-tdep.c                            |   3 +-
>  gdb/m68k-tdep.c                               |  17 +-
>  gdb/mep-tdep.c                                |   3 +-
>  gdb/mi/mi-main.c                              |   3 +-
>  gdb/mips-tdep.c                               |  29 +-
>  gdb/msp430-tdep.c                             |   3 +-
>  gdb/nat/aarch64-hw-point.c                    |   3 +-
>  gdb/nat/aarch64-scalable-linux-ptrace.c       |  20 +-
>  gdb/nat/linux-btrace.c                        |   3 +-
>  gdb/nds32-tdep.c                              |   8 +-
>  gdb/python/py-frame.c                         |   3 +-
>  gdb/python/py-unwind.c                        |   4 +-
>  gdb/regcache.c                                | 563 +++++++++++-------
>  gdb/regcache.h                                | 110 +++-
>  gdb/riscv-tdep.c                              |  13 +-
>  gdb/rl78-tdep.c                               |   3 +-
>  gdb/rs6000-tdep.c                             |  21 +-
>  gdb/s12z-tdep.c                               |   2 +-
>  gdb/s390-tdep.c                               |   3 +-
>  gdb/sh-tdep.c                                 |   9 +-
>  gdb/sparc-tdep.c                              |   3 +-
>  gdb/sparc64-tdep.c                            |   3 +-
>  gdb/std-regs.c                                |  11 +-
>  .../gdb.arch/aarch64-pseudo-unwind-asm.S      |  82 +++
>  .../gdb.arch/aarch64-pseudo-unwind.c          |  33 +
>  .../gdb.arch/aarch64-pseudo-unwind.exp        |  88 +++
>  .../gdb.arch/amd64-pseudo-unwind-asm.S        |  66 ++
>  gdb/testsuite/gdb.arch/amd64-pseudo-unwind.c  |  33 +
>  .../gdb.arch/amd64-pseudo-unwind.exp          |  91 +++
>  .../gdb.arch/arm-pseudo-unwind-asm.S          |  79 +++
>  .../gdb.arch/arm-pseudo-unwind-legacy-asm.S   |  84 +++
>  .../gdb.arch/arm-pseudo-unwind-legacy.c       |  33 +
>  .../gdb.arch/arm-pseudo-unwind-legacy.exp     |  86 +++
>  gdb/testsuite/gdb.arch/arm-pseudo-unwind.c    |  33 +
>  gdb/testsuite/gdb.arch/arm-pseudo-unwind.exp  |  88 +++
>  gdb/valops.c                                  |  31 +-
>  gdb/value.c                                   | 153 +++++
>  gdb/value.h                                   |  64 +-
>  gdb/xtensa-tdep.c                             |   3 +-
>  gdbserver/linux-arm-low.cc                    |   4 +-
>  gdbserver/regcache.cc                         |  66 +-
>  gdbserver/regcache.h                          |   4 +-
>  gdbsupport/common-regcache.cc                 |   2 +-
>  gdbsupport/common-regcache.h                  |  55 +-
>  gdbsupport/rsp-low.cc                         |   8 +
>  gdbsupport/rsp-low.h                          |   2 +
>  79 files changed, 2329 insertions(+), 1141 deletions(-)
>  create mode 100644 gdb/testsuite/gdb.arch/aarch64-pseudo-unwind-asm.S
>  create mode 100644 gdb/testsuite/gdb.arch/aarch64-pseudo-unwind.c
>  create mode 100644 gdb/testsuite/gdb.arch/aarch64-pseudo-unwind.exp
>  create mode 100644 gdb/testsuite/gdb.arch/amd64-pseudo-unwind-asm.S
>  create mode 100644 gdb/testsuite/gdb.arch/amd64-pseudo-unwind.c
>  create mode 100644 gdb/testsuite/gdb.arch/amd64-pseudo-unwind.exp
>  create mode 100644 gdb/testsuite/gdb.arch/arm-pseudo-unwind-asm.S
>  create mode 100644 gdb/testsuite/gdb.arch/arm-pseudo-unwind-legacy-asm.S
>  create mode 100644 gdb/testsuite/gdb.arch/arm-pseudo-unwind-legacy.c
>  create mode 100644 gdb/testsuite/gdb.arch/arm-pseudo-unwind-legacy.exp
>  create mode 100644 gdb/testsuite/gdb.arch/arm-pseudo-unwind.c
>  create mode 100644 gdb/testsuite/gdb.arch/arm-pseudo-unwind.exp
> 
> 
> base-commit: 9d8fc40eb0e611162844eb7b89f1c76875153fbe
  
Simon Marchi Dec. 14, 2023, 4:20 p.m. UTC | #3
On 12/14/23 09:51, Luis Machado wrote:
> Hi Simon,
> 
> I re-tested this on aarch64 and arm, and the result with the changes are still clean.

Thanks a lot for testing, I pushed the series.

Simon