From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12140 invoked by alias); 29 Jan 2018 09:30:40 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 10722 invoked by uid 89); 29 Jan 2018 09:28:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy= 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; Mon, 29 Jan 2018 09:28:44 +0000 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w0T9Qrx1092852 for ; Mon, 29 Jan 2018 04:28:43 -0500 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ft0gbhdet-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 29 Jan 2018 04:28:42 -0500 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 29 Jan 2018 09:28:40 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 29 Jan 2018 09:28:38 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w0T9SbsN37093576; Mon, 29 Jan 2018 09:28:37 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7E38252045; Mon, 29 Jan 2018 08:20:55 +0000 (GMT) Received: from ThinkPad (unknown [9.152.212.63]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 55AE15204C; Mon, 29 Jan 2018 08:20:55 +0000 (GMT) Date: Mon, 29 Jan 2018 09:30:00 -0000 From: Philipp Rudo To: Simon Marchi Cc: Alan Hayward , "gdb-patches@sourceware.org" , nd Subject: Re: [PATCH] Use visitors for make_gdb_type In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 18012909-0008-0000-0000-000004C6E5E0 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18012909-0009-0000-0000-00001E5A7720 Message-Id: <20180129102836.5d521e5f@ThinkPad> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-01-29_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1801290127 X-IsSubscribed: yes X-SW-Source: 2018-01/txt/msg00583.txt.bz2 Hi Alan, besides the comments Simon already made, the patch looks fine to me. Thanks Philipp On Sun, 28 Jan 2018 21:24:19 -0500 Simon Marchi wrote: > On 2018-01-26 10:30 AM, Alan Hayward wrote: > > I appear to still have email issues - previous post had the tabs stripped out. > > Hoping this version is ok. Apologies. > > Hi Alan, > > I was able to apply it correctly. > > This patch implements the suggestion in the review for > > [PATCH v2 6/8] Create xml from target descriptions. > > > > Remove the make_gdb_type functions from the tdesc_type_ classes. > > Replace with a static make_gdb_type function that uses a element > > visitor called gdb_type_creator. > > > > I've defined gdb_type_creator inside make_gdb_type because it shouldn't > > be needed outside the function. > > > > The method of creating the types has not changed. > > > > This patch will allow a future patch to commonise the tdesc_types with > > gdbserver without having to move any gdb_type functionality. > > > > Alan. > > make_gdb_type_union & co could be methods of gdb_type_creator and access gdbarch > directly. I think it would make sense to have all the knowledge of the tdesc type > to gdb type conversion inside that class. > > > - type *make_gdb_type (struct gdbarch *gdbarch) const override > > +static type * > > +make_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *ttype) > > +{ > > + class gdb_type_creator : public tdesc_element_visitor > > { > > - type *gdb_type = tdesc_find_type (gdbarch, this->name.c_str ()); > > - if (gdb_type != NULL) > > - return gdb_type; > > + public: > > + gdb_type_creator (struct gdbarch *gdbarch) > > + : m_gdbarch (gdbarch) > > + {} > > > > - switch (this->kind) > > + type *get_type () > > { > > - case TDESC_TYPE_STRUCT: > > - return make_gdb_type_struct (gdbarch); > > - case TDESC_TYPE_UNION: > > - return make_gdb_type_union (gdbarch); > > - case TDESC_TYPE_FLAGS: > > - return make_gdb_type_flags (gdbarch); > > - case TDESC_TYPE_ENUM: > > - return make_gdb_type_enum (gdbarch); > > + return m_type; > > } > > > > - internal_error (__FILE__, __LINE__, > > - "Type \"%s\" has an unknown kind %d", > > - this->name.c_str (), this->kind); > > + void visit_pre (const target_desc *e) > > + {} > > I think we should have empty default implementations of these visit functions in the > base class, instead of having to declare them empty when unnecessary. Maybe Yao had > a reason not to do this initially? > > In any case, make sure to mark the overriden methods with the "override" keyword. Using > clang: > > /home/simark/src/binutils-gdb/gdb/target-descriptions.c:416:10: error: 'visit_pre' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override] > void visit_pre (const target_desc *e) > ^ > /home/simark/src/binutils-gdb/gdb/target-descriptions.c:48:16: note: overridden virtual function is here > virtual void visit_pre (const target_desc *e) = 0; > ^ > /home/simark/src/binutils-gdb/gdb/target-descriptions.c:419:10: error: 'visit_post' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override] > void visit_post (const target_desc *e) > ^ > /home/simark/src/binutils-gdb/gdb/target-descriptions.c:49:16: note: overridden virtual function is here > virtual void visit_post (const target_desc *e) = 0; > ^ > /home/simark/src/binutils-gdb/gdb/target-descriptions.c:422:10: error: 'visit_pre' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override] > void visit_pre (const tdesc_feature *e) > ^ > /home/simark/src/binutils-gdb/gdb/target-descriptions.c:51:16: note: overridden virtual function is here > virtual void visit_pre (const tdesc_feature *e) = 0; > ^ > /home/simark/src/binutils-gdb/gdb/target-descriptions.c:425:10: error: 'visit_post' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override] > void visit_post (const tdesc_feature *e) > ^ > /home/simark/src/binutils-gdb/gdb/target-descriptions.c:52:16: note: overridden virtual function is here > virtual void visit_post (const tdesc_feature *e) = 0; > ^ > /home/simark/src/binutils-gdb/gdb/target-descriptions.c:544:10: error: 'visit' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override] > void visit (const tdesc_reg *reg) > ^ > /home/simark/src/binutils-gdb/gdb/target-descriptions.c:58:16: note: overridden virtual function is here > virtual void visit (const tdesc_reg *e) = 0; > ^ > > Otherwise, LGTM. > > Thanks, > > Simon >