From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.136; helo=mga12.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (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 A00232253FB70 for ; Fri, 9 Mar 2018 01:05:15 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Mar 2018 01:11:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,444,1515484800"; d="scan'208";a="23792166" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga008.jf.intel.com with ESMTP; 09 Mar 2018 01:11:31 -0800 Received: from fmsmsx126.amr.corp.intel.com (10.18.125.43) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 9 Mar 2018 01:11:31 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX126.amr.corp.intel.com (10.18.125.43) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 9 Mar 2018 01:11:30 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.235]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.166]) with mapi id 14.03.0319.002; Fri, 9 Mar 2018 17:11:29 +0800 From: "Zhu, Yonghong" To: "Feng, YunhuaX" , "edk2-devel@lists.01.org" CC: "Gao, Liming" , "Zhu, Yonghong" Thread-Topic: [PATCH] BaseTools: Fix parse OFFSET_OF get wrong offset Thread-Index: AdO3gwxVfWeJN58tSxqDXeFi1CuVRQAA28vw Date: Fri, 9 Mar 2018 09:11:28 +0000 Message-ID: References: <47C64442C08CCD4089DC43B6B5E46BC4834B1F@shsmsx102.ccr.corp.intel.com> In-Reply-To: <47C64442C08CCD4089DC43B6B5E46BC4834B1F@shsmsx102.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOGUwYjk3YjMtMGMzMC00ZDY4LTk2Y2QtZGJkYzUwOTRmMmFmIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6ImlRMVowcm5oZlY4cVVTUjBCZXp5bXpjaW5TYkdvNUEyMFNrc01KcmlTVzg9In0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] BaseTools: Fix parse OFFSET_OF get wrong offset X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Mar 2018 09:05:16 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Yonghong Zhu =20 Best Regards, Zhu Yonghong -----Original Message----- From: Feng, YunhuaX=20 Sent: Friday, March 9, 2018 4:46 PM To: edk2-devel@lists.01.org Cc: Zhu, Yonghong ; Gao, Liming Subject: [PATCH] BaseTools: Fix parse OFFSET_OF get wrong offset Fix parse OFFSET_OF get wrong offset Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/Common/Expression.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Sourc= e/Python/Common/Expression.py index 5a0ade9e7e..47fa190eb8 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -888,12 +888,13 @@ class ValueExpressionEx(ValueExpression): ReLabel =3D re.compile('LABEL\((\w+)\)') ReOffset =3D re.compile('OFFSET_OF\((\w+)\)') LabelOffset =3D 0 for Index, Item in enumerate(PcdValueList): # compute byte offset of every LABEL - Item =3D Item.strip() LabelList =3D ReLabel.findall(Item) + Item =3D ReLabel.sub('', Item) + Item =3D Item.strip() if LabelList: for Label in LabelList: if not IsValidCString(Label): raise BadExpression('%s is not a v= alid c variable name' % Label) if Label not in LabelDict.keys(): @@ -1001,12 +1002,14 @@ class ValueExpressionEx(ValueExpression): =20 if RealValue: return PcdValue =20 if __name__ =3D=3D '__main__': - pass - while True: + Value =3D "{UINT32(OFFSET_OF(Cert0)),UINT32(OFFSET_OF(Cert1)), UINT32(= OFFSET_OF(Cert2)), UINT32(OFFSET_OF(Cert3)), UINT32(OFFSET_OF(Cert4)), UINT= 32(OFFSET_OF(Cert5)), UINT32(OFFSET_OF(Cert6)), UINT32(OFFSET_OF(Cert7)), U= INT32(OFFSET_OF(Cert8)), LABEL(Cert0) UINT8(1),LABEL(Cert1) UINT16(2), LABE= L(Cert2) UINT32(4), LABEL(Cert3) UINT64(8), LABEL(Cert4) 'ABC', LABEL(Cert5= ) \"ABC\", LABEL(Cert6) L'ABC', LABEL(Cert7) L\"ABC\", LABEL(Cert8) 0}" + Ret =3D ValueExpressionEx(Value, "VOID*")(True) + print Ret + while False: input =3D raw_input('Input expr: ') if input in 'qQ': break try: print ValueExpression(input)(True) --=20 2.12.2.windows.2