From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 91846 invoked by alias); 25 Jan 2018 15:45:05 -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 91820 invoked by uid 89); 25 Jan 2018 15:45:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1499, H*r:sk:static., visit X-HELO: mail-wr0-f174.google.com Received: from mail-wr0-f174.google.com (HELO mail-wr0-f174.google.com) (209.85.128.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 25 Jan 2018 15:45:01 +0000 Received: by mail-wr0-f174.google.com with SMTP id a1so3444402wri.5 for ; Thu, 25 Jan 2018 07:45:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=0DjPaQW35no0BLDSU5qwobWqvmpryANb2PoNc23V5JM=; b=KNhfeuw4lkTP4nzRy8loVi3zFFuXS+etuj0mvJG/ghsniy5fdLgCNY9XiXfaeZYO85 gaPDg4hDMHL5kwL9qpL6hEmDeWzXB9opulC5LkNI3DN3Sxuw5fJBrByBehe0USvZruG6 HT6TUjD4TXsh4d5nJkGQtAT3Qc5arAzUdEb6YBS7llpKkjnTSV9icRSWofyMDOS9NNyl LdHcczLWqFLU2L9c7yFR0oO+SFp7XXPBLEvUzhVgET+3SYSgoHZ8gPIohK5jtldahAdP al165Qz24y27lpXei/V1RPLVBYDFYLk9VbRAUzLJh1gTdJ6Ot5XqmYplfEUJQrtLxi3J bNlg== X-Gm-Message-State: AKwxyteFPTc8lrUopud7nUMTyoUAR2ul3O40CUoSkIXcCeegR95D939Z Y0mtkLapdDCXfvqMEeglOus= X-Google-Smtp-Source: AH8x224ozwnbMvVPpDr9/I1D/4rE8BLWItAUW041m/cMrQFpEbBDpFb4pLQB/bOtpnouQTCTxADDjg== X-Received: by 10.223.191.7 with SMTP id p7mr3452335wrh.34.1516895099150; Thu, 25 Jan 2018 07:44:59 -0800 (PST) Received: from E107787-LIN (static.42.136.251.148.clients.your-server.de. [148.251.136.42]) by smtp.gmail.com with ESMTPSA id d63sm1546418wmd.9.2018.01.25.07.44.58 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 25 Jan 2018 07:44:58 -0800 (PST) From: Yao Qi To: Philipp Rudo Cc: Alan Hayward , "gdb-patches\@sourceware.org" , nd Subject: Re: [PATCH v2 6/8] Create xml from target descriptions References: <7C97CC6A-92CB-4702-820D-206022F07102@arm.com> <20180125141423.1ff34025@ThinkPad> Date: Thu, 25 Jan 2018 15:45:00 -0000 In-Reply-To: <20180125141423.1ff34025@ThinkPad> (Philipp Rudo's message of "Thu, 25 Jan 2018 14:14:23 +0100") Message-ID: <86vafqc58o.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2018-01/txt/msg00530.txt.bz2 Philipp Rudo writes: > Same for tdesc_type::make_gdb_type (patch #5). But here i would prefer t= o not > even declare the method for GDBserver, i.e. > > struct tdesc_type > { > > [...] > > #ifndef GDBSERVER > virtual type *make_gdb_type (struct gdbarch *gdbarch) const =3D 0; > #endif > }; > > The problem i see with implementing stubs calling error is that you canno= t find > out you made a mistake until you call the function during run-time. This= gives > room to nasty bugs which could easily be prevented when there is a compil= e bug. make_gdb_type and gdbarch shouldn't be put into arch/tdesc.h at all, if possible. You can create an sub-class of tdesc_element_visitor in gdb side, and create the gdb type by visiting these elements, like this, class gdb_type_creator : public tdesc_element_visitor { public: gdb_type_createor (struct gdbarch *gdbarch) : m_gdbarch (gdbarch) {} void visit (const tdesc_type_builtin *e) override { switch (e->kind) { case TDESC_TYPE_BOOL: m_type =3D builtin_type (m_gdbarch)->builtin_bool; break; .... }; } void visit (const tdesc_type_vector *e) override { // do what tdesc_type_vector::make_gdb_type does. } void visit (const tdesc_type_with_fields *e) override { // likewise. } =20=20 private: // input struct * const m_gdbarch; // output type *m_type; }; gdb_type_creator gdb_type (gdbarch); tdesc_type->accept (gdb_type); gdb_type.m_type is the type we need. --=20 Yao (=E9=BD=90=E5=B0=A7)