From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22845 invoked by alias); 22 Feb 2016 22:20:39 -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 22732 invoked by uid 89); 22 Feb 2016 22:20:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=UD:E, be, UD:gdb.threads, UD:threads X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 22 Feb 2016 22:20:36 +0000 Received: from svr-orw-fem-04.mgc.mentorg.com ([147.34.97.41]) by relay1.mentorg.com with esmtp id 1aXyqF-00033O-Tt from Luis_Gustavo@mentor.com ; Mon, 22 Feb 2016 14:20:31 -0800 Received: from opsys.world.mentorg.com (147.34.91.1) by svr-orw-fem-04.mgc.mentorg.com (147.34.97.41) with Microsoft SMTP Server id 14.3.224.2; Mon, 22 Feb 2016 14:20:31 -0800 From: Luis Machado To: CC: , Subject: [PATCH, v3] Expect SI_KERNEL or TRAP_BRKPT si_code values for MIPS breakpoint traps Date: Mon, 22 Feb 2016 22:20:00 -0000 Message-ID: <1456179628-14249-1-git-send-email-lgustavo@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2016-02/txt/msg00667.txt.bz2 This is v3 of the patch, which adds a comment to how MIPS' kernel handles/will handle si_code values. Pedro, Maciej, does this look reasonable? Should i expand the comment with any other bits of information? -- While doing some MIPS/Linux tests, i've found a number of threading tests failing due to spurious SIGTRAP's. Turns out those spurious SIGTRAP's were actually software breakpoint hits that were supposed to be handled silently by GDB/GDBserver, returning a swbreak event. gdb.threads/continue-pending-status.exp is one of the testcases that show this behavior. -- Breakpoint 1, main () at gdb.threads/continue-pending-status.c:44^M 44 pthread_barrier_init (&barrier, NULL, NUM_THREADS);^M (gdb) b continue-pending-status.c:36^M Breakpoint 2 at 0x400a04: file gdb.threads/continue-pending-status.c, line 36.^M (gdb) PASS: gdb.threads/continue-pending-status.exp: attempt 0: set break in tight loop continue^M Continuing.^M [New Thread 5850]^M [New Thread 5851]^M [Switching to Thread 5850]^M ^M Breakpoint 2, thread_function (arg=0x0) at gdb.threads/continue-pending-status.c:36^M 36 while (1); /* break here */^M (gdb) PASS: gdb.threads/continue-pending-status.exp: attempt 0: continue to tight loop print /x $_thread^M $1 = 0x2^M (gdb) PASS: gdb.threads/continue-pending-status.exp: attempt 0: get thread number thread 3^M [Switching to thread 3 (Thread 5851)]^M 36 while (1); /* break here */^M (gdb) PASS: gdb.threads/continue-pending-status.exp: attempt 0: switch to non-event thread delete breakpoints^M Delete all breakpoints? (y or n) y^M (gdb) info breakpoints^M No breakpoints or watchpoints.^M (gdb) continue^M Continuing.^M ^M Program received signal SIGTRAP, Trace/breakpoint trap.^M <<<< This SIGTRAP was a pending breakpoint event that wasn't supposed to cause <<<< a stop, but gdbserver did not figure out this was a breakpoint hit. PASS: gdb.threads/continue-pending-status.exp: attempt 0: continue for ctrl-c thread_function (arg=0x0) at gdb.threads/continue-pending-status.c:36^M 36 while (1); /* break here */^M (gdb) FAIL: gdb.threads/continue-pending-status.exp: attempt 0: caught interrupt -- I tracked this down to the lack of a proper definition of what MIPS' kernel returns in the si_code for a software breakpoint trap. Further discussion with MIPS maintainers showed that, historically, MIPS kernels have never set a proper si_code and thus they use the default value of SI_KERNEL. There are plans to update the MIPS kernel to provide more meaningful si_code values though, so we should expect both SI_KERNEL and TRAP_BRKPT from now on, as GDB will handle both correctly, like powerpc. With the following patch i have cleaner results for thread tests on MIPS/Linux. Regression-tested on a few MIPS boards. OK? gdb/ChangeLog: 2016-02-20 Luis Machado * nat/linux-ptrace.h: Check for both SI_KERNEL and TRAP_BRKPT si_code for MIPS. --- gdb/nat/linux-ptrace.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gdb/nat/linux-ptrace.h b/gdb/nat/linux-ptrace.h index ba58717..72b32b1 100644 --- a/gdb/nat/linux-ptrace.h +++ b/gdb/nat/linux-ptrace.h @@ -140,11 +140,16 @@ 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 the default si_code of SI_KERNEL for software + breakpoints, hardware watchpoints and SIGTRAP's in general. There are + plans to start using a si_code value of TRAP_BRKPT in the kernel, so + we check for both values. + The generic Linux target code should use GDB_ARCH_IS_TRAP_BRKPT instead of TRAP_BRKPT to abstract out these peculiarities. */ #if defined __i386__ || defined __x86_64__ # define GDB_ARCH_IS_TRAP_BRKPT(X) ((X) == SI_KERNEL) -#elif defined __powerpc__ +#elif defined __powerpc__ || defined __mips__ # define GDB_ARCH_IS_TRAP_BRKPT(X) ((X) == SI_KERNEL || (X) == TRAP_BRKPT) #else # define GDB_ARCH_IS_TRAP_BRKPT(X) ((X) == TRAP_BRKPT) -- 1.9.1