From patchwork Thu Sep 15 12:01:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Arnez X-Patchwork-Id: 15664 Received: (qmail 54049 invoked by alias); 15 Sep 2016 12:02:00 -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 53945 invoked by uid 89); 15 Sep 2016 12:01:58 -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=H*Ad:U*uweigand, 454, 7, 4547, Hx-languages-length:4291 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 12:01:57 +0000 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u8FBwcIP140260 for ; Thu, 15 Sep 2016 08:01:55 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0a-001b2d01.pphosted.com with ESMTP id 25fr7xs87d-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 15 Sep 2016 08:01:55 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 15 Sep 2016 13:01:51 +0100 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 15 Sep 2016 13:01:48 +0100 X-IBM-Helo: d06dlp02.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 d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 375B12190066 for ; Thu, 15 Sep 2016 13:01:09 +0100 (BST) Received: from d06av09.portsmouth.uk.ibm.com (d06av09.portsmouth.uk.ibm.com [9.149.37.250]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u8FC1mp223789876 for ; Thu, 15 Sep 2016 12:01:48 GMT Received: from d06av09.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u8FC1lNc031037 for ; Thu, 15 Sep 2016 06:01:47 -0600 Received: from oc1027705133.ibm.com (dyn-9-152-212-159.boeblingen.de.ibm.com [9.152.212.159]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u8FC1ln2031017; Thu, 15 Sep 2016 06:01:47 -0600 From: Andreas Arnez To: gdb-patches@sourceware.org Cc: Ulrich Weigand Subject: [PATCH 2/6] S390: Migrate watch areas from list to VEC type Date: Thu, 15 Sep 2016 14:01:43 +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: 16091512-0016-0000-0000-00000233A63B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16091512-0017-0000-0000-00002306636B Message-Id: <1473940907-4449-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 For S390, the list of active watchpoints is maintained in a list based at "watch_base". This refactors the list to a vector "watch_areas". gdb/ChangeLog: * s390-linux-nat.c (s390_watch_area): New typedef. Define a VEC. (watch_base): Remove variable. (watch_areas): New variable. (s390_stopped_by_watchpoint): Transform operations on the watch_base list to equivalent operations on the watch_areas VEC. (s390_prepare_to_resume): Likewise. (s390_insert_watchpoint): Likewise. (s390_remove_watchpoint): Likewise. --- gdb/s390-linux-nat.c | 71 +++++++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 37 deletions(-) diff --git a/gdb/s390-linux-nat.c b/gdb/s390-linux-nat.c index 1e937f9..13bf7fd 100644 --- a/gdb/s390-linux-nat.c +++ b/gdb/s390-linux-nat.c @@ -436,14 +436,15 @@ s390_linux_store_inferior_registers (struct target_ops *ops, The only thing we actually need is the total address space area spanned by the watchpoints. */ -struct watch_area +typedef struct watch_area { - struct watch_area *next; CORE_ADDR lo_addr; CORE_ADDR hi_addr; -}; +} s390_watch_area; + +DEF_VEC_O (s390_watch_area); -static struct watch_area *watch_base = NULL; +VEC_s390_watch_area *watch_areas = NULL; static int s390_stopped_by_watchpoint (struct target_ops *ops) @@ -453,7 +454,7 @@ s390_stopped_by_watchpoint (struct target_ops *ops) int result; /* Speed up common case. */ - if (!watch_base) + if (VEC_empty (s390_watch_area, watch_areas)) return 0; parea.len = sizeof (per_lowcore); @@ -487,7 +488,8 @@ s390_prepare_to_resume (struct lwp_info *lp) ptrace_area parea; CORE_ADDR watch_lo_addr = (CORE_ADDR)-1, watch_hi_addr = 0; - struct watch_area *area; + unsigned ix; + s390_watch_area *area; struct arch_lwp_info *lp_priv = lwp_arch_private_info (lp); if (lp_priv == NULL || !lp_priv->per_info_changed) @@ -499,20 +501,22 @@ s390_prepare_to_resume (struct lwp_info *lp) if (tid == 0) tid = ptid_get_pid (ptid_of_lwp (lp)); - for (area = watch_base; area; area = area->next) - { - watch_lo_addr = min (watch_lo_addr, area->lo_addr); - watch_hi_addr = max (watch_hi_addr, area->hi_addr); - } - parea.len = sizeof (per_info); parea.process_addr = (addr_t) & per_info; parea.kernel_addr = offsetof (struct user_regs_struct, per_info); if (ptrace (PTRACE_PEEKUSR_AREA, tid, &parea, 0) < 0) perror_with_name (_("Couldn't retrieve watchpoint status")); - if (watch_base) + if (!VEC_empty (s390_watch_area, watch_areas)) { + for (ix = 0; + VEC_iterate (s390_watch_area, watch_areas, ix, area); + ix++) + { + watch_lo_addr = min (watch_lo_addr, area->lo_addr); + watch_hi_addr = max (watch_hi_addr, area->hi_addr); + } + per_info.control_regs.bits.em_storage_alteration = 1; per_info.control_regs.bits.storage_alt_space_ctl = 1; } @@ -575,16 +579,11 @@ s390_insert_watchpoint (struct target_ops *self, CORE_ADDR addr, int len, enum target_hw_bp_type type, struct expression *cond) { - struct watch_area *area = XNEW (struct watch_area); + s390_watch_area area; - if (!area) - return -1; - - area->lo_addr = addr; - area->hi_addr = addr + len - 1; - - area->next = watch_base; - watch_base = area; + area.lo_addr = addr; + area.hi_addr = addr + len - 1; + VEC_safe_push (s390_watch_area, watch_areas, &area); return s390_refresh_per_info (); } @@ -594,25 +593,23 @@ s390_remove_watchpoint (struct target_ops *self, CORE_ADDR addr, int len, enum target_hw_bp_type type, struct expression *cond) { - struct watch_area *area, **parea; - - for (parea = &watch_base; *parea; parea = &(*parea)->next) - if ((*parea)->lo_addr == addr - && (*parea)->hi_addr == addr + len - 1) - break; + unsigned ix; + s390_watch_area *area; - if (!*parea) + for (ix = 0; + VEC_iterate (s390_watch_area, watch_areas, ix, area); + ix++) { - fprintf_unfiltered (gdb_stderr, - "Attempt to remove nonexistent watchpoint.\n"); - return -1; + if (area->lo_addr == addr && area->hi_addr == addr + len - 1) + { + VEC_unordered_remove (s390_watch_area, watch_areas, ix); + return s390_refresh_per_info (); + } } - area = *parea; - *parea = area->next; - xfree (area); - - return s390_refresh_per_info (); + fprintf_unfiltered (gdb_stderr, + "Attempt to remove nonexistent watchpoint.\n"); + return -1; } static int