Message ID | 994fa101380c1495e1ca97a6dcbfdb3bd23ae173.1523286728.git.andrew.burgess@embecosm.com |
---|---|
State | New, archived |
Headers |
Received: (qmail 118436 invoked by alias); 9 Apr 2018 15:15:45 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 118386 invoked by uid 89); 9 Apr 2018 15:15:43 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=2122 X-HELO: mail-wr0-f196.google.com Received: from mail-wr0-f196.google.com (HELO mail-wr0-f196.google.com) (209.85.128.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 09 Apr 2018 15:15:40 +0000 Received: by mail-wr0-f196.google.com with SMTP id 80so9971523wrb.2 for <gdb-patches@sourceware.org>; Mon, 09 Apr 2018 08:15:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=j1aRKYg8+MnuN93AGyEFVXvUrKlnX28lHn1hY353xvA=; b=H0oJb2C/fJo3XqRTq7+jFY5qy0k4jny7MvKdztCSGD4JvSrXBTiZCdxzkOGhLlVHYK HM4VpKueQTwniERBmyWXJHXb4/DoDTFcD1HqG2b+YOnS2yDDOZFDXRIBLZ/6JIQQdmgK XREtOp373dDVOuivux8fdyZiiiXcTwA42PETJ/xpOrnxxtTUYo5c0HHOEnmN5oD05Gam 6ZQrU/07fK3PxRw9MVf/1+U9FDcvEzLGxm2hfZ1CYr0p+xjgkRzd0dHcmoOjAB1RkVBv S0LK7hGr0VbShgVqvNocPqCDEBklot0dGojDTthgGEO/5hKh7i9nassSVCgTIllYJI16 VnYA== X-Gm-Message-State: AElRT7EvAj4nLOsinbR32HfLBpvQaSu1aOel5r+XQSV/hZ5mn1x2Q+0f e19cMGJcpkJ2yvgBCPpqYc/cL2ym X-Google-Smtp-Source: AIpwx484794ajMGcHjWxsknEfr6Tqly4BCror9jFnxT3qM3tUY1HkRxuhCxIaG8smp276Fp+mghKGg== X-Received: by 10.223.172.226 with SMTP id o89mr24319844wrc.264.1523286934760; Mon, 09 Apr 2018 08:15:34 -0700 (PDT) Received: from localhost (host81-148-252-121.range81-148.btcentralplus.com. [81.148.252.121]) by smtp.gmail.com with ESMTPSA id s49sm775635wrc.36.2018.04.09.08.15.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Apr 2018 08:15:34 -0700 (PDT) From: Andrew Burgess <andrew.burgess@embecosm.com> To: gdb-patches@sourceware.org Cc: Andrew Burgess <andrew.burgess@embecosm.com> Subject: [PATCH 2/3] gdb/testsuite: Filter out some registers for riscv Date: Mon, 9 Apr 2018 16:15:28 +0100 Message-Id: <994fa101380c1495e1ca97a6dcbfdb3bd23ae173.1523286728.git.andrew.burgess@embecosm.com> In-Reply-To: <cover.1523286728.git.andrew.burgess@embecosm.com> References: <cover.1523286728.git.andrew.burgess@embecosm.com> In-Reply-To: <cover.1523286728.git.andrew.burgess@embecosm.com> References: <cover.1523286728.git.andrew.burgess@embecosm.com> X-IsSubscribed: yes |
Commit Message
Andrew Burgess
April 9, 2018, 3:15 p.m. UTC
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(+)
Comments
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.
* 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
On Mon, 09 Apr 2018 15:26:07 PDT (-0700), andrew.burgess@embecosm.com wrote: > * 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. I think it's fine for now, we can fix it when another test fails :)
On 04/10/2018 09:25 PM, Palmer Dabbelt wrote: > On Mon, 09 Apr 2018 15:26:07 PDT (-0700), andrew.burgess@embecosm.com wrote: >> Let me know how you'd feel about leaving this as it is for now, and >> extending the filter list at a later date. > > I think it's fine for now, we can fix it when another test fails :) This is OK, then. For the register lists, I wonder whether a better option would be to instead let gdb determine which registers should be compared, instead of hard coding in the testcase. Like, look at the save/restore reggroups instead of all registers. Thanks, Pedro Alves
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