public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2 1/1] MdePkg/Include: Use DEBUG_FILE_PATH to specify debug file path.
@ 2022-04-12 10:24 Guomin Jiang
  2022-04-13  1:02 ` 回复: " gaoliming
  0 siblings, 1 reply; 7+ messages in thread
From: Guomin Jiang @ 2022-04-12 10:24 UTC (permalink / raw)
  To: devel; +Cc: Michael D Kinney, Liming Gao, Zhiguang Liu

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 <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Signed-off-by: Guomin Jiang <guomin.jiang@intel.com>
---
 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.<BR>
+Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.<BR>
 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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-05-13  9:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-12 10:24 [PATCH v2 1/1] MdePkg/Include: Use DEBUG_FILE_PATH to specify debug file path Guomin Jiang
2022-04-13  1:02 ` 回复: " gaoliming
2022-04-13  5:42   ` [edk2-devel] " Guomin Jiang
2022-04-17  3:21     ` 回复: " gaoliming
2022-04-20  8:57       ` Guomin Jiang
2022-04-21  1:22         ` 回复: " gaoliming
2022-05-13  9:14           ` Guomin Jiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox