From: Andrew Burgess <andrew.burgess@embecosm.com>
To: Palmer Dabbelt <palmer@sifive.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 2/3] gdb/testsuite: Filter out some registers for riscv
Date: Mon, 09 Apr 2018 22:26:00 -0000 [thread overview]
Message-ID: <20180409222607.GN13407@embecosm.com> (raw)
In-Reply-To: <mhng-74df0d03-8bb9-46b9-b50a-779b86c1aa81@palmer-si-x1c4>
* Palmer Dabbelt <palmer@sifive.com> [2018-04-09 14:28:33 -0700]:
> On Mon, 09 Apr 2018 08:15:28 PDT (-0700), andrew.burgess@embecosm.com wrote:
> > On riscv the cycle counter, and instructions retired counter CSRs are
> > read only, this causes problems in the gdb.base/callfuncs.exp test, as
> > the values in these CSRs change after an inferior call, the check that
> > no target registers have been modified then fails.
> >
> > Luckily the test already has a mechanism in place for filtering out
> > registers that are modified (and can't be restored) by an inferior call,
> > so this commit adds the problem registers into this list for riscv.
> >
> > In the future we may end up needing to filter out more CSRs, but right
> > now, for the targets I have access too, these are the only ones causing
> > problems.
> >
> > gdb/testsuite/ChangeLog:
> >
> > * gdb.base/callfuncs.exp (fetch_all_registers): Add riscv register
> > filter pattern.
> > ---
> > gdb/testsuite/ChangeLog | 5 +++++
> > gdb/testsuite/gdb.base/callfuncs.exp | 10 ++++++++++
> > 2 files changed, 15 insertions(+)
> >
> > diff --git a/gdb/testsuite/gdb.base/callfuncs.exp b/gdb/testsuite/gdb.base/callfuncs.exp
> > index 94636938752..c5e39918c2a 100644
> > --- a/gdb/testsuite/gdb.base/callfuncs.exp
> > +++ b/gdb/testsuite/gdb.base/callfuncs.exp
> > @@ -285,6 +285,16 @@ proc fetch_all_registers {test} {
> > }
> > exp_continue
> > }
> > + -re "^\(?:cycle\|instret\)\[ \t\]+\[^\r\n\]+\r\n" {
> > + if [istarget "riscv*-*-*"] {
> > + # Filter out the cycle counter and instructions
> > + # retired counter CSRs which are read-only, giving
> > + # spurious differences.
> > + } else {
> > + lappend all_registers_lines $expect_out(0,string)
> > + }
> > + exp_continue
> > + }
> > -re "^\[^ \t\]+\[ \t\]+\[^\r\n\]+\r\n" {
> > lappend all_registers_lines $expect_out(0,string)
> > exp_continue
>
> I think we only want to check the X and F registers here -- essentially
> every CSR is a special register where you can't really rely on the value not
> being changed somewhere by hardware. For example:
>
> * The interrupt pending bits could flip at any point, even if interrupts are
> disabled.
> * The floating-point dirty and exception state bits could change if a
> floating-point instruction executes.
> * The various trap CSRs (epc, badaddr, cause, etc) get set whenever a trap
> is executed.
I'm not sure about the second case. If GDB is stopped and we perform
an inferior call, then ideally the entire floating point state,
including contents of things like fcsr would be reset, otherwise, when
we continue the behaviour might not be as we expect.
I do agree with you that the two registers I've filtered so far
probably aren't enough, but I'm really reluctant to _only_ check X and
F registers. I think a better selection would be X, F, and read/write
user CSRs. Which means I need to build the list of CSRs to filter, I
was hoping to put that off for another day for now...
Let me know how you'd feel about leaving this as it is for now, and
extending the filter list at a later date.
thanks,
Andrew
next prev parent reply other threads:[~2018-04-09 22:26 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-09 15:15 [PATCH 0/3] Small testsuite updates Andrew Burgess
2018-04-09 15:15 ` [PATCH 3/3] gdb/testsuite: Handle targets with lots of registers Andrew Burgess
2018-04-12 23:40 ` Maciej W. Rozycki
2018-04-13 13:10 ` Pedro Alves
2018-04-13 13:57 ` Maciej W. Rozycki
2018-05-04 12:01 ` Andrew Burgess
2018-05-04 12:47 ` Pedro Alves
2018-04-09 15:15 ` [PATCH 1/3] gdb/testsuite: Fix broken regexp in gdbstub case Andrew Burgess
2018-04-13 12:12 ` Pedro Alves
2018-05-03 19:41 ` Andrew Burgess
2018-05-04 9:18 ` Pedro Alves
2018-04-09 15:15 ` [PATCH 2/3] gdb/testsuite: Filter out some registers for riscv Andrew Burgess
2018-04-09 21:28 ` Palmer Dabbelt
2018-04-09 22:26 ` Andrew Burgess [this message]
2018-04-10 20:25 ` Palmer Dabbelt
2018-04-13 12:55 ` Pedro Alves
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=20180409222607.GN13407@embecosm.com \
--to=andrew.burgess@embecosm.com \
--cc=gdb-patches@sourceware.org \
--cc=palmer@sifive.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