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.6523.1584495590728316751 for ; Tue, 17 Mar 2020 18:39:50 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: zhiguang.liu@intel.com) IronPort-SDR: PXcRbopsM8/ROwiQoWanBSkklN2W4vabHqTtsxOHNX2YSm9VZOnDwM2d8bMELs7A2pwMmC6IOJ gW3rMtvmksFw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2020 18:39:47 -0700 IronPort-SDR: p6YV7M+4rzZtpGkmSvVthizP/EmyVaeHBNQUHzxHjDgUYHKDRIM/VlpzJOFjVvKaHebAlvUnwX s0CDzv6pCHrg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,565,1574150400"; d="scan'208";a="291168677" Received: from fieedk002.ccr.corp.intel.com ([10.239.158.178]) by FMSMGA003.fm.intel.com with ESMTP; 17 Mar 2020 18:39:40 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Michael D Kinney , Liming Gao Subject: [Patch V2] MdePkg DebugLib: Enable FILE NAME as DEBUG ASSERT for CLANG Date: Wed, 18 Mar 2020 09:39:30 +0800 Message-Id: <20200318013930.597-1-zhiguang.liu@intel.com> X-Mailer: git-send-email 2.25.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1548 For clang compiler, This change will make the generated image not include t= he absolute file path. If so, the generated debug image can be reproduced in t= he different root directory. Also, it will reduce the size of debug image size. To do so, use __FILE_NAME__ macro to replace __FILE__. __FILE_NAME__ is Clang-specific extension that functions similar to __FILE__ but only renders the last path component (the filename) instead of an invocation dependent f= ull path to that file, and __FILE_NAME__ is introduced since clang 9. CC: Michael D Kinney CC: Liming Gao Signed-off-by: Zhiguang Liu --- MdePkg/Include/Library/DebugLib.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MdePkg/Include/Library/DebugLib.h b/MdePkg/Include/Library/Deb= ugLib.h index f1d55cf62b..baab34bf05 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_NDEB= UG is=0D defined, then debug and assert related macros wrapped by it are the NULL= implementations.=0D =0D -Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
=0D +Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D **/=0D @@ -289,7 +289,11 @@ DebugPrintLevelEnabled ( @param Expression Boolean expression that evaluated to FALSE=0D =0D **/=0D +#if defined(__clang__) && defined(__FILE_NAME__)=0D +#define _ASSERT(Expression) DebugAssert (__FILE_NAME__, __LINE__, #Expres= sion)=0D +#else=0D #define _ASSERT(Expression) DebugAssert (__FILE__, __LINE__, #Expression)= =0D +#endif=0D =0D =0D /**=0D --=20 2.25.1.windows.1