@@ -93,7 +93,11 @@ enum AssertBehavior
* user-space dispatching.
*/
NO_RETURN
-void __assert(AssertBehavior i_assertb, int i_line);
+void __assert(AssertBehavior i_assertb, int i_line, const char *msg);
+
+#define stringify(expr) stringify_1(expr)
+/* Double-indirection required to stringify expansions */
+#define stringify_1(expr) #expr
#ifdef __HOSTBOOT_MODULE // Only allow traced assert in module code.
@@ -132,7 +136,8 @@ 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__);\
+ __LINE__,
+ __FILE__ ":" stringify(__LINE__) ":" stringify(expr));\
}\
}
@@ -147,7 +152,7 @@ void __assert(AssertBehavior i_assertb, int i_line);
{\
if (unlikely(!(expr)))\
{\
- __assert(ASSERT_KERNEL, __LINE__);\
+ __assert(ASSERT_KERNEL, __LINE__, __FILE__ ":" stringify(__LINE__) ":" stringify(expr));\
}\
}
@@ -41,7 +41,7 @@
/** Hook location for trace module to set up when loaded. */
namespace TRACE { void (*traceCallback)(void*, size_t) = NULL; };
-extern "C" void __assert(AssertBehavior i_assertb, int i_line)
+extern "C" void __assert(AssertBehavior i_assertb, int i_line, const char *msg)
{
if ((i_assertb == ASSERT_CRITICAL) && (KernelMisc::in_kernel_mode()))
{
@@ -61,23 +61,23 @@ extern "C" void __assert(AssertBehavior i_assertb, int i_line)
}
else
{
- printk("Assertion failed @%p on line %d.\n",
- linkRegister(), i_line);
+ printk("Assertion failed @%p: %s\n",
+ linkRegister(), msg);
}
task_crash();
break;
case ASSERT_CRITICAL: // Critical task, trace not available.
- printk("Assertion failed @%p on line %d.(Crit_Assert)\n",
- linkRegister(), i_line);
+ printk("Assertion failed @%p (Crit_Assert): %s\n",
+ linkRegister(), msg);
// Need to call the external CritAssert system call
cpu_crit_assert(reinterpret_cast<uint64_t>(linkRegister()));
break;
case ASSERT_KERNEL: // Kernel assert called.
- printk("Assertion failed @%p on line %d. (kassert)\n",
- linkRegister(), i_line);
+ printk("Assertion failed @%p (kassert): %s\n",
+ linkRegister(), msg);
/*@
* @errortype
@@ -28,12 +28,13 @@
/** Hook location for trace module to set up when loaded. */
namespace TRACE { void (*traceCallback)(void*, size_t) = NULL; };
-extern "C" void __assert(AssertBehavior i_assertb, int i_line)
+extern "C" void __assert(AssertBehavior i_assertb, int i_line, const char *msg)
{
+ (void)i_line;
if (i_assertb != ASSERT_TRACE_DONE)
{
- printk("Assertion failed @%p on line %d.\n",
- linkRegister(), i_line);
+ printk("Assertion failed @%p: %s.\n",
+ linkRegister(), msg);
}
g_hostInterfaces->assert();
Daniel M Crowell <dcrowell@us.ibm.com> writes: > I thought things were working now so that is new news to me. weirdly, if I build a statically linked opal-prd, it does work... well, fails somewhere deeper in HBRT with: HBRT: Assertion failed @0x3fffa6f60e2c on line 96. Which isn't so clear... Here's a (completely untested) patch that would make the assert notice from HB/HBRT also include source file name and line number. Feel free to grab/try or I could probably clean it up a bit and submit upstream if that'd help.