From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21581 invoked by alias); 5 Jul 2018 22:54:37 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 21567 invoked by uid 89); 5 Jul 2018 22:54:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_SOFTFAIL autolearn=no version=3.3.2 spammy=H*u:Mac, sk:has_com, H*UA:Intel, H*u:Intel X-HELO: mail.baldwin.cx Received: from bigwig.baldwin.cx (HELO mail.baldwin.cx) (96.47.65.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 05 Jul 2018 22:54:35 +0000 Received: from John-Baldwins-MacBook-Pro-2.local (ralph.baldwin.cx [66.234.199.215]) by mail.baldwin.cx (Postfix) with ESMTPSA id 2FCDB10A87D; Thu, 5 Jul 2018 18:54:33 -0400 (EDT) Subject: Re: RISC-V: decr_pc_after_break causing problems To: Palmer Dabbelt , Jim Wilson , andrew.burgess@embecosm.com References: Cc: gdb@sourceware.org From: John Baldwin Message-ID: <95eb8848-182b-dab4-f9dc-298269885f53@FreeBSD.org> Date: Thu, 05 Jul 2018 22:54:00 -0000 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2018-07/txt/msg00012.txt.bz2 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 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. -- John Baldwin