diff options
| author | Mike Jones <mjjones@us.ibm.com> | 2013-01-22 09:41:25 -0600 |
|---|---|---|
| committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2013-02-08 16:49:45 -0600 |
| commit | caf328ccd931de4ce4e4d285d1a4e5ddd151abb5 (patch) | |
| tree | 650c28362fef4b7fd3d8e727d2b13e25f119434b /src/usr/errl/parser | |
| parent | 7c50ac8fa046052334326fd4f3c8447cb0c9514d (diff) | |
| download | blackbird-hostboot-caf328ccd931de4ce4e4d285d1a4e5ddd151abb5.tar.gz blackbird-hostboot-caf328ccd931de4ce4e4d285d1a4e5ddd151abb5.zip | |
ERRL: Create Hostboot error log SRC/UD parser and deliver to FSP bld
A new script called genErrlParsers will scan the Hostboot code for
error log tags and create a SRC parser for each component. The
script will also scan the Hostboot code for plugin directories
containing User Detail Data parsers and will create a makefile
that is used by the FSP to build each component's SRC/UD parser.
Change-Id: I7113f6cd8069447a1caaa199aff199b663d59072
RTC: 47518
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/2975
Tested-by: Jenkins Server
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/errl/parser')
| -rwxr-xr-x | src/usr/errl/parser/genErrlParsers.pl | 898 | ||||
| -rw-r--r-- | src/usr/errl/parser/makefile | 56 | ||||
| -rwxr-xr-x | src/usr/errl/parser/scanforsrcs.pl | 781 |
3 files changed, 926 insertions, 809 deletions
diff --git a/src/usr/errl/parser/genErrlParsers.pl b/src/usr/errl/parser/genErrlParsers.pl new file mode 100755 index 000000000..33ddabbdc --- /dev/null +++ b/src/usr/errl/parser/genErrlParsers.pl @@ -0,0 +1,898 @@ +#!/usr/bin/perl +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: src/usr/errl/parser/genErrlParsers.pl $ +# +# IBM CONFIDENTIAL +# +# COPYRIGHT International Business Machines Corp. 2013 +# +# 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 otherwise +# divested of its trade secrets, irrespective of what has been +# deposited with the U.S. Copyright Office. +# +# Origin: 30 +# +# IBM_PROLOG_END_TAG + +# Purpose: Generates files needed to parse SRC and User Detail Data from +# Hostboot error logs. The files are delivered to the FSP and built there +# +# It scans the hostboot source code for the doxygen like error log tags and +# generates a C file for each component containing a function called by the FSP +# errl tool to parse the error log SRC, for example: +# - hbfwSrcParse1.C (For parsing errlogs generated by comp-id 0x01) +# - hbfwSrcParse2.C +# - hbfwSrcParse3.C +# It generates a file that contains IDs needed by the Hostboot User Detail Data +# parsers +# - hbfwUdIds.H +# It generates a makefile that builds the Hostboot SRC/UserDetailData parsers +# - makefile + +use strict; +use Time::localtime; + +#------------------------------------------------------------------------------ +# Process Arguments +#------------------------------------------------------------------------------ +my $DEBUG = 0; +my $base = "."; +my $outputDir = "."; + +while( $ARGV = shift ) +{ + if( $ARGV =~ m/-b/ ) + { + $base = shift; + } + elsif( $ARGV =~ m/-o/i ) + { + $outputDir = shift; + } + elsif( $ARGV =~ m/-d/i ) + { + $DEBUG = 1; + } + else + { + usage(); + } +} + +#------------------------------------------------------------------------------ +# Global variables +#------------------------------------------------------------------------------ +my $compIdFile = $base."/src/include/usr/hbotcompid.H"; +my $compPath = $base."/src/usr"; +my $compIncPath = $base."/src/include/usr"; +my $genFilesPath = $base."/obj/genfiles"; + +#------------------------------------------------------------------------------ +# Call subroutines to populate the following arrays: +# - @reasonCodeFiles (The list of files to parse through for reason codes) +# - @filesToParse (The list of files to parse through for SRC tags) +# - @pluginDirsToParse (the list of plugin directories containing User Detail +# Data parsers) +#------------------------------------------------------------------------------ +my @reasonCodeFiles; +my @filesToParse; +my @pluginDirsToParse; +getReasonCodeFiles($compIncPath); +getFilesToParse($compPath); +getFilesToParse($compIncPath); +getFilesToParse($genFilesPath); +getPluginDirsToParse($compPath); + +if ($DEBUG) +{ + print("---> ReasonCode files to process\n"); + foreach my $file(@reasonCodeFiles) + { + print("RC File: $file\n"); + } +} + +if ($DEBUG) +{ + print("---> Files to parse for error log tags\n"); + foreach my $file(@filesToParse) + { + print("File to Parse: $file\n"); + } +} + +if ($DEBUG) +{ + print("---> Directories to parse for user detail data\n"); + foreach my $dir(@pluginDirsToParse) + { + print("Plugin Directory to Parse: $dir\n"); + } +} + +#------------------------------------------------------------------------------ +# Process the compIdFile, recording all of the component ID values +#------------------------------------------------------------------------------ +my %compIdToValueHash; + +open(COMP_ID_FILE, $compIdFile) or die("Cannot open: $compIdFile: $!"); + +while (my $line = <COMP_ID_FILE>) +{ + # An example of the component ID line is: + # const compId_t DEVFW_COMP_ID = 0x0200; + if ($line =~ /^const compId_t (\w+) = 0x([\dA-Fa-f]+)00/) + { + my $compId = $1; + my $compValue = $2; + + # Strip off any leading zeroes from the component value + $compValue =~ s/^0//g; + + $compIdToValueHash{$compId} = $compValue; + } +} + +close(COMP_ID_FILE); + +if ($DEBUG) +{ + print("---> Component ID values\n"); + foreach my $key (keys %compIdToValueHash) + { + print ("CompId: $key = $compIdToValueHash{$key},\n"); + } +} + +#------------------------------------------------------------------------------ +# Process the reasonCodeFiles, recording all of the module ids, reason codes +# and user detail data sections in hashes: The module ids and reason codes +# can be duplicated across components and so the namespace is also stored. +# Example hashes: +# +# %modIdToValueHash = ( +# 'PNOR' => { 'MOD_PNORDD_ERASEFLASH' => '1A', +# 'MOD_PNORDD_READFLASH' => '12'}, +# 'IBSCOM' => { 'IBSCOM_GET_TARG_VIRT_ADDR' => '03', +# 'IBSCOM_SANITY_CHECK' => '02'} +# ); +# +# %rcToValueHash = ( +# 'PNOR' => { 'RC_UNSUPPORTED_OPERATION' => '0607', +# 'RC_STARTUP_FAIL' => '0605'}, +# 'IBSCOM' => { 'IBSCOM_INVALID_CONFIG' => '1C03', +# 'IBSCOM_INVALID_OP_TYPE' => '1C02'} +# ); +# +# %udIdToValueHash = ( +# 'HWPF_UDT_HWP_RCVALUE' => '0x01', +# 'ERRL_UDT_CALLOUT' => '0x07' +# ); +#------------------------------------------------------------------------------ +my %modIdToValueHash; +my %rcToValueHash; +my %udIdToValueHash; + +foreach my $file (@reasonCodeFiles) +{ + open(RC_FILE, $file) or die("Cannot open: $file: $!"); + my $namespace = "NO_NS"; + my $processing = 0; + my $processingModIds = 1; + my $processingRcs = 2; + my $processingUds = 3; + my $compId = ""; + + while (my $line = <RC_FILE>) + { + if ($line =~ /^\s*namespace\s+(\w+)/) + { + if ($namespace ne "NO_NS") + { + print ("$0: Multiple namespaces in '$file'\n"); + exit(1); + } + $namespace = $1; + + # Check for common code files where the reason codes do not contain + # component IDs. Expand this hash as needed to add more components + my %namespaceToCompHash = ( + "HWAS" => "HWAS_COMP_ID"); + + if (exists $namespaceToCompHash{$namespace}) + { + # Reason codes do not contain component IDs + $compId = $namespaceToCompHash{$namespace}; + } + else + { + # Reason codes contain component IDs + $compId = ""; + } + + next; + } + elsif ($line =~ /enum.+ModuleId/i) + { + $processing = $processingModIds; + next; + } + elsif ($line =~ /enum.+ReasonCode/i) + { + $processing = $processingRcs; + next; + } + elsif ($line =~ /enum.+UserDetail/i) + { + $processing = $processingUds; + next; + } + elsif ($line =~ /}/) + { + $processing = 0; + next; + } + + if ($processing == $processingModIds) + { + # Example: "MOD_PNORRP_WAITFORMESSAGE = 0x01" + if ($line =~ /(\w+)\s+=\s+0x([\dA-Fa-f]+)/) + { + $modIdToValueHash{$namespace}->{$1} = $2; + } + } + elsif ($processing == $processingRcs) + { + if ($compId ne "") + { + # Reason code line does not contain Component ID + # Example: "RC_TARGET_NOT_DECONFIGURABLE = 0x01," + if ($line =~ /(\w+)\s+=\s+0x([\dA-Fa-f]+)/) + { + if (! exists $compIdToValueHash{$compId}) + { + print ("$0: Could not find CompID '$compId'\n"); + exit(1); + } + $rcToValueHash{$namespace}->{$1} = + $compIdToValueHash{$compId} . $2; + } + } + else + { + # Reason code line contains Component ID + # Example: "RC_INVALID_MESSAGE_TYPE = PNOR_COMP_ID | 0x01" + if ($line =~ /(\w+)\s+=\s+(\w+)\s+\|\s+0x([\dA-Fa-f]+)/) + { + if (! exists $compIdToValueHash{$2}) + { + print ("$0: Could not find CompID '$2'\n"); + exit(1); + } + $rcToValueHash{$namespace}->{$1} = + $compIdToValueHash{$2} . $3; + } + } + } + elsif ($processing == $processingUds) + { + # Example: "HWPF_UDT_HWP_RCVALUE = 0x01," + if ($line =~ /(\w+)\s+=\s+(0x[\dA-Fa-f]+)/) + { + my $udId = $1; + my $udValue = $2; + + if (exists($udIdToValueHash{$udId})) + { + print ("$0: duplicate user data section in '$file'\n"); + print ("$0: section is '$udId'\n"); + exit(1); + } + + $udIdToValueHash{$udId} = $udValue; + } + } + } + + close(RC_FILE); +} + +if ($DEBUG) +{ + print("---> ModuleId values\n"); + foreach my $namespaceKey (keys %modIdToValueHash) + { + foreach my $modIdKey (keys %{$modIdToValueHash{$namespaceKey}}) + { + print ("$namespaceKey:$modIdKey:$modIdToValueHash{$namespaceKey}->{$modIdKey}\n"); + } + } + + print("---> ReasonCode values\n"); + foreach my $namespaceKey (keys %rcToValueHash) + { + foreach my $rcKey (keys %{$rcToValueHash{$namespaceKey}}) + { + print ("$namespaceKey:$rcKey:$rcToValueHash{$namespaceKey}->{$rcKey}\n"); + } + } + + print("---> User Detail Data Section values\n"); + foreach my $udKey (keys %udIdToValueHash) + { + print ("$udKey:$udIdToValueHash{$udKey}\n"); + } +} + +#------------------------------------------------------------------------------ +# Generate the FSP hbfwUdIds.H file that contains the set of Hostboot component +# IDs and user detail data IDs. This is used by the user data parsers +#------------------------------------------------------------------------------ +my $outputFileName = $outputDir . "/hbfwUdIds.H"; +open(OFILE, ">", $outputFileName) or die("Cannot open: $outputFileName: $!"); + +print OFILE "// Automatically generated by Hostboot's $0\n"; +print OFILE "// Do not modify this file in the FSP tree, it is provided by\n"; +print OFILE "// Hostboot and will be overwritten\n"; +print OFILE "//\n\n"; +print OFILE "\#ifndef HBFWUDIDS_H\n"; +print OFILE "\#define HBFWUDIDS_H\n\n"; +print OFILE "// Hostboot component IDs\n"; +print OFILE "namespace hbfw\n"; +print OFILE "{\n"; +print OFILE " enum\n"; +print OFILE " {\n"; +foreach my $key (keys %compIdToValueHash) +{ + print OFILE " $key = 0x$compIdToValueHash{$key}00,\n"; +} +print OFILE " };\n"; +print OFILE "}\n\n"; +print OFILE "// Hostboot User Detail Data IDs\n"; +print OFILE "enum\n"; +print OFILE "{\n"; +foreach my $udKey (keys %udIdToValueHash) +{ + print OFILE " $udKey = $udIdToValueHash{$udKey},\n"; +} +print OFILE "};\n\n"; +print OFILE "#endif\n"; + +close(OFILE); + +#------------------------------------------------------------------------------ +# Process the code files, looking for error log tags, save the parsing for each +# in a hash indexed by the component value +#------------------------------------------------------------------------------ +my %compValueToParseHash; +my %rcModValuesUsed; + +foreach my $file (@filesToParse) +{ + open(PARSE_FILE, $file) or die("Cannot open: $file: $!"); + my @namespaces; + push(@namespaces, "NO_NS"); + + #------------------------------------------------------------------------- + # Example Tag: + # /*@ + # * @errortype + # * @reasoncode I2C_INVALID_OP_TYPE + # * @severity ERRL_SEV_UNRECOVERABLE + # * @moduleid I2C_PERFORM_OP + # * @userdata1 i_opType + # * @userdata2 addr + # * @devdesc Invalid Operation type. + # */ + # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + while (my $line = <PARSE_FILE>) + { + if ($line =~ /namespace\s+(\w+)/) + { + # Found a namespace, record it to be used when searching for + # moduleid and reasoncode values + push(@namespaces, $1); + next; + } + + if ($line =~ /\/\*\@/) + { + # Found the start of an error log tag + my $modId = ""; + my $modIdValue = ""; + my $rc = ""; + my $rcValue = ""; + my @userData; + my $desc = ""; + + # Read the entire error log tag into an array + my @tag; + + while ($line = <PARSE_FILE>) + { + if ($line =~ /\*\//) + { + # Found the end of an error log tag + last; + } + push(@tag, $line); + } + + # Process the error log tag + my $numLines = scalar (@tag); + + for (my $lineNum = 0; $lineNum < $numLines; $lineNum++) + { + $line = $tag[$lineNum]; + + if ($line =~ /\@moduleid\s+(\S+)/i) + { + # Found a moduleid, find out the value + $modId = $1; + + if ($modId =~ /(\w+)::(\w+)/) + { + # The namespace was provided + if ((exists $modIdToValueHash{$1}) && + (exists ${modIdToValueHash{$1}->{$2}})) + { + $modIdValue = ${modIdToValueHash{$1}->{$2}}; + } + } + else + { + # The namespace was not provided, look through all + # namespaces mentioned in the file + foreach my $namespace(@namespaces) + { + if ((exists $modIdToValueHash{$namespace}) && + (exists ${modIdToValueHash{$namespace}->{$modId}})) + { + $modIdValue = ${modIdToValueHash{$namespace}->{$modId}}; + last; + } + } + } + + if ($modIdValue eq "") + { + print ("$0: Error finding moduleid value for '$file:$line'\n"); + exit(1); + } + } + elsif ($line =~ /\@reasoncode\s+(\S+)/i) + { + # Found a reasoncode, figure out the value + $rc = $1; + + if ($rc =~ /(\w+)::(\w+)/) + { + # The namespace was provided + if ((exists $rcToValueHash{$1}) && + (exists ${rcToValueHash{$1}->{$2}})) + { + $rcValue = ${rcToValueHash{$1}->{$2}}; + } + } + else + { + # The namespace was not provided, look through all + # namespaces mentioned in the file + foreach my $namespace(@namespaces) + { + if ((exists $rcToValueHash{$namespace}) && + (exists ${rcToValueHash{$namespace}->{$rc}})) + { + $rcValue = ${rcToValueHash{$namespace}->{$rc}}; + last; + } + } + } + + if ($rcValue eq "") + { + print ("$0: Error finding reasoncode value for '$file:$line'\n"); + exit(1); + } + } + elsif ($line =~ /\@(userdata\S+)\s+(\S+.*)/i) + { + # Found user data, strip out any double-quotes and trailing + # whitespace + my $udDesc = $1; + my $udText = $2; + $udText =~ s/\"//g; + $udText =~ s/\s+$//; + + # Look for follow-on lines + for ($lineNum++; $lineNum < $numLines; $lineNum++) + { + $line = $tag[$lineNum]; + + if ($line =~ /\@/) + { + # Found the next element, rewind + $lineNum--; + last; + } + + # Continuation of user data, strip out any double-quotes + # and leading / trailing whitespace + $line =~ s/^.+\*\s+//; + $line =~ s/\"//g; + $line =~ s/\s+$//; + + if ($line ne "") + { + $udText = $udText . " " . $line; + } + } + + my $udString = "\"$udDesc\", \"$udText\""; + push(@userData, $udString); + } + elsif ($line =~ /\@devdesc\s+(\S+.*)/i) + { + # Found a description, strip out any double-quotes and + # trailing whitespace + $desc = $1; + $desc =~ s/\"//g; + $desc =~ s/\s+$//; + + # Look for follow-on lines + for ($lineNum++; $lineNum < $numLines; $lineNum++) + { + $line = $tag[$lineNum]; + + if ($line =~ /\@/) + { + # Found the next element, rewind + $lineNum--; + last; + } + + # Continuation of description, strip out any double- + # quotes and leading / trailing whitespace + $line =~ s/^.+\*\s+//; + $line =~ s/\"//g; + $line =~ s/\s+$//; + + if ($line ne "") + { + $desc = $desc . " " . $line; + } + } + } + } + + # Check that the required fields were found + if ($modId eq "") + { + print ("$0: moduleid missing from error log tag in '$file'\n"); + print ("$0: reasoncode is '$rc'\n"); + exit(1); + } + + if ($rc eq "") + { + print ("$0: reasoncode missing from error log tag in '$file'\n"); + print ("$0: moduleid is '$modId'\n"); + exit(1); + } + + if ($desc eq "") + { + print ("$0: description missing from error log tag in '$file'\n"); + print ("$0: moduleid is '$modId', reasoncode is '$rc'\n"); + exit(1); + } + + # Create the combined returncode/moduleid value that the parser looks for and + # ensure that it is not a duplicate of one already found + my $rcModValue = $rcValue . $modIdValue; + + if (exists($rcModValuesUsed{$rcModValue})) + { + print ("$0: duplicate moduleid/reasoncode error log tag in '$file'\n"); + print ("$0: moduleid is '$modId', reasoncode is '$rc'\n"); + exit(1); + } + + $rcModValuesUsed{$rcModValue} = 1; + + # Create the parser code for this error + my $parserCode = " case 0x$rcModValue:\n" + . " i_parser.PrintString(\"devdesc\", \"$desc\");\n" + . " i_parser.PrintString(\"moduleid\", \"$modId\");\n" + . " i_parser.PrintString(\"reasoncode\", \"$rc\");\n"; + foreach my $udString(@userData) + { + $parserCode .= " i_parser.PrintString($udString);\n"; + } + $parserCode .= " break;\n\n"; + + # The component value is the first two characters of the 4 character rc + my $compValue = $rcValue; + $compValue =~ s/..$//; + + # Add the parser code to compValueToParseHash + $compValueToParseHash{$compValue} .= $parserCode; + } + } + + close(PARSE_FILE); +} + +#------------------------------------------------------------------------------ +# For each component value, print a file containing the parse code +#------------------------------------------------------------------------------ +my $timestamp = ctime(); +my $imageId = getImageId(); + +foreach my $compValue (keys %compValueToParseHash) +{ + my $outputFileName = $outputDir . "/hbfwSrcParse$compValue.C"; + open(OFILE, ">", $outputFileName) or die("Cannot open: $outputFileName: $!"); + + print OFILE "/*\n"; + print OFILE " * Automatically generated by Hostboot's $0\n"; + print OFILE " * Do not modify this file in the FSP tree, it is provided by\n"; + print OFILE " * Hostboot and will be overwritten\n"; + print OFILE " *\n"; + print OFILE " * TimeStamp: $timestamp\n"; + print OFILE " * Image Id: $imageId\n"; + print OFILE " *\n"; + print OFILE " */\n\n"; + print OFILE "#include <errlplugins.H>\n"; + print OFILE "#include <errlusrparser.H>\n"; + print OFILE "#include <srcisrc.H>\n\n"; + print OFILE "static bool SrcDataParse(ErrlUsrParser & i_parser,\n"; + print OFILE " const SrciSrc & i_src)\n"; + print OFILE "{\n"; + print OFILE " uint32_t l_error = (i_src.reasonCode() << 8) + i_src.moduleId();\n"; + print OFILE " bool l_success = true;\n\n"; + print OFILE " switch(l_error)\n"; + print OFILE " {\n"; + print OFILE $compValueToParseHash{$compValue}; + print OFILE " default:\n"; + print OFILE " l_success = false;\n"; + print OFILE " break;\n"; + print OFILE " };\n"; + print OFILE " return l_success;\n"; + print OFILE "}\n\n"; + print OFILE "static errl::SrcPlugin g_SrcPlugin(0x$compValue"; + print OFILE "00, SrcDataParse);\n"; + + close(OFILE); +} + +#------------------------------------------------------------------------------ +# Figure out the user detail data files to compile for each component +#------------------------------------------------------------------------------ +my %compValToUdFilesHash; + +foreach my $dir(@pluginDirsToParse) +{ + my $ofiles = ""; + my $compId = ""; + my $compVal = 0; + + # Open the directory and read all entries (files) skipping any beginning + # with "." + my @dirEntries; + opendir(DH, $dir) or die("Cannot open $dir directory"); + @dirEntries = grep { !/^\./ } readdir(DH); + closedir(DH); + + # The plugin directory must contain a <COMP_ID>_Parse.C file which contains + # the user detail data parser for that component + foreach my $file(@dirEntries) + { + if ($file =~ /^(.+).C$/) + { + # Found a C file add it to the files to compile list + $ofiles .= "$1\.o "; + + if ($file =~ /^(.+COMP_ID)_Parse.C$/) + { + # Found the main Parse.C file for a component + $compId = $1; + } + } + } + + if ($compId eq "") + { + print ("$0: Could not find CompID Parser file in $dir\n"); + exit(1); + } + + # Find the component ID value + if (! exists $compIdToValueHash{"$compId"}) + { + print ("$0: Could not find CompID $compId while processing $dir\n"); + exit(1); + } + $compVal = $compIdToValueHash{$compId}; + + $compValToUdFilesHash{$compVal} = $ofiles; +} + +#------------------------------------------------------------------------------ +# Generate the FSP makefile that builds the Hostboot error log parsers +#------------------------------------------------------------------------------ +$outputFileName = $outputDir . "/makefile"; +open(OFILE, ">", $outputFileName) or die("Cannot open: $outputFileName: $!"); + +print OFILE "\# Automatically generated by Hostboot's $0\n"; +print OFILE "\# Do not modify this file in the FSP tree, it is provided by\n"; +print OFILE "\# Hostboot and will be overwritten\n"; +print OFILE "\#\n"; +print OFILE "CFLAGS += -DPARSER\n\n"; + +print OFILE "\#-------------------------------------------------------------\n"; +print OFILE "\# SRC Parsers\n"; +print OFILE "\#-------------------------------------------------------------\n"; +foreach my $compValue (keys %compValueToParseHash) +{ + print OFILE "libB-$compValue" . "00.so_OFILES = hbfwSrcParse$compValue.o\n"; + print OFILE "libB-$compValue" . "00.so_EXTRA_LIBS = libbase.so\n\n"; +} + +print OFILE "\#-------------------------------------------------------------\n"; +print OFILE "\# User Detail Data Parsers\n"; +print OFILE "\#-------------------------------------------------------------\n"; +foreach my $compValue (keys %compValToUdFilesHash) +{ + print OFILE "libB-$compValue" . "00.so_OFILES += $compValToUdFilesHash{$compValue}\n\n"; +} + +print OFILE "\#-------------------------------------------------------------\n"; +print OFILE "\# Shared library for each component\n"; +print OFILE "\#-------------------------------------------------------------\n"; +print OFILE "SHARED_LIBRARIES = "; + +foreach my $compValue (keys %compValueToParseHash) +{ + print OFILE "libB-$compValue" . "00.so "; +} + +print OFILE "\n\n.include<\${RULES_MK}>\n"; + +close(OFILE); + +#------------------------------------------------------------------------------ +# Subroutine that prints the usage +#------------------------------------------------------------------------------ +sub usage +{ + print "Usage: $0 <-b base> <-d> <-o output dir>\"\n"; + print "\n"; + print "-b: Base directory containing Hostboot src directory (default is pwd)\n"; + print "-o: Output directory where files are created (default is pwd)\n"; + print "-d Enable Debug messages.\n"; + print "\n\n"; + exit 1; +} + +#------------------------------------------------------------------------------ +# Subroutine that updates @reasonCodeFiles +#------------------------------------------------------------------------------ +sub getReasonCodeFiles +{ + # Open the input directory and read all entries (files/directories) + # Skipping any beginning with "." + my $inputDir = @_[0]; + my @dirEntries; + opendir(DH, $inputDir) or die("Cannot open $inputDir directory"); + @dirEntries = grep { !/^\./ } readdir(DH); + closedir(DH); + + foreach my $dirEntry (@dirEntries) + { + my $dirEntryPath = "$inputDir/$dirEntry"; + + if (-d $dirEntryPath) + { + # Recursively call this function + getReasonCodeFiles($dirEntryPath); + } + elsif(($dirEntry =~ /reasoncodes/i) || + ($dirEntry =~ /service_codes/i) || + ($dirEntry =~ /examplerc/i)) + { + # Found reason-codes file + push(@reasonCodeFiles, $dirEntryPath); + } + } +} + +#------------------------------------------------------------------------------ +# Subroutine that updates @filesToParse +#------------------------------------------------------------------------------ +sub getFilesToParse +{ + # Open the input directory and read all entries (files/directories) + # Skipping any beginning with "." + my $inputDir = @_[0]; + my @dirEntries; + opendir(DH, $inputDir) or die("Cannot open $inputDir directory"); + @dirEntries = grep { !/^\./ } readdir(DH); + closedir(DH); + + foreach my $dirEntry (@dirEntries) + { + my $dirEntryPath = "$inputDir/$dirEntry"; + + if (-d $dirEntryPath) + { + # Recursively call this function + getFilesToParse($dirEntryPath); + } + elsif($dirEntry =~ /\.[H|C]$/) + { + # Found file to parse + push(@filesToParse, $dirEntryPath); + } + } +} + +#------------------------------------------------------------------------------ +# Subroutine that updates @pluginDirsToParse +#------------------------------------------------------------------------------ +sub getPluginDirsToParse +{ + # Open the input directory and read all entries (files/directories) + # Skipping any beginning with "." + my $inputDir = @_[0]; + my @dirEntries; + opendir(DH, $inputDir) or die("Cannot open $inputDir directory"); + @dirEntries = grep { !/^\./ } readdir(DH); + closedir(DH); + + foreach my $dirEntry (@dirEntries) + { + my $dirEntryPath = "$inputDir/$dirEntry"; + + if (-d $dirEntryPath) + { + if ($dirEntryPath =~ /plugins/) + { + # Found plugins directory + push(@pluginDirsToParse, $dirEntryPath); + } + else + { + # Recursively call this function + getPluginDirsToParse($dirEntryPath); + } + } + } +} + +#------------------------------------------------------------------------------ +# Subroutine that gets the Image ID +#------------------------------------------------------------------------------ +sub getImageId +{ + my $imageId = `git describe --dirty || echo Unknown-Image \`git rev-parse --short HEAD\``; + chomp $imageId; + + if (($imageId =~ m/Unknown-Image/) || # Couldn't find git describe tag. + ($imageId =~ m/dirty/) || # Find 'dirty' commit. + ($imageId =~ m/^.{15}-[1-9]+/)) # Found commits after a tag. + { + $imageId = $imageId."/".$ENV{"USER"}; + } + + return $imageId; +} + diff --git a/src/usr/errl/parser/makefile b/src/usr/errl/parser/makefile index e0307c629..69451597a 100644 --- a/src/usr/errl/parser/makefile +++ b/src/usr/errl/parser/makefile @@ -1,25 +1,25 @@ -# IBM_PROLOG_BEGIN_TAG -# This is an automatically generated prolog. +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. # -# $Source: src/usr/errl/parser/makefile $ +# $Source: src/usr/errl/parser/makefile $ # -# IBM CONFIDENTIAL +# IBM CONFIDENTIAL # -# COPYRIGHT International Business Machines Corp. 2011 +# COPYRIGHT International Business Machines Corp. 2011,2013 # -# p1 +# p1 # -# Object Code Only (OCO) source materials -# Licensed Internal Code Source Materials -# IBM HostBoot Licensed Internal Code +# 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. +# The source code for this program is not published or otherwise +# divested of its trade secrets, irrespective of what has been +# deposited with the U.S. Copyright Office. # -# Origin: 30 +# Origin: 30 # -# IBM_PROLOG_END +# IBM_PROLOG_END_TAG # makefile for errlparser a 32-bit x86 linux binary # to extract the PEL of an error log and @@ -28,10 +28,9 @@ # "Pretty printing" of those error logs is the # function of FipS 'errl' and its plugins, not this program. # -# This makefile runs 'scanforsrc.pl' which generates -# hostBootSrcParse.H, a file that hostboot plugins will include. - - +# This makefile runs 'genErrlParsers' which generates +# the Hostboot SRC parsers and the makefile to build the +# Hostboot SRC and User Detail Data parsers ROOTPATH=../../../.. @@ -40,18 +39,18 @@ IMGDIR = ${ROOTPATH}/img OBJDIR = ${ROOTPATH}/obj/modules/errl/parser -SRCPARSE_HEADER_TARGET = \ - ${GENDIR}/hostBootSrcParse.H - +ERRLPARSE_TARGETS = \ + ${GENDIR}/plugins/hbfwUdIds.H \ + ${GENDIR}/plugins/makefile CC=i686-mcp6-g++ -m32 CFLAGS:=-g -O0 -I $(ROOTPATH)/src/include/usr -I ${GENDIR} all: gen_pass code_pass -gen_pass: mkdirs ${GENDIR}/comps.C +gen_pass: mkdirs ${GENDIR}/comps.C ${ERRLPARSE_TARGETS} -code_pass: ${SRCPARSE_HEADER_TARGET} ${IMGDIR}/errlparser +code_pass: ${IMGDIR}/errlparser # errlparserbase and errlusrparser are plugins stuff, not errlparser. # OBJFILES = ${OBJDIR}/errlparserbase.o ${OBJDIR}/errlusrparser.o @@ -62,9 +61,9 @@ mkdirs: mkdir -p ${OBJDIR} mkdir -p ${GENDIR} -# Parse for error log tags in the Hostboot code, and generate hostBootSrcParse.H -${SRCPARSE_HEADER_TARGET} :: - ./scanforsrcs.pl -b ${ROOTPATH} -o ${GENDIR} +# Generate error log parser code +${ERRLPARSE_TARGETS} :: + ./genErrlParsers.pl -b ${ROOTPATH} -o ${GENDIR}/plugins ${GENDIR}/comps.C: ${ROOTPATH}/src/include/usr/hbotcompid.H grep "const compId_t [A-Z0-9]*_COMP_ID" $^ | \ @@ -72,7 +71,7 @@ ${GENDIR}/comps.C: ${ROOTPATH}/src/include/usr/hbotcompid.H sed 's/const compId_t \([A-Z0-9]*\)_COMP_ID[ =\t]*\(0[xX][0-9a-fA-F]*\).*/{ "\1", \2 },/' \ > $@ -${OBJDIR}/errlparser.o: errlparser.C ${ROOTPATH}/src/include/usr/errl/hberrltypes.H ${GENDIR}/comps.C ${SRCPARSE_HEADER_TARGET} +${OBJDIR}/errlparser.o: errlparser.C ${ROOTPATH}/src/include/usr/errl/hberrltypes.H ${GENDIR}/comps.C $(CC) -c $(CFLAGS) -o $@ $< @@ -80,7 +79,8 @@ ${IMGDIR}/errlparser: ${OBJDIR}/errlparser.o $(CC) -o $@ $< clean: - rm -f ${SRCPARSE_HEADER_TARGET} + rm -f ${ERRLPARSE_TARGETS} + rm -f ${GENDIR}/plugins/hbfwSrcParse*.C rm -f ${GENDIR}/comps.C rm -f ${IMGDIR}/errlparser rm -fr ${OBJDIR} diff --git a/src/usr/errl/parser/scanforsrcs.pl b/src/usr/errl/parser/scanforsrcs.pl deleted file mode 100755 index ebed31b65..000000000 --- a/src/usr/errl/parser/scanforsrcs.pl +++ /dev/null @@ -1,781 +0,0 @@ -#!/usr/bin/perl -# IBM_PROLOG_BEGIN_TAG -# This is an automatically generated prolog. -# -# $Source: src/usr/errl/parser/scanforsrcs.pl $ -# -# IBM CONFIDENTIAL -# -# COPYRIGHT International Business Machines Corp. 2011 -# -# p1 -# -# Object Code Only (OCO) source materials -# Licensed Internal Code Source Materials -# IBM HostBoot Licensed Internal Code -# -# The source code for this program is not published or other- -# wise divested of its trade secrets, irrespective of what has -# been deposited with the U.S. Copyright Office. -# -# Origin: 30 -# -# IBM_PROLOG_END -# -# Purpose: Scan the hostboot source code to extract the doxygen like tags -# and generate a header file for the error log parser to include. -# - -use strict; -use File::Find (); -use Time::localtime; -use File::Path; - -# Vairables -my $DEBUG = 0; -my $component = "VOID"; -my $sandBase = $ENV{HOSTBOOTROOT}; - -my $arg; -my %Comps; -my $wordn = "userdata1"; -my $wordnd = 1; -my $NA = 1; -my $fh; - -my $argOutput = ""; -my $output = ""; - -# Arrays -my @compHeaders; -my %namespaceList; -my @reasonCodeFiles; - -while( $ARGV = shift ) -{ - if( $ARGV =~ m/-b/ ) - { - $sandBase = shift; - } - elsif( $ARGV =~ m/-o/i ) - { - $argOutput = shift; - } - elsif( $ARGV =~ m/-h/i ) - { - usage(); - } - elsif( $ARGV =~ m/-d/i ) - { - $DEBUG = 1; - } - else - { - usage(); - } -} - -# Variables depending on input parameters -if( $argOutput eq "" ) -{ - $output = "$sandBase/obj/genfiles"; -} -else -{ - $output = $argOutput; -} -my $comp_id = "$sandBase/src/include/usr/hbotcompid.H"; - -# Setup all the different paths that need to be searched -my $sourcebasePath = $sandBase."/src/usr"; -my $includePath = $sandBase."/src/include/usr"; -my $genfilesPath = $sandBase."/obj/genfiles"; - -# Get the listing of components -opendir my( $dir ), $sourcebasePath or die "Couldn't open directory $sourcebasePath, $!"; -my @components = readdir $dir; -closedir $dir; - -my %sourcebase; -my %sourcebaseInc; -my %sourcebaseGenfiles; - -my @fileList; - -################################################################ -# Debug Printing -################################################################ -debugMsg( "Comp id file: $comp_id" ); -debugMsg( "Source Base Path: $sourcebasePath" ); -debugMsg( "Sandbox Base Dir: $sandBase" ); -debugMsg( "Output Dir: $output" ); -################################################################ - -foreach( @components ) -{ - # Both src/usr directories as well as src/include/usr directories - # are done here to make sure they line up with the same "component" - # generated files will be done after this loop under the "genfiles" - # component name. - $component = $_; - debugMsg( "Component: $component" ); - - # Print components for debug. - my $compDir = "$sourcebasePath/$component"; - debugMsg( "Component Dir: $compDir" ); - - # Skip files and dirs . and .. - if( -d "$compDir" ) - { - if( ($component eq ".") || - ($component eq ".." ) || - ($component eq "example" ) ) - { - debugMsg( "exiting..." ); - next; - } - } - else - { - debugMsg( "exiting-->" ); - next; - } - - # Check to be sure the main src directory is available - if( -e "$compDir" ) - { - # Get a list of files to be scanned - %sourcebase = getFiles( $compDir ); - } - else - { - # Exit since the path of the user code wasn't found. - die( "\nERROR! Path ($compDir) does not exist. Cannot run!\n" ); - } - - # Get the associated component include files - my $incCompDir = "$includePath/$component"; - debugMsg( "Include Path: $incCompDir" ); - - # Skip files and dirs . and .. - if( -d "$incCompDir" ) - { - # Do nothing, we want the directories - } - else - { - debugMsg( "exiting-->" ); - next; - } - - # if include dir exists, get the files - if( -e "$incCompDir" ) - { - # Add the include files - %sourcebaseInc = getFiles( $incCompDir ); - } - else - { - # Exit since the path of the user code wasn't found. - die( "\nERROR! Path ($incCompDir) does not exist. Cannot run!\n" ); - } - - # Put each file on list to be scanned - foreach( values %sourcebase ) - { - push( @fileList, $_ ); - debugMsg( "File: $_" ); - - # Delete hash entry - delete $sourcebase{$_}; - } - - # Put each file on list to be scanned - foreach( values %sourcebaseInc ) - { - push( @fileList, $_ ); - debugMsg( "File (include): $_" ); - - # Delete hash entry - delete $sourcebaseInc{$_}; - } - - foreach( @fileList ) - { - debugMsg( "Calling extractTags for file: $_" ); - extractTags( $_, $component ); - } - - # Clear the file list so we don't reuse them - @fileList = (); -} - -# Scan the generated files and add to file list -if( -e $genfilesPath ) -{ - %sourcebaseGenfiles = getFiles( $genfilesPath ); - foreach( values %sourcebaseGenfiles ) - { - push( @fileList, $_ ); - debugMsg( "File (genfiles): $_" ); - delete $sourcebaseGenfiles{$_}; - } - - foreach( @fileList ) - { - debugMsg( "Calling extractTags for file: $_" ); - extractTags( $_, "genfiles" ); - } -} -else -{ - die( "\nERROR! Path($genfilesPath) does not exist. Cannot continue!\n" ); -} - -# Get the file open -$fh = openHeaderFile(); - -# Start writing the main header file that will be included by errlparser.C -startMainHeaderFile( $fh ); - -my $found_dup = 0; - -# Write each case statement for printing -foreach my $key (sort(keys(%Comps))) -{ - writePrintStatement( $fh, $key, \@{$Comps{$key}} ); -} -if($found_dup > 0) -{ - die( "ERROR! Duplicate hash found!\n" ); -} - -# Finish writing the header -finishMainHeaderFile( $fh ); - -exit 0; - -#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -# End of Main program -#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -################################################################################ -# -# Print the Usage message -# -################################################################################ - -sub usage -{ - print "Usage: $0 < -b base > <-d> < -o output dir >\"\n"; - print "\n"; - print "-b: base directory ( default is pwd )\n"; - print "-o: Used as the output directory where header file is dropped\n"; - print "-d Enable Debug messages.\n"; - print "-h Display usage message.\n"; - print "\n\n"; - exit 1; -} - - -################################################################################ -# -# Print debug messages if $DEBUG is enabled. -# -################################################################################ - -sub debugMsg -{ - my ($msg) = @_; - if( $DEBUG ) - { - print "DEBUG: $msg\n"; - } -} - - -################################################################################ -# -# Extracts each tag and description from each entry for the given file. -# -################################################################################ - -sub extractTags -{ - my $data; - my ($file, $comp) = @_; - debugMsg( "extractTags: Component: $comp" ); - local *FH; - - debugMsg( "Processing: $file" ); - - open(FH, "$file") or die("Cannot open: $file: $!"); - read(FH, $data, -s FH) or die("Error reading $file: $!"); - close FH; - - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - # Capture everything from opening '/*@' to end of tags '*/' - # - # Example: - # /*@ - # * @errortype - # * @reasoncode I2C_INVALID_OP_TYPE - # * @severity ERRL_SEV_UNRECOVERABLE - # * @moduleid I2C_PERFORM_OP - # * @userdata1 i_opType - # * @userdata2 addr - # * @devdesc Invalid Operation type. - # */ - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - while ($data =~ /\/\*\@((.|\n)+?)\*\//mgo ) - { - debugMsg( "Found New Error Tag!" ); - - my $text = $1; - debugMsg( "Text1: $text" ); - my %hash = $text =~ /\@(\S+)(?:\s+|\.+)\b(.+?)$/gm; - my $tmp; - my $tmpKey; - - foreach my $key (sort keys %hash) - { - $tmpKey = AddSlashes( $key ); - debugMsg( "Key: $tmpKey" ); - # Extract multi-line string - $text =~ /\@$tmpKey(?:\s+|\.+)(.+?)(?:\@|$).*/s; - debugMsg( "Text3: $text" ); - $tmp = $1; - debugMsg( "Tmp: $tmp" ); - $tmp =~ s/\s*\*\s*/ \n/gm; - debugMsg( "Tmp again: $tmp" ); - $tmp = stripWhitespace( $tmp ); - debugMsg( "Tmp trimmed: $tmp" ); - $hash{$key} = $tmp; - debugMsg( "Assigning '$key' = '$tmp'" ); - } - - push @{$Comps{$comp}}, \%hash; - } -} - - -################################################################################ -# -# getFiles - find *.H or *.C files -# This recursively searches the input directory passed in for all C/H files. -# -################################################################################ - -sub getFiles -{ - my ($l_input_dir) = @_; - my @dir_entry; - my %l_input_files; - local *DH; - - debugMsg( "Getting Files for dir: $l_input_dir" ); - - # Open the directory and read all entry names. - opendir(DH, $l_input_dir) or die("Cannot open $l_input_dir: $!"); - # skip the dots - @dir_entry = grep { !/^\./ } readdir(DH); - closedir(DH); - while (@dir_entry) - { - my $l_entry = shift(@dir_entry); - my $full_path = "$l_input_dir/$l_entry"; - - debugMsg( "getFiles: Full Path: $full_path" ); - - if ($l_entry =~ /\.[H|C]$/) - { - $l_input_files{$l_entry} = $full_path; - debugMsg( "getFiles: Adding file: $full_path" ); - } - elsif (-d $full_path) - { - # recursive here - my %local_hash = getFiles($full_path); - my @keys = keys(%local_hash); - - foreach(@keys) - { - $l_input_files{$_} = $local_hash{$_}; - } - } - } - return(%l_input_files); -} - - -################################################################################ -# -# Add escape characters to strings -# -################################################################################ - -sub AddSlashes -{ - my ($text) = @_; - ## Make sure to do the backslash first! - $text =~ s/\\/\\\\/g; - $text =~ s/'/\\'/g; - $text =~ s/"/\\"/g; - $text =~ s/\\0/\\\\0/g; - - $text =~ s/\[/\\[/g; - $text =~ s/\]/\\]/g; - return $text; -} - - -################################################################################ -# -# Strip whitespace from beginning/end of string -# -################################################################################ - -sub stripWhitespace -{ - my ($text) = @_; - - $text =~ s/^\s+//; # strip leading spaces - $text =~ s/\s+$//; # strip trailing spaces - - return $text; -} - -################################################################################ -# -# Look for the components reasoncode file and include it -# -################################################################################ - -sub includeReasonCodes -{ - my ( $fh,$incPath,$level ) = @_; - - debugMsg( "includeReasonCodes incpath: $incPath" ); - debugMsg( "includeReasonCodes level: $level" ); - - my @incDirs = glob( $incPath ); - my $incFileName = ""; - - foreach my $file( @incDirs ) - { - debugMsg( "includeReasonCodes file: $file" ); - my @allDirs = split( '/', $file ); - - if( $file =~ m/reasoncodes/i ) - { - for( my $count = 0; $count < $level; $count++ ) - { - my $tmpTxt = pop @allDirs; - - if( $incFileName ne "" ) - { - $incFileName = $tmpTxt . "/$incFileName"; - } - else - { - $incFileName = $tmpTxt; - } - } - debugMsg( "ReasonCode file: $file" ); - debugMsg( "Include string: $incFileName" ); - - print $fh "#include <$incFileName>\n"; - - # Find the namespace of the reason codes - findNameSpace( $file ); - - # Clear out incFileName, in case there are 2 reason code files - # in the same directory - $incFileName = ""; - } - elsif( -d $file ) - { - debugMsg( "includeReasonCodes recursion" ); - # Recursion is done here. - includeReasonCodes( $fh, $file."/*", ($level+1) ); - } - } -} - - -################################################################################ -# -# Build the main header file that errlparser.C will use to include all of -# the generated header files. -# -################################################################################ - -sub startMainHeaderFile -{ - my ($fh) = @_; - my $timestamp = ctime(); - my $imageId = getImageId(); - - print $fh <<EOF; -/* - * Automatically generated by src/usr/errl/parser/scanforsrcs.pl - * - * TimeStamp: $timestamp - * Image Id: $imageId - * -*/ - - -/*****************************************************************************/ -// I n c l u d e s -/*****************************************************************************/ -EOF - - # Add the includes - start in src/include/usr - my $startDir = $sandBase."/src/include/usr/*"; - includeReasonCodes( $fh, $startDir, 1 ); - - # Also include reason codes from generated files - $startDir = $sandBase."/obj/genfiles"; - includeReasonCodes( $fh, $startDir, 0 ); - - print $fh <<EOF; - - -/*****************************************************************************/ -// N a m e s p a c e s -/*****************************************************************************/ -EOF - - foreach( values %namespaceList ) - { - my $namespace = $_; - print $fh "using namespace $namespace;\n" - } - - print $fh <<EOF; - - -static void printErrorTags ( ErrlUsrParser & i_parser, - uint64_t i_src, - uint64_t i_modId ) -{ - uint64_t error = (i_src << 8) | i_modId; - - switch( error ) - { -EOF -} - - -################################################################################ -# -# Finish writing main header file -# -################################################################################ - -sub finishMainHeaderFile -{ - my ($fh) = @_; - - print $fh <<EOF; - - default: - uint32_t src = i_src & 0xFFFFFFFF; - uint32_t modId = i_modId & 0xFFFFFFFF; - printf( "\\nThere was not a valid Errorlog tag found for the given error combination!\\n" ); - printf( " Reason: 0x%04x, Module Id: 0x%02x\\n\\n", src, modId ); - break; - - }; -} -EOF -} - - -################################################################################ -# -# Open generated header file -# -################################################################################ - -sub openHeaderFile -{ - my $filename = "$output/hostBootSrcParse.H"; - my $fh; - - if (! -e $output) - { - debugMsg( "Creating directory $output" ); - eval { mkpath($output) }; - - if ($@) - { - die("Couldn't create $output: $@"); - } - } - - if (-e $filename) - { - chmod(0777, $filename); - } - - open($fh, ">$filename") or die("Cannot open $filename: $!"); - return $fh; -} - - -################################################################################ -# -# Write the print statements to the header -# -################################################################################ - -sub writePrintStatement -{ - my ($fh, $compName, $aref) = @_; - my $wordstart = "userdata1"; - my $modId; - my $reasonCode; - my $caseValue; - my $line; - - my %caseHash = (); - - foreach my $href ( @$aref ) - { - # Get the ModId and Reasoncode tags - foreach my $tag ( sort keys %$href ) - { - $href->{$tag} =~ s/\"/\\\"/g; - my @lines = split /^/, $href->{$tag}; - - if( scalar( @lines ) > 1 ) - { - foreach $line( @lines ) - { - $line =~ s/\n//g; - } - } - else - { - $line = $href->{$tag}; - $line =~ s/\n//g; - } - - $line = stripWhitespace( $line ); - if( "moduleid" eq $tag ) - { - $modId = $line; - } - elsif( "reasoncode" eq $tag ) - { - $reasonCode = $line; - } - } - debugMsg( "Comp Name: $compName" ); - debugMsg( "Module Id: $modId" ); - debugMsg( "Reason Code: $reasonCode" ); - - # If we've got a duplicate Module Id/Reason code go, on to the - # next one. We can't have duplicates, so if we do we set found_dup - # so that we can die after this loop - if( exists $caseHash{ $modId.$reasonCode } ) - { - debugMsg( "Hash exists, skip subsequent." ); - - # Print a error message - print "\n#################################################################\n"; - print " ERROR - Duplicate hash found for:\n"; - print " component $compName\n"; - print " module id $modId\n"; - print " reason code $reasonCode\n"; - print "#################################################################\n"; - $found_dup = 1; - next; - } - else - { - $caseHash{ $modId.$reasonCode } = 1; - } - - - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - # - # This check will be used to exclude module Ids which aren't set - # in stone... I think they should be, but ... - # So, as more oddities show up, this will need to be modified - # to accomodate. - # - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - if( ($modId =~ /see/i) && - ($modId =~ /task/i) ) - { - # Move to the next loop if this tag is invalid. - debugMsg( "Invalid Mod Id: $modId" ); - next; - } - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - - print $fh " case \(\($reasonCode \<\< 8\) \| $modId\) \:\n"; - - foreach my $tag ( sort keys %$href ) - { - $href->{$tag} =~ s/\"/\\\"/g; - my $line = $href->{$tag}; - $line =~ s/\n//g; - print $fh " i_parser.PrintString( \"$tag\" \, \"$line\" )\;\n"; - } - print $fh " break;\n\n"; - } -} - - -################################################################################ -# -# find the namespace of the file. -# -################################################################################ - -sub findNameSpace -{ - my ( $file ) = @_; - my $data; - open(FH, "$file") or die("Cannot open: $file: $!"); - read(FH, $data, -s FH) or die("Error reading $file: $!"); - close FH; - - # get the namespace - my $namespace = "VOID"; - while( $data =~ /^namespace(.+?\n)/gm ) - { - $namespace = $1; - $namespace =~ s/\;+$//; # strip trailing semicolon - $namespace =~ s/\{+$//; # strip opening bracket - $namespace = stripWhitespace( $namespace ); - $namespaceList{$namespace} = $namespace; - } - debugMsg( "Namespace: $namespace" ); - debugMsg( " from File: $file" ); -} - - -################################################################################ -# -# Get the Image id -# -################################################################################ -sub getImageId -{ - my $imageId = `git describe --dirty || echo Unknown-Image \`git rev-parse --short HEAD\``; - chomp $imageId; - - if (($imageId =~ m/Unknown-Image/) || # Couldn't find git describe tag. - ($imageId =~ m/dirty/) || # Find 'dirty' commit. - ($imageId =~ m/^.{15}-[1-9]+/)) # Found commits after a tag. - { - $imageId = $imageId."/".$ENV{"USER"}; - } - - return $imageId; -} |

