From nobody Sun Feb 8 19:39:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+83012+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+83012+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1635791946; cv=none; d=zohomail.com; s=zohoarc; b=JDQXvkiaeTIr7qn8ivI8yBntKRwgR9znA9ltArjTmtLbnX7OvNmiQ2Lz82/byzNQvsZqZeUdKDTM9/2/Br6/oOq6NL1ywttT5iGhZedJZbFHIvtpSLs6auNySZHZ9RqJMxSTQRspv2cXfrNQrs07N5xIJqGXEst10jmwts6zKXc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635791946; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=AFVN1aMjC99durUGHkp/0ncK2sMW/F7igL5g2fWDmx8=; b=Ch0Wl7bvzJcPLiN2ZGcTqHB7zLYIULfRDI+a8ZPUY/bQx5tdbEDMLmtf9mBvElFzBc1SARlb5vTDlINgLd5z0rI9TA2kk5GJJm6G8FY5mf6CwiAKAVX2e204xZOXCWajUyvRuuiTJCc1Cuf48IuKHrvDthGSXj91jp6c3UTq1m8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+83012+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1635791946969671.1885752985694; Mon, 1 Nov 2021 11:39:06 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id EzXaYY1788612xq2wilJwQ0Y; Mon, 01 Nov 2021 11:39:06 -0700 X-Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web11.378.1635791944897474298 for ; Mon, 01 Nov 2021 11:39:06 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10155"; a="217997879" X-IronPort-AV: E=Sophos;i="5.87,200,1631602800"; d="scan'208";a="217997879" X-Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2021 11:29:53 -0700 X-IronPort-AV: E=Sophos;i="5.87,200,1631602800"; d="scan'208";a="488751822" X-Received: from mdkinney-mobl2.amr.corp.intel.com ([10.209.76.205]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2021 11:29:53 -0700 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Liming Gao , Zhiguang Liu , Michael Kubacki Subject: [edk2-devel] [Patch 1/6] MdePkg: Reproduce builds across source format changes Date: Mon, 1 Nov 2021 11:29:37 -0700 Message-Id: <20211101182942.321-2-michael.d.kinney@intel.com> In-Reply-To: <20211101182942.321-1-michael.d.kinney@intel.com> References: <20211101182942.321-1-michael.d.kinney@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,michael.d.kinney@intel.com X-Gm-Message-State: 0DBE59xTGapl6f7qYoLn2XwJx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1635791946; bh=9008v2i7qvIgBfSOKJQZEZsHPZsehSnhcvKFc0S2ONE=; h=Cc:Date:From:Reply-To:Subject:To; b=cA6DPp5DThKxvwGD0JQQI4W98qej8J7UiZGhqXKkVfRhXxml34hfPHyErlDoHasLy20 7aY1/g+5L7ZD26VWyLFl4Jkoab6+QCKqEpYcq9ammoFAshpS+fX0P+LFuOLnLg0SZANCd PdyvNlAPK7V5QHBsetCUrVMEcS/eYHJMIag= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1635791948564100009 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3688 * Add DEBUG_LINE_NUMBER define to DebugLib.h that is by default mapped to __LINE__. A build can pre-define DEBUG_LINE_NUMBER to use a fixed value. * Add DEBUG_EXPRESSION_STRING(Expression) macrso to DebugLib.h that is by default mapped to #Expression. A build can define DEBUG_EXPRESSION_STRING_VALUE to set all expression strings to a fixed string value. * Use DEBUG_LINE_NUMBER instead of __LINE__. * Use DEBUG_EXPRESSION_STRING instead of #Expression. Cc: Liming Gao Cc: Zhiguang Liu Cc: Michael Kubacki Signed-off-by: Michael D Kinney --- MdePkg/Include/Library/DebugLib.h | 42 +++++++++++++++++++++++++--- MdePkg/Include/Library/UnitTestLib.h | 18 ++++++------ MdePkg/Library/BaseLib/SafeString.c | 2 +- 3 files changed, 48 insertions(+), 14 deletions(-) diff --git a/MdePkg/Include/Library/DebugLib.h b/MdePkg/Include/Library/Deb= ugLib.h index 4cacd4b8e243..287b922e9f74 100644 --- a/MdePkg/Include/Library/DebugLib.h +++ b/MdePkg/Include/Library/DebugLib.h @@ -71,6 +71,40 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define EFI_D_VERBOSE DEBUG_VERBOSE #define EFI_D_ERROR DEBUG_ERROR =20 +// +// Source file line number. +// Default is use the to compiler provided __LINE__ macro value. The __LIN= E__ +// mapping can be overriden by predefining DEBUG_LINE_NUMBER +// +// Defining DEBUG_LINE_NUMBER to a fixed value is useful when comparing bu= ilds +// across source code formatting changes that may add/remove lines in a so= urce +// file. +// +#ifndef DEBUG_LINE_NUMBER +#define DEBUG_LINE_NUMBER __LINE__ +#endif + +/** + Macro that converts a Boolean expression to a Null-terminated ASCII stri= ng. + + The default is to use the C pre-processor stringizing operator '#' to add + quotes around the C expression. If DEBUG_EXPRESSION_STRING_VALUE is defi= ned + then the C expression is converted to the fixed string value. + + Defining DEBUG_EXPRESSION_STRING_VALUE to a fixed value is useful when + comparing builds across source code formatting changes that may make + changes to spaces or parenthesis in a Boolean expression. + + @param Expression Boolean expression. + +**/ + +#ifndef DEBUG_EXPRESSION_STRING_VALUE +#define DEBUG_EXPRESSION_STRING(Expression) #Expression +#else +#define DEBUG_EXPRESSION_STRING(Expression) DEBUG_EXPRESSION_STRING_VALUE +#endif + /** Prints a debug message to the debug output device if the specified error= level is enabled. =20 @@ -310,15 +344,15 @@ UnitTestDebugAssert ( ); =20 #if defined(__clang__) && defined(__FILE_NAME__) -#define _ASSERT(Expression) UnitTestDebugAssert (__FILE_NAME__, __LINE__,= #Expression) +#define _ASSERT(Expression) UnitTestDebugAssert (__FILE_NAME__, DEBUG_LIN= E_NUMBER, DEBUG_EXPRESSION_STRING(Expression)) #else -#define _ASSERT(Expression) UnitTestDebugAssert (__FILE__, __LINE__, #Exp= ression) +#define _ASSERT(Expression) UnitTestDebugAssert (__FILE__, DEBUG_LINE_NUM= BER, DEBUG_EXPRESSION_STRING(Expression)) #endif #else #if defined(__clang__) && defined(__FILE_NAME__) -#define _ASSERT(Expression) DebugAssert (__FILE_NAME__, __LINE__, #Expres= sion) +#define _ASSERT(Expression) DebugAssert (__FILE_NAME__, DEBUG_LINE_NUMBER= , DEBUG_EXPRESSION_STRING(Expression)) #else -#define _ASSERT(Expression) DebugAssert (__FILE__, __LINE__, #Expression) +#define _ASSERT(Expression) DebugAssert (__FILE__, DEBUG_LINE_NUMBER, DEB= UG_EXPRESSION_STRING(Expression)) #endif #endif =20 diff --git a/MdePkg/Include/Library/UnitTestLib.h b/MdePkg/Include/Library/= UnitTestLib.h index 99175496c8cd..7cc6082387bb 100644 --- a/MdePkg/Include/Library/UnitTestLib.h +++ b/MdePkg/Include/Library/UnitTestLib.h @@ -348,7 +348,7 @@ SaveFrameworkState ( @param[in] Expression Expression to be evaluated for TRUE. **/ #define UT_ASSERT_TRUE(Expression) = \ - if(!UnitTestAssertTrue ((Expression), __FUNCTION__, __LINE__, __FILE__, = #Expression)) { \ + if(!UnitTestAssertTrue ((Expression), __FUNCTION__, DEBUG_LINE_NUMBER, _= _FILE__, #Expression)) { \ return UNIT_TEST_ERROR_TEST_FAILED; = \ } =20 @@ -360,7 +360,7 @@ SaveFrameworkState ( @param[in] Expression Expression to be evaluated for FALSE. **/ #define UT_ASSERT_FALSE(Expression) = \ - if(!UnitTestAssertFalse ((Expression), __FUNCTION__, __LINE__, __FILE__,= #Expression)) { \ + if(!UnitTestAssertFalse ((Expression), __FUNCTION__, DEBUG_LINE_NUMBER, = __FILE__, #Expression)) { \ return UNIT_TEST_ERROR_TEST_FAILED; = \ } =20 @@ -373,7 +373,7 @@ SaveFrameworkState ( @param[in] ValueB Value to be compared for equality (64-bit comparison= ). **/ #define UT_ASSERT_EQUAL(ValueA, ValueB) = \ - if(!UnitTestAssertEqual ((UINT64)(ValueA), (UINT64)(ValueB), __FUNCTION_= _, __LINE__, __FILE__, #ValueA, #ValueB)) { \ + if(!UnitTestAssertEqual ((UINT64)(ValueA), (UINT64)(ValueB), __FUNCTION_= _, DEBUG_LINE_NUMBER, __FILE__, #ValueA, #ValueB)) { \ return UNIT_TEST_ERROR_TEST_FAILED; = \ } =20 @@ -387,7 +387,7 @@ SaveFrameworkState ( @param[in] Length Number of bytes to compare in BufferA and BufferB. **/ #define UT_ASSERT_MEM_EQUAL(BufferA, BufferB, Length) = \ - if(!UnitTestAssertMemEqual ((VOID *)(UINTN)(BufferA), (VOID *)(UINTN)(Bu= fferB), (UINTN)Length, __FUNCTION__, __LINE__, __FILE__, #BufferA, #BufferB= )) { \ + if(!UnitTestAssertMemEqual ((VOID *)(UINTN)(BufferA), (VOID *)(UINTN)(Bu= fferB), (UINTN)Length, __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #BufferA,= #BufferB)) { \ return UNIT_TEST_ERROR_TEST_FAILED; = \ } =20 @@ -400,7 +400,7 @@ SaveFrameworkState ( @param[in] ValueB Value to be compared for inequality (64-bit comparis= on). **/ #define UT_ASSERT_NOT_EQUAL(ValueA, ValueB) = \ - if(!UnitTestAssertNotEqual ((UINT64)(ValueA), (UINT64)(ValueB), __FUNCTI= ON__, __LINE__, __FILE__, #ValueA, #ValueB)) { \ + if(!UnitTestAssertNotEqual ((UINT64)(ValueA), (UINT64)(ValueB), __FUNCTI= ON__, DEBUG_LINE_NUMBER, __FILE__, #ValueA, #ValueB)) { \ return UNIT_TEST_ERROR_TEST_FAILED; = \ } =20 @@ -412,7 +412,7 @@ SaveFrameworkState ( @param[in] Status EFI_STATUS value to check. **/ #define UT_ASSERT_NOT_EFI_ERROR(Status) = \ - if(!UnitTestAssertNotEfiError ((Status), __FUNCTION__, __LINE__, __FILE_= _, #Status)) { \ + if(!UnitTestAssertNotEfiError ((Status), __FUNCTION__, DEBUG_LINE_NUMBER= , __FILE__, #Status)) { \ return UNIT_TEST_ERROR_TEST_FAILED; = \ } =20 @@ -425,7 +425,7 @@ SaveFrameworkState ( @param[in] Expected EFI_STATUS values to compare for equality. **/ #define UT_ASSERT_STATUS_EQUAL(Status, Expected) = \ - if(!UnitTestAssertStatusEqual ((Status), (Expected), __FUNCTION__, __LIN= E__, __FILE__, #Status)) { \ + if(!UnitTestAssertStatusEqual ((Status), (Expected), __FUNCTION__, DEBUG= _LINE_NUMBER, __FILE__, #Status)) { \ return UNIT_TEST_ERROR_TEST_FAILED; = \ } =20 @@ -437,7 +437,7 @@ SaveFrameworkState ( @param[in] Pointer Pointer to be checked against NULL. **/ #define UT_ASSERT_NOT_NULL(Pointer) = \ - if(!UnitTestAssertNotNull ((Pointer), __FUNCTION__, __LINE__, __FILE__, = #Pointer)) { \ + if(!UnitTestAssertNotNull ((Pointer), __FUNCTION__, DEBUG_LINE_NUMBER, _= _FILE__, #Pointer)) { \ return UNIT_TEST_ERROR_TEST_FAILED; = \ } =20 @@ -482,7 +482,7 @@ SaveFrameworkState ( } \ if (!UnitTestExpectAssertFailure ( \ UnitTestJumpStatus, \ - __FUNCTION__, __LINE__, __FILE__, \ + __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, = \ #FunctionCall, Status)) { \ return UNIT_TEST_ERROR_TEST_FAILED; \ } \ diff --git a/MdePkg/Library/BaseLib/SafeString.c b/MdePkg/Library/BaseLib/S= afeString.c index 3bb23ca1a130..ce6db2b94eff 100644 --- a/MdePkg/Library/BaseLib/SafeString.c +++ b/MdePkg/Library/BaseLib/SafeString.c @@ -17,7 +17,7 @@ if (!(Expression)) { \ DEBUG ((DEBUG_VERBOSE, \ "%a(%d) %a: SAFE_STRING_CONSTRAINT_CHECK(%a) failed. Return %r\n"= , \ - __FILE__, __LINE__, __FUNCTION__, #Expression, Status)); \ + __FILE__, DEBUG_LINE_NUMBER, __FUNCTION__, DEBUG_EXPRESSION_STRING= (Expression), Status)); \ return Status; \ } \ } while (FALSE) --=20 2.32.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#83012): https://edk2.groups.io/g/devel/message/83012 Mute This Topic: https://groups.io/mt/86748727/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-