]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg DebugLib: Enable FILE NAME as DEBUG ASSERT for CLANG
authorZhiguang Liu <zhiguang.liu@intel.com>
Wed, 18 Mar 2020 01:39:30 +0000 (09:39 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Mon, 13 Apr 2020 07:17:27 +0000 (07:17 +0000)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1548
For clang compiler, This change will make the generated image not include the
absolute file path. If so, the generated debug image can be reproduced in the
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 full
path to that file, and __FILE_NAME__ is introduced since clang 9.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
MdePkg/Include/Library/DebugLib.h

index f1d55cf62b0e111bfbcace5a2aba8b48ffe90fed..baab34bf0528c380d879107be89aaaedd1a2773e 100644 (file)
@@ -8,7 +8,7 @@
   of size reduction when compiler optimization is disabled. If MDEPKG_NDEBUG is\r
   defined, then debug and assert related macros wrapped by it are the NULL implementations.\r
 \r
-Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR>\r
 SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -289,7 +289,11 @@ DebugPrintLevelEnabled (
   @param  Expression  Boolean expression that evaluated to FALSE\r
 \r
 **/\r
+#if defined(__clang__) && defined(__FILE_NAME__)\r
+#define _ASSERT(Expression)  DebugAssert (__FILE_NAME__, __LINE__, #Expression)\r
+#else\r
 #define _ASSERT(Expression)  DebugAssert (__FILE__, __LINE__, #Expression)\r
+#endif\r
 \r
 \r
 /**\r