diff options
author | Monte Copeland <copelanm@us.ibm.com> | 2011-08-17 12:13:20 -0500 |
---|---|---|
committer | Monte K. Copeland <copelanm@us.ibm.com> | 2011-08-18 08:46:41 -0500 |
commit | fe59bf54606f8dc2e12723d962f70a551f753666 (patch) | |
tree | 0a142500d584f7cc84eee352ade4c1a5e34b0789 /src | |
parent | c56648379cde6ea3bcfac07923bb560734c6e16f (diff) | |
download | talos-hostboot-fe59bf54606f8dc2e12723d962f70a551f753666.tar.gz talos-hostboot-fe59bf54606f8dc2e12723d962f70a551f753666.zip |
Errl parser update to accept pre-extracted storage buffer.
Change-Id: I86f0a887845399f639a11bb39bb160b33af5d156
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/262
Tested-by: Jenkins Server
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Reviewed-by: CAMVAN T. NGUYEN <ctnguyen@us.ibm.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/usr/errl/parser/errlparser.C | 92 | ||||
-rw-r--r-- | src/usr/errl/parser/makefile | 2 |
2 files changed, 81 insertions, 13 deletions
diff --git a/src/usr/errl/parser/errlparser.C b/src/usr/errl/parser/errlparser.C index 037eeb03f..91a468c69 100644 --- a/src/usr/errl/parser/errlparser.C +++ b/src/usr/errl/parser/errlparser.C @@ -26,11 +26,30 @@ using namespace ERRORLOG; #define USAGE "\ Usage:\n\ \n\ -errlparser <imagefile> <symsfile> [-l | -d <logid>]\n\ +errlparser [-i] <imagefile> [[-s] <symsfile>] [-l | -d <logid>] [-v]\n\ \n\ -Provide L3 memory image file and its hbicore*.syms file.\n\ +Arguments:\n\ + <imagefile> data file name\n\ + <symsfile> symbols file name\n\ -l summarize all error logs (default)\n\ -d id print detail from specific error log\n\ + -s name explicitly name the symbols file\n\ + -i name explicitly name the image file\n\ + -v verbose output to stdout\n\ +\n\ +Sample command lines:\n\ + errlparser image.bin hbicore.syms # list logs from a full L3 image\n\ + errlparser image.bin hbicore.syms -d 1 # print detail about log 1\n\ + errlparser buffer.bin # list logs from pre-extracted storage buffer\n\ + errlparser buffer.bin -d 1 # detail log 1 from pre-extracted storage buffer\n\ +\n\ +Remarks:\n\ +[] If no symbols file name is given, <imagefile> is assumed to be an error\n\ + log storage buffer, usually 64KB in size, that has been pre-extracted\n\ + from an L3 image.\n\ +[] All output written to stdout\n\ +[] '-s' is optional if the symbols file name contains 'syms'\n\ +[] '-i' can be optional in most cases\n\ \n\ Contact: Monte Copeland\n\ " @@ -257,7 +276,7 @@ char* ReadStorageBuffer(char* i_Image, uint32_t i_ulAddr, uint32_t &io_cbBuffer) char * l_pchBuffer = NULL; // pointer to return storage_header_t header; - // open the binary image of L3 RAM and read the errl log buffer + // open the image file and read the errl log buffer fd = open( i_Image, O_RDONLY ); if ( fd == -1 ) { @@ -291,6 +310,14 @@ char* ReadStorageBuffer(char* i_Image, uint32_t i_ulAddr, uint32_t &io_cbBuffer) // io_cbBuffer is a count of bytes in storage io_cbBuffer = header.cbStorage; + if( io_cbBuffer > ( 5 * ERRL_STORAGE_SIZE )) + { + // Unreasonable + fprintf( stdout, "Problem with image file %s\n", i_Image ); + fprintf( stdout, "Buffer size %d is unreasonable.\n", io_cbBuffer ); + exit(2); + } + if( ( i_ulAddr + io_cbBuffer ) > offsetEnd ) { fprintf( stdout, "Image file %s appears to be truncated. " @@ -496,7 +523,7 @@ int main( int argc, char *argv[] ) char * pszSearch; char * pszAddr = NULL; char * pchBuffer; - uint32_t ulAddr; + uint32_t ulAddr = 0; char szDivider[ 256 ]; uint32_t ulLogId = 0; int c; @@ -550,6 +577,26 @@ int main( int argc, char *argv[] ) fList = 0; fDetail = 1; } + else if( 0 == strcmp( "-i", argv[i] )) + { + i++; + if( i >= argc ) + { + fprintf( stdout, "Provide -i <imagefile>\n" ); + exit( 2 ); + } + pszImageFile = strdup( argv[i] ); + } + else if( 0 == strcmp( "-s", argv[i] )) + { + i++; + if( i >= argc ) + { + fprintf( stdout, "Provide -s <symsfile>\n" ); + exit( 2 ); + } + pszSymbolFile = strdup( argv[i] ); + } else if( 0 == strcmp( "-l", argv[i] )) { fList = 1; @@ -574,10 +621,18 @@ int main( int argc, char *argv[] ) pch = strstr( argv[i], "syms" ); if( pch ) { + if( pszSymbolFile ) + { + halt( USAGE ); + } pszSymbolFile = strdup( argv[i] ); } else { + if( pszImageFile ) + { + halt( USAGE ); + } pszImageFile = strdup( argv[i] ); } } @@ -587,24 +642,37 @@ int main( int argc, char *argv[] ) // Check args. - if((!pszImageFile) || (!pszSymbolFile)) + if( !pszImageFile ) { halt( USAGE ); } - - // Given the symbols file, locate the address/offset of the errl storage - // buffer. - ulAddr = FindSymbol( pszSymbolFile, "g_ErrlStorage" ); - if( fVerbose ) + if( pszSymbolFile ) { - printf( "Error log storage buffer offset: 0x%08x\n", ulAddr ); + // Given the symbols file, locate the address/offset of the + // errl storage buffer. + ulAddr = FindSymbol( pszSymbolFile, "g_ErrlStorage" ); + if( fVerbose ) + { + printf( "Error log storage buffer offset: 0x%08x\n", ulAddr ); + } + } + else + { + // No symbols file name given. + // Proceed as though the image file is the 64KB storage buffer, + // already extracted for me. This is the case for awan. + ulAddr = 0; + if( fVerbose ) + { + printf( "Assuming '%s' is errl storage buffer.\n", pszImageFile ); + } } // Given the image file, read the portion that contains the - // error logs. + // error log storage buffer. pchBuffer = ReadStorageBuffer( pszImageFile, ulAddr, cbBuffer ); assert( pchBuffer ); assert( cbBuffer ); diff --git a/src/usr/errl/parser/makefile b/src/usr/errl/parser/makefile index 2a5b44417..fa5aabfd5 100644 --- a/src/usr/errl/parser/makefile +++ b/src/usr/errl/parser/makefile @@ -24,7 +24,7 @@ $(BIN)/comps.C: $(ROOTPATH)/src/include/usr/hbotcompid.H mkdir -p $(BIN) grep "const compId_t [A-Z0-9]*_COMP_ID" $^ | \ grep -v MY_COMP_ID | \ - sed 's/const compId_t \([A-Z0-9]*\)_COMP_ID[ =\t]*\(0[xX][0-0a-fA-F]*\).*/{ "\1", \2 },/' \ + sed 's/const compId_t \([A-Z0-9]*\)_COMP_ID[ =\t]*\(0[xX][0-9a-fA-F]*\).*/{ "\1", \2 },/' \ > $@ $(BIN)/errlparser.o: errlparser.C $(ROOTPATH)/src/include/usr/errl/errltypes.H $(BIN)/comps.C |