summaryrefslogtreecommitdiffstats
path: root/src/usr
diff options
context:
space:
mode:
authorTerry J. Opie <opiet@us.ibm.com>2011-10-18 14:06:28 -0500
committerTerry J. Opie <opiet@us.ibm.com>2011-12-01 09:55:33 -0600
commit1de45373ef02d33ae6a97c583db3b6d1db9bce1c (patch)
tree180c24555b3a4dbc32206da2f1312ecd503624ba /src/usr
parentac378e7e2f4debe9e53dc0a68dbf6aaa225a6660 (diff)
downloadblackbird-hostboot-1de45373ef02d33ae6a97c583db3b6d1db9bce1c.tar.gz
blackbird-hostboot-1de45373ef02d33ae6a97c583db3b6d1db9bce1c.zip
Error Log Backtrace Support
This code collects the addresses for each of the frames, but does not parse the data. The support to do this isn't available in the errl parser as of yet. Change-Id: I4804ab100fc376e26ef908c472c94202b4642aac Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/515 Tested-by: Jenkins Server Reviewed-by: Terry J. Opie <opiet@us.ibm.com>
Diffstat (limited to 'src/usr')
-rwxr-xr-xsrc/usr/errl/backtrace.C69
-rw-r--r--src/usr/errl/errlentry.C39
-rw-r--r--src/usr/errl/makefile2
3 files changed, 104 insertions, 6 deletions
diff --git a/src/usr/errl/backtrace.C b/src/usr/errl/backtrace.C
new file mode 100755
index 000000000..93c4c4fed
--- /dev/null
+++ b/src/usr/errl/backtrace.C
@@ -0,0 +1,69 @@
+// IBM_PROLOG_BEGIN_TAG
+// This is an automatically generated prolog.
+//
+// $Source: src/usr/errl/backtrace.C $
+//
+// IBM CONFIDENTIAL
+//
+// COPYRIGHT International Business Machines Corp. 2011
+//
+// p1
+//
+// Object Code Only (OCO) source materials
+// Licensed Internal Code Source Materials
+// IBM HostBoot Licensed Internal Code
+//
+// The source code for this program is not published or other-
+// wise divested of its trade secrets, irrespective of what has
+// been deposited with the U.S. Copyright Office.
+//
+// Origin: 30
+//
+// IBM_PROLOG_END
+/**
+ * @file backtrace.C
+ *
+ * @brief Provide backtrace support to the errorlog classes.
+ */
+
+/*****************************************************************************/
+// I n c l u d e s
+/*****************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <trace/interface.H>
+#include <errl/backtrace.H>
+#include <vector>
+
+#include <kernel/console.H>
+
+namespace ERRORLOG
+{
+
+// ------------------------------------------------------------------
+// collectBacktrace
+// ------------------------------------------------------------------
+void collectBacktrace ( std::vector<uint64_t> & o_addrVector )
+{
+ o_addrVector.clear();
+
+ uint64_t* frame = static_cast<uint64_t*>(framePointer());
+ bool first = true;
+ while (frame != NULL)
+ {
+ if ((0 != *frame) && (!first))
+ {
+ TRACDCOMP( g_trac_back,
+ "Addr: %016llx",
+ frame[2] );
+ o_addrVector.push_back( frame[2] );
+ }
+
+ frame = reinterpret_cast<uint64_t*>(*frame);
+ first = false;
+ }
+} // End collectBacktrace
+
+
+} // End ERRORLOG namespace
+
diff --git a/src/usr/errl/errlentry.C b/src/usr/errl/errlentry.C
index 553bdab8f..5c7c39a83 100644
--- a/src/usr/errl/errlentry.C
+++ b/src/usr/errl/errlentry.C
@@ -37,6 +37,7 @@
#include <errl/errlmanager.H>
#include <trace/interface.H>
#include <arch/ppc.H>
+#include <errl/backtrace.H>
namespace ERRORLOG
@@ -60,8 +61,36 @@ ErrlEntry::ErrlEntry(const errlSeverity_t i_sev,
iv_Src( SRC_ERR_INFO, i_modId, i_reasonCode, i_user1, i_user2 ),
iv_termState(TERM_STATE_UNKNOWN)
{
+ // Collect the Backtrace
+ std::vector<uint64_t> bt;
+ collectBacktrace( bt );
+ // Add Backtrace to user data section
+ ErrlUD * ffdcPtr = NULL;
+ for( uint32_t i = 0; i < bt.size(); i++ )
+ {
+ if( 0 == i )
+ {
+ ffdcPtr = addFFDC( ERRL_COMP_ID,
+ &bt[i],
+ sizeof(bt[i]),
+ 0, 0 );
+ // Make sure we got a pointer to the user details
+ if( NULL == ffdcPtr )
+ {
+ TRACFCOMP( g_trac_errl,
+ ERR_MRK"NULL FFDC pointer!" );
+ break;
+ }
+ }
+ else
+ {
+ appendToFFDC( ffdcPtr,
+ &bt[i],
+ sizeof(bt[i]) );
+ }
+ }
}
@@ -145,7 +174,7 @@ bool ErrlEntry::collectTrace(const char i_name[], const uint64_t i_max)
do
{
// By passing nil arguments 2 and 3, obtain the size of the buffer.
- // Besides getting buffer size, it validates i_name.
+ // Besides getting buffer size, it validates i_name.
uint64_t l_cbFull = TRACE::Trace::getTheInstance().getBuffer( i_name,
NULL,
0 );
@@ -168,11 +197,11 @@ bool ErrlEntry::collectTrace(const char i_name[], const uint64_t i_max)
l_cbBuffer = i_max;
}
- // allocate the buffer
- l_pBuffer = new char[ l_cbBuffer ];
+ // allocate the buffer
+ l_pBuffer = new char[ l_cbBuffer ];
// Get the data into the buffer.
- l_cbOutput =
+ l_cbOutput =
TRACE::Trace::getTheInstance().getBuffer( i_name,
l_pBuffer,
l_cbBuffer );
@@ -181,7 +210,7 @@ bool ErrlEntry::collectTrace(const char i_name[], const uint64_t i_max)
{
// Problem.
TRACFCOMP( g_trac_errl,
- "ErrlEntry::collectTrace(): getBuffer(%s,%ld) rets zero.",
+ "ErrlEntry::collectTrace(): getBuffer(%s,%ld) rets zero.",
i_name,
l_cbBuffer );
break;
diff --git a/src/usr/errl/makefile b/src/usr/errl/makefile
index 1a219ccb3..8020e07a9 100644
--- a/src/usr/errl/makefile
+++ b/src/usr/errl/makefile
@@ -24,7 +24,7 @@ ROOTPATH = ../../..
MODULE = errl
OBJS = errlentry.o errlmanager.o errlsctn.o errlsctnhdr.o errlprvt.o errluh.o \
- errlud.o errlsrc.o errluserdetails.o
+ errlud.o errlsrc.o errluserdetails.o backtrace.o
SUBDIRS = test.d parser.d
OpenPOWER on IntegriCloud