[v5,00/12] GDB support for more powerpc registers on linux

Message ID 20181022223242.7858-1-pedromfc@linux.ibm.com
Headers show
Series
  • GDB support for more powerpc registers on linux
Related show

Message

Pedro Franco de Carvalho Oct. 22, 2018, 10:32 p.m.
This is V5 of: https://sourceware.org/ml/gdb-patches/2018-08/msg00381.html

Changes from V4:

* Explained further limitations of unavailable registers with respect
  to 'G' packets in the commit message of "[PowerPC] Add support for
  EBB and PMU registers".

* Changed linux_collect_regset_section_cb to use std::vector<gdb_byte>
  instead of std::vector<char> in the first patch ("Zero-initialize
  linux note sections").

* Defined ppc_linux_collect_core_cpgrregset in ppc-linux-tdep.c and
  changed ppc_linux_iterate_over_regset_sections to call it when
  generating core files, in order to fill in the checkpointed NIP and
  MSR slots in the core file with reasonable values (TFHAR and the
  regular MSR), in "[PowerPC] Add support for HTM registers".

* Removed ppc_linux_regset_available_p, removed call to store_regset
  with regsets that can be unavailable when store_registers is called
  with -1, added comment explaining why.

* Changed fetch_regset/store_regset in ppc-linux-nat.c to call the
  supply/collect function pointers from the regset instead of
  regcache_supply/collect_regset.

* Reordered some of the regmap/regset definitions in ppc-linux-tdep.c
  for consistency with the existing definitions.

* Added various comments for global variables, functions and to the
  new test cases.

Edjunior Barbosa Machado (4):
  [PowerPC] Add support for PPR and DSCR
  [PowerPC] Add support for TAR
  [PowerPC] Add support for EBB and PMU registers
  [PowerPC] Add support for HTM registers

Pedro Franco de Carvalho (8):
  Zero-initialize linux note sections
  [PowerPC] Don't zero-initialize vector register buffers
  Add decfloat registers to float reggroup
  [PowerPC] Remove rs6000_pseudo_register_reggroup_p
  [PowerPC] Fix two if statements in gdb/ppc-linux-nat.c
  [PowerPC] Fix indentation in arch/ppc-linux-common.c
  [PowerPC] Refactor have_ initializers in rs6000-tdep.c
  [PowerPC] Reject tdescs with VSX and no FPU or Altivec

 gdb/NEWS                                           |   4 +
 gdb/arch/ppc-linux-common.c                        |  30 +-
 gdb/arch/ppc-linux-common.h                        |  20 +
 gdb/arch/ppc-linux-tdesc.h                         |   6 +
 gdb/doc/gdb.texinfo                                |  60 ++
 gdb/features/Makefile                              |  11 +
 gdb/features/rs6000/power-dscr.xml                 |  12 +
 gdb/features/rs6000/power-ebb.xml                  |  14 +
 gdb/features/rs6000/power-htm-altivec.xml          |  58 ++
 gdb/features/rs6000/power-htm-core.xml             |  48 ++
 gdb/features/rs6000/power-htm-dscr.xml             |  12 +
 gdb/features/rs6000/power-htm-fpu.xml              |  45 ++
 gdb/features/rs6000/power-htm-ppr.xml              |  12 +
 gdb/features/rs6000/power-htm-spr.xml              |  14 +
 gdb/features/rs6000/power-htm-tar.xml              |  12 +
 gdb/features/rs6000/power-htm-vsx.xml              |  43 ++
 gdb/features/rs6000/power-linux-pmu.xml            |  17 +
 gdb/features/rs6000/power-ppr.xml                  |  12 +
 gdb/features/rs6000/power-tar.xml                  |  12 +
 gdb/features/rs6000/power64-htm-core.xml           |  48 ++
 .../rs6000/powerpc-isa205-ppr-dscr-vsx32l.c        | 200 +++++
 .../rs6000/powerpc-isa205-ppr-dscr-vsx32l.xml      |  18 +
 .../rs6000/powerpc-isa205-ppr-dscr-vsx64l.c        | 200 +++++
 .../rs6000/powerpc-isa205-ppr-dscr-vsx64l.xml      |  18 +
 gdb/features/rs6000/powerpc-isa207-htm-vsx32l.c    | 396 ++++++++++
 gdb/features/rs6000/powerpc-isa207-htm-vsx32l.xml  |  29 +
 gdb/features/rs6000/powerpc-isa207-htm-vsx64l.c    | 396 ++++++++++
 gdb/features/rs6000/powerpc-isa207-htm-vsx64l.xml  |  29 +
 gdb/features/rs6000/powerpc-isa207-vsx32l.c        | 215 ++++++
 gdb/features/rs6000/powerpc-isa207-vsx32l.xml      |  21 +
 gdb/features/rs6000/powerpc-isa207-vsx64l.c        | 215 ++++++
 gdb/features/rs6000/powerpc-isa207-vsx64l.xml      |  21 +
 gdb/gdbserver/configure.srv                        |  28 +-
 gdb/gdbserver/linux-ppc-ipa.c                      |  18 +
 gdb/gdbserver/linux-ppc-low.c                      | 428 ++++++++++-
 gdb/gdbserver/linux-ppc-tdesc-init.h               |  21 +
 gdb/linux-tdep.c                                   |  14 +-
 gdb/nat/ppc-linux.h                                |  80 ++
 gdb/ppc-linux-nat.c                                | 440 ++++++++++-
 gdb/ppc-linux-tdep.c                               | 606 ++++++++++++++-
 gdb/ppc-linux-tdep.h                               |  21 +
 gdb/ppc-tdep.h                                     |  93 +++
 .../rs6000/powerpc-isa205-ppr-dscr-vsx32l.dat      | 146 ++++
 .../rs6000/powerpc-isa205-ppr-dscr-vsx64l.dat      | 146 ++++
 .../rs6000/powerpc-isa207-htm-vsx32l.dat           | 296 ++++++++
 .../rs6000/powerpc-isa207-htm-vsx64l.dat           | 296 ++++++++
 gdb/regformats/rs6000/powerpc-isa207-vsx32l.dat    | 155 ++++
 gdb/regformats/rs6000/powerpc-isa207-vsx64l.dat    | 155 ++++
 gdb/reggroups.c                                    |   4 +-
 gdb/rs6000-tdep.c                                  | 813 ++++++++++++++++++---
 gdb/testsuite/gdb.arch/powerpc-htm-regs.c          |  39 +
 gdb/testsuite/gdb.arch/powerpc-htm-regs.exp        | 328 +++++++++
 gdb/testsuite/gdb.arch/powerpc-ppr-dscr.c          |  34 +
 gdb/testsuite/gdb.arch/powerpc-ppr-dscr.exp        | 120 +++
 gdb/testsuite/gdb.arch/powerpc-tar.c               |  33 +
 gdb/testsuite/gdb.arch/powerpc-tar.exp             | 122 ++++
 56 files changed, 6528 insertions(+), 156 deletions(-)
 create mode 100644 gdb/features/rs6000/power-dscr.xml
 create mode 100644 gdb/features/rs6000/power-ebb.xml
 create mode 100644 gdb/features/rs6000/power-htm-altivec.xml
 create mode 100644 gdb/features/rs6000/power-htm-core.xml
 create mode 100644 gdb/features/rs6000/power-htm-dscr.xml
 create mode 100644 gdb/features/rs6000/power-htm-fpu.xml
 create mode 100644 gdb/features/rs6000/power-htm-ppr.xml
 create mode 100644 gdb/features/rs6000/power-htm-spr.xml
 create mode 100644 gdb/features/rs6000/power-htm-tar.xml
 create mode 100644 gdb/features/rs6000/power-htm-vsx.xml
 create mode 100644 gdb/features/rs6000/power-linux-pmu.xml
 create mode 100644 gdb/features/rs6000/power-ppr.xml
 create mode 100644 gdb/features/rs6000/power-tar.xml
 create mode 100644 gdb/features/rs6000/power64-htm-core.xml
 create mode 100644 gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c
 create mode 100644 gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.xml
 create mode 100644 gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c
 create mode 100644 gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.xml
 create mode 100644 gdb/features/rs6000/powerpc-isa207-htm-vsx32l.c
 create mode 100644 gdb/features/rs6000/powerpc-isa207-htm-vsx32l.xml
 create mode 100644 gdb/features/rs6000/powerpc-isa207-htm-vsx64l.c
 create mode 100644 gdb/features/rs6000/powerpc-isa207-htm-vsx64l.xml
 create mode 100644 gdb/features/rs6000/powerpc-isa207-vsx32l.c
 create mode 100644 gdb/features/rs6000/powerpc-isa207-vsx32l.xml
 create mode 100644 gdb/features/rs6000/powerpc-isa207-vsx64l.c
 create mode 100644 gdb/features/rs6000/powerpc-isa207-vsx64l.xml
 create mode 100644 gdb/regformats/rs6000/powerpc-isa205-ppr-dscr-vsx32l.dat
 create mode 100644 gdb/regformats/rs6000/powerpc-isa205-ppr-dscr-vsx64l.dat
 create mode 100644 gdb/regformats/rs6000/powerpc-isa207-htm-vsx32l.dat
 create mode 100644 gdb/regformats/rs6000/powerpc-isa207-htm-vsx64l.dat
 create mode 100644 gdb/regformats/rs6000/powerpc-isa207-vsx32l.dat
 create mode 100644 gdb/regformats/rs6000/powerpc-isa207-vsx64l.dat
 create mode 100644 gdb/testsuite/gdb.arch/powerpc-htm-regs.c
 create mode 100644 gdb/testsuite/gdb.arch/powerpc-htm-regs.exp
 create mode 100644 gdb/testsuite/gdb.arch/powerpc-ppr-dscr.c
 create mode 100644 gdb/testsuite/gdb.arch/powerpc-ppr-dscr.exp
 create mode 100644 gdb/testsuite/gdb.arch/powerpc-tar.c
 create mode 100644 gdb/testsuite/gdb.arch/powerpc-tar.exp

-- 
2.13.6

Comments

Pedro Alves Oct. 23, 2018, 3:36 p.m. | #1
On 10/22/2018 11:32 PM, Pedro Franco de Carvalho wrote:
> This is V5 of: https://sourceware.org/ml/gdb-patches/2018-08/msg00381.html

> 


AFAICT, this mainly refreshes the patch set, and applies some polish,
but doesn't address the previously discussed issues, right?

TBC, I don't want to block this at all, I think it's looking good.
Just want to understand if there's a plan, and if so, what is it.

I.e., what is the conclusion wrt to the differences in one of the note
sections generated by the kernel for a core file and the one generated
by GDB?  Was that resolved?  Will it be?

As for the EBB/PMU patch, about gdbserver writing all registers in one go
before resuming the inferior, and the error would not being detected at the
time the user tries to write them, did you try making gdbserver flush
the regcache after handling 'G' and 'P' packets?  From the previous
discussion, it sounded like that would work?

> Changes from V4:

> 

> * Explained further limitations of unavailable registers with respect

>   to 'G' packets in the commit message of "[PowerPC] Add support for

>   EBB and PMU registers".

> 

> * Changed linux_collect_regset_section_cb to use std::vector<gdb_byte>

>   instead of std::vector<char> in the first patch ("Zero-initialize

>   linux note sections").

> 

> * Defined ppc_linux_collect_core_cpgrregset in ppc-linux-tdep.c and

>   changed ppc_linux_iterate_over_regset_sections to call it when

>   generating core files, in order to fill in the checkpointed NIP and

>   MSR slots in the core file with reasonable values (TFHAR and the

>   regular MSR), in "[PowerPC] Add support for HTM registers".

> 

> * Removed ppc_linux_regset_available_p, removed call to store_regset

>   with regsets that can be unavailable when store_registers is called

>   with -1, added comment explaining why.

> 

> * Changed fetch_regset/store_regset in ppc-linux-nat.c to call the

>   supply/collect function pointers from the regset instead of

>   regcache_supply/collect_regset.

> 

> * Reordered some of the regmap/regset definitions in ppc-linux-tdep.c

>   for consistency with the existing definitions.

> 

> * Added various comments for global variables, functions and to the

>   new test cases.

> 

> Edjunior Barbosa Machado (4):

>   [PowerPC] Add support for PPR and DSCR

>   [PowerPC] Add support for TAR

>   [PowerPC] Add support for EBB and PMU registers

>   [PowerPC] Add support for HTM registers

> 

> Pedro Franco de Carvalho (8):

>   Zero-initialize linux note sections

>   [PowerPC] Don't zero-initialize vector register buffers

>   Add decfloat registers to float reggroup

>   [PowerPC] Remove rs6000_pseudo_register_reggroup_p

>   [PowerPC] Fix two if statements in gdb/ppc-linux-nat.c

>   [PowerPC] Fix indentation in arch/ppc-linux-common.c

>   [PowerPC] Refactor have_ initializers in rs6000-tdep.c

>   [PowerPC] Reject tdescs with VSX and no FPU or Altivec

> 

>  gdb/NEWS                                           |   4 +

>  gdb/arch/ppc-linux-common.c                        |  30 +-

>  gdb/arch/ppc-linux-common.h                        |  20 +

>  gdb/arch/ppc-linux-tdesc.h                         |   6 +

>  gdb/doc/gdb.texinfo                                |  60 ++

>  gdb/features/Makefile                              |  11 +

>  gdb/features/rs6000/power-dscr.xml                 |  12 +

>  gdb/features/rs6000/power-ebb.xml                  |  14 +

>  gdb/features/rs6000/power-htm-altivec.xml          |  58 ++

>  gdb/features/rs6000/power-htm-core.xml             |  48 ++

>  gdb/features/rs6000/power-htm-dscr.xml             |  12 +

>  gdb/features/rs6000/power-htm-fpu.xml              |  45 ++

>  gdb/features/rs6000/power-htm-ppr.xml              |  12 +

>  gdb/features/rs6000/power-htm-spr.xml              |  14 +

>  gdb/features/rs6000/power-htm-tar.xml              |  12 +

>  gdb/features/rs6000/power-htm-vsx.xml              |  43 ++

>  gdb/features/rs6000/power-linux-pmu.xml            |  17 +

>  gdb/features/rs6000/power-ppr.xml                  |  12 +

>  gdb/features/rs6000/power-tar.xml                  |  12 +

>  gdb/features/rs6000/power64-htm-core.xml           |  48 ++

>  .../rs6000/powerpc-isa205-ppr-dscr-vsx32l.c        | 200 +++++

>  .../rs6000/powerpc-isa205-ppr-dscr-vsx32l.xml      |  18 +

>  .../rs6000/powerpc-isa205-ppr-dscr-vsx64l.c        | 200 +++++

>  .../rs6000/powerpc-isa205-ppr-dscr-vsx64l.xml      |  18 +

>  gdb/features/rs6000/powerpc-isa207-htm-vsx32l.c    | 396 ++++++++++

>  gdb/features/rs6000/powerpc-isa207-htm-vsx32l.xml  |  29 +

>  gdb/features/rs6000/powerpc-isa207-htm-vsx64l.c    | 396 ++++++++++

>  gdb/features/rs6000/powerpc-isa207-htm-vsx64l.xml  |  29 +

>  gdb/features/rs6000/powerpc-isa207-vsx32l.c        | 215 ++++++

>  gdb/features/rs6000/powerpc-isa207-vsx32l.xml      |  21 +

>  gdb/features/rs6000/powerpc-isa207-vsx64l.c        | 215 ++++++

>  gdb/features/rs6000/powerpc-isa207-vsx64l.xml      |  21 +

>  gdb/gdbserver/configure.srv                        |  28 +-

>  gdb/gdbserver/linux-ppc-ipa.c                      |  18 +

>  gdb/gdbserver/linux-ppc-low.c                      | 428 ++++++++++-

>  gdb/gdbserver/linux-ppc-tdesc-init.h               |  21 +

>  gdb/linux-tdep.c                                   |  14 +-

>  gdb/nat/ppc-linux.h                                |  80 ++

>  gdb/ppc-linux-nat.c                                | 440 ++++++++++-

>  gdb/ppc-linux-tdep.c                               | 606 ++++++++++++++-

>  gdb/ppc-linux-tdep.h                               |  21 +

>  gdb/ppc-tdep.h                                     |  93 +++

>  .../rs6000/powerpc-isa205-ppr-dscr-vsx32l.dat      | 146 ++++

>  .../rs6000/powerpc-isa205-ppr-dscr-vsx64l.dat      | 146 ++++

>  .../rs6000/powerpc-isa207-htm-vsx32l.dat           | 296 ++++++++

>  .../rs6000/powerpc-isa207-htm-vsx64l.dat           | 296 ++++++++

>  gdb/regformats/rs6000/powerpc-isa207-vsx32l.dat    | 155 ++++

>  gdb/regformats/rs6000/powerpc-isa207-vsx64l.dat    | 155 ++++

>  gdb/reggroups.c                                    |   4 +-

>  gdb/rs6000-tdep.c                                  | 813 ++++++++++++++++++---

>  gdb/testsuite/gdb.arch/powerpc-htm-regs.c          |  39 +

>  gdb/testsuite/gdb.arch/powerpc-htm-regs.exp        | 328 +++++++++

>  gdb/testsuite/gdb.arch/powerpc-ppr-dscr.c          |  34 +

>  gdb/testsuite/gdb.arch/powerpc-ppr-dscr.exp        | 120 +++

>  gdb/testsuite/gdb.arch/powerpc-tar.c               |  33 +

>  gdb/testsuite/gdb.arch/powerpc-tar.exp             | 122 ++++

>  56 files changed, 6528 insertions(+), 156 deletions(-)

>  create mode 100644 gdb/features/rs6000/power-dscr.xml

>  create mode 100644 gdb/features/rs6000/power-ebb.xml

>  create mode 100644 gdb/features/rs6000/power-htm-altivec.xml

>  create mode 100644 gdb/features/rs6000/power-htm-core.xml

>  create mode 100644 gdb/features/rs6000/power-htm-dscr.xml

>  create mode 100644 gdb/features/rs6000/power-htm-fpu.xml

>  create mode 100644 gdb/features/rs6000/power-htm-ppr.xml

>  create mode 100644 gdb/features/rs6000/power-htm-spr.xml

>  create mode 100644 gdb/features/rs6000/power-htm-tar.xml

>  create mode 100644 gdb/features/rs6000/power-htm-vsx.xml

>  create mode 100644 gdb/features/rs6000/power-linux-pmu.xml

>  create mode 100644 gdb/features/rs6000/power-ppr.xml

>  create mode 100644 gdb/features/rs6000/power-tar.xml

>  create mode 100644 gdb/features/rs6000/power64-htm-core.xml

>  create mode 100644 gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c

>  create mode 100644 gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.xml

>  create mode 100644 gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c

>  create mode 100644 gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.xml

>  create mode 100644 gdb/features/rs6000/powerpc-isa207-htm-vsx32l.c

>  create mode 100644 gdb/features/rs6000/powerpc-isa207-htm-vsx32l.xml

>  create mode 100644 gdb/features/rs6000/powerpc-isa207-htm-vsx64l.c

>  create mode 100644 gdb/features/rs6000/powerpc-isa207-htm-vsx64l.xml

>  create mode 100644 gdb/features/rs6000/powerpc-isa207-vsx32l.c

>  create mode 100644 gdb/features/rs6000/powerpc-isa207-vsx32l.xml

>  create mode 100644 gdb/features/rs6000/powerpc-isa207-vsx64l.c

>  create mode 100644 gdb/features/rs6000/powerpc-isa207-vsx64l.xml

>  create mode 100644 gdb/regformats/rs6000/powerpc-isa205-ppr-dscr-vsx32l.dat

>  create mode 100644 gdb/regformats/rs6000/powerpc-isa205-ppr-dscr-vsx64l.dat

>  create mode 100644 gdb/regformats/rs6000/powerpc-isa207-htm-vsx32l.dat

>  create mode 100644 gdb/regformats/rs6000/powerpc-isa207-htm-vsx64l.dat

>  create mode 100644 gdb/regformats/rs6000/powerpc-isa207-vsx32l.dat

>  create mode 100644 gdb/regformats/rs6000/powerpc-isa207-vsx64l.dat

>  create mode 100644 gdb/testsuite/gdb.arch/powerpc-htm-regs.c

>  create mode 100644 gdb/testsuite/gdb.arch/powerpc-htm-regs.exp

>  create mode 100644 gdb/testsuite/gdb.arch/powerpc-ppr-dscr.c

>  create mode 100644 gdb/testsuite/gdb.arch/powerpc-ppr-dscr.exp

>  create mode 100644 gdb/testsuite/gdb.arch/powerpc-tar.c

>  create mode 100644 gdb/testsuite/gdb.arch/powerpc-tar.exp


Thanks,
Pedro Alves
Pedro Franco de Carvalho Oct. 23, 2018, 6:42 p.m. | #2
Pedro Alves <palves@redhat.com> writes:

> I.e., what is the conclusion wrt to the differences in one of the note

> sections generated by the kernel for a core file and the one generated

> by GDB?  Was that resolved?  Will it be?


Sorry, I really should have explained this better in the cover letter,
and I forgot to update the commit message explaining the solution we
picked for this issue.

I discussed this with Ulrich and we came to the conclusion that it would
be simpler to fill in the data for two of the registers that were
different in the core file using other registers that are available to
GDB, since they are not particularly useful as separate user-visible
registers.  This still leaves out some additional registers in this
regset that GDB isn't aware of, which are most of the time 0.  I will
explain this in more detail below, but in this patch this is implemented
with a different collect function used
(ppc_linux_collect_core_cpgrregset) used by
ppc_linux_iterate_over_regset_sections.

To give you some background, the checkpointed registers are the values
that are used to restore some of the regular registers to
pre-transactional values in case a hardware transaction fails.  This
includes the GPRs, FPRs, vector registers and others.

The kernel uses a pt_regs struct to hold the regular GPRs and various
others registers.  It also uses this struct to represent the equivalent
checkpointed registers, and to generate the note section, except that
only a subset of the registers in pt_regs is actually checkpointed by
the processor.  All of the registers that are actually checkpointed are
visible to the GDB user and are correctly filled in the note section
generated by GDB.

This leaves out various other registers from pt_regs.  One of these is
the NIP (the pc), which the kernel fills in with the value of another
register, TFHAR.  Since TFHAR is in fact visible to GDB, GDB uses its
value to fill in the corresponding slot in the core file.  The
"checkpointed" MSR (processor status register), is used by the kernel
for some internal state tracking.  We use the regular MSR to fill in the
corresponding slot.  These usually differ in some bits, and in certain
conditions the checkpointed MSR from the kernel can be zero.

The remaining registers in the checkpointed pt_regs are not filled in by
the kernel and don't represent anything.  They will only have non-zero
values in a kernel-generated core file if someone explicitly sets them
with ptrace before the process crashes.

> As for the EBB/PMU patch, about gdbserver writing all registers in one go

> before resuming the inferior, and the error would not being detected at the

> time the user tries to write them, did you try making gdbserver flush

> the regcache after handling 'G' and 'P' packets?  From the previous

> discussion, it sounded like that would work?


I haven't tried this yet.  I did think about this more and although it
might work using 'P' packets, I'm not sure how to go about handling
unavailable registers in general with the 'G' packet.  The problem is
that the server would need to somehow only flush these registers in
response to 'P' packets, and ignore them when they come from 'G'
packets.

This is becasue if the client always uses 'G' packets to store any
registers, including the ones that are always available, and the server
flushes the regcache to detect errors, most 'G' packets would return in
error because the inferior is usually not in a state in which the
unavailable registers can be written.

It's not clear that the 'xxxxx' encoding for unavailable registers can
be used in 'G' packets, like it is for 'g' packets.  The gdbserver stub
doesn't handle this and assumes the 'G' packet contents will be properly
encoded register values, it only uses this encoding when replying to 'g'
packets.

Maybe a solution is to prevent writing to these registers on the client
side if the target is remote and print a warning (possibly through
gdbarch_cannot_store_register).

Thanks!!

--
Pedro Franco de Carvalho