From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@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 08:41:00 -0000 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 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2015-04/txt/msg00364.txt.bz2 Pedro Alves writes: >> 3, on native, >> -PASS: gdb.base/info-shared.exp: continue to breakpoint: library functio= n #4 >> +FAIL: gdb.base/info-shared.exp: continue to breakpoint: library functio= n #4 >>=20 >> 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. --=20 Yao (=E9=BD=90=E5=B0=A7) From: Yao Qi Subject: [PATCH] [arm] Fix displaced stepping for thumb alu reg instruction Recent patch series "V2 All-stop on top of non-stop" causes a SIGSEGV in the test case, > -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 fun= ction #4 and an ARM displaced stepping bug is exposed. It can be reproduced by the modified gdb.arch/arm-disp-step.exp as below, continue^M Continuing.^M ^M Program received signal SIGSEGV, Segmentation fault.^M 0xa713cfcc in ?? ()^M (gdb) FAIL: gdb.arch/arm-disp-step.exp: continue to breakpoint: continue to= test_add_rn_pc_end This patch is to fix it. gdb: 2015-04-09 Yao Qi * arm-tdep.c (install_alu_reg): Update comment. (thumb_copy_alu_reg): Remove local variable rn. Update debugging message. Use r2 instead of r1 in the modified instruction. gdb/testsuite: 2015-04-09 Yao Qi * gdb.arch/arm-disp-step.S (main): Call test_add_rn_pc. (test_add_rn_pc): New function. * gdb.arch/arm-disp-step.exp (test_add_rn_pc): New proc. (top level): Invoke test_add_rn_pc. 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 regc= ache *regs, =20 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 */ =20 @@ -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; =20 - rd =3D bits (insn, 3, 6); - rn =3D (bit (insn, 7) << 3) | bits (insn, 0, 2); - rm =3D 2; + rm =3D bits (insn, 3, 6); + rd =3D (bit (insn, 7) << 3) | bits (insn, 0, 2); =20 - if (rd !=3D ARM_PC_REGNUM && rn !=3D ARM_PC_REGNUM) + if (rd !=3D ARM_PC_REGNUM && rm !=3D ARM_PC_REGNUM) return thumb_copy_unmodified_16bit (gdbarch, insn, "ALU reg", dsc); =20 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); =20 - dsc->modinsn[0] =3D ((insn & 0xff00) | 0x08); + dsc->modinsn[0] =3D ((insn & 0xff00) | 0x10); =20 - install_alu_reg (gdbarch, regs, dsc, rd, rn, rm); + install_alu_reg (gdbarch, regs, dsc, rd, rd, rm); =20 return 0; } diff --git a/gdb/testsuite/gdb.arch/arm-disp-step.S b/gdb/testsuite/gdb.arc= h/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.a= rch/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.*" } =20 +# 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} =3D=3D $r3_val] } +} + # Get things started. =20 clean_restart ${testfile} @@ -410,6 +449,8 @@ test_pop_pc =20 test_str_pc =20 +test_add_rn_pc + ########################################## =20 # Done, run program to exit.