From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 109337 invoked by alias); 28 Jun 2017 16:13:16 -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 109325 invoked by uid 89); 28 Jun 2017 16:13:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.4 required=5.0 tests=BAYES_00,GIT_PATCH_1,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_SORBS_SPAM,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= 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 ESMTP; Wed, 28 Jun 2017 16:13:14 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5EF71883B1; Wed, 28 Jun 2017 16:13:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5EF71883B1 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5EF71883B1 Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E9B160BE3; Wed, 28 Jun 2017 16:13:12 +0000 (UTC) Subject: Re: [PATCH 08/25] Add "maint check xml-descriptions" to test builtin xml target descriptions To: Yao Qi , gdb-patches@sourceware.org References: <1497256916-4958-1-git-send-email-yao.qi@linaro.org> <1497256916-4958-9-git-send-email-yao.qi@linaro.org> From: Pedro Alves Message-ID: Date: Wed, 28 Jun 2017 16:13:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <1497256916-4958-9-git-send-email-yao.qi@linaro.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-06/txt/msg00765.txt.bz2 On 06/12/2017 09:41 AM, Yao Qi wrote: > > +@kindex maint check xml-descriptions > +@item maint check xml-descriptions @var{dir} > +Check the target descriptions created by @value{GDBN} equal to these > +which are created from XML files in @var{dir}. I'd suggest: Check that the target descriptions created dynamically by @value{GDBN} equal the descriptions created from XML files found in @var{dir}. > } > + bool operator!= (const tdesc_feature &other) const > + { (Missing empty line just above the method.) Nit, it's a bit more conventional to define operator== instead, and then operator!= in terms of operator==, like you had in other cases. Can you do the same here? It'd just mean swapping true/false in the body of this function, I think. > + > + bool operator!= (const target_desc &other) const > + { Ditto. > > +namespace selftests { > + > +static std::vector> xml_tdesc; > + > +#if GDB_SELF_TEST > +void > +record_xml_tdesc (const char *xml_file, const struct target_desc *tdesc) > +{ > + xml_tdesc.emplace_back (xml_file, tdesc); > +} > +#endif > + Missing intro comments. > +} > + > +/* Test these GDB builtin target descriptions equal to these which > + are generated by the corresponding xml files. */ "these" here isn't specified (two times). Can you name what "these" are instead, avoiding indirection? Maybe: Check that the target descriptions created dynamically by architecture-specific code, as registered in XML_TDESC, equal the descriptions created from XML files found in the specified directory. > + > +static void > +maintenance_check_xml_descriptions (char *name, int from_tty) > +{ > + if (name == NULL) > + error (_("Missing dir name")); > + > + std::string feature_dir (name); > + unsigned int failed = 0; I'd suggest s/name/dir/ for a tiny bit more clarify. > + > + for (auto const &e : selftests::xml_tdesc) > + { > + std::string tdesc_xml = (feature_dir + SLASH_STRING + e.first); > + const target_desc *tdesc > + = file_read_description_xml (tdesc_xml.data ()); > + > + if (tdesc == NULL || *tdesc != *e.second) > + failed++; > + } > + printf_filtered (_("%lu XML are tested, %d failed\n"), > + (long) selftests::xml_tdesc.size (), failed); s/are/were/. Or better, I think: printf_filtered (_("Tested %lu XML files, %d failed\n"), (long) selftests::xml_tdesc.size (), failed); In the same spirit of "maint selftest"'s output. > + > + add_cmd ("xml-descriptions", class_maintenance, > + maintenance_check_xml_descriptions, _("\ > +Check the target descriptions.\n\ > +Takes a directory parameter."), Can you expand this a little bit? > + &maintenancechecklist); Also, I tried the command manually, and noticed that it doesn't support filename TAB completion. You can fix that with: set_cmd_completer (c, filename_completer); It'd be convenient too if it support tilde expansion: (gdb) maintenance check xml-descriptions ~/gdb/mygit/src/gdb/features warning: Could not open "~/gdb/mygit/src/gdb/features/i386/i386-linux.xml" warning: Could not open "~/gdb/mygit/src/gdb/features/i386/i386-mmx-linux.xml" warning: Could not open "~/gdb/mygit/src/gdb/features/i386/i386-avx-linux.xml" warning: Could not open "~/gdb/mygit/src/gdb/features/i386/i386-mpx-linux.xml" warning: Could not open "~/gdb/mygit/src/gdb/features/i386/i386-avx-mpx-linux.xml" warning: Could not open "~/gdb/mygit/src/gdb/features/i386/i386-avx-avx512-linux.xml" warning: Could not open "~/gdb/mygit/src/gdb/features/i386/i386-avx-mpx-avx512-pku-linux.xml" 7 XML are tested, 7 failed (gdb) maintenance check xml-descriptions /home/pedro/gdb/mygit/src/gdb/features 7 XML are tested, 0 failed You can fix that by simply calling tilde_expand. > > +#if GDB_SELF_TEST > +namespace selftests { > + > +/* Record the target description TDESC generated by XML_FILE. */ "record for what?" is a reasonable question that the comment doesn't help with. Maybe write something like this: Record that XML_FILE should generate a target description that equals TDESC, to be verified by the "maintenance check xml-descriptions" command. > + > +void record_xml_tdesc (const char *xml_file, > + const struct target_desc *tdesc); > +} > +#endif > + Thanks, Pedro Alves