From: Palmer Dabbelt <palmer@sifive.com>
To: Jim Wilson <jimw@sifive.com>, andrew.burgess@embecosm.com
Cc: gdb@sourceware.org
Subject: Re: RISC-V: decr_pc_after_break causing problems
Date: Wed, 04 Jul 2018 00:35:00 -0000 [thread overview]
Message-ID: <mhng-c2172dd6-d7fb-4df6-87d4-a180afd408e3@palmer-si-x1c4> (raw)
In-Reply-To: <CAFyWVaZ2_CTM2rL0OMv2V8R_0L52rUVOTgxuZ5Er9mW+Qw-+Jw@mail.gmail.com>
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.
next prev parent reply other threads:[~2018-07-04 0:35 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 [this message]
2018-07-05 22:54 ` John Baldwin
2018-07-11 14:52 ` Andrew Burgess
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=mhng-c2172dd6-d7fb-4df6-87d4-a180afd408e3@palmer-si-x1c4 \
--to=palmer@sifive.com \
--cc=andrew.burgess@embecosm.com \
--cc=gdb@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