public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: [PATCH 00/24] Fix reading and writing pseudo registers in non-current frames
Date: Wed,  8 Nov 2023 00:00:44 -0500	[thread overview]
Message-ID: <20231108051222.1275306-1-simon.marchi@polymtl.ca> (raw)

This series fixes reading/writing pseudo registers from/to non-current
frames (that is, frames other than frame 0).  Currently, we get this:

    (gdb) frame 0
    #0  break_here_asm () at /home/smarchi/src/binutils-gdb/gdb/testsuite/gdb.arch/amd64-pseudo-unwind-asm.S:38
    38              pop %rbx
    (gdb) p/x $rbx
    $1 = 0x2021222324252627
    (gdb) p/x $ebx
    $2 = 0x24252627
    (gdb) frame 1
    #1  0x000055555555517d in caller () at /home/smarchi/src/binutils-gdb/gdb/testsuite/gdb.arch/amd64-pseudo-unwind-asm.S:58
    58              call callee
    (gdb) p/x $rbx
    $3 = 0x1011121314151617
    (gdb) p/x $ebx
    $4 = 0x24252627

This is a bit surprising, we would expect the last value to be
0x14151617, the bottom half of the rbx value from frame 1 (the currently
selected frame at that point).  Instead, we got the bottom half of the
rbx value from frame 0.  This is because pseudo registers are always
read/written from/to the current thread's regcache.

This series fixes this (as well as writing to pseudo registers) by
making it so pseudo registers are read/written using a frame.

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                            | 297 +++++-----
 gdb/alpha-tdep.c                              |  11 +-
 gdb/amd64-tdep.c                              |  82 +--
 gdb/arch/arm-get-next-pcs.c                   |   6 +-
 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                                | 548 +++++++++++-------
 gdb/regcache.h                                | 113 +++-
 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        |  90 +++
 .../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          |  81 +++
 .../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                                   | 149 +++++
 gdb/value.h                                   |  64 +-
 gdb/xtensa-tdep.c                             |   3 +-
 gdbserver/linux-arm-low.cc                    |   4 +-
 gdbserver/regcache.cc                         |  69 ++-
 gdbserver/regcache.h                          |   6 +-
 gdbsupport/common-regcache.cc                 |   2 +-
 gdbsupport/common-regcache.h                  |  58 +-
 gdbsupport/rsp-low.cc                         |   8 +
 gdbsupport/rsp-low.h                          |   2 +
 79 files changed, 2324 insertions(+), 1144 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: 1185b5b79a12ba67eb60bee3f75babf7a222fde0
-- 
2.42.1


             reply	other threads:[~2023-11-08  5:12 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-08  5:00 Simon Marchi [this message]
2023-11-08  5:00 ` [PATCH 01/24] gdb: don't handle i386 k registers as pseudo registers Simon Marchi
2023-11-11 19:29   ` John Baldwin
2023-11-08  5:00 ` [PATCH 02/24] gdb: use reg_buffer_common throughout gdbsupport/common-regcache.h Simon Marchi
2023-11-11 19:42   ` John Baldwin
2023-11-08  5:00 ` [PATCH 03/24] gdb: make store_integer take an array_view Simon Marchi
2023-11-08  5:00 ` [PATCH 04/24] gdb: simplify conditions in regcache::{read,write,raw_collect,raw_supply}_part Simon Marchi
2023-11-08  5:00 ` [PATCH 05/24] gdb: change regcache interface to use array_view Simon Marchi
2023-11-13 13:43   ` Andrew Burgess
2023-11-13 14:00     ` Andrew Burgess
2023-11-13 16:47       ` Simon Marchi
2023-11-08  5:00 ` [PATCH 06/24] gdb: fix bugs in {get,put}_frame_register_bytes Simon Marchi
2023-11-13 15:00   ` Andrew Burgess
2023-11-13 19:51     ` Simon Marchi
2023-11-08  5:00 ` [PATCH 07/24] gdb: make put_frame_register take an array_view Simon Marchi
2023-11-08  5:00 ` [PATCH 08/24] gdb: change value_of_register and value_of_register_lazy to take the next frame Simon Marchi
2023-11-08  5:00 ` [PATCH 09/24] gdb: remove frame_register Simon Marchi
2023-11-08  5:00 ` [PATCH 10/24] gdb: make put_frame_register take the next frame Simon Marchi
2023-11-08  5:00 ` [PATCH 11/24] gdb: make put_frame_register_bytes " Simon Marchi
2023-11-08  5:00 ` [PATCH 12/24] gdb: make get_frame_register_bytes " Simon Marchi
2023-11-08  5:00 ` [PATCH 13/24] gdb: add value::allocate_register Simon Marchi
2023-11-08  5:00 ` [PATCH 14/24] gdb: read pseudo register through frame Simon Marchi
2023-11-11 20:11   ` John Baldwin
2023-11-08  5:00 ` [PATCH 15/24] gdb: change parameter name in frame_unwind_register_unsigned declaration Simon Marchi
2023-11-08  5:01 ` [PATCH 16/24] gdb: rename gdbarch_pseudo_register_write to gdbarch_deprecated_pseudo_register_write Simon Marchi
2023-11-14 12:12   ` Andrew Burgess
2023-11-14 15:16     ` Simon Marchi
2023-11-08  5:01 ` [PATCH 17/24] gdb: add gdbarch_pseudo_register_write that takes a frame Simon Marchi
2023-11-14 12:20   ` Andrew Burgess
2023-11-14 15:20     ` Simon Marchi
2023-11-08  5:01 ` [PATCH 18/24] gdb: migrate i386 and amd64 to the new gdbarch_pseudo_register_write Simon Marchi
2023-11-11 20:16   ` John Baldwin
2023-11-13  2:59     ` Simon Marchi
2023-11-08  5:01 ` [PATCH 19/24] gdb: make aarch64_za_offsets_from_regnum return za_offsets Simon Marchi
2023-11-08  5:01 ` [PATCH 20/24] gdb: add missing raw register read in aarch64_sme_pseudo_register_write Simon Marchi
2023-11-08  5:01 ` [PATCH 21/24] gdb: migrate aarch64 to new gdbarch_pseudo_register_write Simon Marchi
2023-11-08  5:01 ` [PATCH 22/24] gdb: migrate arm to gdbarch_pseudo_register_read_value Simon Marchi
2023-11-08  5:01 ` [PATCH 23/24] gdb: migrate arm to new gdbarch_pseudo_register_write Simon Marchi
2023-11-08  5:01 ` [PATCH 24/24] gdb/testsuite: add tests for unwinding of pseudo registers Simon Marchi
2023-11-08  5:16 ` [PATCH 00/24] Fix reading and writing pseudo registers in non-current frames Simon Marchi
2023-11-09  3:05   ` Simon Marchi
2023-11-08 11:57 ` Luis Machado
2023-11-08 15:47   ` Simon Marchi
2023-11-08 17:08     ` Luis Machado
2023-11-08 19:34       ` Simon Marchi
2023-11-09 19:04         ` Simon Marchi
2023-11-13 13:10           ` Luis Machado
2023-11-13 15:08             ` Luis Machado
2023-11-11 20:26 ` John Baldwin
2023-11-13  3:03   ` Simon Marchi
2023-12-01 16:27 Simon Marchi
2023-12-01 16:56 ` Simon Marchi
2023-12-14 14:51 ` Luis Machado
2023-12-14 16:20   ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231108051222.1275306-1-simon.marchi@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).