diff options
author | Mike Jones <mjjones@us.ibm.com> | 2012-03-12 10:12:01 -0500 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2012-03-16 09:13:39 -0500 |
commit | 8a1168142bd3f273dbd4edf841c53a3ae394cd5e (patch) | |
tree | 94029d881fa5b89d186073859c7de2fd6dcdfcb8 | |
parent | ff8472f5e338d17194b5a1300b9553dd1ac3a241 (diff) | |
download | blackbird-hostboot-8a1168142bd3f273dbd4edf841c53a3ae394cd5e.tar.gz blackbird-hostboot-8a1168142bd3f273dbd4edf841c53a3ae394cd5e.zip |
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 <iawillia@us.ibm.com>
37 files changed, 1381 insertions, 1049 deletions
diff --git a/src/include/usr/errl/errlUserDetailsTarget.H b/src/include/usr/errl/errlUserDetailsTarget.H deleted file mode 100644 index 2fcce1545..000000000 --- a/src/include/usr/errl/errlUserDetailsTarget.H +++ /dev/null @@ -1,171 +0,0 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: src/include/usr/errl/errlUserDetailsTarget.H $ -// -// IBM CONFIDENTIAL -// -// COPYRIGHT International Business Machines Corp. 2012 -// -// 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 -#ifndef ERRL_USERDETAILS_TARGET_H -#define ERRL_USERDETAILS_TARGET_H - -/** - * @file ErrlTarget.H - * - * Target FFDC Helper - * - * Framework defining how User Detail Data sections of error logs should - * be created and parsed. - * - * Creation methods will show up when the PARSER macro is NOT defined. - * These will compile and run under HostBoot. - * - * Parsing methods will show up when the PARSER macro IS defined. - * These will compile and run in the errl tool. - * -*/ - -/*****************************************************************************/ -// I n c l u d e s -/*****************************************************************************/ -#include <stdint.h> -#include <errl/errluserdetails.H> -#include <targeting/targetservice.H> - -namespace ERRORLOG -{ - -#ifndef PARSER - -class ErrlUserDetailsTarget : public ErrlUserDetails -{ -public: - - /** - * @brief Constructor - * - */ - ErrlUserDetailsTarget(const TARGETING::Target * i_target); - - /** - * @brief Destructor - * - */ - virtual ~ErrlUserDetailsTarget(); - - /** - * @brief Adds or appends FFDC data to error log - * - * @param i_errl - * Error log handle to add detail data to. - * - * @param i_buf - * pointer to the new data buffer to be added/appended. - * - * @param i_len - * length of the new data buffer to be added/appended in bytes - * - * @return none - * - */ - void addToLog( errlHndl_t i_errl, void *i_buf, const uint32_t i_len ); - -private: - - // Disabled - ErrlUserDetailsTarget(const ErrlUserDetailsTarget &); - ErrlUserDetailsTarget & operator=(const ErrlUserDetailsTarget &); - - const TARGETING::Target *iv_pTarget; -}; - -#else // (if PARSER defined) - -/** - * @brief Target FFDC Helper - * - * Framework defining how User Detail Data sections of error logs should - * be created and parsed. - * - * Creation methods will show up when the PARSER macro is NOT defined. - * These will compile and run under HostBoot. - * - * Parsing methods will show up when the PARSER macro IS defined. - * These will compile and run in the errl tool. - * -*/ - -class ErrlUserDetailsTarget : public ErrlUserDetails -{ -public: - - /** - * @brief Constructor - * - */ - ErrlUserDetailsTarget() : ErrlUserDetails() {} - - /** - * @brief Destructor - * - */ - virtual ~ErrlUserDetailsTarget() {} - - /** - * @brief Parses user detail data from an error log - * - * @param i_version - * Version of the data - * - * @param i_parse - * ErrlUsrParser object for outputting information - * - * @param i_pBuffer - * Pointer to buffer containing detail data - * - * @param i_buflen - * Length of the buffer - * - * @return None - * - */ - virtual void parse(errlver_t i_version, - ErrlUsrParser & i_parser, - const void * i_pBuffer, const uint32_t i_buflen) const - { - char * l_ptr = i_pBuffer; - for (uint32_t i = 0; i < i_buflen; ) - { - i_parser.PrintString( "", l_ptr ); - i += strlen(l_ptr) + 1; - l_ptr += strlen(l_ptr) + 1; - } - } - -private: - - // Disabled - ErrlUserDetailsTarget(const ErrlUserDetailsTarget &); - ErrlUserDetailsTarget & operator=(const ErrlUserDetailsTarget &); - -}; - -#endif - -} - -#endif diff --git a/src/include/usr/errl/errlreasoncodes.H b/src/include/usr/errl/errlreasoncodes.H index 00b156f7e..89d31e1d4 100644 --- a/src/include/usr/errl/errlreasoncodes.H +++ b/src/include/usr/errl/errlreasoncodes.H @@ -36,7 +36,7 @@ enum { HBERRL_FIRST_MODULE_ID = 0x00, - HBERRL_USERDETAILS_MODULE_ID = 1, + HBERRL_USERDATA_TEST_MOD_ID = 1, HBERRL_TEST_MOD_ID = 2, //........ HBERRL_LAST_MODULE_ID = 0xFF @@ -46,10 +46,8 @@ enum enum errlReasonCode { HBERRL_FIRST_ERR = HBERRL_COMP_ID | 0x01, - HBERRL_FILENAME_TEST = HBERRL_COMP_ID | 0x02, - HBERRL_ERRORMSG_TEST = HBERRL_COMP_ID | 0x03, - HBERRL_XMLTOKEN_TEST = HBERRL_COMP_ID | 0x04, - HBERRL_TEST_REASON_CODE = HBERRL_COMP_ID | 0x0F, + HBERRL_TEST_STRING_UD = HBERRL_COMP_ID | 0x02, + HBERRL_TEST_REASON_CODE = HBERRL_COMP_ID | 0x03, //........ HBERRL_LAST_ERR = HBERRL_COMP_ID | 0xFF }; diff --git a/src/include/usr/errl/errludbacktrace.H b/src/include/usr/errl/errludbacktrace.H new file mode 100644 index 000000000..193064e36 --- /dev/null +++ b/src/include/usr/errl/errludbacktrace.H @@ -0,0 +1,184 @@ +// IBM_PROLOG_BEGIN_TAG +// This is an automatically generated prolog. +// +// $Source: src/include/usr/errl/errludbacktrace.H $ +// +// IBM CONFIDENTIAL +// +// COPYRIGHT International Business Machines Corp. 2012 +// +// 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 +#ifndef ERRL_UDBACKTRACE_H +#define ERRL_UDBACKTRACE_H + +/** + * @file errludbacktrace.H + * + * Defines the following classes: + * + * ErrlUserDetailsBackTrace: Adds backtrace FFDC to an error log as user detail + * data + * ErrlUserDetailsParserBackTrace: Parses backtrace FFDC user detail in an + * error log + */ + +#include <errl/errluserdetails.H> + +namespace ERRORLOG +{ + +#ifndef PARSER + +/** + * @class ErrlUserDetailsBackTrace + * + * Adds backtrace FFDC to an error log as user detail data +*/ +class ErrlUserDetailsBackTrace : public ErrlUserDetails +{ +public: + /** + * @brief Constructor + * + * Captures the backtrace internally + */ + ErrlUserDetailsBackTrace(); + + /** + * @brief Destructor + */ + virtual ~ErrlUserDetailsBackTrace(); + +private: + // Disabled + ErrlUserDetailsBackTrace(const ErrlUserDetailsBackTrace &); + ErrlUserDetailsBackTrace & operator=(const ErrlUserDetailsBackTrace &); +}; + +#else // (if PARSER defined) + +/** + * @class ErrlUserDetailsParserBackTrace + * + * Parses backtrace user detail in an error log +*/ +class ErrlUserDetailsParserBackTrace : public ErrlUserDetailsParser +{ +public: + /** + * @brief Constructor + */ + ErrlUserDetailsParserBackTrace() {} + + /** + * @brief Destructor + */ + virtual ~ErrlUserDetailsParserBackTrace() {} + + /** + * @brief Parses backtrace user detail data from an error log + * + * @param i_version Version of the data + * @param i_parse ErrlUsrParser object for outputting information + * @param i_pBuffer Pointer to buffer containing detail data + * @param i_buflen Length of the buffer + */ + virtual void parse(errlver_t i_version, + ErrlUsrParser & i_parser, + void * i_pBuffer, + const uint32_t i_buflen) const + { + // This buffer contains a number of 64-bit frame pointers. + + // A character vector for storing a backtrace entry and the space + // required for the header (frame number and address (with some padding + // for safety)) and the symbol name. This vector is resized if a longer + // symbol name is encountered. + const uint8_t BACKTRACE_ENTRY_HEADER_SIZE = 32; + const uint8_t BACKTRACE_ENTRY_SYMBOL_SIZE = 64; + std::vector<char> l_traceEntry(BACKTRACE_ENTRY_HEADER_SIZE + + BACKTRACE_ENTRY_SYMBOL_SIZE); + + // 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<uint64_t *>(i_pBuffer); + 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; + } + + uint16_t l_traceSize = + (BACKTRACE_ENTRY_HEADER_SIZE + strlen(l_pSymbol) + 1); + + if (l_traceEntry.size() < l_traceSize) + { + l_traceEntry.resize(l_traceSize); + } + sprintf(&(l_traceEntry[0]), + "#%2d %016llX %s", i, l_addr, l_pSymbol); + } + else + { + sprintf(&(l_traceEntry[0]),"#%2d %016llX", i, l_addr); + } + i_parser.PrintString( l_pLabel, &(l_traceEntry[0]) ); + + // next stack address in the buffer + p64++; + + // don't print the label for subsequent backtraces + l_pLabel = ""; + } + } + +private: + // Disabled + ErrlUserDetailsParserBackTrace(const ErrlUserDetailsParserBackTrace &); + ErrlUserDetailsParserBackTrace & operator=( + const ErrlUserDetailsParserBackTrace &); +}; + +#endif + +} + +#endif + diff --git a/src/include/usr/errl/errludparserfactory.H b/src/include/usr/errl/errludparserfactory.H new file mode 100755 index 000000000..ea39297cc --- /dev/null +++ b/src/include/usr/errl/errludparserfactory.H @@ -0,0 +1,134 @@ +// IBM_PROLOG_BEGIN_TAG +// This is an automatically generated prolog. +// +// $Source: src/include/usr/errl/errludparserfactory.H $ +// +// IBM CONFIDENTIAL +// +// COPYRIGHT International Business Machines Corp. 2012 +// +// 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 +#ifndef ERRL_UDPARSERFACTORY_H +#define ERRL_UDPARSERFACTORY_H + +#ifdef PARSER + +/** + * @file errludparserfactory.H + * + * Defines the ErrlUserDetailsParserFactory base class + */ +#include <map> + +namespace ERRORLOG +{ + +/** + * @class ErrlUserDetailsParserFactory + * + * This is a factory that produces ErrlUserDetailsParser objects. If a component + * creates user detail data then it should derive a class from this and register + * all of its ErrlUserDetailsParser classes with it. The parse file in the + * plugins directory can then call the factory to create parser objects to parse + * any user detail data. + * + * This class is only compiled when PARSER is defined + */ +class ErrlUserDetailsParserFactory +{ +public: + /** + * @brief Constructor + */ + ErrlUserDetailsParserFactory() + { + } + + /** + * @brief Destructor + */ + ~ErrlUserDetailsParserFactory() + { + } + + /** + * @brief Register a class derived from ErrlUserDetailsParser with the + * factory that can parse user detail data with the specified + * subsection. + * + * @param i_subSection The user detail data subsection that is parsed by + * class T + */ + template<typename T> + void registerParser(const errlsubsec_t i_subSection) + { + iv_createObjectMap[i_subSection] = &(createParserObject<T>); + } + + /** + * @brief Create an object of type ErrlUserDetailsParser that can parse + * user detail data with the specified subsection. The returned + * pointer will be polymorphic and will actually point to a type + * derived from ErrlUserDetailsParser. + * + * @param i_subSection The user detail data subsection to parse + * + * @return ErrlUserDetailsParser * + * Pointer to a ErrlUserDetailsParser object. Null if there is no + * parser registered for the specified subsection. The user must delete + * the object after use. + */ + ErrlUserDetailsParser * createParser(const errlsubsec_t i_subSection) + { + std::map<errlsubsec_t, createParserObject_t>::const_iterator itr = + iv_createObjectMap.find(i_subSection); + + if (itr != iv_createObjectMap.end()) + { + // Call the object creator function (createParserObject) + return((itr->second)()); + } + return NULL; + } + +private: + /** + * @brief Creates a ErrlUserDetailsParser of the specified derived type + * + * @return ErrlUserDetailsParser * Pointer to newly created object + */ + template<typename T> + static ErrlUserDetailsParser * createParserObject() + { + return new T(); + } + + // Function pointer type of createParserObject + typedef ErrlUserDetailsParser *(*createParserObject_t)(); + + // Map of subsections and their createobject function + std::map<errlsubsec_t, createParserObject_t> iv_createObjectMap; + + // Disabled + ErrlUserDetailsParserFactory(const ErrlUserDetailsParserFactory &); + ErrlUserDetailsParserFactory & operator=( + const ErrlUserDetailsParserFactory &); +}; + +} + +#endif +#endif + diff --git a/src/include/usr/errl/errludparserfactoryerrl.H b/src/include/usr/errl/errludparserfactoryerrl.H new file mode 100644 index 000000000..510265e89 --- /dev/null +++ b/src/include/usr/errl/errludparserfactoryerrl.H @@ -0,0 +1,73 @@ +// IBM_PROLOG_BEGIN_TAG +// This is an automatically generated prolog. +// +// $Source: src/include/usr/errl/errludparserfactoryerrl.H $ +// +// IBM CONFIDENTIAL +// +// COPYRIGHT International Business Machines Corp. 2012 +// +// 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 +#ifndef ERRL_UDPARSERFACTORYERRL_H +#define ERRL_UDPARSERFACTORYERRL_H + +#ifdef PARSER + +/** + * @file errludparserfactoryerrl.H + * + * Defines the errlUserDetailsParserFactoryErrl.H class +*/ +#include <errl/errludstring.H> +#include <errl/errludtarget.H> +#include <errl/errludbacktrace.H> +#include <errl/errludparserfactory.H> + +namespace ERRORLOG +{ + +/** + * @class ErrlUserDetailsParserFactoryErrl + * + * This factory produces ErrlUserDetailsParser objects to parse the specified + * ERRL user detail data. +*/ +class ErrlUserDetailsParserFactoryErrl : public ErrlUserDetailsParserFactory +{ +public: + + /** + * @brief Constructor + */ + ErrlUserDetailsParserFactoryErrl() + { + registerParser<ErrlUserDetailsParserString>(HBERRL_UDT_STRING); + registerParser<ErrlUserDetailsParserTarget>(HBERRL_UDT_TARGET); + registerParser<ErrlUserDetailsParserBackTrace>(HBERRL_UDT_BACKTRACE); + } + +private: + + // Disabled + ErrlUserDetailsParserFactoryErrl(const ErrlUserDetailsParserFactoryErrl &); + ErrlUserDetailsParserFactoryErrl & operator=( + const ErrlUserDetailsParserFactoryErrl &); +}; + +} + +#endif +#endif + diff --git a/src/include/usr/errl/errludstring.H b/src/include/usr/errl/errludstring.H new file mode 100644 index 000000000..fb72c5498 --- /dev/null +++ b/src/include/usr/errl/errludstring.H @@ -0,0 +1,118 @@ +// IBM_PROLOG_BEGIN_TAG +// This is an automatically generated prolog. +// +// $Source: src/include/usr/errl/errludstring.H $ +// +// IBM CONFIDENTIAL +// +// COPYRIGHT International Business Machines Corp. 2012 +// +// 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 +#ifndef ERRL_UDSTRING_H +#define ERRL_UDSTRING_H + +/** + * @file errludstring.H + * + * Defines the following classes: + * + * ErrlUserDetailsString: Adds string FFDC to an error log as user detail data + * ErrlUserDetailsParserString: Parses string FFDC user detail in an error log +*/ + +#include <errl/errluserdetails.H> + +namespace ERRORLOG +{ + +#ifndef PARSER + +/** + * @class ErrlUserDetailsString + * + * Adds String FFDC to an error log as user detail data + */ +class ErrlUserDetailsString : public ErrlUserDetails +{ +public: + /** + * @brief Constructor + * + * Captures the supplied string internally + * + * @param i_pString Pointer to string to capture as user detail data + */ + ErrlUserDetailsString(const char * i_pString); + + /** + * @brief Destructor + */ + virtual ~ErrlUserDetailsString(); + +private: + // Disabled + ErrlUserDetailsString(const ErrlUserDetailsString &); + ErrlUserDetailsString & operator=(const ErrlUserDetailsString &); +}; + +#else // (if PARSER defined) + +/** + * @class ErrlUserDetailsString + * + * Parses String user detail in an error log +*/ +class ErrlUserDetailsParserString : public ErrlUserDetailsParser +{ +public: + /** + * @brief Constructor + */ + ErrlUserDetailsParserString() {} + + /** + * @brief Destructor + */ + virtual ~ErrlUserDetailsParserString() {} + + /** + * @brief Parses string user detail data from an error log + * + * @param i_version Version of the data + * @param i_parse ErrlUsrParser object for outputting information + * @param i_pBuffer Pointer to buffer containing detail data + * @param i_buflen Length of the buffer + */ + virtual void parse(errlver_t i_version, + ErrlUsrParser & i_parser, + void * i_pBuffer, + const uint32_t i_buflen) const + { + i_parser.PrintString("String data", static_cast<char *>(i_pBuffer)); + } + +private: + // Disabled + ErrlUserDetailsParserString(const ErrlUserDetailsParserString &); + ErrlUserDetailsParserString & operator=( + const ErrlUserDetailsParserString &); +}; + +#endif + +} + +#endif + diff --git a/src/include/usr/errl/errludtarget.H b/src/include/usr/errl/errludtarget.H new file mode 100644 index 000000000..3ec24fc60 --- /dev/null +++ b/src/include/usr/errl/errludtarget.H @@ -0,0 +1,141 @@ +// IBM_PROLOG_BEGIN_TAG +// This is an automatically generated prolog. +// +// $Source: src/include/usr/errl/errludtarget.H $ +// +// IBM CONFIDENTIAL +// +// COPYRIGHT International Business Machines Corp. 2012 +// +// 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 +#ifndef ERRL_UDTARGET_H +#define ERRL_UDTARGET_H + +/** + * @file errludTarget.H + * + * Defines the following classes: + * + * ErrlUserDetailsTarget: Adds Target FFDC to an error log as user detail data + * ErrlUserDetailsParserTarget: Parses Target FFDC user detail in an error log +*/ + +#include <errl/errluserdetails.H> + +// Forward reference +namespace TARGETING +{ + class Target; +} + +namespace ERRORLOG +{ + +#ifndef PARSER + +/** + * @class ErrlUserDetailsTarget + * + * Adds Target FFDC to an error log as user detail data +*/ +class ErrlUserDetailsTarget : public ErrlUserDetails +{ +public: + /** + * @brief Constructor + * + * Captures the supplied Target's FFDC data internally + * + * @param i_pTarget Pointer to Target to capture as user detail data + */ + ErrlUserDetailsTarget(const TARGETING::Target * i_pTarget); + + /** + * @brief Destructor + */ + virtual ~ErrlUserDetailsTarget(); + + /** + * @brief Adds the Target as user detail data to an error log + * + * @param i_errl Error log to add detail data to. + */ + virtual void addToLog(errlHndl_t i_errl); + +private: + // Target pointer + const TARGETING::Target * iv_pTarget; + + // Disabled + ErrlUserDetailsTarget(const ErrlUserDetailsTarget &); + ErrlUserDetailsTarget & operator=(const ErrlUserDetailsTarget &); +}; + +#else // (if PARSER defined) + +/** + * @class ErrlUserDetailsParserTarget + * + * Parses Target FFDC user detail in an error log +*/ +class ErrlUserDetailsParserTarget : public ErrlUserDetailsParser +{ +public: + /** + * @brief Constructor + */ + ErrlUserDetailsParserTarget() {} + + /** + * @brief Destructor + */ + virtual ~ErrlUserDetailsParserTarget() {} + + /** + * @brief Parses Target user detail data from an error log + * + * @param i_version Version of the data + * @param i_parse ErrlUsrParser object for outputting information + * @param i_pBuffer Pointer to buffer containing detail data + * @param i_buflen Length of the buffer + */ + virtual void parse(errlver_t i_version, + ErrlUsrParser & i_parser, + void * i_pBuffer, + const uint32_t i_buflen) const + { + i_parser.PrintString("Target data", NULL); + char * l_ptr = static_cast<char *>(i_pBuffer); + for (uint32_t i = 0; i < i_buflen; ) + { + i_parser.PrintString(NULL, l_ptr); + i += strlen(l_ptr) + 1; + l_ptr += strlen(l_ptr) + 1; + } + } + +private: + // Disabled + ErrlUserDetailsParserTarget(const ErrlUserDetailsParserTarget &); + ErrlUserDetailsParserTarget & operator=( + const ErrlUserDetailsParserTarget &); +}; + +#endif + +} + +#endif + diff --git a/src/include/usr/errl/errluserdetails.H b/src/include/usr/errl/errluserdetails.H index 7dd052650..75a00c115 100755 --- a/src/include/usr/errl/errluserdetails.H +++ b/src/include/usr/errl/errluserdetails.H @@ -26,51 +26,29 @@ /** * @file errluserdetails.H * - * Error Log User Detail Data Helper + * Defines the ErrlUserDetails and ErrlUserDetailsParser base classes * - * Framework defining how User Detail Data sections of error logs should - * be created and parsed. - * - * Creation methods will show up when the PARSER macro is NOT defined. - * These will compile and run under HostBoot. - * - * Parsing methods will show up when the PARSER macro IS defined. - * These will compile and run in the errl tool. - * -*/ - -// -// @page ErrlUserDetails Error Log User Details -// -// - - -/*****************************************************************************/ -// I n c l u d e s -/*****************************************************************************/ - - -// safe to include these, PARSER or no PARSER -#include <hbotcompid.H> // list of compid's supported -#include <errl/hberrltypes.H> // errlver_t, errlsubsec_t - - - + * Derive a class from ErrlUserDetails to create user detail data + * Derive a class from ErrlUserDetailsParser to parse user detail data + */ +#include <stdint.h> +#include <errl/hberrltypes.H> // errlver_t, errlsubsec_t #ifndef PARSER -#include <errl/errlentry.H> // addFFDC, appendFFDC + +#include <errl/errlentry.H> namespace ERRORLOG { - /** - * @brief ERRL User Data Details - * - * HostBoot Support - base class for Errorlog User Details. + * @class ErrlUserDetails * + * This class creates user detail data. If a component creates user detail data + * then for each different type of data it should derive a class from this. * -*/ + * This class is only compiled when PARSER is not defined. + */ class ErrlUserDetails { public: @@ -80,7 +58,6 @@ public: * * Sets up instance variables. A derived class should set up the instance * variables to reflect a specific format of user detail data - * */ ErrlUserDetails(); @@ -88,82 +65,56 @@ public: * @brief Destructor * * Performs any necessary cleanup - * */ virtual ~ErrlUserDetails(); /** - * @brief Adds or appends more user detail data to error log + * @brief Adds user detail data to an error log * - * Adds or appends user detail data stored in the internal buffer to - * the error log - * Subclasses should override if the detail data is not stored in the + * Adds the user detail data stored in the internal buffer to the error + * log. Subclasses should override if the detail data is not stored in the * internal buffer. * - * @param i_errl - * Error log handle to add detail data to. - * This will call appendFFDC() in the errorlog. - * - * @param i_pappendBuf - * pointer to the new data buffer to append. - * - * @param i_pappendBufLen - * length of the new data buffer to append in bytes. - * - * @return None - * + * @param i_errl Error log handle to add detail data to. */ - virtual void addToLog( - errlHndl_t i_errl, - const void *i_paddBuf=NULL, - const uint32_t i_addBufLen=0 ); + virtual void addToLog(errlHndl_t i_errl); protected: /** * @brief Allocates the internal data buffer for storing detail data * - * If the internal buffer is already allocated then it is freed. The - * data buffer is allocated with the specified size. - * - * @param i_size - * Size of buffer + * If the internal buffer is already allocated then it is reallocated and + * the contents preserved (up to the lesser of the new and old sizes). * - * @return uint8_t* - * Pointer to the data buffer + * @param i_size Size of buffer * + * @return uint8_t* Pointer to the data buffer */ - uint8_t * allocUsrBuf(const uint32_t i_size); + uint8_t * reallocUsrBuf(const uint32_t i_size); /** * @brief Returns the size of the internal data buffer * - * @return uint32_t - * Size of the internal data buffer - * + * @return uint32_t Size of the internal data buffer */ uint32_t getUsrBufSize() const; /** * Protected Data: ID of component adding user details */ - compId_t iv_CompId; + compId_t iv_CompId; /** * Protected Data: Version number of the user details */ - errlver_t iv_Version; + errlver_t iv_Version; /** * Protected Data: Subsection number of the user details */ errlsubsec_t iv_SubSection; - /** - * Pointer to the ErrlFFDC passed back by addFFDC() - */ - ErrlFFDC *iv_pErrlFFDC; - private: // Disabled @@ -176,31 +127,27 @@ private: */ uint8_t * iv_pBuffer; // Pointer to internal buffer uint32_t iv_BufLen; // Length of internal buffer - }; -} // namespace + +} #else // (if PARSER defined) +namespace ERRORLOG +{ + /** * - * @brief Error Log User Detail Data Helper - * - * Framework defining how User Detail Data sections of error logs should - * be created and parsed. + * @class ErrlUserDetailsParser * - * Creation methods will show up when the PARSER macro is NOT defined. - * These will compile and run under HostBoot. + * This is an abstract base class that defines how user detail error log data + * should be parsed. For every different format of user detail data, a + * component should create a class that derives from this class. * - * Parsing methods will show up when the PARSER macro IS defined. - * These will compile and run in the errl tool. + * This is only compiled when PARSER is defined. * */ -namespace ERRORLOG -{ - - -class ErrlUserDetails +class ErrlUserDetailsParser { public: @@ -208,16 +155,15 @@ public: * @brief Constructor * */ - ErrlUserDetails() + ErrlUserDetailsParser() { - } /** * @brief Destructor * */ - virtual ~ErrlUserDetails() + virtual ~ErrlUserDetailsParser() { } @@ -245,19 +191,18 @@ public: */ virtual void parse(errlver_t i_version, ErrlUsrParser & i_parser, - const void * i_pBuffer, + void * i_pBuffer, const uint32_t i_buflen) const = 0; private: // Disabled - ErrlUserDetails(const ErrlUserDetails &); - ErrlUserDetails & operator=(const ErrlUserDetails &); + ErrlUserDetailsParser(const ErrlUserDetailsParser &); + ErrlUserDetailsParser & operator=(const ErrlUserDetailsParser &); }; -} // namespace - - -#endif //PARSER +} #endif +#endif + diff --git a/src/include/usr/errl/hberrltypes.H b/src/include/usr/errl/hberrltypes.H index 3bb767b0c..35b7a0417 100644 --- a/src/include/usr/errl/hberrltypes.H +++ b/src/include/usr/errl/hberrltypes.H @@ -35,31 +35,21 @@ * */ #include <hbotcompid.H> // compId_t +#include <stdint.h> /** * @brief Pointer to an ErrlEntry object */ namespace ERRORLOG { class ErrlEntry; }; - - // Identifiers for Hostboot ERRL user-defined data sections. // Range: 0 .. 255 -enum +enum errlUserDataType_t { - HBERRL_SST_NOFORMAT = 0, - HBERRL_SST_DEFAULT = 0, - HBERRL_VER_DEFAULT = 0, // 0,0 not handled - HBERRL_SST_PRESIDENT = 1, // testing - HBERRL_SST_FIRSTLADY = 2, // testing - HBERRL_SST_STRING = 3, // null-ended string - HBERRL_VER_STRINGNAME = 0, // label: "Name" - HBERRL_VER_STRINGTASK = 1, // label: "Task" - HBERRL_VER_STRINGTASKNAME = 2, // label: "Task name" - HBERRL_VER_STRINGATTRNAME = 3, // label: "Attribute name" - HBERRL_VER_STRINGFILENAME = 4, // label: "File name" - HBERRL_VER_STRINGPROCNAME = 5, // label: "Procedure name" - HBERRL_SST_BACKTRACE = 4, // backtrace + HBERRL_UDT_NOFORMAT = 0, + HBERRL_UDT_STRING = 1, + HBERRL_UDT_TARGET = 2, + HBERRL_UDT_BACKTRACE = 3, }; @@ -294,7 +284,6 @@ enum errlTermState_t enum errlUserDataType_t { ERRL_UDT_TRACE = 0x0C, // A trace buffer - ERRL_UDT_TARGET_FFDC = 0x0D, // A target FFDC buffer }; diff --git a/src/include/usr/hbotcompid.H b/src/include/usr/hbotcompid.H index 6e812ea5b..df0280f14 100644 --- a/src/include/usr/hbotcompid.H +++ b/src/include/usr/hbotcompid.H @@ -178,23 +178,21 @@ const compId_t SPD_COMP_ID = 0x1000; const char SPD_COMP_NAME[] = "spd"; //@} -/** @name MBOX +/** @name HBMBOX * MBOX component */ //@{ -const compId_t MBOX_COMP_ID = 0x1100; -const char MBOX_COMP_NAME[] = "mbox"; +const compId_t HBMBOX_COMP_ID = 0x1100; +const char HBMBOX_COMP_NAME[] = "mbox"; //@} -/** @name RESERVED - * Reserved component ID. x3100 is the component ID - * of FipS ERRL component. Due to our use of - * of the FipS errl tool, let no Hostboot component - * use this component ID. +/** @name FIPS_ERRL + * Used to add component trace to an error log + * so that it can be decoded by the FSP errlog parser */ //@{ -const compId_t RESERVED_COMP_ID = 0x3100; -const char RESERVED_COMP_NAME[] = "reserved"; +const compId_t FIPS_ERRL_COMP_ID = 0x3100; +const char FIPS_ERRL_COMP_NAME[] = "hb-trace"; // ---------------------------------------------------------- // CXXTEST Unit Test, reserve compid near the end... diff --git a/src/include/usr/initservice/initsvcreasoncodes.H b/src/include/usr/initservice/initsvcreasoncodes.H index 2fe48948d..9d15c5ef3 100644 --- a/src/include/usr/initservice/initsvcreasoncodes.H +++ b/src/include/usr/initservice/initsvcreasoncodes.H @@ -111,6 +111,11 @@ enum InitServiceReasonCode }; +enum InitServiceUserDetailDataSubSection +{ + INIT_SVC_UDT_ISTEP = 0x01, +}; + }; // namespace INITSERVICE #endif diff --git a/src/include/usr/initservice/initsvcudistep.H b/src/include/usr/initservice/initsvcudistep.H new file mode 100644 index 000000000..9dc8f2106 --- /dev/null +++ b/src/include/usr/initservice/initsvcudistep.H @@ -0,0 +1,139 @@ +// IBM_PROLOG_BEGIN_TAG +// This is an automatically generated prolog. +// +// $Source: src/include/usr/initservice/initsvcudistep.H $ +// +// IBM CONFIDENTIAL +// +// COPYRIGHT International Business Machines Corp. 2012 +// +// 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 +#ifndef INITSVC_UDSTEP_H +#define INITSVC_UDSTEP_H + +/** + * @file initsvcudistep.H + * + * Defines the following classes: + * + * InitSvcUserDetailsIstep: Adds IStep FFDC to an error log as user detail data + * InitSvcUserDetailsParserIstep: Parses IStep FFDC user detail in an error log +*/ + +#include <errl/errluserdetails.H> + +namespace INITSERVICE +{ + +/** + * @struct InitSvcUserDetailsIstepData + * + * Defines the user detail data + */ +struct InitSvcUserDetailsIstepData +{ + uint16_t iv_step; + uint16_t iv_substep; + char iv_pIstepname[0]; +}; + +#ifndef PARSER + +/** + * @class InitSvcUserDetailsIstep + * + * Adds IStep FFDC to an error log as user detail data + */ +class InitSvcUserDetailsIstep : public ERRORLOG::ErrlUserDetails +{ +public: + /** + * @brief Constructor + * + * Captures the supplied IStep FFDC data internally + * + * @param i_pIstepname Istep name + * @param i_step Step number + * @param i_substep Sub-step number + */ + InitSvcUserDetailsIstep(const char * i_pIstepname, + const uint16_t i_step, + const uint16_t i_substep); + + /** + * @brief Destructor + */ + virtual ~InitSvcUserDetailsIstep(); + +private: + // Disabled + InitSvcUserDetailsIstep(const InitSvcUserDetailsIstep &); + InitSvcUserDetailsIstep & operator=(const InitSvcUserDetailsIstep &); +}; + +#else // (if PARSER defined) + +/** + * @class InitSvcUserDetailsParserIstep + * + * Parses Istep user detail in an error log +*/ +class InitSvcUserDetailsParserIstep : public ERRORLOG::ErrlUserDetailsParser +{ +public: + /** + * @brief Constructor + */ + InitSvcUserDetailsParserIstep() {} + + /** + * @brief Destructor + */ + virtual ~InitSvcUserDetailsParserIstep() {} + + /** + * @brief Parses Istep user detail data from an error log + * + * @param i_version Version of the data + * @param i_parse ErrlUsrParser object for outputting information + * @param i_pBuffer Pointer to buffer containing detail data + * @param i_buflen Length of the buffer + */ + virtual void parse(errlver_t i_version, + ErrlUsrParser & i_parser, + void * i_pBuffer, + const uint32_t i_buflen) const + { + InitSvcUserDetailsIstepData * l_pData = + static_cast<InitSvcUserDetailsIstepData *>(i_pBuffer); + + i_parser.PrintString("IStep name", l_pData->iv_pIstepname); + i_parser.PrintNumber("Step", "%d", ntohs(l_pData->iv_step)); + i_parser.PrintNumber("Sub-step", "%d", ntohs(l_pData->iv_substep)); + } + +private: + // Disabled + InitSvcUserDetailsParserIstep(const InitSvcUserDetailsParserIstep &); + InitSvcUserDetailsParserIstep & operator=( + const InitSvcUserDetailsParserIstep &); +}; + +#endif + +} + +#endif + diff --git a/src/include/usr/initservice/initsvcudparserfactory.H b/src/include/usr/initservice/initsvcudparserfactory.H new file mode 100644 index 000000000..ea1178282 --- /dev/null +++ b/src/include/usr/initservice/initsvcudparserfactory.H @@ -0,0 +1,69 @@ +// IBM_PROLOG_BEGIN_TAG +// This is an automatically generated prolog. +// +// $Source: src/include/usr/initservice/initsvcudparserfactory.H $ +// +// IBM CONFIDENTIAL +// +// COPYRIGHT International Business Machines Corp. 2012 +// +// 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 +#ifndef INITSVC_UDPARSERFACTORY_H +#define INITSVC_UDPARSERFACTORY_H + +#ifdef PARSER + +/** + * @file initsvcudparserfactory.H + * + * Defines the InitSvcUserDetailsParserFactory.H class +*/ +#include <initservice/initsvcudistep.H> +#include <initservice/initsvcreasoncodes.H> +#include <errl/errludparserfactory.H> + +namespace INITSERVICE +{ + +/** + * @class InitSvcUserDetailsParserFactory + * + * This factory produces ErrlUserDetailsParser objects to parse the specified + * InitService user detail data. +*/ +class InitSvcUserDetailsParserFactory : public ERRORLOG::ErrlUserDetailsParserFactory +{ +public: + + /** + * @brief Constructor + */ + InitSvcUserDetailsParserFactory() + { + registerParser<InitSvcUserDetailsParserIstep>(INIT_SVC_UDT_ISTEP); + } + +private: + + // Disabled + InitSvcUserDetailsParserFactory(const InitSvcUserDetailsParserFactory &); + InitSvcUserDetailsParserFactory & operator=( + const InitSvcUserDetailsParserFactory &); +}; + +} + +#endif +#endif diff --git a/src/include/usr/mbox/mbox_reasoncodes.H b/src/include/usr/mbox/mbox_reasoncodes.H index 126eb2f75..0ee58ff58 100644 --- a/src/include/usr/mbox/mbox_reasoncodes.H +++ b/src/include/usr/mbox/mbox_reasoncodes.H @@ -36,10 +36,10 @@ namespace MBOX enum MBOXReasonCode { - RC_INVALID_LENGTH = MBOX_COMP_ID | 0x01, - RC_INVALID_MESSAGE_TYPE = MBOX_COMP_ID | 0x02, - RC_NO_PERM_TO_SEND = MBOX_COMP_ID | 0x03, - RC_MSG_PENDING = MBOX_COMP_ID | 0x04, + RC_INVALID_LENGTH = HBMBOX_COMP_ID | 0x01, + RC_INVALID_MESSAGE_TYPE = HBMBOX_COMP_ID | 0x02, + RC_NO_PERM_TO_SEND = HBMBOX_COMP_ID | 0x03, + RC_MSG_PENDING = HBMBOX_COMP_ID | 0x04, }; }; diff --git a/src/include/usr/targeting/targreasoncodes.H b/src/include/usr/targeting/targreasoncodes.H index 42b14eba5..4e6f1108e 100644 --- a/src/include/usr/targeting/targreasoncodes.H +++ b/src/include/usr/targeting/targreasoncodes.H @@ -29,15 +29,17 @@ namespace TARGETING { enum TargetingModuleId { - TARG_MOD_ATTRRP = 0x01, + TARG_MOD_TEST = 0x01, + TARG_MOD_ATTRRP = 0x02, }; enum TargetingReasonCode { - TARG_RC_BAD_EYECATCH = TARG_COMP_ID | 0x01, - TARG_RC_MM_BLOCK_FAIL = TARG_COMP_ID | 0x02, - TARG_RC_MM_PERM_FAIL = TARG_COMP_ID | 0x03, - TARG_RC_ATTR_MSG_FAIL = TARG_COMP_ID | 0x04, + TARG_RC_TEST_TARGET_FFDC = TARG_COMP_ID | 0x01, + TARG_RC_BAD_EYECATCH = TARG_COMP_ID | 0x02, + TARG_RC_MM_BLOCK_FAIL = TARG_COMP_ID | 0x03, + TARG_RC_MM_PERM_FAIL = TARG_COMP_ID | 0x04, + TARG_RC_ATTR_MSG_FAIL = TARG_COMP_ID | 0x05, }; }; diff --git a/src/usr/errl/errlUserDetailsTarget.C b/src/usr/errl/errlUserDetailsTarget.C deleted file mode 100644 index 16b7c1c33..000000000 --- a/src/usr/errl/errlUserDetailsTarget.C +++ /dev/null @@ -1,79 +0,0 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: src/usr/errl/errlUserDetailsTarget.C $ -// -// IBM CONFIDENTIAL -// -// COPYRIGHT International Business Machines Corp. 2012 -// -// 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 -/*****************************************************************************/ -// I n c l u d e s -/*****************************************************************************/ -#include <hbotcompid.H> // list of compid's supported -#include <errl/errlentry.H> -#include <errl/errlUserDetailsTarget.H> -#include <targeting/targetservice.H> - -namespace ERRORLOG -{ - -//#ifndef PARSER - -// Constructor -ErrlUserDetailsTarget::ErrlUserDetailsTarget(const TARGETING::Target * i_target ) : - ErrlUserDetails() -{ - iv_pTarget = i_target; -} - -// Destructor -ErrlUserDetailsTarget::~ErrlUserDetailsTarget() {} - -// @brief Add FFDC to an user detailed data section of the errorlog -// Each data is always terminated with nul-char -void ErrlUserDetailsTarget::addToLog( errlHndl_t i_errl, - void *i_buf, const uint32_t i_len ) -{ - if (i_errl != NULL) - { - if (iv_pTarget == TARGETING::MASTER_PROCESSOR_CHIP_TARGET_SENTINEL) - { - const char *l_bufPtr = "MASTER_PROCESSOR_CHIP_TARGET_SENTINEL"; - iv_pErrlFFDC = i_errl->addFFDC( HBERRL_COMP_ID, - l_bufPtr, strlen(l_bufPtr)+1, - ERRL_UDV_DEFAULT_VER_1, - ERRL_UDT_TARGET_FFDC ); - } - else - { - uint32_t l_bufSize = 0; - char * l_bufPtr = NULL; - - l_bufPtr = iv_pTarget->targetFFDC( l_bufSize ); - if (l_bufPtr) - { - iv_pErrlFFDC = i_errl->addFFDC( HBERRL_COMP_ID, - l_bufPtr, l_bufSize, - ERRL_UDV_DEFAULT_VER_1, - ERRL_UDT_TARGET_FFDC ); - free (l_bufPtr); - } - } - } -} - -} diff --git a/src/usr/errl/errlentry.C b/src/usr/errl/errlentry.C index 89248bce5..ad83ce3df 100644 --- a/src/usr/errl/errlentry.C +++ b/src/usr/errl/errlentry.C @@ -35,10 +35,9 @@ #include <hbotcompid.H> #include <errl/errlentry.H> #include <errl/errlmanager.H> +#include <errl/errludbacktrace.H> #include <trace/interface.H> #include <arch/ppc.H> -#include <errl/backtrace.H> - namespace ERRORLOG { @@ -61,40 +60,10 @@ 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( HBERRL_COMP_ID, - &bt[i], - sizeof(bt[i]), - 0, HBERRL_SST_BACKTRACE ); - - // 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]) ); - } - } + // Collect the Backtrace and add it to the error log + ErrlUserDetailsBackTrace().addToLog(this); } - - /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// ErrlEntry::~ErrlEntry() @@ -166,7 +135,6 @@ void ErrlEntry::appendToFFDC(ErrlUD * i_pErrlUD, // Use these to tag the UD section containing the trace. const int FIPS_ERRL_UDT_TRACE = 0x0c; -const int FIPS_ERRL_COMP_ID = 0x3100; const int FIPS_ERRL_UDV_DEFAULT_VER_1 = 1; bool ErrlEntry::collectTrace(const char i_name[], const uint64_t i_max) @@ -176,12 +144,6 @@ bool ErrlEntry::collectTrace(const char i_name[], const uint64_t i_max) uint64_t l_cbOutput = 0; uint64_t l_cbBuffer = 0; - // Trying to enforce a rule that no Hostboot component - // use the same component ID as FIPS Errl due to our - // use of the errl tool and its ability to format - // FSP traces attached to Hostboot error logs. - CPPASSERT( FIPS_ERRL_COMP_ID == RESERVED_COMP_ID ); - do { // By passing nil arguments 2 and 3, obtain the size of the buffer. diff --git a/src/usr/errl/errludbacktrace.C b/src/usr/errl/errludbacktrace.C new file mode 100644 index 000000000..407af55de --- /dev/null +++ b/src/usr/errl/errludbacktrace.C @@ -0,0 +1,61 @@ +// IBM_PROLOG_BEGIN_TAG +// This is an automatically generated prolog. +// +// $Source: src/usr/errl/errludbacktrace.C $ +// +// IBM CONFIDENTIAL +// +// COPYRIGHT International Business Machines Corp. 2012 +// +// 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 errludbacktrace.C + * + * @brief Implementation of ErrlUserDetailsBackTrace + */ +#include <errl/errludbacktrace.H> +#include <errl/backtrace.H> + +namespace ERRORLOG +{ + +//------------------------------------------------------------------------------ +ErrlUserDetailsBackTrace::ErrlUserDetailsBackTrace() +{ + // Collect the backtrace + std::vector<uint64_t> l_bt; + collectBacktrace(l_bt); + + if (l_bt.size()) + { + uint32_t l_size = l_bt.size() * sizeof(uint64_t); + uint8_t * l_pBuf = reallocUsrBuf(l_size); + memcpy(l_pBuf, &l_bt[0], l_size); + + // Set up ErrlUserDetails instance variables + iv_CompId = HBERRL_COMP_ID; + iv_Version = 1; + iv_SubSection = HBERRL_UDT_BACKTRACE; + } +} + +//------------------------------------------------------------------------------ +ErrlUserDetailsBackTrace::~ErrlUserDetailsBackTrace() +{ + +} + +} + diff --git a/src/usr/errl/errludstring.C b/src/usr/errl/errludstring.C new file mode 100644 index 000000000..42f185248 --- /dev/null +++ b/src/usr/errl/errludstring.C @@ -0,0 +1,54 @@ +// IBM_PROLOG_BEGIN_TAG +// This is an automatically generated prolog. +// +// $Source: src/usr/errl/errludstring.C $ +// +// IBM CONFIDENTIAL +// +// COPYRIGHT International Business Machines Corp. 2012 +// +// 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 errludstring.C + * + * @brief Implementation of ErrlUserDetailsString + */ +#include <errl/errludstring.H> +#include <string.h> + +namespace ERRORLOG +{ + +//------------------------------------------------------------------------------ +ErrlUserDetailsString::ErrlUserDetailsString(const char * i_pString) +{ + char * l_pBuf = reinterpret_cast<char *>( + reallocUsrBuf(strlen(i_pString) + 1)); + strcpy(l_pBuf, i_pString); + + // Set up ErrlUserDetails instance variables + iv_CompId = HBERRL_COMP_ID; + iv_Version = 1; + iv_SubSection = HBERRL_UDT_STRING; +} + +//------------------------------------------------------------------------------ +ErrlUserDetailsString::~ErrlUserDetailsString() +{ + +} + +} + diff --git a/src/usr/errl/errludtarget.C b/src/usr/errl/errludtarget.C new file mode 100644 index 000000000..a04285cf8 --- /dev/null +++ b/src/usr/errl/errludtarget.C @@ -0,0 +1,78 @@ +// IBM_PROLOG_BEGIN_TAG +// This is an automatically generated prolog. +// +// $Source: src/usr/errl/errludtarget.C $ +// +// IBM CONFIDENTIAL +// +// COPYRIGHT International Business Machines Corp. 2012 +// +// 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 errludtarget.C + * + * @brief Implementation of ErrlUserDetailsTarget + */ +#include <errl/errludtarget.H> +#include <targeting/targetservice.H> + +namespace ERRORLOG +{ + +//------------------------------------------------------------------------------ +ErrlUserDetailsTarget::ErrlUserDetailsTarget( + const TARGETING::Target * i_pTarget) +: iv_pTarget(i_pTarget) +{ + +} + +//------------------------------------------------------------------------------ +ErrlUserDetailsTarget::~ErrlUserDetailsTarget() +{ + +} + +//------------------------------------------------------------------------------ +void ErrlUserDetailsTarget::addToLog(errlHndl_t i_errl) +{ + if (i_errl != NULL) + { + if (iv_pTarget == TARGETING::MASTER_PROCESSOR_CHIP_TARGET_SENTINEL) + { + const char *l_bufPtr = "MASTER_PROCESSOR_CHIP_TARGET_SENTINEL"; + i_errl->addFFDC(HBERRL_COMP_ID, + l_bufPtr, strlen(l_bufPtr)+1, + 1, HBERRL_UDT_TARGET); + } + else + { + uint32_t l_bufSize = 0; + char * l_bufPtr = NULL; + + l_bufPtr = iv_pTarget->targetFFDC( l_bufSize ); + if (l_bufPtr) + { + i_errl->addFFDC(HBERRL_COMP_ID, + l_bufPtr, l_bufSize, + 1, HBERRL_UDT_TARGET); + free (l_bufPtr); + } + } + } +} + +} + diff --git a/src/usr/errl/errluserdetails.C b/src/usr/errl/errluserdetails.C index d05af09f3..7adef60a4 100644 --- a/src/usr/errl/errluserdetails.C +++ b/src/usr/errl/errluserdetails.C @@ -27,27 +27,9 @@ * * 2011-09-28 mww Forked from /esw/fips740/Builds/b0824a_1135.740/src/util/fsp * -*/ - - -/******************************************************************************/ -// I n c l u d e s -/*****************************************************************************/ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> // memcpy - -#include <hbotcompid.H> -#include <errl/errlentry.H> -#include <errl/errlmanager.H> -#include <errl/errlreasoncodes.H> - + */ #include <errl/errluserdetails.H> -#include "errlsctn.H" -#include <errl/errlud.H> // ErrlFFDC - - namespace ERRORLOG { @@ -58,7 +40,6 @@ ErrlUserDetails::ErrlUserDetails() : iv_CompId(HBERRL_COMP_ID), iv_Version(0), iv_SubSection(0), - iv_pErrlFFDC(NULL), iv_pBuffer(NULL), iv_BufLen(0) { @@ -69,55 +50,27 @@ ErrlUserDetails::ErrlUserDetails() /*****************************************************************************/ ErrlUserDetails::~ErrlUserDetails() { - if (iv_pBuffer) - { - delete [] iv_pBuffer; - iv_pBuffer = NULL; - } - + delete [] iv_pBuffer; + iv_pBuffer = NULL; } /*****************************************************************************/ // ErrlUserDetails add/appendToLog /*****************************************************************************/ -void ErrlUserDetails::addToLog( - errlHndl_t i_errl, - const void *i_paddBuf, - const uint32_t i_addBufLen ) +void ErrlUserDetails::addToLog(errlHndl_t i_errl) { - - assert( i_errl != NULL ); - - if ( iv_pErrlFFDC == NULL ) + if((i_errl) && (iv_BufLen)) { - // first time through, do an addFFDC() and save the returned handle - iv_pErrlFFDC = i_errl->addFFDC( - iv_CompId, - iv_pBuffer, - iv_BufLen, - iv_Version, - iv_SubSection ); - - // assert if fails to addFFDC - assert( iv_pErrlFFDC != NULL ); - } - - // if there is a buffer/len , append it to the existing FFDC. - if ( ( i_paddBuf != NULL ) && ( i_addBufLen > 0 ) ) - { - i_errl->appendToFFDC( - iv_pErrlFFDC, - i_paddBuf, - i_addBufLen ); + i_errl->addFFDC(iv_CompId, iv_pBuffer, iv_BufLen, iv_Version, + iv_SubSection ); } } - /*****************************************************************************/ -// ErrlUserDetails allocUsrBuf +// ErrlUserDetails reallocUsrBuf /*****************************************************************************/ -uint8_t * ErrlUserDetails::allocUsrBuf(const uint32_t i_size) +uint8_t * ErrlUserDetails::reallocUsrBuf(const uint32_t i_size) { uint8_t * pNewBuffer = new uint8_t[i_size]; if (iv_pBuffer) diff --git a/src/usr/errl/makefile b/src/usr/errl/makefile index bad776ee9..1d5c515e9 100644 --- a/src/usr/errl/makefile +++ b/src/usr/errl/makefile @@ -24,7 +24,8 @@ ROOTPATH = ../../.. MODULE = errl OBJS = errlentry.o errlmanager.o errlsctn.o errlsctnhdr.o errlprvt.o errluh.o \ - errlud.o errlsrc.o errluserdetails.o backtrace.o errlUserDetailsTarget.o + errlud.o errlsrc.o errluserdetails.o backtrace.o errludtarget.o \ + errludstring.o errludbacktrace.o SUBDIRS = test.d parser.d 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 <stdio.h> -#include <stdlib.h> -#include <stdint.h> -#include <unistd.h> -#include <string.h> +/** + * @file initsvcParse.C + * + * errl user data parser + */ #include <netinet/in.h> -#include <endian.h> -#include <vector> -// Get these from a FipS/FSP backing build. +// FSP includes #include <errlplugins.H> #include <errlusrparser.H> #include <srcisrc.H> -// These are from Hostboot. +// Hostboot includes. #include <hbotcompid.H> #include <hostBootSrcParse.H> -#include <errl/hberrltypes.H> - -// 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 <errl/errludparserfactoryerrl.H> - - -//-------------------------------------------------------------------------- -// 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<uint64_t*>(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 <vector> + /** * @file symbols.H * diff --git a/src/usr/errl/test/errltest.H b/src/usr/errl/test/errltest.H index 4e186a98e..8075ed232 100644 --- a/src/usr/errl/test/errltest.H +++ b/src/usr/errl/test/errltest.H @@ -98,7 +98,8 @@ public: * @reasoncode HBERRL_TEST_REASON_CODE * @severity ERRORLOG::ERRL_SEV_INFORMATIONAL * @moduleid HBERRL_TEST_MOD_ID - * @devdesc Errl test, errl log the first. + * @devdesc Errl test. Error with non-decoded string + * and lots of trace buffers. */ // Create an error log @@ -122,16 +123,8 @@ public: // but errlffdc.H is not publicly includable to give me the definition // for it. addFFDC() should return a Boolean indication of success. - const char * pch = "martha washington"; - pffdc = l_err->addFFDC( HBERRL_COMP_ID, pch, strlen( pch ), 0, HBERRL_SST_FIRSTLADY ); - if ( NULL == pffdc ) - { - TS_FAIL("testErrl1: addFFDC() output NULL pointer"); - break; - } - // really short user data - pch = "A"; + const char * pch = "A"; pffdc = l_err->addFFDC( DEVFW_COMP_ID, pch, strlen( pch )); if ( NULL == pffdc ) { @@ -139,32 +132,8 @@ public: break; } - pch = "george washington"; - pffdc = l_err->addFFDC( DEVFW_COMP_ID, pch, strlen( pch ), 0, HBERRL_SST_PRESIDENT ); - if ( NULL == pffdc ) - { - TS_FAIL("testErrl1: addFFDC() output NULL pointer"); - break; - } - - pch = "dwight eisenhour"; - pffdc = l_err->addFFDC( SCOM_COMP_ID, pch, strlen( pch ), 1, 12 ); - if ( NULL == pffdc ) - { - TS_FAIL("testErrl1: addFFDC() output NULL pointer"); - break; - } - - pch = "ronald "; - pffdc = l_err->addFFDC( HBERRL_COMP_ID, pch, strlen( pch ), 0, HBERRL_SST_PRESIDENT ); - if ( NULL == pffdc ) - { - TS_FAIL("testErrl1: addFFDC() output NULL pointer"); - break; - } - // Append data to something already added. - pch = "reagan"; + pch = " test-user-data-string"; l_err->appendToFFDC( pffdc, pch, strlen(pch) ); // Collect trace diff --git a/src/usr/errl/test/errluserdetailtest.H b/src/usr/errl/test/errluserdetailtest.H index b32a655f0..5ac4e9084 100644 --- a/src/usr/errl/test/errluserdetailtest.H +++ b/src/usr/errl/test/errluserdetailtest.H @@ -30,300 +30,50 @@ * */ -#include <cxxtest/TestSuite.H> -#include <errl/errlentry.H> -#include <errl/errluserdetails.H> -#include <errl/errlreasoncodes.H> +#include <cxxtest/TestSuite.H> +#include <errl/errlentry.H> +#include <errl/errluserdetails.H> +#include <errl/errlreasoncodes.H> +#include <errl/errludstring.H> using namespace ERRORLOG; - -enum -{ - UTIL_COMP_ID = 0x8A00, - -}; -// Subsection values, copied from FIPS. -enum -{ - UTIL_UDT_STREAM_PERC = 0x0001,///< Perc Data for Streams - UTIL_UDT_MEM_ALLOC = 0x0002,///< Memory Allocation Failure - UTIL_UDT_REG_KEYS = 0x0003,///< Registry key name, with data - UTIL_UDT_FILENAME = 0x0004,///< A null terminated filename - UTIL_UDT_FLOCK = 0x0005,///< An flock struct - UTIL_UDT_SEMAPHORE = 0x0006,///< A semaphore object - UTIL_UDT_LIBNAME = 0x0007,///< Name of the library - UTIL_UDT_REG_DATA = 0x0008,///< Payload data for UtilReg::write - UTIL_UDT_ERR_MSG = 0x0009,///< An error message string - UTIL_UDT_INOTIFY_PATH = 0x000a,///< The path name in error - UTIL_UDT_XML_TOKEN = 0x000b,///< The XML token in error - // - // dummy one for Stackdump - TEST_STACKDUMP_SUBSECT = 0x0055 // dummy subsection # for stackdump -}; - - -/** - * Declare a test UserDetails derived class to post a filename string to - * the errorlog. - * These are canned routines that are handled by the errl tool. - * - * This is just for test purposes, it will not show up in production code. - * The values for version and subsection should match the actual filename - * UD section parser routing in the errl tool - you should see it parse it - * correctly. - */ -class TestFilename : public ErrlUserDetails -{ -public: - - TestFilename(const char *i_filename) - { - - iv_CompId = UTIL_COMP_ID; - iv_Version = 1; - iv_SubSection = UTIL_UDT_FILENAME; - - // Store the string in the internal buffer - char * l_pString = (char *)allocUsrBuf( strlen(i_filename)+1 ); - strcpy(l_pString, i_filename ); - } - - /** - * @brief Destructor - * - */ - virtual ~TestFilename() {} - -private: - - // Disabled - TestFilename(const TestFilename &); - TestFilename & operator=(const TestFilename &); -}; - - -/** - * Declare a test UserDetails derived class to post an error message - * filename string to the errorlog - * These are canned routines that are handled by the errl tool. - * - * This is just for test purposes, it will not show up in production code. - * The values for version and subsection should match the actual filename - * UD section parser routing in the errl tool - you should see it parse it - * correctly. - */ -class TestErrorMsg : public ErrlUserDetails -{ -public: - - TestErrorMsg(const char *i_filename) - { - - iv_CompId = UTIL_COMP_ID; - iv_Version = 1; - iv_SubSection = UTIL_UDT_ERR_MSG; - - // Store the string in the internal buffer - char * l_pString = (char *)allocUsrBuf( strlen(i_filename)+1 ); - strcpy(l_pString, i_filename ); - } - - /** - * @brief Destructor - * - */ - virtual ~TestErrorMsg() {} - -private: - - // Disabled - TestErrorMsg(const TestErrorMsg &); - TestErrorMsg & operator=(const TestErrorMsg &); -}; - -/** - * Declare a test UserDetails derived class to post an XML token in error - * to the errorlog - * These are canned routines that are handled by the errl tool. - * - * This is just for test purposes, it will not show up in production code. - * The values for version and subsection should match the actual filename - * UD section parser routing in the errl tool - you should see it parse it - * correctly. - */ -class TestXMLToken : public ErrlUserDetails -{ -public: - - TestXMLToken(const char *i_filename) - { - - iv_CompId = UTIL_COMP_ID; - iv_Version = 1; - iv_SubSection = UTIL_UDT_XML_TOKEN; - - // Store the string in the internal buffer - char * l_pString = (char *)allocUsrBuf( strlen(i_filename)+1 ); - strcpy(l_pString, i_filename ); - } - - /** - * @brief Destructor - * - */ - virtual ~TestXMLToken() {} - -private: - - // Disabled - TestXMLToken(const TestXMLToken &); - TestXMLToken & operator=(const TestXMLToken &); -}; - - -// -------------------------------------------------------------------------- -// begin actual test code.. -// -------------------------------------------------------------------------- class UtilErrlUsrDataTest: public CxxTest::TestSuite { public: - + + // Note that errlUserDetailsTarget is tested in the targeting unit test + /** - * @test testFILENAME - create a simple UD section in the errorlog that - * stores a filename string + * @test testString - Capture a String in an error log */ - void testFILENAME(void) + void testString(void) { - errlHndl_t l_errl = NULL; + errlHndl_t l_errl = NULL; - TS_TRACE( "testFILENAME user data buffer for errorlog"); + TS_TRACE( "testString errorlog user detail data"); /*@ * @errortype * @severity ERRORLOG_SEV_INFORMATIONAL - * @moduleid HBERRL_USERDETAILS_MODULE_ID - * @reasoncode HBERRL_FILENAME_TEST - * @userdata1 <UNUSED> - * @userdata2 <UNUSED> - * @devdesc User Details unit test - post a filename user data section + * @moduleid HBERRL_USERDATA_TEST_MOD_ID + * @reasoncode HBERRL_TEST_STRING_UD + * @userdata1 Test data 1 + * @userdata2 Test data 2 + * @devdesc User Details unit test - create string user detail data */ l_errl = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_INFORMATIONAL, - HBERRL_USERDETAILS_MODULE_ID, - HBERRL_FILENAME_TEST, // compid/reasoncode + HBERRL_USERDATA_TEST_MOD_ID, + HBERRL_TEST_STRING_UD, 0x1234567890, // user1 0x9876543210 ); // user2 - if( l_errl == NULL ) - { - TS_FAIL("Could not create errlog.\n"); - return; - } - - // create the filename userdata object - TestFilename l_FN_userdata( "/path/to/myfile.txt" ); - - // Add filename user data block to errorlog. this should add - // the original constructor string, and the second string passed - // in here. - const char testfnstr1[] = "addedfilename.txt"; - l_FN_userdata.addToLog( l_errl, testfnstr1, sizeof(testfnstr1) ); - - // - // Add another string. - // - const char testfnstr2[] = "thirdfilename.txt"; - l_FN_userdata.addToLog( l_errl, testfnstr2, sizeof(testfnstr2) ); - - // commit the errorlog - errlCommit(l_errl, HBERRL_COMP_ID ); - - // Maybe do some stuff here to find the committed errorlog back and - // see if it is still correct? Later. - - } - - /** - * @test testErrorMsg - create a simple UD section in the errorlog - * that stores an error message - */ - void testErrorMsg(void) - { - errlHndl_t l_errl = NULL; - - TS_TRACE( "testErrorMsg user data buffer for errorlog"); - /*@ - * @errortype - * @severity ERRORLOG_SEV_INFORMATIONAL - * @moduleid HBERRL_USERDETAILS_MODULE_ID - * @reasoncode HBERRL_ERRORMSG_TEST - * @userdata1 <UNUSED> - * @userdata2 <UNUSED> - * @devdesc User Details unit test - post an error message in a - * user data section - */ - l_errl = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_INFORMATIONAL, - HBERRL_USERDETAILS_MODULE_ID, - HBERRL_ERRORMSG_TEST, // compid/reasoncode - 0x1212121212, // user1 - 0x3434343434 ); // user2 - if( l_errl == NULL ) - { - TS_FAIL("Could not create errlog.\n"); - return; - } - - // create the filename userdata object - TestErrorMsg l_userdata( "The UserData library has failed to fail." ); - // add it to the log - l_userdata.addToLog( l_errl ); + // Create a test string and add it to the error log as user detail data + const char * l_pString = "This is a test string"; + ErrlUserDetailsString(l_pString).addToLog(l_errl); // commit the errorlog - errlCommit(l_errl, HBERRL_COMP_ID ); - - } - - /** - * @test testXMLToken - create a simple UD section in the errorlog - * that stores the name of an xml token in error. - */ - void testXMLToken(void) - { - errlHndl_t l_errl = NULL; - - TS_TRACE( "testXMLToken user data buffer for errorlog"); - /*@ - * @errortype - * @severity ERRORLOG_SEV_INFORMATIONAL - * @moduleid HBERRL_USERDETAILS_MODULE_ID - * @reasoncode HBERRL_XMLTOKEN_TEST - * @userdata1 <UNUSED> - * @userdata2 <UNUSED> - * @devdesc User Details unit test - post an XML token in error as - * a user data section - */ - l_errl = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_INFORMATIONAL, - HBERRL_USERDETAILS_MODULE_ID, - HBERRL_XMLTOKEN_TEST, // compid/reasoncode - 0xa5a5a5a5a5, // user1 - 0xd2d2d2d2d2 ); // user2 - if( l_errl == NULL ) - { - TS_FAIL("Could not create errlog.\n"); - return; - } - - // create the filename userdata object - TestXMLToken l_userdata( "HWAS_STATE" ); - - // add it to the log - l_userdata.addToLog( l_errl ); - - // commit the errorlog - errlCommit( l_errl, HBERRL_COMP_ID ); - + errlCommit(l_errl, HBERRL_COMP_ID); } }; diff --git a/src/usr/hwas/deconfigGard.C b/src/usr/hwas/deconfigGard.C index 169d5bf1a..082b0e930 100644 --- a/src/usr/hwas/deconfigGard.C +++ b/src/usr/hwas/deconfigGard.C @@ -29,7 +29,7 @@ #include <string.h> #include <targeting/targetservice.H> #include <errl/errlmanager.H> -#include <errl/errlUserDetailsTarget.H> +#include <errl/errludtarget.H> #include <hwas/deconfigGard.H> #include <hwas/hwas_reasoncodes.H> #include <pnor/pnorif.H> @@ -279,8 +279,8 @@ void DeconfigGard::_deconfigureTarget(TARGETING::Target & i_target, l_pErr = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_INFORMATIONAL, MOD_DECONFIG_GARD, RC_TARGET_NOT_DECONFIGURABLE); - ERRORLOG::ErrlUserDetailsTarget l_errlUdTarget( &i_target ); - l_errlUdTarget.addToLog( l_pErr, NULL, 0 ); + + ERRORLOG::ErrlUserDetailsTarget(&i_target).addToLog(l_pErr); errlCommit(l_pErr,HWAS_COMP_ID); } else @@ -460,9 +460,8 @@ errlHndl_t DeconfigGard::_createGardRecord(const TARGETING::Target & i_target, l_pErr = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE, MOD_DECONFIG_GARD, RC_TARGET_NOT_GARDABLE); - - ERRORLOG::ErrlUserDetailsTarget l_errlUdTarget( &i_target ); - l_errlUdTarget.addToLog( l_pErr, NULL, 0 ); + + ERRORLOG::ErrlUserDetailsTarget(&i_target).addToLog(l_pErr); errlCommit(l_pErr,HWAS_COMP_ID); } else @@ -502,8 +501,8 @@ errlHndl_t DeconfigGard::_createGardRecord(const TARGETING::Target & i_target, MOD_DECONFIG_GARD, RC_GARD_REPOSITORY_FULL, iv_maxGardRecords); - ERRORLOG::ErrlUserDetailsTarget l_errlUdTarget( &i_target ); - l_errlUdTarget.addToLog( l_pErr, NULL, 0 ); + + ERRORLOG::ErrlUserDetailsTarget(&i_target).addToLog(l_pErr); } else { diff --git a/src/usr/hwpf/hwp/dram_training/dram_training.H b/src/usr/hwpf/hwp/dram_training/dram_training.H index 67c71fcd7..7cf4f58ad 100644 --- a/src/usr/hwpf/hwp/dram_training/dram_training.H +++ b/src/usr/hwpf/hwp/dram_training/dram_training.H @@ -38,8 +38,7 @@ * */ -/*@ - * @tag isteplist +/* @tag isteplist * @docversion v0.99 (02/10/12) * @istepname dram_training * @istepnum 13 diff --git a/src/usr/hwpf/hwp/mc_init/mc_init.H b/src/usr/hwpf/hwp/mc_init/mc_init.H index 81770cad2..cd09f6257 100644 --- a/src/usr/hwpf/hwp/mc_init/mc_init.H +++ b/src/usr/hwpf/hwp/mc_init/mc_init.H @@ -38,8 +38,7 @@ * */ -/*@ - * @tag isteplist +/* @tag isteplist * @docversion v0.99 (02/10/12) * @istepname mc_init * @istepnum 12 diff --git a/src/usr/hwpf/hwp/sbe_centaur_init/sbe_centaur_init.H b/src/usr/hwpf/hwp/sbe_centaur_init/sbe_centaur_init.H index 4948bdf8f..f0e5cfd12 100644 --- a/src/usr/hwpf/hwp/sbe_centaur_init/sbe_centaur_init.H +++ b/src/usr/hwpf/hwp/sbe_centaur_init/sbe_centaur_init.H @@ -30,8 +30,7 @@ * */ -/*@ - * @tag isteplist +/* @tag isteplist * @docversion v0.99 (02/10/12) * @istepname sbe_centaur_init * @istepnum 10 diff --git a/src/usr/initservice/baseinitsvc/initservice.C b/src/usr/initservice/baseinitsvc/initservice.C index 0dc75b45c..ed4191e87 100644 --- a/src/usr/initservice/baseinitsvc/initservice.C +++ b/src/usr/initservice/baseinitsvc/initservice.C @@ -43,6 +43,8 @@ #include <sys/mm.h> #include <vmmconst.h> +#include <errl/errludstring.H> + #include "initservice.H" #include "initsvctasks.H" @@ -91,6 +93,9 @@ errlHndl_t InitService::startTask( const TaskInfo *i_ptask, if ( static_cast<int16_t> (l_tidrc) < 0 ) { // task failed to launch, post an errorlog and dump some trace + TRACFCOMP(g_trac_initsvc, "ERROR: starting task '%s'", + i_ptask->taskname); + /*@ errorlog tag * @errortype ERRL_SEV_CRITICAL_SYS_TERM * @moduleid INITSVC_START_TASK_MOD_ID @@ -107,6 +112,9 @@ errlHndl_t InitService::startTask( const TaskInfo *i_ptask, INITSERVICE::START_TASK_FAILED, i_ptask->taskflags.module_id, l_tidrc ); + + // Add the task name as user detail data + ERRORLOG::ErrlUserDetailsString(i_ptask->taskname).addToLog(l_errl); } // endif tidrc else { @@ -142,6 +150,9 @@ errlHndl_t InitService::executeFn( const TaskInfo *i_ptask, l_tidrc = task_create( i_ptask->taskfn, io_pargs); if (static_cast<int16_t> (l_tidrc) < 0) { + TRACFCOMP(g_trac_initsvc, "ERROR: starting function in task'%s'", + i_ptask->taskname); + /*@ errorlog tag * @errortype ERRL_SEV_CRITICAL_SYS_TERM * @moduleid INITSVC_START_FN_MOD_ID @@ -160,6 +171,8 @@ errlHndl_t InitService::executeFn( const TaskInfo *i_ptask, i_ptask->taskflags.module_id, l_tidrc ); + // Add the task name as user detail data + ERRORLOG::ErrlUserDetailsString(i_ptask->taskname).addToLog(l_errl); } // endif tidrc else { @@ -312,7 +325,7 @@ void InitService::init( void *io_ptr ) if ( l_childrc != 0 ) { TRACFCOMP( g_trac_initsvc, - "IS: Child task %s returned 0x%llx, no errlog", + "ERROR: Child task '%s' returned 0x%llx, no errlog", l_ptask->taskname, l_childrc ); @@ -413,6 +426,7 @@ void InitService::doShutdown(uint64_t i_status) l_rc = mm_remove_pages(FLUSH,(*l_rb_iter)->vaddr,(*l_rb_iter)->size); if (l_rc) { + TRACFCOMP(g_trac_initsvc, "ERROR: flushing virtual memory"); /* * @errorlog tag * @errortype ERRL_SEV_CRITICAL_SYS_TERM diff --git a/src/usr/initservice/istepdispatcher/initsvcudistep.C b/src/usr/initservice/istepdispatcher/initsvcudistep.C new file mode 100644 index 000000000..7385087f5 --- /dev/null +++ b/src/usr/initservice/istepdispatcher/initsvcudistep.C @@ -0,0 +1,62 @@ +// IBM_PROLOG_BEGIN_TAG +// This is an automatically generated prolog. +// +// $Source: src/usr/initservice/istepdispatcher/initsvcudistep.C $ +// +// IBM CONFIDENTIAL +// +// COPYRIGHT International Business Machines Corp. 2012 +// +// 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 initsvcudistep.C + * + * @brief Implementation of InitSvcUserDetailsIstep + */ +#include <initservice/initsvcudistep.H> +#include <initservice/initsvcreasoncodes.H> + +namespace INITSERVICE +{ + +//------------------------------------------------------------------------------ +InitSvcUserDetailsIstep::InitSvcUserDetailsIstep( + const char * i_pIstepname, + const uint16_t i_step, + const uint16_t i_substep) +{ + InitSvcUserDetailsIstepData * l_pBuf = + reinterpret_cast<InitSvcUserDetailsIstepData *>( + reallocUsrBuf(sizeof(InitSvcUserDetailsIstepData) + + (strlen(i_pIstepname) + 1))); + + l_pBuf->iv_step = i_step; + l_pBuf->iv_substep = i_substep; + strcpy(l_pBuf->iv_pIstepname, i_pIstepname); + + // Set up ErrlUserDetails instance variables + iv_CompId = INITSVC_COMP_ID; + iv_Version = 1; + iv_SubSection = INIT_SVC_UDT_ISTEP; +} + +//------------------------------------------------------------------------------ +InitSvcUserDetailsIstep::~InitSvcUserDetailsIstep() +{ + +} + +} + diff --git a/src/usr/initservice/istepdispatcher/istepdispatcher.C b/src/usr/initservice/istepdispatcher/istepdispatcher.C index 744b4e74d..1b8b68a5a 100644 --- a/src/usr/initservice/istepdispatcher/istepdispatcher.C +++ b/src/usr/initservice/istepdispatcher/istepdispatcher.C @@ -49,10 +49,9 @@ #include <devicefw/userif.H> // targeting #include <initservice/isteps_trace.H> // ISTEPS_TRACE buffer - +#include <initservice/initsvcudistep.H> // InitSvcUserDetailsIstep #include <initservice/taskargs.H> // TaskArgs structs -#include <errl/errluserdetails.H> // ErrlUserDetails base class #include <targeting/attributes.H> // ISTEP_MODE attribute #include <targeting/entitypath.H> @@ -76,57 +75,6 @@ trace_desc_t *g_trac_isteps_trace = NULL; } // end namespace // ----- end namespace ISTEPS_TRACE ----------------------------------- -// ----- namespace ERRORLOG ------------------------------------------- -namespace ERRORLOG -{ -/** - * @class IStepNameUserDetail - * - * report the failing IStepName to an errorlog - * - * @todo: get rid of magic numbers in version and subsection. - * set up tags, plugins, include files, etc. - * For now we just want to report the failing istep string for debug. - * @todo: Expand this to report the istep / substep, error returned, etc. - */ - -class IStepNameUserDetail : public ErrlUserDetails -{ - -public: - - IStepNameUserDetail( - const char *i_istepname, - const uint16_t i_istep = 0, - const uint16_t i_substep = 0, - const uint64_t i_isteprc = 0 ) - { - - iv_CompId = INITSVC_COMP_ID; - iv_Version = 1; - iv_SubSection = 1; - - // Store the string in the internal buffer - char * l_pString = (char *)allocUsrBuf( strlen(i_istepname)+1 ); - strcpy(l_pString, i_istepname ); - } - -/** - * @brief Destructor - * - */ -virtual ~IStepNameUserDetail() {} - -private: - -// Disabled -IStepNameUserDetail(const IStepNameUserDetail &); -IStepNameUserDetail & operator=(const IStepNameUserDetail &); -}; - -} // ----- end namespace ERRORLOG ----------------------------------- - - // ----- namespace INITSERVICE ------------------------------------------- namespace INITSERVICE { @@ -763,10 +711,11 @@ void IStepDispatcher::runAllISteps( void * io_ptr ) const INITSERVICE::ISTEP_FAILED_NO_ERRLOG, ( l_IStep << 8 | l_SubStep ), l_isteprc ); - // attach the istep name to the error log - // @todo - IStepNameUserDetail l_istepud( l_pistep->taskname ); - l_istepud.addToLog( l_errl ); + + // Add IStep user detail data to the error log + InitSvcUserDetailsIstep(l_pistep->taskname, l_IStep, + l_SubStep).addToLog( l_errl ); + // drop out of inner loop with errlog set. break; } // end if ( ) diff --git a/src/usr/initservice/istepdispatcher/makefile b/src/usr/initservice/istepdispatcher/makefile index 43e064f00..c65342107 100644 --- a/src/usr/initservice/istepdispatcher/makefile +++ b/src/usr/initservice/istepdispatcher/makefile @@ -24,7 +24,7 @@ ROOTPATH = ../../../.. MODULE = istepdisp -OBJS = istepdispatcher.o +OBJS = istepdispatcher.o initsvcudistep.o ## SUBDIRS = test.d diff --git a/src/usr/initservice/plugins/initsvcParse.C b/src/usr/initservice/plugins/initsvcParse.C new file mode 100644 index 000000000..227c3f85b --- /dev/null +++ b/src/usr/initservice/plugins/initsvcParse.C @@ -0,0 +1,63 @@ +// IBM_PROLOG_BEGIN_TAG +// This is an automatically generated prolog. +// +// $Source: src/usr/initservice/plugins/initsvcParse.C $ +// +// IBM CONFIDENTIAL +// +// COPYRIGHT International Business Machines Corp. 2012 +// +// 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 initsvcParse.C + * + * Initservice user data parser + */ +#include <netinet/in.h> + +// FSP includes +#include <errlplugins.H> +#include <errlusrparser.H> + +// Hostboot includes +#include <initservice/initsvcudparserfactory.H> + +static bool myDataParse( + ErrlUsrParser& i_parser, + void* i_buffer, + uint32_t i_buflen, + errlver_t i_ver, + errlsubsec_t i_sst) +{ + bool l_rc = false; + + // Create a InitSvcUserDetailsParserFactory object + INITSERVICE::InitSvcUserDetailsParserFactory 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 l_rc; +} + +// Map my Hostboot component ID to the function above. +static errl::DataPlugin g_DataPlugin(INITSVC_COMP_ID, myDataParse ); + diff --git a/src/usr/initservice/plugins/makefile b/src/usr/initservice/plugins/makefile index 58f562153..b2583f58d 100644 --- a/src/usr/initservice/plugins/makefile +++ b/src/usr/initservice/plugins/makefile @@ -28,8 +28,7 @@ .include "../plugins.mk" MY_PLUGIN = libB-0500 -MY_OBJS = # initserviceParse.o - +MY_OBJS = initsvcParse.o .if ( $(CONTEXT) == "x86.nfp" ) diff --git a/src/usr/targeting/test/targetingtest.H b/src/usr/targeting/test/targetingtest.H index 31f041426..e1a535660 100644 --- a/src/usr/targeting/test/targetingtest.H +++ b/src/usr/targeting/test/targetingtest.H @@ -56,7 +56,8 @@ #include <targeting/iterators/rangefilter.H> #include <targeting/predicates/predicatectm.H> #include <targeting/predicates/predicatepostfixexpr.H> -#include <errl/errlUserDetailsTarget.H> +#include <targeting/targreasoncodes.H> +#include <errl/errludtarget.H> #include <kernel/console.H> //@fixme @@ -1486,20 +1487,27 @@ class TargetingTestSuite: public CxxTest::TestSuite TARGETING::Target* l_pTarget2 = MASTER_PROCESSOR_CHIP_TARGET_SENTINEL; l_service.masterProcChipTargetHandle( l_pTarget1); - ErrlUserDetailsTarget l_errlUdTarget1( l_pTarget1 ); - ErrlUserDetailsTarget l_errlUdTarget2( l_pTarget2 ); - - // Create errorlogs to test FFDC capture of a target - errlHndl_t l_err1, l_err2; - l_err1 = new ErrlEntry( ERRL_SEV_UNRECOVERABLE, 1, 2, 3, 4); - l_err2 = new ErrlEntry( ERRL_SEV_UNRECOVERABLE, 5, 6, 7, 8); - - l_errlUdTarget1.addToLog( l_err1, NULL, 0 ); - l_errlUdTarget2.addToLog( l_err2, NULL, 0 ); - l_errlUdTarget1.addToLog( l_err1, NULL, 0 ); - - ERRORLOG::errlCommit( l_err1, TARG_COMP_ID ); - ERRORLOG::errlCommit( l_err2, TARG_COMP_ID ); + // Create an errorlog to test FFDC capture of targets + /*@ + * @errortype + * @severity ERRORLOG_SEV_INFORMATIONAL + * @moduleid TARG_MOD_TEST + * @reasoncode TARG_RC_TEST_TARGET_FFDC + * @userdata1 Test data 1 + * @userdata2 Test data 2 + * @devdesc User Details unit test - create target user detail data + */ + errlHndl_t l_err; + l_err = new ErrlEntry(ERRL_SEV_INFORMATIONAL, + TARG_MOD_TEST, + TARG_RC_TEST_TARGET_FFDC, + 0x0011223344556677, + 0x8899aabbccddeeff); + + ErrlUserDetailsTarget(l_pTarget1).addToLog(l_err); + ErrlUserDetailsTarget(l_pTarget2).addToLog(l_err); + + errlCommit(l_err, TARG_COMP_ID); TS_TRACE(EXIT_MRK "testErrlTargetFFDC"); } |