From patchwork Mon Sep 8 15:25:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gary Benson X-Patchwork-Id: 2685 Received: (qmail 19899 invoked by alias); 8 Sep 2014 16:00:13 -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 19875 invoked by uid 89); 8 Sep 2014 16:00:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.4 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 08 Sep 2014 16:00:12 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s88FPSbh030609 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 8 Sep 2014 11:25:29 -0400 Received: from blade.nx (ovpn-116-108.ams2.redhat.com [10.36.116.108]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s88FPRTG020599 for ; Mon, 8 Sep 2014 11:25:27 -0400 Received: from blade.nx (localhost [127.0.0.1]) by blade.nx (Postfix) with ESMTP id 8006B2640F9 for ; Mon, 8 Sep 2014 16:25:25 +0100 (BST) From: Gary Benson To: gdb-patches@sourceware.org Subject: [PATCH 10/14] Linux x86 low-level debug register code synchronization Date: Mon, 8 Sep 2014 16:25:18 +0100 Message-Id: <1410189922-18320-11-git-send-email-gbenson@redhat.com> In-Reply-To: <1410189922-18320-1-git-send-email-gbenson@redhat.com> References: <1410189922-18320-1-git-send-email-gbenson@redhat.com> X-IsSubscribed: yes This commit makes several small changes to the low-level debug register code for Linux x86, making the code in the GDB and gdbserver implementations identical. gdb/ChangeLog: * x86-linux-nat.c (x86_linux_dr_set_addr): Updated assertion. (x86_linux_new_thread): Renamed argument. gdb/gdbserver/ChangeLog: * linux-x86-low.c (x86_linux_dr_get): Add assertion. Use perror_with_name. (x86_linux_dr_set): Likewise. --- gdb/ChangeLog | 5 +++++ gdb/gdbserver/ChangeLog | 6 ++++++ gdb/gdbserver/linux-x86-low.c | 6 ++++-- gdb/x86-linux-nat.c | 6 +++--- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c index 79e75e5..9171824 100644 --- a/gdb/gdbserver/linux-x86-low.c +++ b/gdb/gdbserver/linux-x86-low.c @@ -528,13 +528,14 @@ x86_linux_dr_get (ptid_t ptid, int regnum) int tid; unsigned long value; + gdb_assert (ptid_lwp_p (ptid)); tid = ptid_get_lwp (ptid); errno = 0; value = ptrace (PTRACE_PEEKUSER, tid, offsetof (struct user, u_debugreg[regnum]), 0); if (errno != 0) - error ("Couldn't read debug register"); + perror_with_name (_("Couldn't read debug register")); return value; } @@ -544,13 +545,14 @@ x86_linux_dr_set (ptid_t ptid, int regnum, unsigned long value) { int tid; + gdb_assert (ptid_lwp_p (ptid)); tid = ptid_get_lwp (ptid); errno = 0; ptrace (PTRACE_POKEUSER, tid, offsetof (struct user, u_debugreg[regnum]), value); if (errno != 0) - error ("Couldn't write debug register"); + perror_with_name (_("Couldn't write debug register")); } static int diff --git a/gdb/x86-linux-nat.c b/gdb/x86-linux-nat.c index 237f4e4..5066ae0 100644 --- a/gdb/x86-linux-nat.c +++ b/gdb/x86-linux-nat.c @@ -146,7 +146,7 @@ x86_linux_dr_set_addr (int regnum, CORE_ADDR addr) { ptid_t pid_ptid = pid_to_ptid (current_inferior_pid ()); - gdb_assert (regnum >= 0 && regnum <= DR_LASTADDR - DR_FIRSTADDR); + gdb_assert (DR_FIRSTADDR <= regnum && regnum <= DR_LASTADDR); iterate_over_lwps (pid_ptid, update_debug_registers_callback, NULL); } @@ -203,9 +203,9 @@ x86_linux_prepare_to_resume (struct lwp_info *lwp) } static void -x86_linux_new_thread (struct lwp_info *lp) +x86_linux_new_thread (struct lwp_info *lwp) { - lwp_set_debug_registers_changed (lp, 1); + lwp_set_debug_registers_changed (lwp, 1); }