Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: Jim Wilson <jimw@sifive.com>
Cc: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [0/1] RISC-V: Update CSR to priv 1.11.
Date: Tue, 9 Jun 2020 11:27:36 +0100	[thread overview]
Message-ID: <20200609102736.GD2737@embecosm.com> (raw)
In-Reply-To: <CAFyWVaap1pf-1Pqt1w2avxEDm2-Zd7N6GqqimnDBg9u=sbwLHw@mail.gmail.com>

* Jim Wilson <jimw@sifive.com> [2020-06-08 18:19:17 -0700]:

> On Mon, Jun 8, 2020 at 2:39 PM Andrew Burgess
> <andrew.burgess@embecosm.com> wrote:
> > Unless I misunderstand here, you asking why we don't use the xml
> > target descriptions?  We do.  Or we _should_ do.  Maybe it's not
> > working?  Is your target definitely sending back a description?  And
> > it definitely includes register "dscratch" ?
> 
> qemu does have xml support; I added it.  The xml register files were
> copied straight from the gdb xml files at the time I wrote the
> patches.  Unfortunately, no one is actively maintaining this code, or
> actively testing it, unless maybe you count Tom who is apparently
> testing it, so the xml files no longer match the gdb ones.

That's absolutely fine.  There's no requirement for QEMU to match
GDB[1], GDB's builtin XML files are only looked at in the case where
the target doesn't provide one[2].

>                                                             The old
> qemu version of the files does have a dscratch register because gdb
> had it at the time.  qemu does have a concept of priv spec version,
> but I doubt anyone has given any thought about how to match the xml
> files to the priv spec version.  Currently, there is a single set of
> xml files, and that isn't going to work long term.  The list of csr
> registers needs to depend on the priv spec version.

Absolutely and right now this is totally a qemu issue, it needs to
dynamically build the xml based on the type of target that's being
emulated.

We already do some of this in riscv_create_target_description, when we
build the default target description, we select 32 or 64 bit x-regs,
and optionally add 32 or 64 bit f-regs based on the features we think
the target has (which is based on the file being debugged).

In the future we might want to extend this if we do more native RISC-V
debugging, this could query the priv level and adjust the csr regs as
needed, but I don't have any targets where I could test this.

>                                                      descratch was
> added in priv spec 1.9, and was dropped in 1.11.  qemu 4.0 has 1.9.1
> and 1.10 support, so dscratch is a valid register name for priv spec
> versions supported by qemu (though qemu is dropping 1.9.1 from the
> development tree).  Anyways, dscratch needs to work in gdb, adding an
> alias sounds like a reasonable solution.

I would suggest that if the target provides a description then we
should be pretty conservative with which aliases we add.  I don't know
if adding a dscratch to dscratch0 alias would be something I'm in
favour of or not.  Though I'm conflicted, because it seems obvious
that GDB should create aliases for things like ra/x1 sp/x2, etc, so
maybe I'm just x-reg elitist...

>                                           There is a DECLARE_CSR_ALIAS
> in include/opcode/riscv-opc.h for dscratch and other affected csrs,
> but I guess gdb isn't handling those at the moment

No but we probably should.  I took a quick look at this but ran into
some issues.  I'm going to try and see if I can get this all figured
out.

Thanks,
Andrew

[1] There are some requirements like the target must announce the full
set of integer registers, but there's no requirement for an exact
match, and as far as CSRs, pretty much anything goes.

[2] I'm willing to be convinced that I messed up, but I'm describing
what _should_ be happening.


  reply	other threads:[~2020-06-09 10:27 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-12 10:00 Nelson Chu
2020-03-12 10:00 ` [PATCH] RISC-V: Update CSR to privileged spec 1.11 Nelson Chu
2020-03-24  5:05   ` [PING] " Nelson Chu
2020-03-24  8:51   ` Andrew Burgess
2020-03-24  9:11     ` Nelson Chu
2020-06-08 15:37 ` [0/1] RISC-V: Update CSR to priv 1.11 Tom Tromey
2020-06-08 21:39   ` Andrew Burgess
2020-06-09  1:19     ` Jim Wilson
2020-06-09 10:27       ` Andrew Burgess [this message]
2020-06-09 20:12     ` Tom Tromey
2020-06-09 17:30   ` [RFC] gdb/riscv: Improved register alias name creation Andrew Burgess
2020-06-09 20:14     ` Jim Wilson
2020-06-09 22:47       ` Andrew Burgess
2020-06-10  9:31         ` Nelson Chu
2020-06-10 10:55           ` Andrew Burgess
2020-06-10 13:26             ` Nelson Chu
2020-06-09 20:54     ` Tom Tromey
2020-06-09 22:30       ` Andrew Burgess
     [not found]         ` <8736735bjx.fsf@tromey.com>
2020-06-10 13:01           ` Tom Tromey
2020-06-10 20:37         ` Jim Wilson
2020-06-11  8:28           ` Andrew Burgess
2020-06-09 22:58       ` Andrew Burgess
2020-06-10 12:53         ` Tom Tromey
     [not found]           ` <87mu5b3vm3.fsf@tromey.com>
2020-06-10 14:46             ` Tom Tromey
2020-06-11 13:16               ` [PATCH 0/2] [PATCHv2] " Andrew Burgess
2020-06-11 13:16                 ` [PATCH 1/2] " Andrew Burgess
2020-06-11 13:16                 ` [PATCH 2/2] gdb/riscv: Take CSR names from target description Andrew Burgess
2020-06-11 14:06                 ` [PATCH 0/2] [PATCHv2] gdb/riscv: Improved register alias name creation Tom Tromey
2020-06-12 22:34                   ` Andrew Burgess
2020-06-15 20:27                     ` Tom Tromey
2020-06-16  7:56                       ` Andrew Burgess
2020-06-16 12:03                         ` Tom Tromey
2020-06-16 20:39                           ` Andrew Burgess
2020-06-10 20:34       ` [RFC] " Jim Wilson

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=20200609102736.GD2737@embecosm.com \
    --to=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jimw@sifive.com \
    --cc=tom@tromey.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