From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 79066 invoked by alias); 4 Jul 2018 00:35:27 -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 78994 invoked by uid 89); 4 Jul 2018 00:35:26 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-3.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=inclined, HX-Received:61a7, HX-Received:sk:i7-v6mr, H*RU:74.125.83.67 X-HELO: mail-pg0-f67.google.com Received: from mail-pg0-f67.google.com (HELO mail-pg0-f67.google.com) (74.125.83.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 04 Jul 2018 00:35:24 +0000 Received: by mail-pg0-f67.google.com with SMTP id e11-v6so1692010pgq.0 for ; Tue, 03 Jul 2018 17:35:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=wfEUOUy0BUNgkZdLLBxV5idzzEkLTE6QUt+dS20C1p0=; b=cGMfWEe56CA1Y68b1NXYXQ55E+7lTls+8EQgI/seRenvLp0GtI9ox1OlA8GEe4dYjl QKT2b+sH3nssIj7q3olBWv380PQVF3BGSkBvnz6T3RaxTfnUzdTTOVlg2N6YoVb55r45 2yQArglS9TUJhLnmlRSpgDh9U6s7HUvJMYx5Lt37SKMhkO27Z76dx5D0yEmP9mR4CEe/ PzQHD/hcZVYNm5n6thL03ZSsa5bix1BR7JY0myeJqpi5pzbIX5Z/mwBil/3CF0iHm3Vb zcDe78jZ2Qqmm6dFAa+T0bGpOkaNRof2p2aZGDMfleZuDBSxnqtPf+2E/6hYBoCBZMm+ 2qMg== Return-Path: Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id u14-v6sm6882555pfd.103.2018.07.03.17.35.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Jul 2018 17:35:21 -0700 (PDT) Date: Wed, 04 Jul 2018 00:35:00 -0000 X-Google-Original-Date: Tue, 03 Jul 2018 17:35:17 PDT (-0700) Subject: Re: RISC-V: decr_pc_after_break causing problems In-Reply-To: CC: gdb@sourceware.org From: Palmer Dabbelt To: Jim Wilson , andrew.burgess@embecosm.com Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-SW-Source: 2018-07/txt/msg00002.txt.bz2 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.