From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web09.9048.1649759099855780703 for ; Tue, 12 Apr 2022 03:25:00 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=CUYnHqBg; spf=pass (domain: intel.com, ip: 192.55.52.136, 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=1649759099; x=1681295099; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=+371dOumZUu5hQUKrr9atfubjBOwhvA3mOCWdiJZ3J4=; b=CUYnHqBgYDrji1UEAlWh4T/gDKvpvX1GgDDdlo5T9umY+gXvdwbvKyNE QG23bgUG3Pje8yAxNAGj64StQ8UrpLlHBBKrP7Ji0hWa+5I1JkaQHbPx5 rEAXvl+7uQnsTAqMC+sY8p0k0uAuBhulvga3Qm0diIPvtPRk8vxh0wow0 IwJ6LkvaekbeXvKHUCphIRVmWi0N8F40En0HFWxCD/M7gEl1/z2ZZuylO 0KQXoPrtPifjYXN2a2SH+KsnQk4mBpRp/IJkgbLSbhqJin/RKcZZVN729 u5L406FPfdD9/6K3Xe3k6JkYmM6uClHq8GqaQbmFv21vxcjXk4ccTiEPA g==; X-IronPort-AV: E=McAfee;i="6400,9594,10314"; a="242279758" X-IronPort-AV: E=Sophos;i="5.90,253,1643702400"; d="scan'208";a="242279758" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2022 03:24:58 -0700 X-IronPort-AV: E=Sophos;i="5.90,253,1643702400"; d="scan'208";a="572697122" Received: from guominji-mobl1.ccr.corp.intel.com ([10.254.210.66]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2022 03:24:56 -0700 From: "Guomin Jiang" To: devel@edk2.groups.io Cc: Michael D Kinney , Liming Gao , Zhiguang Liu Subject: [PATCH v2 1/1] MdePkg/Include: Use DEBUG_FILE_PATH to specify debug file path. Date: Tue, 12 Apr 2022 18:24:34 +0800 Message-Id: <20220412102434.923-1-guomin.jiang@intel.com> X-Mailer: git-send-email 2.35.1.windows.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3840 Use DEBUG_FILE_PATH to control ASSERT path Motivation and Goal: 1. Make replication build more easy and less toolchain dependency 2. Consume the ASSERT string easy for downstream 3. Make code more clear Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Signed-off-by: Guomin Jiang --- MdePkg/Include/Library/DebugLib.h | 34 +++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/MdePkg/Include/Library/DebugLib.h b/MdePkg/Include/Library/DebugLib.h index 8d3d08638d73..a76a268a00b6 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,26 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define DEBUG_LINE_NUMBER __LINE__ #endif +// +// Source file path. +// Default is use the __FILE__ macro value provided by compiler. The __FILE__ +// mapping can be overriden by predefining DEBUG_FILE_PATH +// +// Defining DEBUG_FILE_PATH to a fixed value is useful when comparing builds +// across machine or configuration with different slash or path file. +// +#ifndef DEBUG_FILE_PATH +#define DEBUG_FILE_PATH __FILE__ +#endif + +// +// Use below override to keep CLANG specific behavior +// +#if defined (__clang__) && defined (__FILE_NAME__) + #undef DEBUG_FILE_PATH +#define DEBUG_FILE_PATH __FILE_NAME__ +#endif + /** Macro that converts a Boolean expression to a Null-terminated ASCII string. @@ -337,17 +357,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_PATH, 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_PATH, DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression)) #endif /** -- 2.35.1.windows.2