Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: pedromfc@linux.ibm.com (Pedro Franco de Carvalho)
Cc: gdb-patches@sourceware.org, edjunior@gmail.com
Subject: Re: [PATCH 13/17] [PowerPC] Add support for HTM registers
Date: Fri, 13 Jul 2018 16:24:00 -0000	[thread overview]
Message-ID: <20180713162433.9A714D80276@oc3748833570.ibm.com> (raw)
In-Reply-To: <20180713135226.2321-14-pedromfc@linux.ibm.com> from "Pedro Franco de Carvalho" at Jul 13, 2018 10:52:22 AM

Pedro Franco de Carvalho wrote:

> The set of checkpointed general-purpose registers is returned by the
> linux kernel in the same format as the regular general-purpose
> registers, defined in struct pt_regs. However, the architecture
> specifies that only some of the registers present in pt_regs are
> checkpointed (GPRs 0-31, CR, XER, LR and CTR). The kernel fills the
> slots for other registers with other info (e.g., nip is filled with
> the contents of TFHAR). GDB doesn't handle these other registers. This
> means that core files generated by GDB will show values of zero for
> these registers, while core files generated by the kernel will have
> other values. Core files generated by the kernel have a note section
> for checkpointed GPRs with the same size for both 32-bit and 64-bit
> threads, and the values for the registers of a 32-bit thread are
> squeezed in the first half, with no useful data in the second
> half. GDB generates a smaller note section for 32-bit threads, but can
> read both sizes.

Well, this is weird.  Either the kernel should be fixed to use the
smaller size as well, or else GDB should also generate the large
section (and zero out the second half).

> Access to the checkpointed CR (condition register) can be
> confusing. The architecture only specifies that CR fields 1 to 7 (the
> 24 least significant bits) are checkpointed, but the kernel provides
> all 8 fields (32 bits). The value of field 0 is not masked by ptrace,
> so it will sometimes show the result of some kernel operation,
> probably treclaim., which sets this field.

Huh. We shold report this to the kernel people.

> The checkpointed registers are marked not to be saved and
> restored. Inferior function calls during an active transaction don't
> work well, and it's unclear what should be done in this case. TEXASR
> and TFIAR can be altered asynchronously, during transaction failure
> recording, so they are also not saved and restored. For consistency
> neither is TFHAR.
> 
> Record and replay also doesn't work well when transactions are
> involved. This patch doesn't address this, so the values of the HTM
> SPRs will sometimes be innacurate when the record/relay target is
> enabled. For instance, executing a "tbegin." alters TFHAR and TEXASR,
> but these changes are not currently recorded.
> 
> Because the checkpointed registers are only available when a
> transaction is active (or suspended), ptrace can return ENODATA when
> gdb tries to read these registers and the inferior is not in a
> transactional state. The registers are set to the unavailable state
> when this happens. When gbd tries to write to one of these registers,
> and it is unavailable, an error is raised. When gdb tries to store to
> all registers in one go (when store_registers called with -1), the
> state of these registers is checked. If they are all unavailable, no
> write is attempted, so that writes to all the other registers are
> unaffected. If all are available, the write is attempted. Otherwise an
> internal_error is raised.

This all makes sense to me.

> Like for the previous patches, configure.srv is updated here to avoid
> breaking the build at this patch.

Same comment as before :-)

> +		    tdep->wordsize == 4? PPC32_LINUX_SIZEOF_CGPRREGSET
> +		    : PPC64_LINUX_SIZEOF_CGPRREGSET,

Use parentheses for formatting.

> +/* Get the checkpointed GPR regset that matches the target wordsize
> +   and byteorder of GDBARCH.  The collect function of the returned
> +   regset will clear the buffer passed to it before collecting the
> +   registers to 0 if CLEAR_ON_COLLECT is true and the collect function
> +   is called with regno == -1 (collect all regs in the regset). This
> +   is useful for generating core files without garbage in the register
> +   slots that are not seen by gdb.  When collecting for storing the
> +   registers in the inferior, these slots should not be cleared.  */

I'm not sure I like this approach.  The problem is only about
generating core files, right?  Why don't we instead simply
change linux-tdep.c:linux_collect_regset_section_cb from

  buf = (char *) xmalloc (size);
  regset->collect_regset (regset, data->regcache, -1, buf, size);

to use xcalloc instead?  This seems prudent anyway.  (The same applies
to the similar code in fbsd-tdep.c.)

Then we can probably even get rid of ppc_linux_collect_vrregset as well.


>      return vsx_pseudo_register_read (gdbarch, regcache, reg_nr, buffer);
>    else if (IS_EFP_PSEUDOREG (tdep, reg_nr))
>      return efpr_pseudo_register_read (gdbarch, regcache, reg_nr, buffer);
> +  else if (IS_CVSX_PSEUDOREG (tdep, reg_nr))
> +    return cvsx_pseudo_register_read (gdbarch, regcache, reg_nr, buffer);

Hmm.  The DFP and EFP pseudo registers are simply GDB views onto the
normal FP / VR register set.  For completeness, shouldn't we also offer
similar views onto the checkpointed register set?

