From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11622 invoked by alias); 18 Dec 2013 16:07:51 -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 11607 invoked by uid 89); 18 Dec 2013 16:07:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: service87.mimecast.com Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 18 Dec 2013 16:07:50 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Wed, 18 Dec 2013 16:07:46 +0000 Received: from [10.1.201.52] ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 18 Dec 2013 16:07:44 +0000 Message-ID: <52B1C84F.4000102@arm.com> Date: Wed, 18 Dec 2013 16:07:00 -0000 From: Yufeng Zhang User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: "gdb-patches@sourceware.org" CC: Marcus Shawcroft Subject: [PATCH, AArch64] Fix bug in hardware watchpoint/breakpoint handling X-MC-Unique: 113121816074600301 Content-Type: multipart/mixed; boundary="------------040801080702060200070007" X-IsSubscribed: yes X-SW-Source: 2013-12/txt/msg00707.txt.bz2 This is a multi-part message in MIME format. --------------040801080702060200070007 Content-Type: text/plain; charset=WINDOWS-1252; format=flowed Content-Transfer-Encoding: quoted-printable Content-length: 994 Hi, This patch fixes an AArch64 GDB bug in handling the hardware debug=20 registers. GDB calls ptrace to set hardware debug registers and it=20 passes a full-length "struct user_hwdebug_state" variable regardless of=20 the number of hardware debug registers available on a target. When=20 there are fewer than 16 (the maximum number) hardware=20 breakpoint/watchpoint registers on a target, the kernel will complain=20 about the gdb's request to set non-existing hardware debug registers.=20 There will be an warning of "Unexpected error setting hardware debug=20 registers" when the inferior starts to run. This patch fixes the issue by setting iov.iov_len with a value=20 reflecting the exact size in use. OK for the mainline? Thanks. Yufeng gdb/ * aarch64-linux-nat.c (aarch64_linux_set_debug_regs): Set iov.iov_len with the real length in use. gdb/gdbserver/ * linux-aarch64-low.c (aarch64_linux_set_debug_regs): Set iov.iov_len with the real length in use.= --------------040801080702060200070007 Content-Type: text/plain; name=patch Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="patch" Content-length: 1551 diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c index 256725b..7d76833 100644 --- a/gdb/aarch64-linux-nat.c +++ b/gdb/aarch64-linux-nat.c @@ -314,10 +314,13 @@ aarch64_linux_set_debug_regs (const struct aarch64_de= bug_reg_state *state, =20 memset (®s, 0, sizeof (regs)); iov.iov_base =3D ®s; - iov.iov_len =3D sizeof (regs); count =3D watchpoint ? aarch64_num_wp_regs : aarch64_num_bp_regs; addr =3D watchpoint ? state->dr_addr_wp : state->dr_addr_bp; ctrl =3D watchpoint ? state->dr_ctrl_wp : state->dr_ctrl_bp; + if (count =3D=3D 0) + return; + iov.iov_len =3D (offsetof (struct user_hwdebug_state, dbg_regs[count - 1= ]) + + sizeof (regs.dbg_regs [count - 1])); =20 for (i =3D 0; i < count; i++) { diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch6= 4-low.c index 93246b3..c2d271a 100644 --- a/gdb/gdbserver/linux-aarch64-low.c +++ b/gdb/gdbserver/linux-aarch64-low.c @@ -602,10 +602,13 @@ aarch64_linux_set_debug_regs (const struct aarch64_de= bug_reg_state *state, =20 memset (®s, 0, sizeof (regs)); iov.iov_base =3D ®s; - iov.iov_len =3D sizeof (regs); count =3D watchpoint ? aarch64_num_wp_regs : aarch64_num_bp_regs; addr =3D watchpoint ? state->dr_addr_wp : state->dr_addr_bp; ctrl =3D watchpoint ? state->dr_ctrl_wp : state->dr_ctrl_bp; + if (count =3D=3D 0) + return; + iov.iov_len =3D (offsetof (struct user_hwdebug_state, dbg_regs[count - 1= ]) + + sizeof (regs.dbg_regs [count - 1])); =20 for (i =3D 0; i < count; i++) {= --------------040801080702060200070007--