Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Sebastian Huber <sebastian.huber@embedded-brains.de>
To: Jim Wilson <jimw@sifive.com>
Cc: gdb-patches@sourceware.org, Andrew Burgess <andrew.burgess@embecosm.com>
Subject: Re: [PATCH] RISC-V: Don't decrement pc after break.
Date: Mon, 23 Jul 2018 17:25:00 -0000	[thread overview]
Message-ID: <1830811266.24706.1532366683342.JavaMail.zimbra@embedded-brains.de> (raw)
In-Reply-To: <CAFyWVab6oUetvAkAMq4u5Dvb1hn2WHJ4GxjtgtNA05XMNRAOfw@mail.gmail.com>

----- Am 23. Jul 2018 um 17:38 schrieb Jim Wilson jimw@sifive.com:

> On Mon, Jul 23, 2018 at 3:30 AM, Sebastian Huber
> <sebastian.huber@embedded-brains.de> wrote:
>> Hello Jim,
>>
>> this patch broke debugging with Qemu (qemu-system-riscv64, Git commit
>> 6598f0cdad6acc6674c4f060fa46e537228c2c47).  The GDB error message is:
>>
>> Register 3921 is not available
> 
> I don't understand how rtems debugging could have worked without this
> patch.  3921 minus 65 in hex is 0xf10 which is the legacy misa.  The
> legacy misa is checked only if a read of the v1.9.1 misa fails.  If
> the read of both the v1.9.1 misa and the legacy misa fails, then you
> get a confusing error stating that register 3921 is not available.
> But the real problem is that both misa reads failed.  The ISA spec
> says that misa must exist and be readable, although an implementation
> is allowed to return 0 when it is read.  Gdb uses misa to determine
> target features.  Gdb does handle the 0 read case by deducing info
> from ELF header flags instead of the misa register.
> 
> If you have a rtems target support, then it must handle reading the
> misa register.  If is OK to just return 0.  That is what my linux port
> does for now.  At some point I may try adding a linux kernel patch to
> add ptrace support for reading misa.  If rtems is running in machine
> mode, you can probably read misa directly.  Otherwise, you would need
> something like a linux ptrace to read it.  For embedded targets using
> openocd, they can just read misa directly.

RTEMS is more or less just a bare metal ELF target with a special Newlib configuration. I think the question is, why it worked at all on bare metal ELF RISC-V targets before.

> 
> The problem with misa is easy to miss, as gdb only tries to read misa
> if you execute a command that requires info about the target, such as
> trying to use hardware floating point.  Actually, one of my other
> patches, the one to remove the pc decrement after a break, modified
> the code so that we try to read misa when checking to see if
> compressed breakpoints could be used.  Before it was only checking ELF
> headers for this, which wasn't right.  This is probably the patch that
> exposed the bug in your rtems target support.

This could be also a Qemu bug. I have to check this with the debugger tomorrow. The misa should be returned by Qemu in csr_read_helper() (target/riscv/op_helper.c). A "info registers" for example returns only the standard registers. For the CSR registers I get "not available".


  reply	other threads:[~2018-07-23 17:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-17  0:12 Jim Wilson
2018-07-17 15:37 ` Andrew Burgess
2018-07-23 10:31 ` Sebastian Huber
2018-07-23 15:38   ` Jim Wilson
2018-07-23 17:25     ` Sebastian Huber [this message]
2018-07-23 23:27       ` Jim Wilson
2018-07-24  6:15         ` Sebastian Huber
2018-07-24 11:41           ` Jim Wilson
2018-07-26  6:30             ` Sebastian Huber
2018-08-03 22:05 ` Palmer Dabbelt

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=1830811266.24706.1532366683342.JavaMail.zimbra@embedded-brains.de \
    --to=sebastian.huber@embedded-brains.de \
    --cc=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jimw@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