From: Andrew Burgess <andrew.burgess@embecosm.com>
To: John Baldwin <jhb@FreeBSD.org>
Cc: Palmer Dabbelt <palmer@sifive.com>, Jim Wilson <jimw@sifive.com>,
gdb@sourceware.org
Subject: Re: RISC-V: decr_pc_after_break causing problems
Date: Wed, 11 Jul 2018 14:52:00 -0000 [thread overview]
Message-ID: <20180711145249.GG3978@embecosm.com> (raw)
In-Reply-To: <95eb8848-182b-dab4-f9dc-298269885f53@FreeBSD.org>
* John Baldwin <jhb@FreeBSD.org> [2018-07-05 15:54:32 -0700]:
> On 7/3/18 5:35 PM, Palmer Dabbelt wrote:
> > On Tue, 03 Jul 2018 17:17:04 PDT (-0700), Jim Wilson wrote:
> >> On Mon, Jun 25, 2018 at 7:54 PM, Jim Wilson <jimw@sifive.com> wrote:
> >>> The RISC-V port in the riscv-tdep.c file has
> >>> set_gdbarch_decr_pc_after_break (gdbarch, (has_compressed_isa ? 2 : 4));
> >>
> >> I'm still hoping to get a response to this. I need to make
> >> coordinated fixes to both gdb and the linux kernel to get breakpoints
> >> working correctly.
> >
> > Andrew: I think this materialized itself when you submitted the GDB patches,
> > probably because we have this in our Linux code:
> >
> > asmlinkage void do_trap_break(struct pt_regs *regs)
> > {
> > #ifdef CONFIG_GENERIC_BUG
> > if (!user_mode(regs)) {
> > enum bug_trap_type type;
> >
> > type = report_bug(regs->sepc, regs);
> > switch (type) {
> > case BUG_TRAP_TYPE_NONE:
> > break;
> > case BUG_TRAP_TYPE_WARN:
> > regs->sepc += sizeof(bug_insn_t);
> > return;
> > case BUG_TRAP_TYPE_BUG:
> > die(regs, "Kernel BUG");
> > }
> > }
> > #endif /* CONFIG_GENERIC_BUG */
> >
> > force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)(regs->sepc), current);
> > regs->sepc += 0x4;
> > }
> >
> > There's at least one bug in the Linux port here: we can enter a breakpoint trap
> > via either ebreak (a 4-byte instruction) or c.ebreak (a 2-byte instruction).
> > c.ebreak is necessary for a sane debugger so we need to support it. Our
> > options are:
> >
> > * Handle c.ebreak in Linux and leave this as it stands.
> > * Remove both the Linux PC adjustment and the GDB PC adjustment.
> >
> > I'm inclined to take the second option as it's less code. I suppose
> > technically it's an ABI break, but since it's broken anyway then I'm happy with
> > taking it.
> >
> > Is there something I'm missing? If not Jim will submit a Linux patch and then
> > we'll pull the trigger on this one.
>
> FWIW, my preference would be for the decr_after_pc_break match the hardware
> which from my understanding of the thread means it should always be
> zero.
I agree this solution is the correct approach and GDB should be
changed.
Thanks,
Andrew
next prev parent reply other threads:[~2018-07-11 14:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-26 2:54 Jim Wilson
2018-06-26 19:15 ` Tim Newsome
2018-07-04 0:17 ` Jim Wilson
2018-07-04 0:35 ` Palmer Dabbelt
2018-07-05 22:54 ` John Baldwin
2018-07-11 14:52 ` Andrew Burgess [this message]
2018-07-11 17:47 ` Andrew Burgess
2018-07-11 18:20 ` Jim Wilson
2018-07-16 22:09 ` 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=20180711145249.GG3978@embecosm.com \
--to=andrew.burgess@embecosm.com \
--cc=gdb@sourceware.org \
--cc=jhb@FreeBSD.org \
--cc=jimw@sifive.com \
--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