summaryrefslogtreecommitdiffstats
path: root/src/usr
diff options
context:
space:
mode:
authorPatrick Williams <iawillia@us.ibm.com>2011-06-24 10:13:59 -0500
committerA. Patrick Williams III <iawillia@us.ibm.com>2011-07-06 13:32:14 -0500
commit9ada6b493e33fe43057b03897d57f2ad931d219f (patch)
treebbf89ebdb16bf9b1fe2b466979d610835e8e58fb /src/usr
parent6c77e26e9454c6753d989f33430c4e361f6ff003 (diff)
downloadtalos-hostboot-9ada6b493e33fe43057b03897d57f2ad931d219f.tar.gz
talos-hostboot-9ada6b493e33fe43057b03897d57f2ad931d219f.zip
Improve assert handling and options.
- Allow a custom assert trace as an optional parameter. - Call a trace function instead of printk for most cases. - Provide a critical library assert (for syslibs, trace, etc.) - Provide a kassert function for kernel code. Change-Id: If24d57d0832a587258503b3fd0046c21da3712b5 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/159 Tested-by: Jenkins Server Reviewed-by: Andrew J. Geissler <andrewg@us.ibm.com> Reviewed-by: CAMVAN T. NGUYEN <ctnguyen@us.ibm.com>
Diffstat (limited to 'src/usr')
-rw-r--r--src/usr/trace/assert.C42
-rw-r--r--src/usr/trace/makefile2
2 files changed, 43 insertions, 1 deletions
diff --git a/src/usr/trace/assert.C b/src/usr/trace/assert.C
new file mode 100644
index 000000000..49724c96e
--- /dev/null
+++ b/src/usr/trace/assert.C
@@ -0,0 +1,42 @@
+/** @file assert.C
+ * Hooks for dealing with trace in assert statements.
+ *
+ * This hook function is registered with the system-library assert functions
+ * when the trace library loads, so that if an application asserts after that
+ * point in time a message will get added to a common ASSERT trace buffer.
+ */
+#include <assert.h>
+#include <trace/interface.H>
+
+namespace TRACE
+{
+ /** Unique trace buffer for assert statements. */
+ trace_desc_t* g_assertTraceBuffer;
+ TRAC_INIT(&g_assertTraceBuffer, "ASSERT", 4096);
+
+ /** @fn assertTrace
+ * @brief Hook to perform a trace on an assert failure.
+ *
+ * @param[in] i_linkRegister - Address from which 'assert' was called.
+ * @param[in] i_lineNumber - Line number in the file which 'assert'ed.
+ */
+ void assertTrace(void* i_linkRegister, size_t i_lineNumber)
+ {
+ TRACFCOMP(g_assertTraceBuffer,
+ "Assertion failed @%p on line %d.",
+ i_linkRegister, i_lineNumber);
+ }
+
+ /** Location to assign the assertTrace hook for __assert function to use. */
+ extern void(*traceCallback)(void*, size_t);
+
+ /** @class __init_trace_callback
+ * @brief Class which registers the assertTrace function statically.
+ */
+ class __init_trace_callback
+ {
+ public:
+ __init_trace_callback() { traceCallback = &assertTrace; };
+ };
+ __init_trace_callback __init_trace_callback_instance;
+};
diff --git a/src/usr/trace/makefile b/src/usr/trace/makefile
index fa4b14324..38ecb9e20 100644
--- a/src/usr/trace/makefile
+++ b/src/usr/trace/makefile
@@ -1,7 +1,7 @@
ROOTPATH = ../../..
MODULE = trace
-OBJS = trace.o tracebuffer.o
+OBJS = trace.o tracebuffer.o assert.o
SUBDIRS = test.d
OpenPOWER on IntegriCloud