From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) by mx.groups.io with SMTP id smtpd.web11.598.1635792749491989374 for ; Mon, 01 Nov 2021 11:52:30 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20210112.gappssmtp.com header.s=20210112 header.b=u/+uIcg2; spf=pass (domain: nuviainc.com, ip: 209.85.221.50, mailfrom: leif@nuviainc.com) Received: by mail-wr1-f50.google.com with SMTP id v17so29447262wrv.9 for ; Mon, 01 Nov 2021 11:52:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=pm2doa6dYQ/GaQxOniOqv16CkRGy1BMCJIZnYfV+Pt8=; b=u/+uIcg2e/SPS8sPOSH9FWJgrjJUfIlX0KNAAuIQBwB2juWPd+qhGIxotJYPIpuJ9Q bStHffRqlaQTDMKRcS5Oh/gn1Mu2leXI3OG/b24NJ1gN7HsytIIiEq2C5N9QWPxStD5u 1E4bxgKmN0j80OfioVTt3aIz4KSZog4q184Id/iekpExaGX+rtzUWy7fhYf3PTMCmETO LOEoonnFh/mMV8gcrDBNbr8/fH9Mh4pU4sXhUmVVpzNBXOrs+5LyKcBKBQ4KJ2lM3D0o u+uyFVBKV/BI0ocZMsKIvaS3zdjZaO9Rfiop801QG8ouSjckITfR+PHUuo9xZAO7WJgc 3fCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=pm2doa6dYQ/GaQxOniOqv16CkRGy1BMCJIZnYfV+Pt8=; b=u2c4hqDTWcOPVN0RmmUr9nVgsMNDvZ+PqxLj+WNTx9kPkrs9fSdg+rall/jji/aBm9 OYilY36ipDfG2XeA999+4Qe9+E3rbJzw0JSi59RpNDa2rkvI9Gs+g0LwPH0J2+att1o3 QBRWuxteyX7BufQuwq97zGQDky098y1xMBuqqu0nWM9Q2D61Z1sANad6kc/t+Jk+GAdr q65gwjjeyoS2IqR74zwUHd2hFubDGeQ1OUxMCx2KSEokguV22QedYIOIq7NuPlWVtoDz N2TIQXATcWWtsiz/d7v2k7cjptTJ58hLa2JtH4gYJjRSkTLPZsb+TJZSgICyZyGOtfXT iHLQ== X-Gm-Message-State: AOAM530Vx7jm0vpTnIaknQTZvtyurHfZf838etZfvALBIghYbuDN3Vjg MWlWUFs1dHhbx4LEg7HVJk1hE54TZxXwbMBpLio3AOXCSjdsxuyh5LxHNN5hxDm3UCVO+X4T6Ex /OC0ZXJG8qtyaOrliJ60TMMwKse2rNuMflQDkhHGcGphj9AAwpQOphSJ6Oz1zolL3cjc7 X-Google-Smtp-Source: ABdhPJwZm391LrhPG//bRnZmWyq7zIT5wkCylRG7r/Sm9/iJXEFySTUGjrG2MfEJvSKG7g7My0PDQw== X-Received: by 2002:a5d:6781:: with SMTP id v1mr31219200wru.239.1635792747848; Mon, 01 Nov 2021 11:52:27 -0700 (PDT) Return-Path: Received: from leviathan (cpc92314-cmbg19-2-0-cust559.5-4.cable.virginm.net. [82.11.186.48]) by smtp.gmail.com with ESMTPSA id 9sm7827195wry.0.2021.11.01.11.52.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 11:52:27 -0700 (PDT) Date: Mon, 1 Nov 2021 18:52:25 +0000 From: "Leif Lindholm" To: devel@edk2.groups.io, michael.d.kinney@intel.com Cc: Liming Gao , Zhiguang Liu , Michael Kubacki Subject: Re: [edk2-devel] [Patch 1/6] MdePkg: Reproduce builds across source format changes Message-ID: <20211101185225.ibaccp5fnvrfqpvw@leviathan> References: <20211101182942.321-1-michael.d.kinney@intel.com> <20211101182942.321-2-michael.d.kinney@intel.com> MIME-Version: 1.0 In-Reply-To: <20211101182942.321-2-michael.d.kinney@intel.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Nov 01, 2021 at 11:29:37 -0700, Michael D Kinney wrote: > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3688 > > * 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. I think it would be useful to separate this > * Use DEBUG_LINE_NUMBER instead of __LINE__. > * Use DEBUG_EXPRESSION_STRING instead of #Expression. from this. I.e., I have no need to verify whether macro use changes in MdePkg are correct, but it is interesting to me to see the new macros being defined. / Leif > 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/DebugLib.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 > > +// > +// Source file line number. > +// Default is use the to compiler provided __LINE__ macro value. The __LINE__ > +// mapping can be overriden by predefining DEBUG_LINE_NUMBER > +// > +// Defining DEBUG_LINE_NUMBER to a fixed value is useful when comparing builds > +// across source code formatting changes that may add/remove lines in a source > +// file. > +// > +#ifndef DEBUG_LINE_NUMBER > +#define DEBUG_LINE_NUMBER __LINE__ > +#endif > + > +/** > + Macro that converts a Boolean expression to a Null-terminated ASCII string. > + > + The default is to use the C pre-processor stringizing operator '#' to add > + quotes around the C expression. If DEBUG_EXPRESSION_STRING_VALUE is defined > + 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. > > @@ -310,15 +344,15 @@ UnitTestDebugAssert ( > ); > > #if defined(__clang__) && defined(__FILE_NAME__) > -#define _ASSERT(Expression) UnitTestDebugAssert (__FILE_NAME__, __LINE__, #Expression) > +#define _ASSERT(Expression) UnitTestDebugAssert (__FILE_NAME__, DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING(Expression)) > #else > -#define _ASSERT(Expression) UnitTestDebugAssert (__FILE__, __LINE__, #Expression) > +#define _ASSERT(Expression) UnitTestDebugAssert (__FILE__, DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING(Expression)) > #endif > #else > #if defined(__clang__) && defined(__FILE_NAME__) > -#define _ASSERT(Expression) DebugAssert (__FILE_NAME__, __LINE__, #Expression) > +#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, DEBUG_EXPRESSION_STRING(Expression)) > #endif > #endif > > 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; \ > } > > @@ -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; \ > } > > @@ -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; \ > } > > @@ -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)(BufferB), (UINTN)Length, __FUNCTION__, __LINE__, __FILE__, #BufferA, #BufferB)) { \ > + if(!UnitTestAssertMemEqual ((VOID *)(UINTN)(BufferA), (VOID *)(UINTN)(BufferB), (UINTN)Length, __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #BufferA, #BufferB)) { \ > return UNIT_TEST_ERROR_TEST_FAILED; \ > } > > @@ -400,7 +400,7 @@ SaveFrameworkState ( > @param[in] ValueB Value to be compared for inequality (64-bit comparison). > **/ > #define UT_ASSERT_NOT_EQUAL(ValueA, ValueB) \ > - if(!UnitTestAssertNotEqual ((UINT64)(ValueA), (UINT64)(ValueB), __FUNCTION__, __LINE__, __FILE__, #ValueA, #ValueB)) { \ > + if(!UnitTestAssertNotEqual ((UINT64)(ValueA), (UINT64)(ValueB), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #ValueA, #ValueB)) { \ > return UNIT_TEST_ERROR_TEST_FAILED; \ > } > > @@ -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; \ > } > > @@ -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__, __LINE__, __FILE__, #Status)) { \ > + if(!UnitTestAssertStatusEqual ((Status), (Expected), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \ > return UNIT_TEST_ERROR_TEST_FAILED; \ > } > > @@ -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; \ > } > > @@ -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/SafeString.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) > -- > 2.32.0.windows.1 > > > > > >