From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web10.6112.1645151475685665381 for ; Thu, 17 Feb 2022 18:31:18 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=N9PfXACE; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: guomin.jiang@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645151478; x=1676687478; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qW05rnqB7NglRdAlR34190PgFuQVCLMEsvLS9ujLxCY=; b=N9PfXACEatnJKrxAFRmG9wcDQYkW7eh3KUk7+B3yVdywXj5x0SWn4HZc IYRrjJxRXp0Poip9uBuBH3YszDhYQ+UYpbMl+M08ztv23LWQ9Oxd0jA7x 0Kc7BXc0I3+2bXDaqc6wNjlwU4woJRuvJZAnzH7aYjM7KHocGu7Kn2KtL OsK/xQZVFpzBZ/UbxV66qCiXeHBsw4BkwEQ9AK4bTxOsNJpfmZDoTF/6N txtupKf8QQEvBqbmzvydf5psFjv2tViKjpdtZddGQcUdMToDGuHQaVAfa U099nMpKCiaFjWF347PQFceKzfOa0l1wsGQydd56wlazBmM7Shw6MP/9w g==; X-IronPort-AV: E=McAfee;i="6200,9189,10261"; a="250789704" X-IronPort-AV: E=Sophos;i="5.88,377,1635231600"; d="scan'208";a="250789704" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:31:18 -0800 X-IronPort-AV: E=Sophos;i="5.88,377,1635231600"; d="scan'208";a="590004718" Received: from guominji-mobl1.ccr.corp.intel.com ([10.238.15.53]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:31:16 -0800 From: "Guomin Jiang" To: devel@edk2.groups.io Cc: Michael D Kinney , Liming Gao , Zhiguang Liu Subject: [PATCH 2/2] MdePkg/Include: Define new DEBUG_FILE to specify path. Date: Fri, 18 Feb 2022 10:30:08 +0800 Message-Id: <20220218023008.1347-3-guomin.jiang@intel.com> X-Mailer: git-send-email 2.35.1.windows.2 In-Reply-To: <20220218023008.1347-1-guomin.jiang@intel.com> References: <20220218023008.1347-1-guomin.jiang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3840 Use DEBUG_FILE to control ASSERT path Motivation and Goal: 1. The path will occupy many size in DEBUG build when file path is long 2. We hope can reduce the size but not impact the debug capability 3. If only use filename, we can search the filename to locate file. It can save many size meanwhile. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Signed-off-by: Guomin Jiang --- MdePkg/Include/Library/DebugLib.h | 39 ++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/MdePkg/Include/Library/DebugLib.h b/MdePkg/Include/Library/DebugLib.h index 8d3d08638d73..5469c6308422 100644 --- a/MdePkg/Include/Library/DebugLib.h +++ b/MdePkg/Include/Library/DebugLib.h @@ -8,7 +8,7 @@ of size reduction when compiler optimization is disabled. If MDEPKG_NDEBUG is defined, then debug and assert related macros wrapped by it are the NULL implementations. -Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -85,6 +85,31 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define DEBUG_LINE_NUMBER __LINE__ #endif +// +// Source file. +// Default is use the to compiler provided __FILE__ macro value. The __FILE__ +// mapping can be overriden by predefining DEBUG_FILE +// +// Defining DEBUG_FILE to a fixed value is useful when comparing builds +// across machine or configuration with different slash or path +// file. +// +// Another benefit is we can customize the ASSERT path without depending on +// compiler ability +// +// It's for all no matter VS, GCC, CLANG +// +#ifdef DEBUG_FILE +#else +#define DEBUG_FILE __FILE__ +#endif + +// Blow override for keep clang behavior +#if defined (__clang__) && defined (__FILE_NAME__) +#undef DEBUG_FILE +#define DEBUG_FILE __FILE_NAME__ +#endif + /** Macro that converts a Boolean expression to a Null-terminated ASCII string. @@ -337,17 +362,9 @@ UnitTestDebugAssert ( IN CONST CHAR8 *Description ); - #if defined (__clang__) && defined (__FILE_NAME__) -#define _ASSERT(Expression) UnitTestDebugAssert (__FILE_NAME__, DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression)) - #else -#define _ASSERT(Expression) UnitTestDebugAssert (__FILE__, DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression)) - #endif +#define _ASSERT(Expression) UnitTestDebugAssert (DEBUG_FILE, DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression)) #else - #if defined (__clang__) && defined (__FILE_NAME__) -#define _ASSERT(Expression) DebugAssert (__FILE_NAME__, DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression)) - #else -#define _ASSERT(Expression) DebugAssert (__FILE__, DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression)) - #endif +#define _ASSERT(Expression) DebugAssert (DEBUG_FILE, DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression)) #endif /** -- 2.35.1.windows.2