From patchwork Tue Jun 30 14:57:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandra Loosemore X-Patchwork-Id: 7434 Received: (qmail 2488 invoked by alias); 30 Jun 2015 14:59:29 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 2473 invoked by uid 89); 30 Jun 2015 14:59:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 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; Tue, 30 Jun 2015 14:59:26 +0000 Received: from svr-orw-fem-05.mgc.mentorg.com ([147.34.97.43]) by relay1.mentorg.com with esmtp id 1Z9x0M-0003S8-Db from Sandra_Loosemore@mentor.com ; Tue, 30 Jun 2015 07:59:22 -0700 Received: from [IPv6:::1] (147.34.91.1) by svr-orw-fem-05.mgc.mentorg.com (147.34.97.43) with Microsoft SMTP Server id 14.3.224.2; Tue, 30 Jun 2015 07:59:22 -0700 Message-ID: <5592AE67.9080905@codesourcery.com> Date: Tue, 30 Jun 2015 08:57:43 -0600 From: Sandra Loosemore User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: Yao Qi , Subject: [patch] unbreak nios2-*-linux* testing As previously noted, on Nios II Linux targets, the kernel now puts signal handler handler trampolines on a read-only page of memory and GDB cannot set single-step breakpoints there. My last attempt at working around this https://sourceware.org/ml/gdb-patches/2015-04/msg01092.html was rejected in favor of some not-yet-implemented target-independent solution: https://sourceware.org/ml/gdb-patches/2015-05/msg00183.html Given that the discussion pointed to by that thread is 11 years old, I think it's safe to say that fixing this is not a priority. :-( Meanwhile, the GDB testsuite remains broken on this target. Tests are not just failing, but getting stuck in infinite loops trying unsuccessfully to step out of a signal handler without recognizing that they are stuck. This is blocking regression testing of other patches in my queue. This patch adds kfails for these issues similar to what other targets with this problem already do. There are no code changes. OK to commit, so I can get on with other work? -Sandra diff --git a/gdb/nios2-tdep.c b/gdb/nios2-tdep.c index 08f2034..988b9fc 100644 --- a/gdb/nios2-tdep.c +++ b/gdb/nios2-tdep.c @@ -1189,7 +1189,15 @@ nios2_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc) return nios2_analyze_prologue (gdbarch, start_pc, start_pc, &cache, NULL); } -/* Implement the breakpoint_from_pc gdbarch hook. */ +/* Implement the breakpoint_from_pc gdbarch hook. + + The Nios II ABI for Linux says: "Userspace programs should not use + the break instruction and userspace debuggers should not insert + one." and "Userspace breakpoints are accomplished using the trap + instruction with immediate operand 31 (all ones)." + + So, we use "trap 31" consistently as the breakpoint on bare-metal + as well as Linux targets. */ static const gdb_byte* nios2_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *bp_addr, @@ -1198,11 +1206,11 @@ nios2_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *bp_addr, enum bfd_endian byte_order_for_code = gdbarch_byte_order_for_code (gdbarch); unsigned long mach = gdbarch_bfd_arch_info (gdbarch)->mach; - /* R1 break encoding: - ((0x1e << 17) | (0x34 << 11) | (0x1f << 6) | (0x3a << 0)) - 0x003da7fa */ - static const gdb_byte r1_breakpoint_le[] = {0xfa, 0xa7, 0x3d, 0x0}; - static const gdb_byte r1_breakpoint_be[] = {0x0, 0x3d, 0xa7, 0xfa}; + /* R1 trap encoding: + ((0x1d << 17) | (0x2d << 11) | (0x1f << 6) | (0x3a << 0)) + 0x003b6ffa */ + static const gdb_byte r1_breakpoint_le[] = {0xfa, 0x6f, 0x3b, 0x0}; + static const gdb_byte r1_breakpoint_be[] = {0x0, 0x3b, 0x6f, 0xfa}; *bp_size = NIOS2_OPCODE_SIZE; if (byte_order_for_code == BFD_ENDIAN_BIG) return r1_breakpoint_be;