From 8a4663c131e113ac85337a55ba72ce9e1688ec49 Mon Sep 17 00:00:00 2001 From: Andrew Jeffery Date: Mon, 17 Sep 2018 17:23:04 +0930 Subject: assert: Include file name in assert output Printing the line number without an associated file is almost meaningless; add the file name to improve debug ergonomics. Change-Id: I454876ccc567cb58066362caced7efbaf92cfe62 Signed-off-by: Andrew Jeffery Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/66117 Tested-by: Jenkins Server Tested-by: Jenkins OP Build CI Tested-by: Jenkins OP HW Tested-by: FSP CI Jenkins Reviewed-by: Corey V. Swenson Reviewed-by: Daniel M. Crowell --- src/include/assert.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/include/assert.h') diff --git a/src/include/assert.h b/src/include/assert.h index c3f7ea0c4..4c4e28678 100644 --- a/src/include/assert.h +++ b/src/include/assert.h @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2011,2015 */ +/* Contributors Listed Below - COPYRIGHT 2011,2018 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -78,6 +78,7 @@ enum AssertBehavior * * @param[in] i_assertb - Internal enumeration used by macros to communicate * desired behavior. + * @param[in] i_file - The file in which the assert exists * @param[in] i_line - Line number at which the assert macro was called. * * Current Behaviors: @@ -93,7 +94,7 @@ enum AssertBehavior * user-space dispatching. */ NO_RETURN -void __assert(AssertBehavior i_assertb, int i_line); +void __assert(AssertBehavior i_assertb, const char* i_file, int i_line); #ifdef __HOSTBOOT_MODULE // Only allow traced assert in module code. @@ -132,7 +133,7 @@ void __assert(AssertBehavior i_assertb, int i_line); __ASSERT_DO_TRACE(expr, __VA_ARGS__); \ __assert((__ASSERT_HAS_TRACE(__VA_ARGS__) ? \ ASSERT_TRACE_DONE : ASSERT_TRACE_NOTDONE),\ - __LINE__);\ + __FILE__, __LINE__);\ }\ } @@ -147,7 +148,7 @@ void __assert(AssertBehavior i_assertb, int i_line); {\ if (unlikely(!(expr)))\ {\ - __assert(ASSERT_KERNEL, __LINE__);\ + __assert(ASSERT_KERNEL, __FILE__, __LINE__);\ }\ } @@ -163,7 +164,7 @@ void __assert(AssertBehavior i_assertb, int i_line); {\ if (unlikely(!(expr)))\ {\ - __assert(ASSERT_CRITICAL, __LINE__);\ + __assert(ASSERT_CRITICAL, __FILE__, __LINE__);\ }\ } -- cgit v1.2.3