From patchwork Mon Sep 8 15:25:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gary Benson X-Patchwork-Id: 2678 Received: (qmail 17524 invoked by alias); 8 Sep 2014 15:25:34 -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 17420 invoked by uid 89); 8 Sep 2014 15:25:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 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 15:25:28 +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 s88FPQo8030136 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 8 Sep 2014 11:25:27 -0400 Received: from blade.nx (ovpn-116-108.ams2.redhat.com [10.36.116.108]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s88FPPn1022082 for ; Mon, 8 Sep 2014 11:25:25 -0400 Received: from blade.nx (localhost [127.0.0.1]) by blade.nx (Postfix) with ESMTP id B93D82640F0 for ; Mon, 8 Sep 2014 16:25:24 +0100 (BST) From: Gary Benson To: gdb-patches@sourceware.org Subject: [PATCH 01/14] Introduce current_inferior_ptid Date: Mon, 8 Sep 2014 16:25:09 +0100 Message-Id: <1410189922-18320-2-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 introduces a new function, current_inferior_ptid, that allows shared code to obtain the ptid of the current inferior. gdb/ChangeLog: * common/common-inferior.h: New file. * Makefile.in (HFILES_NO_SRCDIR): Add common/common-inferior.h. * inferior.h: Include common-inferior.h. * inferior.c (current_inferior_ptid): New function. * x86-linux-nat.c (x86_linux_dr_get_addr): Use the above. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. gdb/gdbserver/ChangeLog: * inferiors.h: Include common-inferior.h. * inferiors.c (current_inferior_ptid): New function. * linux-x86-low.c (x86_dr_low_get_addr): Use the above. (x86_dr_low_get_control): Likewise. (x86_dr_low_get_status): Likewise. --- gdb/ChangeLog | 10 ++++++++++ gdb/Makefile.in | 2 +- gdb/common/common-inferior.h | 28 ++++++++++++++++++++++++++++ gdb/gdbserver/ChangeLog | 8 ++++++++ gdb/gdbserver/inferiors.c | 8 ++++++++ gdb/gdbserver/inferiors.h | 2 ++ gdb/gdbserver/linux-x86-low.c | 12 +++--------- gdb/inferior.c | 8 ++++++++ gdb/inferior.h | 2 ++ gdb/x86-linux-nat.c | 6 +++--- 10 files changed, 73 insertions(+), 13 deletions(-) create mode 100644 gdb/common/common-inferior.h diff --git a/gdb/Makefile.in b/gdb/Makefile.in index c394ea3..acea04b 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -939,7 +939,7 @@ common/print-utils.h common/rsp-low.h nat/x86-dregs.h x86-linux-nat.h \ i386-linux-nat.h common/common-defs.h common/errors.h common/common-types.h \ common/common-debug.h common/cleanups.h common/gdb_setjmp.h \ common/common-exceptions.h target/target.h target/symbol.h \ -common/common-regcache.h +common/common-regcache.h common/common-inferior.h # Header files that already have srcdir in them, or which are in objdir. diff --git a/gdb/common/common-inferior.h b/gdb/common/common-inferior.h new file mode 100644 index 0000000..fa23b22 --- /dev/null +++ b/gdb/common/common-inferior.h @@ -0,0 +1,28 @@ +/* Inferior process information. + + Copyright (C) 2014 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef COMMON_INFERIOR_H +#define COMMON_INFERIOR_H + +/* Return the ptid of the current inferior. This function must be + provided by the client. */ + +extern ptid_t current_inferior_ptid (void); + +#endif /* COMMON_INFERIOR_H */ diff --git a/gdb/gdbserver/inferiors.c b/gdb/gdbserver/inferiors.c index 29a07e0..c87de27 100644 --- a/gdb/gdbserver/inferiors.c +++ b/gdb/gdbserver/inferiors.c @@ -358,3 +358,11 @@ current_process (void) gdb_assert (current_inferior != NULL); return get_thread_process (current_inferior); } + +/* See common/common-inferior.h. */ + +ptid_t +current_inferior_ptid (void) +{ + return ptid_of (current_inferior); +} diff --git a/gdb/gdbserver/inferiors.h b/gdb/gdbserver/inferiors.h index f584339..10aa095 100644 --- a/gdb/gdbserver/inferiors.h +++ b/gdb/gdbserver/inferiors.h @@ -19,6 +19,8 @@ #ifndef INFERIORS_H #define INFERIORS_H +#include "common-inferior.h" + /* Generic information for tracking a list of ``inferiors'' - threads, processes, etc. */ struct inferior_list diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c index a66f61e..04f66aa 100644 --- a/gdb/gdbserver/linux-x86-low.c +++ b/gdb/gdbserver/linux-x86-low.c @@ -602,11 +602,9 @@ x86_dr_low_set_addr (int regnum, CORE_ADDR addr) static CORE_ADDR x86_dr_low_get_addr (int regnum) { - ptid_t ptid = ptid_of (current_inferior); - gdb_assert (DR_FIRSTADDR <= regnum && regnum <= DR_LASTADDR); - return x86_linux_dr_get (ptid, regnum); + return x86_linux_dr_get (current_inferior_ptid (), regnum); } /* Update the inferior's DR7 debug control register from STATE. */ @@ -625,9 +623,7 @@ x86_dr_low_set_control (unsigned long control) static unsigned long x86_dr_low_get_control (void) { - ptid_t ptid = ptid_of (current_inferior); - - return x86_linux_dr_get (ptid, DR_CONTROL); + return x86_linux_dr_get (current_inferior_ptid (), DR_CONTROL); } /* Get the value of the DR6 debug status register from the inferior @@ -636,9 +632,7 @@ x86_dr_low_get_control (void) static unsigned long x86_dr_low_get_status (void) { - ptid_t ptid = ptid_of (current_inferior); - - return x86_linux_dr_get (ptid, DR_STATUS); + return x86_linux_dr_get (current_inferior_ptid (), DR_STATUS); } /* Low-level function vector. */ diff --git a/gdb/inferior.c b/gdb/inferior.c index 23da0c7..e19168d 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -68,6 +68,14 @@ set_current_inferior (struct inferior *inf) current_inferior_ = inf; } +/* See common/common-inferior.h. */ + +ptid_t +current_inferior_ptid (void) +{ + return inferior_ptid; +} + /* A cleanups callback, helper for save_current_program_space below. */ diff --git a/gdb/inferior.h b/gdb/inferior.h index 58557a4..72ecfda 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -21,6 +21,8 @@ #if !defined (INFERIOR_H) #define INFERIOR_H 1 +#include "common-inferior.h" + struct target_waitstatus; struct frame_info; struct ui_file; diff --git a/gdb/x86-linux-nat.c b/gdb/x86-linux-nat.c index 67300d8..9370976 100644 --- a/gdb/x86-linux-nat.c +++ b/gdb/x86-linux-nat.c @@ -97,7 +97,7 @@ x86_linux_dr_get_addr (int regnum) /* DR6 and DR7 are retrieved with some other way. */ gdb_assert (DR_FIRSTADDR <= regnum && regnum <= DR_LASTADDR); - return x86_linux_dr_get (inferior_ptid, regnum); + return x86_linux_dr_get (current_inferior_ptid (), regnum); } /* Return the inferior's DR7 debug control register. */ @@ -105,7 +105,7 @@ x86_linux_dr_get_addr (int regnum) static unsigned long x86_linux_dr_get_control (void) { - return x86_linux_dr_get (inferior_ptid, DR_CONTROL); + return x86_linux_dr_get (current_inferior_ptid (), DR_CONTROL); } /* Get DR_STATUS from only the one LWP of INFERIOR_PTID. */ @@ -113,7 +113,7 @@ x86_linux_dr_get_control (void) static unsigned long x86_linux_dr_get_status (void) { - return x86_linux_dr_get (inferior_ptid, DR_STATUS); + return x86_linux_dr_get (current_inferior_ptid (), DR_STATUS); } /* Callback for iterate_over_lwps. Update the debug registers of