> +      if (IS_VSX_PSEUDOREG (tdep, reg_nr))
> +	{
> +	  reg_index = reg_nr - tdep->ppc_vsr0_regnum;
> +	  vr0 = tdep->ppc_vr0_regnum;
> +	  fp0 = tdep->ppc_fp0_regnum;
> +	  vsr0_upper = tdep->ppc_vsr0_upper_regnum;
> +	}
> +      else
> +	{
> +	  reg_index = reg_nr - tdep->ppc_cvsr0_regnum;
> +	  vr0 = PPC_CVR0_REGNUM;
> +	  fp0 = PPC_CF0_REGNUM;
> +	  vsr0_upper = PPC_CVS0H_REGNUM;
> +	}

It looks a bit odd that we need to use variable numbers for
the vr0 / fp0 / vsr0 registers, but can hard-code the numbers
for the checkpointed register set.  Why is this the case?

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  Ulrich.Weigand@de.ibm.com


  reply	other threads:[~2018-07-13 16:24 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-13 13:53 [PATCH 00/17] GDB support for more powerpc registers on linux Pedro Franco de Carvalho
2018-07-13 13:53 ` [PATCH 12/17] [PowerPC] Add tests for TAR Pedro Franco de Carvalho
2018-07-13 15:33   ` Ulrich Weigand
2018-07-13 13:53 ` [PATCH 08/17] [PowerPC] Add tests for PPR and DSCR Pedro Franco de Carvalho
2018-07-13 15:27   ` Ulrich Weigand
2018-07-13 13:53 ` [PATCH 10/17] [PowerPC] Add record/replay support for TAR Pedro Franco de Carvalho
2018-07-13 15:31   ` Ulrich Weigand
2018-07-13 13:53 ` [PATCH 09/17] [PowerPC] Add " Pedro Franco de Carvalho
2018-07-13 15:30   ` Ulrich Weigand
2018-07-13 13:53 ` [PATCH 13/17] [PowerPC] Add support for HTM registers Pedro Franco de Carvalho
2018-07-13 16:24   ` Ulrich Weigand [this message]
2018-07-13 18:16     ` Pedro Franco de Carvalho
2018-07-13 13:53 ` [PATCH 03/17] [PowerPC] Fix indentation in arch/ppc-linux-common.c Pedro Franco de Carvalho
2018-07-13 15:18   ` Ulrich Weigand
2018-07-13 13:53 ` [PATCH 05/17] [PowerPC] Add support for PPR and DSCR Pedro Franco de Carvalho
2018-07-13 15:23   ` Ulrich Weigand
2018-07-13 13:53 ` [PATCH 16/17] [PowerPC] Add support for EBB and PMU registers Pedro Franco de Carvalho
2018-07-13 16:38   ` Ulrich Weigand
2018-07-13 18:23     ` Pedro Franco de Carvalho
2018-07-13 13:53 ` [PATCH 06/17] [PowerPC] Add record/replay support for PPR and DSCR Pedro Franco de Carvalho
2018-07-13 15:25   ` Ulrich Weigand
2018-07-13 13:53 ` [PATCH 04/17] [PowerPC] Refactor have_ initializers in rs6000-tdep.c Pedro Franco de Carvalho
2018-07-13 15:19   ` Ulrich Weigand
2018-07-13 13:53 ` [PATCH 14/17] [PowerPC] Add gdbserver support for HTM registers Pedro Franco de Carvalho
2018-07-13 16:26   ` Ulrich Weigand
2018-07-13 13:53 ` [PATCH 01/17] [PowerPC] Simplify rs6000_pseudo_register_reggroup_p Pedro Franco de Carvalho
2018-07-13 15:17   ` Ulrich Weigand
2018-07-13 13:53 ` [PATCH 02/17] [PowerPC] Fix two if statements in gdb/ppc-linux-nat.c Pedro Franco de Carvalho
2018-07-13 15:17   ` Ulrich Weigand
2018-07-13 13:53 ` [PATCH 07/17] [PowerPC] Add gdbserver support for PPR and DSCR Pedro Franco de Carvalho
2018-07-13 15:26   ` Ulrich Weigand
2018-07-13 14:23 ` [PATCH 15/17] [PowerPC] Add tests for HTM registers Pedro Franco de Carvalho
2018-07-13 16:27   ` Ulrich Weigand
2018-07-13 14:49 ` [PATCH 17/17] [PowerPC] Add gdbserver support for EBB and PMU registers Pedro Franco de Carvalho
2018-07-13 16:40   ` Ulrich Weigand
2018-07-13 18:29     ` Pedro Franco de Carvalho
2018-07-13 15:33 ` [PATCH 11/17] [PowerPC] Add gdbserver support for TAR Pedro Franco de Carvalho
2018-07-13 15:33   ` Ulrich Weigand

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=20180713162433.9A714D80276@oc3748833570.ibm.com \
    --to=uweigand@de.ibm.com \
    --cc=edjunior@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedromfc@linux.ibm.com \
    /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