public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "wilson at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/28486] [riscv64] GDB doesn't allow stepping over cbreak trap instruction
Date: Thu, 21 Oct 2021 22:38:40 +0000	[thread overview]
Message-ID: <bug-28486-4717-fhvPJR8kX6@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-28486-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=28486

Jim Wilson <wilson at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |wilson at gcc dot gnu.org

--- Comment #1 from Jim Wilson <wilson at gcc dot gnu.org> ---
RISC-V doesn't have a breakpoint instruction.  ebreak is a generic trap
instruction used for multiple purposes.  The compiler uses it for program
ending traps for instance.  gdb does use ebreak, but gdb will only recognize an
ebreak it emitted itself as an actual breakpoint.  Any others are program
ending traps.

Note that the MIPS break instruction accepts an argument, and MIPS has defined
one specific value to indicate a breakpoint.  However, on RISC-V, ebreak does
not take an argument, so we can't use that method to distinguish a program
ending trap from a breakpoint.

The semihosting spec uses ebreak, but it uses a specific sequence of
instructions to indicate that this is a semihosting call and not a program
ending trap.  It does this because ebreak does not take an argument, and hence
there is no other way to specify that this is a semihosting call.  See
https://github.com/riscv/riscv-semihosting-spec/blob/main/riscv-semihosting-spec.adoc#11-semihosting-trap-instruction-sequence

Because an ebreak instruction is ambiguous, I'm concerned that it would be
dangerous to let the debugger step over it by default.  We could maybe add an
option to allow someone to step over ebreak if they really want to, and leave
it off by default.  Or we could define a sequence of instructions that is meant
to be a user breakpoint like was done for the semihosting spec, and then teach
gdb to respect that.

Or maybe it is normal for gdb to let users step over a trap instruction, even
though program state may be undefined at that point?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  reply	other threads:[~2021-10-21 22:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-21 20:25 [Bug gdb/28486] New: " kip at thevertigo dot com
2021-10-21 22:38 ` wilson at gcc dot gnu.org [this message]
2021-10-22  5:43 ` [Bug gdb/28486] " kip at thevertigo dot com
2021-10-25 20:53 ` wilson at gcc dot gnu.org
2021-10-25 21:14 ` kip at thevertigo dot com
2022-04-09 15:03 ` [Bug tdep/28486] " tromey at sourceware dot org

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=bug-28486-4717-fhvPJR8kX6@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).