From 8a1168142bd3f273dbd4edf841c53a3ae394cd5e Mon Sep 17 00:00:00 2001 From: Mike Jones Date: Mon, 12 Mar 2012 10:12:01 -0500 Subject: ERRL: Ensure all Hostboot code uses ErrlUserDetails framework. RTC: 36920 Change-Id: I82667c8e63e8a99b9cc7eb1dfbbbdbe1c3b2bb2a Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/730 Tested-by: Jenkins Server Reviewed-by: A. Patrick Williams III --- src/usr/errl/plugins/errlParse.C | 190 ++++++--------------------------------- src/usr/errl/plugins/symbols.H | 2 + 2 files changed, 30 insertions(+), 162 deletions(-) (limited to 'src/usr/errl/plugins') diff --git a/src/usr/errl/plugins/errlParse.C b/src/usr/errl/plugins/errlParse.C index a70dc3ab3..bd859ad42 100644 --- a/src/usr/errl/plugins/errlParse.C +++ b/src/usr/errl/plugins/errlParse.C @@ -21,33 +21,23 @@ // // IBM_PROLOG_END - - - -#include -#include -#include -#include -#include +/** + * @file initsvcParse.C + * + * errl user data parser + */ #include -#include -#include -// Get these from a FipS/FSP backing build. +// FSP includes #include #include #include -// These are from Hostboot. +// Hostboot includes. #include #include -#include - -// Get these from current directory. #include "symbols.H" - - //------------------------------------------------------------- // endian switch a uint64 // TODO all plugins are probably going to want this. @@ -74,159 +64,37 @@ static uint64_t ntohll( uint64_t i ) #error Unexpected endian context. #endif +#include - - -//-------------------------------------------------------------------------- -// Use methods of i_parser such as -// i_parser.PrintString( "label", "datastring" ); -// to format my user-defined data attached to error logs for my component. -// Parameters i_sst (subsection type) and i_ver (version) identify -// the nature of the user-defined data as defined by my component. -// The file $bb/export/x86.nfp/fips/include/errlusrparser.H defines the -// ErrlUsrParser class. -// -// Return true if handled, suppressing the default hex dump of the data. - -static bool myDataParse ( - ErrlUsrParser& i_parser, - void* i_buffer, - uint32_t i_buflen, - errlver_t i_ver, - errlsubsec_t i_sst) +static bool myDataParse( + ErrlUsrParser& i_parser, + void* i_buffer, + uint32_t i_buflen, + errlver_t i_ver, + errlsubsec_t i_sst) { - bool rc = false; - char szWork[ 256 ]; - - - switch( i_sst ) { - case HBERRL_SST_FIRSTLADY: - { - memcpy( szWork, i_buffer, i_buflen ); - szWork[ i_buflen ] = 0; - i_parser.PrintString( "First Lady", szWork ); - rc = true; - } - break; - case HBERRL_SST_PRESIDENT: - { - memcpy( szWork, i_buffer, i_buflen ); - szWork[ i_buflen ] = 0; - i_parser.PrintString( "President", szWork ); - rc = true; - } - break; - case HBERRL_SST_STRING: - { - // How to label this string? - const char * l_pLabel; - switch( i_ver ) - { - case HBERRL_VER_STRINGTASK: - l_pLabel = "Task"; - break; - case HBERRL_VER_STRINGTASKNAME: - l_pLabel = "Task name"; - break; - case HBERRL_VER_STRINGATTRNAME: - l_pLabel = "Attribute name"; - break; - case HBERRL_VER_STRINGFILENAME: - l_pLabel = "File name"; - break; - case HBERRL_VER_STRINGPROCNAME: - l_pLabel = "Procedure name"; - break; - case HBERRL_VER_STRINGNAME: - default: - l_pLabel = "Name"; - break; - } - // Expect to have a null-ended string in the data, - // but add a null for good measure. - int cb = i_buflen + 1; - char * pWork = new char[cb]; - memcpy( pWork, i_buffer, i_buflen ); - pWork[i_buflen] = 0; - i_parser.PrintString( l_pLabel, pWork ); - delete pWork; - rc = true; - } - break; - - case HBERRL_SST_BACKTRACE: - { - // This buffer contains a number of 64-bit frame pointers. - // Awkward because FipS/FSP errl provides no PrintNumber() - // for a 64-bit number as of Jan 2012. - - // Initialize l_the symbol table. - const char * l_pSymFile = "hbicore.syms"; - hbSymbolTable symTab; - int readRC = symTab.readSymbols( l_pSymFile ); - if( readRC ) - { - i_parser.PrintString( "Symbols not found", l_pSymFile ); - // symTab.nearestSymbol() will return NULL because of this. - // Carry on. - } - - const char * l_pErrlEntry = "ErrlEntry::ErrlEntry"; - const char * l_pLabel = "Backtrace"; - - // loop thru the buffer which is an array of 64-bit addresses - uint64_t * p64 = static_cast(i_buffer); - int l_count = i_buflen / sizeof( uint64_t ); - for( int i = 0; i < l_count; i++ ) - { - // endian convert the stack address - uint64_t l_addr = ntohll(*p64); - - // get nearest symbol - const char * l_pSymbol = symTab.nearestSymbol( l_addr ); - - if( l_pSymbol ) - { - if( strstr( l_pSymbol, l_pErrlEntry )) - { - // hackish, makes for better looking output - // it's in every backtrace (jan2012) - l_pSymbol = l_pErrlEntry; - } - sprintf( szWork,"#%2d %016llX %s", i, l_addr, l_pSymbol ); - } - else - { - sprintf( szWork,"#%2d %016llX", i, l_addr ); - } - i_parser.PrintString( l_pLabel, szWork ); - - // next stack address in the buffer - p64++; - - // don't print the label for subsequent backtraces - l_pLabel = ""; - } - - rc = true; - } - break; - default: - break; + bool l_rc = false; + + // Create a ErrlUserDetailsParserFactoryErrl object + ERRORLOG::ErrlUserDetailsParserFactoryErrl l_factory; + + // Use the factory to create a ErrlUserDetailsParser object + ERRORLOG::ErrlUserDetailsParser * l_pParser = l_factory.createParser(i_sst); + + if (l_pParser) + { + l_rc = true; + l_pParser->parse(i_ver, i_parser, i_buffer, i_buflen); } - - - return rc; + + return l_rc; } // Map my Hostboot component ID to the function above. // static errl::DataPlugin g_DataPlugin( HBERRL_COMP_ID, hberrl_DataParse ); static errl::DataPlugin g_DataPlugin( HBERRL_COMP_ID, myDataParse ); - - - //---------------------------------------------------------------------------- // Call the code generated by scanforsrc.pl @@ -250,5 +118,3 @@ static bool hbSrcParse( ErrlUsrParser & i_parser, const SrciSrc & i_src ) // Create an instance of SrcPlugin by type (instead of the usual component). static errl::SrcPlugin g_SrcPlugin( errl::Plugin::HOSTBOOT_SRCPARSE, hbSrcParse ); - - diff --git a/src/usr/errl/plugins/symbols.H b/src/usr/errl/plugins/symbols.H index 4be1512b4..b7f1f0d0d 100644 --- a/src/usr/errl/plugins/symbols.H +++ b/src/usr/errl/plugins/symbols.H @@ -28,6 +28,8 @@ #ifndef ERRL_PLUGINS_SYMS_H #define ERRL_PLUGINS_SYMS_H +#include + /** * @file symbols.H * -- cgit v1.2.1