From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.132.183.28; helo=mx1.redhat.com; envelope-from=lersek@redhat.com; receiver=edk2-devel@lists.01.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 10E5F211C2814 for ; Tue, 5 Feb 2019 03:22:18 -0800 (PST) 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 1333718B24A; Tue, 5 Feb 2019 11:22:18 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-79.rdu2.redhat.com [10.10.120.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7042560F93; Tue, 5 Feb 2019 11:22:16 +0000 (UTC) From: Laszlo Ersek To: edk2-devel@lists.01.org Cc: Bob Feng , Liming Gao , Vladimir Olovyannikov , Yonghong Zhu Date: Tue, 5 Feb 2019 12:22:13 +0100 Message-Id: <20190205112213.682-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 05 Feb 2019 11:22:18 +0000 (UTC) Subject: [PATCH] BaseTools/BuildReport: fix report for platforms/arches without struct PCDs X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Feb 2019 11:22:19 -0000 Content-Transfer-Encoding: 8bit The goal of commit 97c8f5b9e7d3 ("BaseTools:StructurePCD value display incorrect in "Not used" section.", 2019-02-02) was to display the full contents of such structure PCDs in the build report that were set in the platform DSC or the FDF, but not used in any module INFs. The listings would appear in the PCDs not used by modules or in conditional directives section of the build report. Commit 97c8f5b9e7d3 assumed that any (platform, architecture) combination would have a (possibly empty) set of structure PCD (and so the set of the structure PCDs could be filtered for set-but-unused ones). This is not the case: in "DscBuildData.py", in method UpdateStructuredPcds(), if "S_pcd_set" remains an empty OrderedDict(), then it is not added to "GlobalData.gStructurePcd" *at all*, for the current (platform, architecture) combination. As a result, when the PCD report tries to fetch the set of structure PCDs for the current (platform, architecture), "GlobalData.gStructurePcd" does not return an empty OrderedDict(); instead, it raises a KeyError. Fix it by defaulting to an empty OrderedDict(), with the get() method. Reported-by: Vladimir Olovyannikov Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1513 Fixes: 97c8f5b9e7d3136b6051a05cf056ce5ca9e79893 Cc: Bob Feng Cc: Liming Gao Cc: Vladimir Olovyannikov Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek --- Notes: Repo: https://github.com/lersek/edk2.git Branch: report_without_struct_pcds BaseTools/Source/Python/build/BuildReport.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py index e457660fcef3..0b98d62cb6aa 100644 --- a/BaseTools/Source/Python/build/BuildReport.py +++ b/BaseTools/Source/Python/build/BuildReport.py @@ -780,7 +780,7 @@ class PcdReport(object): # Collect the PCD defined in DSC/FDF file, but not used in module # UnusedPcdFullList = [] - StructPcdDict = GlobalData.gStructurePcd[self.Arch] + StructPcdDict = GlobalData.gStructurePcd.get(self.Arch, collections.OrderedDict()) for Name, Guid in StructPcdDict: if (Name, Guid) not in Pa.Platform.Pcds: Pcd = StructPcdDict[(Name, Guid)] -- 2.19.1.3.g30247aa5d201