From patchwork Thu Sep 15 11:59:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Arnez X-Patchwork-Id: 15661 Received: (qmail 45766 invoked by alias); 15 Sep 2016 11:59:39 -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 45695 invoked by uid 89); 15 Sep 2016 11:59:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, RCVD_IN_SORBS_SPAM autolearn=no version=3.3.2 spammy=PER, H*Ad:U*uweigand, lp, resume X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 15 Sep 2016 11:59:37 +0000 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u8FBwll3140451 for ; Thu, 15 Sep 2016 07:59:36 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 25fr9h10k2-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 15 Sep 2016 07:59:35 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 15 Sep 2016 12:59:33 +0100 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 15 Sep 2016 12:59:30 +0100 X-IBM-Helo: d06dlp03.portsmouth.uk.ibm.com X-IBM-MailFrom: arnez@linux.vnet.ibm.com X-IBM-RcptTo: gdb-patches@sourceware.org Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 71C2F1B08023 for ; Thu, 15 Sep 2016 13:01:19 +0100 (BST) Received: from d06av08.portsmouth.uk.ibm.com (d06av08.portsmouth.uk.ibm.com [9.149.37.249]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u8FBxUr415860114 for ; Thu, 15 Sep 2016 11:59:30 GMT Received: from d06av08.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av08.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u8FBxU6n028475 for ; Thu, 15 Sep 2016 05:59:30 -0600 Received: from oc1027705133.ibm.com (dyn-9-152-212-159.boeblingen.de.ibm.com [9.152.212.159]) by d06av08.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u8FBxTbb028472; Thu, 15 Sep 2016 05:59:29 -0600 From: Andreas Arnez To: gdb-patches@sourceware.org Cc: Ulrich Weigand Subject: [PATCH 1/6] S390: Avoid direct access to lwp_info structure Date: Thu, 15 Sep 2016 13:59:29 +0200 In-Reply-To: <1473940399-2891-1-git-send-email-arnez@linux.vnet.ibm.com> References: <1473940399-2891-1-git-send-email-arnez@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16091511-0020-0000-0000-000001FC58AD X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16091511-0021-0000-0000-00001D82C72F Message-Id: <1473940769-3870-1-git-send-email-arnez@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-09-15_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609020000 definitions=main-1609150162 X-IsSubscribed: yes When using the lwp_info structure, avoid accessing its members directly, and use the advertised function interfaces instead. This is according to the instructions in linux-nat.h and prepares for making some of the code common between gdb and gdbserver. gdb/ChangeLog: * s390-linux-nat.c (s390_prepare_to_resume): Use advertised lwp functions instead of accessing lwp_info structure members. (s390_mark_per_info_changed): New function. (s390_new_thread): Use it. (s390_refresh_per_info_cb): New function. (s390_refresh_per_info): Remove parameter. Refresh all lwps of the current process. (s390_insert_watchpoint): Adjust call to s390_refresh_per_info. (s390_remove_watchpoint): Likewise. --- gdb/s390-linux-nat.c | 60 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/gdb/s390-linux-nat.c b/gdb/s390-linux-nat.c index e91297b..1e937f9 100644 --- a/gdb/s390-linux-nat.c +++ b/gdb/s390-linux-nat.c @@ -488,16 +488,16 @@ s390_prepare_to_resume (struct lwp_info *lp) CORE_ADDR watch_lo_addr = (CORE_ADDR)-1, watch_hi_addr = 0; struct watch_area *area; + struct arch_lwp_info *lp_priv = lwp_arch_private_info (lp); - if (lp->arch_private == NULL - || !lp->arch_private->per_info_changed) + if (lp_priv == NULL || !lp_priv->per_info_changed) return; - lp->arch_private->per_info_changed = 0; + lp_priv->per_info_changed = 0; - tid = ptid_get_lwp (lp->ptid); + tid = ptid_get_lwp (ptid_of_lwp (lp)); if (tid == 0) - tid = ptid_get_pid (lp->ptid); + tid = ptid_get_pid (ptid_of_lwp (lp)); for (area = watch_base; area; area = area->next) { @@ -528,19 +528,15 @@ s390_prepare_to_resume (struct lwp_info *lp) perror_with_name (_("Couldn't modify watchpoint status")); } -/* Make sure that LP is stopped and mark its PER info as changed, so - the next resume will update it. */ +/* Mark the PER info as changed, so the next resume will update it. */ static void -s390_refresh_per_info (struct lwp_info *lp) +s390_mark_per_info_changed (struct lwp_info *lp) { - if (lp->arch_private == NULL) - lp->arch_private = XCNEW (struct arch_lwp_info); + if (lwp_arch_private_info (lp) == NULL) + lwp_set_arch_private_info (lp, XCNEW (struct arch_lwp_info)); - lp->arch_private->per_info_changed = 1; - - if (!lp->stopped) - linux_stop_lwp (lp); + lwp_arch_private_info (lp)->per_info_changed = 1; } /* When attaching to a new thread, mark its PER info as changed. */ @@ -548,8 +544,30 @@ s390_refresh_per_info (struct lwp_info *lp) static void s390_new_thread (struct lwp_info *lp) { - lp->arch_private = XCNEW (struct arch_lwp_info); - lp->arch_private->per_info_changed = 1; + s390_mark_per_info_changed (lp); +} + +/* Iterator callback for s390_refresh_per_info. */ + +static int +s390_refresh_per_info_cb (struct lwp_info *lp, void *arg) +{ + s390_mark_per_info_changed (lp); + + if (!lwp_is_stopped (lp)) + linux_stop_lwp (lp); + return 0; +} + +/* Make sure that threads are stopped and mark PER info as changed. */ + +static int +s390_refresh_per_info (void) +{ + ptid_t pid_ptid = pid_to_ptid (ptid_get_pid (current_lwp_ptid ())); + + iterate_over_lwps (pid_ptid, s390_refresh_per_info_cb, NULL); + return 0; } static int @@ -557,7 +575,6 @@ s390_insert_watchpoint (struct target_ops *self, CORE_ADDR addr, int len, enum target_hw_bp_type type, struct expression *cond) { - struct lwp_info *lp; struct watch_area *area = XNEW (struct watch_area); if (!area) @@ -569,9 +586,7 @@ s390_insert_watchpoint (struct target_ops *self, area->next = watch_base; watch_base = area; - ALL_LWPS (lp) - s390_refresh_per_info (lp); - return 0; + return s390_refresh_per_info (); } static int @@ -579,7 +594,6 @@ s390_remove_watchpoint (struct target_ops *self, CORE_ADDR addr, int len, enum target_hw_bp_type type, struct expression *cond) { - struct lwp_info *lp; struct watch_area *area, **parea; for (parea = &watch_base; *parea; parea = &(*parea)->next) @@ -598,9 +612,7 @@ s390_remove_watchpoint (struct target_ops *self, *parea = area->next; xfree (area); - ALL_LWPS (lp) - s390_refresh_per_info (lp); - return 0; + return s390_refresh_per_info (); } static int