From patchwork Fri Apr 10 08:40:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 6125 Received: (qmail 113438 invoked by alias); 10 Apr 2015 08:41:07 -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 113420 invoked by uid 89); 10 Apr 2015 08:41:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f48.google.com Received: from mail-pa0-f48.google.com (HELO mail-pa0-f48.google.com) (209.85.220.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 10 Apr 2015 08:41:04 +0000 Received: by paboj16 with SMTP id oj16so15354378pab.0 for ; Fri, 10 Apr 2015 01:41:02 -0700 (PDT) X-Received: by 10.66.137.98 with SMTP id qh2mr852986pab.76.1428655262677; Fri, 10 Apr 2015 01:41:02 -0700 (PDT) Received: from E107787-LIN (gcc1-power7.osuosl.org. [140.211.15.137]) by mx.google.com with ESMTPSA id a11sm1363480pdj.54.2015.04.10.01.41.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 10 Apr 2015 01:41:01 -0700 (PDT) From: Yao Qi To: Pedro Alves Cc: Yao Qi , gdb-patches@sourceware.org Subject: Re: [PATCH v2 00/23] All-stop on top of non-stop References: <1428410990-28560-1-git-send-email-palves@redhat.com> <86mw2jvtqk.fsf@gmail.com> <55250048.9050801@redhat.com> Date: Fri, 10 Apr 2015 09:40:56 +0100 In-Reply-To: <55250048.9050801@redhat.com> (Pedro Alves's message of "Wed, 08 Apr 2015 11:17:44 +0100") Message-ID: <86h9sov0iv.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes Pedro Alves writes: >> 3, on native, >> -PASS: gdb.base/info-shared.exp: continue to breakpoint: library function #4 >> +FAIL: gdb.base/info-shared.exp: continue to breakpoint: library function #4 >> >> continue^M >> Continuing.^M >> ^M >> Program received signal SIGSEGV, Segmentation fault.^M >> 0x40021564 in ?? () gdb/testsuite/gdb.base/info-shared-solib1.so^M >> (gdb) FAIL: gdb.base/info-shared.exp: continue to breakpoint: >> library function #4 > > Most of the SIGSEGV/SIGILL/SIGBUS inferior crashes I saw were > due to a displaced stepping bug. Force disabling displaced > stepping with "set displaced off" usually "fixes" it. The next > step I would usually take would be to run the test manually, with > "set debug infrun 1" + "set debug displaced 1" + "set debug lin-lwp 1". Yeah, it is a bug in displaced stepping... Here is the patch to fix it. diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 630a207..8181f25 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -6407,7 +6407,7 @@ install_alu_reg (struct gdbarch *gdbarch, struct regcache *regs, Preparation: tmp1, tmp2, tmp3 <- r0, r1, r2; r0, r1, r2 <- rd, rn, rm - Insn: r0, r1, r2 [, ] + Insn: r0, [r1,] r2 [, ] Cleanup: rd <- r0; r0, r1, r2 <- tmp1, tmp2, tmp3 */ @@ -6454,22 +6454,21 @@ thumb_copy_alu_reg (struct gdbarch *gdbarch, uint16_t insn, struct regcache *regs, struct displaced_step_closure *dsc) { - unsigned rn, rm, rd; + unsigned rm, rd; - rd = bits (insn, 3, 6); - rn = (bit (insn, 7) << 3) | bits (insn, 0, 2); - rm = 2; + rm = bits (insn, 3, 6); + rd = (bit (insn, 7) << 3) | bits (insn, 0, 2); - if (rd != ARM_PC_REGNUM && rn != ARM_PC_REGNUM) + if (rd != ARM_PC_REGNUM && rm != ARM_PC_REGNUM) return thumb_copy_unmodified_16bit (gdbarch, insn, "ALU reg", dsc); if (debug_displaced) - fprintf_unfiltered (gdb_stdlog, "displaced: copying reg %s insn %.4x\n", - "ALU", (unsigned short) insn); + fprintf_unfiltered (gdb_stdlog, "displaced: copying ALU reg insn %.4x\n", + (unsigned short) insn); - dsc->modinsn[0] = ((insn & 0xff00) | 0x08); + dsc->modinsn[0] = ((insn & 0xff00) | 0x10); - install_alu_reg (gdbarch, regs, dsc, rd, rn, rm); + install_alu_reg (gdbarch, regs, dsc, rd, rd, rm); return 0; } diff --git a/gdb/testsuite/gdb.arch/arm-disp-step.S b/gdb/testsuite/gdb.arch/arm-disp-step.S index c9c9447..c3b1088 100644 --- a/gdb/testsuite/gdb.arch/arm-disp-step.S +++ b/gdb/testsuite/gdb.arch/arm-disp-step.S @@ -78,6 +78,11 @@ test_ret_end: #if !defined(__thumb__) bl test_str_pc #endif + + /* Test add with pc in Thumb and Thumb-2 */ +#if defined(__thumb__) + bl test_add_rn_pc +#endif /* Return */ mov sp, r7 sub sp, sp, #4 @@ -372,3 +377,17 @@ pc_offset_wrong: test_str_pc_end: bx lr #endif + +#if defined(__thumb__) + .global test_add_rn_pc + .code 16 + .thumb_func +test_add_rn_pc: + mov r3, 4 +test_add_rn_pc_start: + add r3, pc + .global test_add_rn_pc_end +test_add_rn_pc_end: + bx lr + .size test_add_rn_pc, .-test_add_rn_pc +#endif diff --git a/gdb/testsuite/gdb.arch/arm-disp-step.exp b/gdb/testsuite/gdb.arch/arm-disp-step.exp index 7eac4d1..e191f73 100644 --- a/gdb/testsuite/gdb.arch/arm-disp-step.exp +++ b/gdb/testsuite/gdb.arch/arm-disp-step.exp @@ -371,6 +371,45 @@ proc test_str_pc {} { ".*bx lr.*" } +# Test 16 bit thumb instruction 'add rd, pc'. + +proc test_add_rn_pc {} { + global srcfile gdb_prompt + + set test "break test_add_rn_pc" + gdb_test_multiple "break *test_add_rn_pc" $test { + -re "Breakpoint.*at.* file .*$srcfile, line.*\r\n$gdb_prompt $" { + pass $test + } + -re "No symbol.*\r\n$gdb_prompt $" { + return + } + } + + gdb_continue_to_breakpoint "continue to test_add_rn_pc" \ + ".*mov.*r3, 4.*" + + gdb_test "break *test_add_rn_pc_start" \ + "Breakpoint.*at.* file .*$srcfile, line.*" \ + "break test_add_rn_pc_start" + + gdb_continue_to_breakpoint "continue to test_add_rn_pc_start" \ + ".*add.*r3,.*pc.*" + + set pc_val [get_integer_valueof "\$pc" 0] + + gdb_test "break *test_add_rn_pc_end" \ + "Breakpoint.*at.* file .*$srcfile, line.*" \ + "break test_add_rn_pc_end" + + gdb_continue_to_breakpoint "continue to test_add_rn_pc_end" \ + ".*bx lr.*" + + set r3_val [get_integer_valueof "\$r3" 0] + # Test the value in r3 is correct. + gdb_assert { [expr {$pc_val + 4 + 4} == $r3_val] } +} + # Get things started. clean_restart ${testfile} @@ -410,6 +449,8 @@ test_pop_pc test_str_pc +test_add_rn_pc + ########################################## # Done, run program to exit.