From patchwork Thu Oct 9 09:52:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gary Benson X-Patchwork-Id: 3157 Received: (qmail 22535 invoked by alias); 9 Oct 2014 09:53:01 -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 22307 invoked by uid 89); 9 Oct 2014 09:52:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD 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; Thu, 09 Oct 2014 09:52:54 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s999qr0K007444 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 9 Oct 2014 05:52:53 -0400 Received: from blade.nx (ovpn-116-100.ams2.redhat.com [10.36.116.100]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s999qpna023451 for ; Thu, 9 Oct 2014 05:52:52 -0400 Received: from blade.nx (localhost [127.0.0.1]) by blade.nx (Postfix) with ESMTP id 583B42626C4 for ; Thu, 9 Oct 2014 10:52:48 +0100 (BST) From: Gary Benson To: gdb-patches@sourceware.org Subject: [PATCH 02/13 v2] Add x86_debug_reg_state to gdbserver Date: Thu, 9 Oct 2014 10:52:27 +0100 Message-Id: <1412848358-9958-3-git-send-email-gbenson@redhat.com> In-Reply-To: <1412848358-9958-1-git-send-email-gbenson@redhat.com> References: <1412848358-9958-1-git-send-email-gbenson@redhat.com> X-IsSubscribed: yes This commit introduces a new function, x86_debug_reg_state, that shared x86 code can use to access the local mirror of a process's debug registers. This function already existed in GDB and was in use by GDB's x86_linux_prepare_to_resume. An equivalent was written for gdbserver and gdbserver's x86_linux_prepare_to_resume was modified to use it. gdb/ChangeLog: * x86-nat.h (x86_debug_reg_state): Move declaration to... * nat/x86-dregs.h (x86_debug_reg_state): New declaration. gdb/gdbserver/ChangeLog: * linux-x86-low.c (x86_debug_reg_state): New function. (x86_linux_prepare_to_resume): Use the above. --- gdb/ChangeLog | 5 +++++ gdb/gdbserver/ChangeLog | 5 +++++ gdb/gdbserver/linux-x86-low.c | 16 ++++++++++++---- gdb/nat/x86-dregs.h | 5 +++++ gdb/x86-nat.h | 5 ----- 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c index d3ca298..e8c6a9c 100644 --- a/gdb/gdbserver/linux-x86-low.c +++ b/gdb/gdbserver/linux-x86-low.c @@ -763,6 +763,16 @@ x86_linux_new_thread (void) return info; } +/* See nat/x86-dregs.h. */ + +struct x86_debug_reg_state * +x86_debug_reg_state (pid_t pid) +{ + struct process_info *proc = find_process_pid (pid); + + return &proc->private->arch_private->debug_reg_state; +} + /* Called when resuming a thread. If the debug regs have changed, update the thread's copies. */ @@ -774,11 +784,9 @@ x86_linux_prepare_to_resume (struct lwp_info *lwp) if (lwp->arch_private->debug_registers_changed) { - int i; - int pid = ptid_get_pid (ptid); - struct process_info *proc = find_process_pid (pid); struct x86_debug_reg_state *state - = &proc->private->arch_private->debug_reg_state; + = x86_debug_reg_state (ptid_get_pid (ptid)); + int i; x86_linux_dr_set (ptid, DR_CONTROL, 0); diff --git a/gdb/nat/x86-dregs.h b/gdb/nat/x86-dregs.h index aebcbce..104d033 100644 --- a/gdb/nat/x86-dregs.h +++ b/gdb/nat/x86-dregs.h @@ -93,6 +93,11 @@ struct x86_debug_reg_state #define ALL_DEBUG_ADDRESS_REGISTERS(i) \ for (i = DR_FIRSTADDR; i <= DR_LASTADDR; i++) +/* Return a pointer to the local mirror of the debug registers of + process PID. This function must be provided by the client + if required. */ +extern struct x86_debug_reg_state *x86_debug_reg_state (pid_t pid); + /* Insert a watchpoint to watch a memory region which starts at address ADDR and whose length is LEN bytes. Watch memory accesses of the type TYPE. Return 0 on success, -1 on failure. */ diff --git a/gdb/x86-nat.h b/gdb/x86-nat.h index df5e9f2..7769572 100644 --- a/gdb/x86-nat.h +++ b/gdb/x86-nat.h @@ -44,11 +44,6 @@ extern void x86_set_debug_register_length (int len); extern void x86_cleanup_dregs (void); -/* Return a pointer to the local mirror of the debug registers of - process PID. */ - -extern struct x86_debug_reg_state *x86_debug_reg_state (pid_t pid); - /* Called whenever GDB is no longer debugging process PID. It deletes data structures that keep track of debug register state. */