From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 38530 invoked by alias); 15 Apr 2016 23:17:52 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 38516 invoked by uid 89); 15 Apr 2016 23:17:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=be, UD:E, sk:macro@i, macro@imgtec.com X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 15 Apr 2016 23:17:41 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DD6AF7F0A2; Fri, 15 Apr 2016 23:17:39 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3FNHcuL011373; Fri, 15 Apr 2016 19:17:39 -0400 Subject: Re: [PATCH] Handle MIPS Linux SIGTRAP siginfo.si_code values To: "Maciej W. Rozycki" References: <1456332239-24007-1-git-send-email-palves@redhat.com> <56CDFB9B.3090708@redhat.com> <56CE3AA6.6090005@redhat.com> <56CE5CBD.9070105@redhat.com> Cc: gdb-patches@sourceware.org From: Pedro Alves Message-ID: <57117692.5090507@redhat.com> Date: Fri, 15 Apr 2016 23:17:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2016-04/txt/msg00371.txt.bz2 On 04/05/2016 05:57 PM, Maciej W. Rozycki wrote: > FYI, the kernel change has now made it upstream: > > commit 3b143cca6e1397188f507a6c727f4108861ceb8b > Author: Maciej W. Rozycki > Date: Fri Mar 4 01:44:28 2016 +0000 > > MIPS: traps: Correct the SIGTRAP debug ABI in `do_watch' and `do_trap_or_bp' > > and will be present starting from Linux 4.6.0 release. > Thanks Maciej, Here's the same patch with updated comments. I've pushed this to both master and the 7.11 branch. I've filed https://sourceware.org/bugzilla/show_bug.cgi?id=19958 (Breakpoints/watchpoints broken on MIPS Linux <= 4.5), as necessary according to our branch backporting procedure. >From f25c3723b2251e33e725afa52280fde679f3e600 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Fri, 15 Apr 2016 23:52:00 +0100 Subject: [PATCH] MIPS/Linux: Also recognize TRAP_BRKPT and TRAP_HWBKPT This makes the MIPS Linux backends recognize TRAP_BRKPT and TRAP_HWBKPT in siginfo.si_code in addition to SI_KERNEL, since Linux 4.6 now reports the finer-grained si_code values too. Refs: https://sourceware.org/ml/gdb-patches/2016-02/msg00756.html https://sourceware.org/ml/gdb-patches/2016-04/msg00090.html On kernels that report SI_KERNEL (<= 4.5), we'll enter the "ambiguous" path of save_stop_reason: if (GDB_ARCH_IS_TRAP_BRKPT (siginfo.si_code) && GDB_ARCH_IS_TRAP_HWBKPT (siginfo.si_code)) { /* The si_code is ambiguous on this arch -- check debug registers. */ if (!check_stopped_by_watchpoint (lp)) lp->stop_reason = TARGET_STOPPED_BY_SW_BREAKPOINT; } while on kernels that report the finer-grained si_code values (>= 4.6), we'll enter the corresponding branches: else if (GDB_ARCH_IS_TRAP_BRKPT (siginfo.si_code)) { } else if (GDB_ARCH_IS_TRAP_HWBKPT (siginfo.si_code)) { ... gdb/ChangeLog: 2016-04-15 Pedro Alves * nat/linux-ptrace.h [__mips__] (GDB_ARCH_IS_TRAP_BRKPT): Also accept TRAP_BRKPT. [__mips__] (GDB_ARCH_IS_TRAP_HWBKPT): Also accept TRAP_HWBKPT. --- gdb/nat/linux-ptrace.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gdb/nat/linux-ptrace.h b/gdb/nat/linux-ptrace.h index b9123c9..0a23bcb 100644 --- a/gdb/nat/linux-ptrace.h +++ b/gdb/nat/linux-ptrace.h @@ -140,8 +140,8 @@ struct buffer; in SPU code on a Cell/B.E. However, SI_KERNEL is never seen on a SIGTRAP for any other reason. - The MIPS kernel uses SI_KERNEL for all kernel generated traps. - Since: + The MIPS kernel up until 4.5 used SI_KERNEL for all kernel + generated traps. Since: - MIPS doesn't do hardware single-step. - We don't need to care about exec SIGTRAPs --- we assume @@ -152,6 +152,9 @@ struct buffer; software breakpoints and hardware watchpoints, which can be done by peeking the debug registers. + Beginning with Linux 4.6, the MIPS port reports proper TRAP_BRKPT and + TRAP_HWBKPT codes, so we also match them. + The generic Linux target code should use GDB_ARCH_IS_TRAP_* instead of TRAP_* to abstract out these peculiarities. */ #if defined __i386__ || defined __x86_64__ @@ -161,8 +164,8 @@ struct buffer; # define GDB_ARCH_IS_TRAP_BRKPT(X) ((X) == SI_KERNEL || (X) == TRAP_BRKPT) # define GDB_ARCH_IS_TRAP_HWBKPT(X) ((X) == TRAP_HWBKPT) #elif defined __mips__ -# define GDB_ARCH_IS_TRAP_BRKPT(X) ((X) == SI_KERNEL) -# define GDB_ARCH_IS_TRAP_HWBKPT(X) ((X) == SI_KERNEL) +# define GDB_ARCH_IS_TRAP_BRKPT(X) ((X) == SI_KERNEL || (X) == TRAP_BRKPT) +# define GDB_ARCH_IS_TRAP_HWBKPT(X) ((X) == SI_KERNEL || (X) == TRAP_HWBKPT) #else # define GDB_ARCH_IS_TRAP_BRKPT(X) ((X) == TRAP_BRKPT) # define GDB_ARCH_IS_TRAP_HWBKPT(X) ((X) == TRAP_HWBKPT) -- 2.5.5