From patchwork Mon Sep 8 15:25:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gary Benson X-Patchwork-Id: 2686 Received: (qmail 20519 invoked by alias); 8 Sep 2014 16:00:18 -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 20413 invoked by uid 89); 8 Sep 2014 16:00:17 -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:13 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s88FPSeJ030611 (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-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s88FPR64017112 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 A4FED2640FB for ; Mon, 8 Sep 2014 16:25:25 +0100 (BST) From: Gary Benson To: gdb-patches@sourceware.org Subject: [PATCH 12/14] Introduce x86_linux_update_debug_registers Date: Mon, 8 Sep 2014 16:25:20 +0100 Message-Id: <1410189922-18320-13-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 moves the entire body of both GDB's and gdbserver's x86_linux_prepare_to_resume functions into new functions, x86_linux_update_debug_registers. This reorganisation allows all Linux x86 low-level debug register code to be placed in one shared file, separate from general Linux x86 shared code. gdb/ChangeLog: * x86-linux-nat.c (x86_linux_update_debug_registers): New function. (x86_linux_prepare_to_resume): Call the above. gdb/gdbserver/ChangeLog: * linux-x86-low.c (x86_linux_update_debug_registers): New function. (x86_linux_prepare_to_resume): Call the above. --- gdb/ChangeLog | 6 ++++++ gdb/gdbserver/ChangeLog | 6 ++++++ gdb/gdbserver/linux-x86-low.c | 16 +++++++++++++--- gdb/x86-linux-nat.c | 16 +++++++++++++--- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c index 9c5590f..9bd4ae2 100644 --- a/gdb/gdbserver/linux-x86-low.c +++ b/gdb/gdbserver/linux-x86-low.c @@ -762,15 +762,17 @@ x86_debug_reg_state (pid_t pid) return &proc->private->arch_private->debug_reg_state; } -/* Called prior to resuming a thread. Updates the thread's debug - registers if the values in our local mirror have been changed. */ +/* Update the thread's debug registers if the values in our local + mirror have been changed. */ static void -x86_linux_prepare_to_resume (struct lwp_info *lwp) +x86_linux_update_debug_registers (struct lwp_info *lwp) { ptid_t ptid = ptid_of_lwp (lwp); int clear_status = 0; + gdb_assert (lwp_is_stopped (lwp)); + if (lwp_debug_registers_changed (lwp)) { struct x86_debug_reg_state *state @@ -806,6 +808,14 @@ x86_linux_prepare_to_resume (struct lwp_info *lwp) if (clear_status || lwp_is_stopped_by_watchpoint (lwp)) x86_linux_dr_set (ptid, DR_STATUS, 0); } + +/* Called prior to resuming a thread. */ + +static void +x86_linux_prepare_to_resume (struct lwp_info *lwp) +{ + x86_linux_update_debug_registers (lwp); +} /* When GDBSERVER is built as a 64-bit application on linux, the PTRACE_GETSIGINFO data is always presented in 64-bit layout. Since diff --git a/gdb/x86-linux-nat.c b/gdb/x86-linux-nat.c index e64f436..5efaf9f 100644 --- a/gdb/x86-linux-nat.c +++ b/gdb/x86-linux-nat.c @@ -152,15 +152,17 @@ x86_linux_dr_set_addr (int regnum, CORE_ADDR addr) iterate_over_lwps (pid_ptid, update_debug_registers_callback, NULL); } -/* Called prior to resuming a thread. Updates the thread's debug - registers if the values in our local mirror have been changed. */ +/* Update the thread's debug registers if the values in our local + mirror have been changed. */ static void -x86_linux_prepare_to_resume (struct lwp_info *lwp) +x86_linux_update_debug_registers (struct lwp_info *lwp) { ptid_t ptid = ptid_of_lwp (lwp); int clear_status = 0; + gdb_assert (lwp_is_stopped (lwp)); + if (lwp_debug_registers_changed (lwp)) { struct x86_debug_reg_state *state @@ -197,6 +199,14 @@ x86_linux_prepare_to_resume (struct lwp_info *lwp) x86_linux_dr_set (ptid, DR_STATUS, 0); } +/* Called prior to resuming a thread. */ + +static void +x86_linux_prepare_to_resume (struct lwp_info *lwp) +{ + x86_linux_update_debug_registers (lwp); +} + /* Called when a new thread is detected. */ static void