diff options
author | CamVan Nguyen <ctnguyen@us.ibm.com> | 2012-07-03 12:03:05 -0500 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2012-07-10 13:52:29 -0500 |
commit | 5151c0b22f5d470008e19307e3b11fb848a2d9a5 (patch) | |
tree | ab384c98770665f153bf983513016a9617156367 /src/usr/hwpf/ifcompiler | |
parent | a480d37a977518ff1075fc50d67a97f54663873d (diff) | |
download | blackbird-hostboot-5151c0b22f5d470008e19307e3b11fb848a2d9a5.tar.gz blackbird-hostboot-5151c0b22f5d470008e19307e3b11fb848a2d9a5.zip |
SCOM Initfile: Improve error and debug tracing in the initfile compiler error/debug paths.
Fix miscellaneous bugs.
Change-Id: I9ca5f870a756a6be2924f3d9e1c0750b2ce1e0ab
RTC: 43488
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/1290
Tested-by: Jenkins Server
Reviewed-by: MIKE J. JONES <mjjones@us.ibm.com>
Reviewed-by: Douglas R. Gilbert <dgilbert@us.ibm.com>
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/hwpf/ifcompiler')
-rwxr-xr-x | src/usr/hwpf/ifcompiler/initCompiler.C | 110 | ||||
-rwxr-xr-x | src/usr/hwpf/ifcompiler/initCompiler.H | 53 | ||||
-rwxr-xr-x | src/usr/hwpf/ifcompiler/initCompiler.lex | 108 | ||||
-rwxr-xr-x | src/usr/hwpf/ifcompiler/initCompiler.y | 12 | ||||
-rwxr-xr-x | src/usr/hwpf/ifcompiler/initRpn.C | 49 | ||||
-rwxr-xr-x | src/usr/hwpf/ifcompiler/initRpn.H | 10 | ||||
-rwxr-xr-x | src/usr/hwpf/ifcompiler/initScom.C | 54 | ||||
-rwxr-xr-x | src/usr/hwpf/ifcompiler/initScom.H | 43 | ||||
-rwxr-xr-x | src/usr/hwpf/ifcompiler/initSymbols.C | 65 | ||||
-rwxr-xr-x | src/usr/hwpf/ifcompiler/initSymbols.H | 46 |
10 files changed, 357 insertions, 193 deletions
diff --git a/src/usr/hwpf/ifcompiler/initCompiler.C b/src/usr/hwpf/ifcompiler/initCompiler.C index 36222c0e9..3c672ea3b 100755 --- a/src/usr/hwpf/ifcompiler/initCompiler.C +++ b/src/usr/hwpf/ifcompiler/initCompiler.C @@ -1,17 +1,26 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: /afs/awd/projects/eclipz/KnowledgeBase/.cvsroot/eclipz/ifcompiler/initCompiler.C,v $ -// -// IBM CONFIDENTIAL -// -// COPYRIGHT International Business Machines Corp. 2010,2010 -// -//UNDEFINED -// -// Origin: UNDEFINED -// -// IBM_PROLOG_END_TAG +/* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/usr/hwpf/ifcompiler/initCompiler.C $ + * + * IBM CONFIDENTIAL + * + * COPYRIGHT International Business Machines Corp. 2010-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_TAG + */ // Change Log ************************************************************************************* // // Flag Track Userid Date Description @@ -23,6 +32,7 @@ // andrewg 09/19/11 Updates based on review // mjjones 11/17/11 Output attribute listing // camvanng 04/12/12 Ability to specify search paths for include files +// camvanng 06/27/12 Improve error and debug tracing // End Change Log ********************************************************************************* /** @@ -52,6 +62,8 @@ using namespace std; int yyline = 1; init::ScomList * yyscomlist = NULL; vector<string> yyincludepath; //path to search for include files +vector<string> yyfname; //list of initfile/define files being parsed +string dbg_fname; //file to dump dbg stringstream ostringstream init::dbg; ostringstream init::erros; @@ -100,9 +112,9 @@ int main(int narg, char ** argv) ifstream ifs(initfile.c_str(), ios_base::in | ios_base::binary); if(!ifs) { - string msg("Can't open "); - msg.append(initfile); - throw invalid_argument(msg); + std::ostringstream msg; + msg << "initCompiler.C: main: Could not open " << initfile << endl; + throw invalid_argument(msg.str()); } while(1) { @@ -114,7 +126,7 @@ int main(int narg, char ** argv) yyscomlist->listing(bin_seq, cout); - erros << parsed.get_scomlist()->get_symbols()->not_found_listing(); + erros << yyscomlist->get_symbols()->not_found_listing(); } else // normal initfile processing @@ -127,14 +139,15 @@ int main(int narg, char ** argv) // if there are missing symbols, SpyList::listing() will add duplicates // So get the listing now - erros << parsed.get_scomlist()->get_symbols()->not_found_listing(); + erros << yyscomlist->get_symbols()->not_found_listing(); string if_fn = parsed.binseq_fn(); ofstream ofs(if_fn.c_str(), ios_base::out | ios_base::binary); if(!ofs) { - erros << "ERROR - Could not open" << if_fn << endl; - throw invalid_argument(if_fn); + std::ostringstream msg; + msg << "initCompiler.C: main: Could not open " << if_fn << endl; + throw invalid_argument(msg.str()); } else { @@ -158,12 +171,22 @@ int main(int narg, char ** argv) } - printf("Generate Debug\n"); - parsed.capture_dbg(); + if (parsed.debug_mode()) + { + printf("Generate Debug\n"); + capture_dbg(dbg_fname); + } //if(parsed.debug_mode()) cout << dbg.str() << endl; } catch(exception & e) { + //Dump dbg stringstream to file + capture_dbg(dbg_fname); + + //Dump current stats + stats << "*********************************************************\n"; + cerr << stats.str() << endl; + cerr << "ERROR! exception caught: " << e.what() << endl; rc = 2; } @@ -215,7 +238,14 @@ Parser::Parser(int narg, char ** argv) else if (arg.compare(0,7,"--debug") == 0) iv_dbg = true; } - if(iv_source_path.size() == 0) iv_source_path = compare.first; + if(iv_source_path.size() == 0) + { + iv_source_path = compare.first; + } + else + { + yyfname.push_back(iv_source_path); + } if(!narg) // TEST MODE { @@ -250,6 +280,8 @@ Parser::Parser(int narg, char ** argv) iv_outfile.insert(0,iv_outdir); + dbg_fname = dbg_fn(); + stats << "*********************************************************" << endl; stats << "* source: " << iv_source_path << endl; stats << "* listing: " << listing_fn() << endl; @@ -283,13 +315,17 @@ Parser::Parser(int narg, char ** argv) iv_list_ostream.open(listing_fn().c_str()); if(!iv_list_ostream) { - throw invalid_argument(string("ERROR! Could not open ") + listing_fn()); + std::ostringstream msg; + msg << "initCompiler.C: Parser: Could not open " << listing_fn() << endl; + throw invalid_argument(msg.str()); } iv_attr_list_ostream.open(attr_listing_fn().c_str()); if(!iv_attr_list_ostream) { - throw invalid_argument(string("ERROR! Could not open ") + attr_listing_fn()); + std::ostringstream msg; + msg << "initCompiler.C: Parser: Could not open " << attr_listing_fn() << endl; + throw invalid_argument(msg.str()); } } @@ -299,23 +335,17 @@ Parser::~Parser() iv_attr_list_ostream.close(); } -void Parser::capture_dbg() +void init::capture_dbg(string i_fname) { - if(iv_dbg) + ofstream dbgfs(i_fname.c_str()); + if(!dbgfs) { - string fname(iv_outdir); - fname.append(iv_initfile); - fname.append(".dbg"); - ofstream dbgfs(fname.c_str()); - if(!dbgfs) - { - string msg("Can't open "); - msg.append(fname); - throw invalid_argument(msg); - } - dbgfs << dbg.str() << endl; - dbgfs.close(); + std::ostringstream msg; + msg << "initCompiler.C: capture_dbg: Could not open " << i_fname << endl; + throw invalid_argument(msg.str()); } + dbgfs << dbg.str() << endl; + dbgfs.close(); } // TODO diff --git a/src/usr/hwpf/ifcompiler/initCompiler.H b/src/usr/hwpf/ifcompiler/initCompiler.H index afd804d01..bcda184c0 100755 --- a/src/usr/hwpf/ifcompiler/initCompiler.H +++ b/src/usr/hwpf/ifcompiler/initCompiler.H @@ -1,17 +1,26 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: /afs/awd/projects/eclipz/KnowledgeBase/.cvsroot/eclipz/ifcompiler/initCompiler.H,v $ -// -// IBM CONFIDENTIAL -// -// COPYRIGHT International Business Machines Corp. 2010,2010 -// -//UNDEFINED -// -// Origin: UNDEFINED -// -// IBM_PROLOG_END_TAG +/* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/usr/hwpf/ifcompiler/initCompiler.H $ + * + * IBM CONFIDENTIAL + * + * COPYRIGHT International Business Machines Corp. 2010-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_TAG + */ #if !defined(INITCOMPILER_H) #define INITCOMPILER_H @@ -26,6 +35,7 @@ // andrewg 09/19/11 Updates based on review // mjjones 11/17/11 Output attribute listing // camvanng 04/12/12 Ability to specify search paths for include files +// camvanng 06/27/12 Improve error and debug tracing // End Change Log ********************************************************************************* /** @@ -50,6 +60,8 @@ extern int yyparse(); void yyerror(const char * s); extern init::ScomList * yyscomlist; extern vector<string> yyincludepath; +extern vector<string> yyfname; +extern string dbg_fname; namespace init { @@ -59,6 +71,12 @@ namespace init extern ostringstream erros; // error output stream extern ostringstream stats; // Misc info to be displayed + /** + * Dump the dbg stringstream to a file + * @param i_fname file to dump dbg stringstream + */ + void capture_dbg(string i_fname); + class Parser @@ -79,16 +97,17 @@ namespace init string source_fn() { return iv_source_path; } string binseq_fn() { return iv_outfile; } //dg003a //{ string s(iv_outdir); s.append(iv_initfile); s.append(".if"); return s; } //dg003d + + // File to dump dbg stringstream + string dbg_fn() {string fname(iv_outdir); fname += iv_initfile + ".dbg"; return fname; } + uint32_t get_source_type() { return iv_type; } ostream & listing_ostream() { return iv_list_ostream; } ostream & attr_listing_ostream() { return iv_attr_list_ostream; } - ScomList * get_scomlist() { return iv_scomlist; } // TODO refactor this out bool debug_mode() { return iv_dbg; } - void capture_dbg(); // if iv_dbg then dump the dbg stringstream to a file - private: string iv_prog_name; string iv_source_path; diff --git a/src/usr/hwpf/ifcompiler/initCompiler.lex b/src/usr/hwpf/ifcompiler/initCompiler.lex index a9b7e5bb3..6cd160aba 100755 --- a/src/usr/hwpf/ifcompiler/initCompiler.lex +++ b/src/usr/hwpf/ifcompiler/initCompiler.lex @@ -45,6 +45,7 @@ // camvanng 05/22/12 Fix "OP" definition // camvanng 06/11/12 Fix shift/reduce warnings from yacc // camvanng 06/15/12 Ability to do bitwise OR and AND operations +// camvanng 06/27/12 Improve error handling // End Change Log *********************************************************************************/ /** * @file initCompiler.lex @@ -85,7 +86,6 @@ uint32_t g_coltype = 0; uint32_t g_scomtype = 0; uint32_t g_paren_level = 0; bool g_equation = false; // equation inside scomv col -std::string g_scomname; // dg02 std::string g_scomdef_name; std::map<std::string,std::string> g_defines; //container for all the defines //i.e. define def_A = (attrA > 1) => key = "DEF_A", value = "(attr_A > 1)" @@ -102,6 +102,8 @@ YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH]; int yyline_stack[MAX_INCLUDE_DEPTH]; int include_stack_num = 0; +extern std::vector<std::string> yyfname; + %} @@ -110,7 +112,7 @@ int include_stack_num = 0; NEWLINE \n FILENAME [A-Za-z][A-Za-z0-9_\.]* ID [A-Za-z][A-Za-z0-9_]* -ID2 [A-Za-z][A-Za-z0-9_]*(\[[0-9]+(..[0-9]+)?(,[0-9]+(..[0-9]+)?)*\]){0,4} +ID2 [A-Za-z][A-Za-z0-9_]*(\[[0-9]+(\.\.[0-9]+)?(,[0-9]+(\.\.[0-9]+)?)*\]){0,4} ID3 [0-9]+[A-Za-z_]+[0-9]* DIGIT [0-9] COMMENT #.*\n @@ -123,6 +125,7 @@ HEX 0[xX][A-Fa-f0-9]+ SINGLE_HEX [A-Fa-f0-9] ATTRIBUTE [\[[A-Fa-f0-9]\]] MULTI_DIGIT [0-9]+ +MULTI_INDEX_RANGE [0-9]+(\.\.[0-9]+)?(,[0-9]+(\.\.[0-9]+)?)* %x scomop %x scomop_hex @@ -165,6 +168,7 @@ MULTI_DIGIT [0-9]+ fclose(yyin); yy_switch_to_buffer(include_stack[include_stack_num]); yyline = yyline_stack[include_stack_num]; + yyfname.pop_back(); } } @@ -190,7 +194,8 @@ include { BEGIN(incl); } /*printf("lex: include file %s\n", yytext);*/ if ( include_stack_num >= MAX_INCLUDE_DEPTH ) { - lex_err("Includes nested too deeply"); + lex_err("Include nested too deeply"); + lex_err(yytext); exit( 1 ); } @@ -213,12 +218,13 @@ include { BEGIN(incl); } if (NULL == yyin) { oss.str(""); - oss << "Cannot open file: " << yytext; + oss << "Cannot open include file: " << yytext; lex_err(oss.str().c_str()); exit(1); } printf("Include file %s\n", filename.c_str()); yyline = 1; //set line number for new buffer + yyfname.push_back(filename); //save file name of new file being parsed yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); BEGIN(INITIAL); @@ -349,7 +355,7 @@ scom { BEGIN(scomop); oss.str(""); return INIT_SCOM; } <scomcolname>{COMMENT} ++yyline; <scomcolname>\n ++yyline; -<scomcolname>{ID2} { +<scomcolname>{ID} { // Only non-array attributes are supported for attribute column g_colstream.push_back(new std::ostringstream()); *(g_colstream.back()) << yytext; } @@ -360,7 +366,14 @@ scom { BEGIN(scomop); oss.str(""); return INIT_SCOM; } <scomrow>{NEWLINE} ++yyline; <scomrow>([^,;\n#\{\}]+{ID2}*)+ push_col(yytext); <scomrow>[,] ++g_scomcol; -<scomrow>[;] g_scomcol = 0; +<scomrow>[;] { + if ((g_scomcol + 1) < g_colstream.size()) + { + lex_err("# Scom columns < # of column headers"); + exit(1); + } + g_scomcol = 0; + } <scomrow>[\}] { pushBackScomBody(); // create new format and put it back on yyin BEGIN(INITIAL); @@ -446,14 +459,19 @@ END_INITFILE return INIT_ENDINITFILE; <*>[\(] { ++g_paren_level; return yytext[0]; } <*>[\)] { --g_paren_level; return yytext[0]; } -<*>\[({MULTI_DIGIT}[,.]*)+\] { yylval.str_ptr = new std::string(yytext); return ATTRIBUTE_INDEX; } +<*>\[{MULTI_INDEX_RANGE}\] { yylval.str_ptr = new std::string(yytext); return ATTRIBUTE_INDEX; } -<*>[\[\]\{\},:] {g_equation = false; return yytext[0]; } +<*>[\{\},:] {g_equation = false; return yytext[0]; } <*>[ \t\r]+ /* Eat up whitespace */ [\n] { BEGIN(INITIAL);++yyline;} -<*>. lex_err(yytext); +<*>. { + oss.str(""); + oss << yytext << " is not valid syntax"; + lex_err(oss.str().c_str()); + exit(1); + } %% @@ -461,7 +479,8 @@ int yywrap() { return 1; } void lex_err(const char *s ) { - std::cerr << "\nERROR: lex: " << s << " -line " << yyline << std::endl; + std::cerr << "\nERROR: lex: " << yyfname.back().c_str() + << ", line " << yyline << ": " << s << std::endl << std::endl; } // Convert left justified bitstring to right-justified 64 bit integer @@ -470,32 +489,36 @@ uint64_t bits2int( const char * bitString) uint32_t idx = 0; uint64_t mask = 0x0000000000000001ull; uint64_t val = 0; - do + + if( (bitString[0] != '0') || + ((bitString[1] != 'b') && (bitString[1] != 'B'))) { - if( (bitString[0] != '0') || - ((bitString[1] != 'b') && (bitString[1] != 'B'))) - { - lex_err("Invalid bit string"); - break; - } - idx = 2; - - while( bitString[idx] != 0 ) - { - val <<= 1; - char c = bitString[idx]; - if( c == '1') val |= mask; - else if(c != '0') - { - lex_err("Invalid bit string"); - break; - } - ++idx; - } - if(idx > 66) //dg01a 64bits + "0B" prefix - lex_err("Bit string greater than 64 bits!"); - - } while (0); + lex_err("Invalid bit string"); + lex_err(bitString); + exit(1); + } + idx = 2; + + while( bitString[idx] != 0 ) + { + val <<= 1; + char c = bitString[idx]; + if( c == '1') val |= mask; + else if(c != '0') + { + lex_err("Invalid bit string"); + lex_err(bitString); + exit(1); + } + ++idx; + } + if(idx > 66) //dg01a 64bits + "0B" prefix + { + lex_err("Bit string greater than 64 bits!"); + lex_err(bitString); + exit(1); + } + return val; } @@ -507,7 +530,8 @@ uint64_t hexs2int(const char * hexString, int32_t size) if(size > 18) //dg01a { lex_err("HEX literal greater than 64 bits"); - size = 18; + lex_err(hexString); + exit(1); } s.insert(2, 18-size,'0'); // 0x + 16 digits val = strtoull(s.c_str(),NULL,16); @@ -541,17 +565,11 @@ void pushBackScomBody() /// help collect column data void push_col(const char * s) { - //dg02a begin - while(g_scomcol >= g_colstream.size()) // more data cols than headers cols + if(g_scomcol >= g_colstream.size()) // more data cols than headers cols { - // This will force an error in the parser where it can stop the compile. - g_colstream.push_back(new std::ostringstream()); - *(g_colstream.back()) << "MISSING_COLUMN_HEADER"; - lex_err(g_scomname.c_str()); - lex_err("Invalid number of scom cols"); + lex_err("Missing column header"); + exit(1); } - //dgxxa end - //dgxxd remove if(g_colstream < g_colstream.size() std::ostringstream & o = *(g_colstream[g_scomcol]); std::ostringstream token; diff --git a/src/usr/hwpf/ifcompiler/initCompiler.y b/src/usr/hwpf/ifcompiler/initCompiler.y index 39254c2b3..8085cf666 100755 --- a/src/usr/hwpf/ifcompiler/initCompiler.y +++ b/src/usr/hwpf/ifcompiler/initCompiler.y @@ -42,6 +42,7 @@ // camvanng 06/11/12 Ability to do logical operations with attribute columns // Fix shift/reduce warnings from yacc // camvanng 06/15/12 Ability to do bitwise OR and AND operations +// camvanng 06/27/12 Improve error and debug tracing // End Change Log ********************************************************************************* /** * @file initCompiler.y @@ -178,6 +179,7 @@ scom: INIT_SCOM {current_scom = new init::Scom(yyscomlist->get_symbols(),y /* printf("Found an INIT_SCOM!\n"); */ /* current_scom = new init::Scom(yyscomlist->get_symbols(),yyline); */ yyscomlist->insert(current_scom); + init::dbg << current_scom->addr_listing() << std::endl; } ; @@ -344,13 +346,17 @@ expr: INIT_INTEGER { $$= new init::Rpn($1,yyscomlist->get_s void yyerror(const char * s) { + //dump dbg stringstream to file + init::capture_dbg(dbg_fname); + init::erros << setfill('-') << setw(80) << '-' << endl; init::erros << setfill('0'); - init::erros << "Parse Error line " << dec << setw(4) << yyline << ": yychar = " - << dec << (uint32_t) yychar << " [0x" << hex << (uint32_t) yychar << "] '"; + init::erros << "Parse Error: " << yyfname.back().c_str() << ", line " + << dec << setw(4) << yyline << ": yychar = " + << dec << (uint32_t) yychar << " = 0x" << hex << (uint32_t) yychar << " = '"; if(isprint(yychar)) init::erros << (char)yychar; else init::erros << ' '; - init::erros << "' yylval = " << hex << "0x" << setw(8) << yylval.integer << endl; + init::erros << "' yylval = " << hex << "0x" << setw(16) << yylval.uint64 << endl; init::erros << "ERROR: " << s << endl; init::erros << setfill('-') << setw(80) << '-' << endl << endl; diff --git a/src/usr/hwpf/ifcompiler/initRpn.C b/src/usr/hwpf/ifcompiler/initRpn.C index 75558428d..2e7df691c 100755 --- a/src/usr/hwpf/ifcompiler/initRpn.C +++ b/src/usr/hwpf/ifcompiler/initRpn.C @@ -42,6 +42,7 @@ // in the scom_data column // SW146714 camvanng 06/08/12 Use two bytes to store row rpn sequence byte count // camvanng 06/15/12 Ability to do bitwise OR and AND operations +// camvanng 06/27/12 Improve error and debug tracing // End Change Log ********************************************************************************* /** @@ -221,7 +222,7 @@ void Rpn::push_id(std::string & i_id, TYPE i_type) else { std::ostringstream oss; - oss << "Invalid associated target attribute " << i_id.c_str(); + oss << "Rpn::push_id: Invalid associated target attribute " << i_id.c_str(); yyerror(oss.str().c_str()); } } @@ -264,7 +265,8 @@ void Rpn::push_array_index(std::string &i_array_idx) if (l_array_val >= l_array_val2) { std::ostringstream oss; - oss << "Invalid attribute array index range: " << l_idxstr.at(i); + oss << "Rpn::push_array_index: Invalid attribute array index range: " + << l_idxstr.at(i); yyerror(oss.str().c_str()); } @@ -293,9 +295,9 @@ void Rpn::push_array_index(std::string &i_array_idx) if (iv_array_idx_range.back() != l_num_idx) { std::ostringstream oss; - oss << "Array attribute has different range of index for each dimension: " - << i_array_idx << " iv_array_idx_range: " << iv_array_idx_range.back() - << " l_num_idx: " << l_num_idx; + oss << "Rpn::push_array_index: Array attribute has different range of index " + << "for each dimension: " << i_array_idx << " iv_array_idx_range: " + << iv_array_idx_range.back() << " l_num_idx: " << l_num_idx; yyerror(oss.str().c_str()); } } @@ -308,17 +310,6 @@ void Rpn::push_array_index(std::string &i_array_idx) } //------------------------------------------------------------------------------------------------- -void Rpn::push_attr_enum(std::string &i_attr_enum) -{ - uint64_t l_attr_enum_val = iv_symbols->get_attr_enum_val(i_attr_enum); - - uint32_t rpn_id = iv_symbols->find_numeric_lit(l_attr_enum_val,8); - iv_rpnstack.push_back(rpn_id); - - //printf("Attribute Enum name: %s Value:%u rpn_id:0x%8X\n",i_attr_enum.c_str(),l_attr_enum_val,rpn_id); -} - -//------------------------------------------------------------------------------------------------- bool Rpn::isTrue() const //dg003a { @@ -683,7 +674,7 @@ void Rpn::bin_read_one_id(BINSEQ::const_iterator & io_bli, Symbols * i_symbols) if(v < LAST_OP) // operator { std::ostringstream errss; - errss << "Rpn::bin_read_one_id: This is an op\n"; + errss << "Rpn::bin_read_one_id: This is an op 0x" << hex << v << endl; throw std::invalid_argument(errss.str()); } @@ -797,6 +788,23 @@ std::string Rpn::listing(const char * i_desc, const std::string & spyname, bool oss << "0x" << std::setw(size * 2) << data << '\t' << "Numerical Literal" << std::endl; } } + else if((*i) & ARRAY_INDEX) + { + uint32_t size = 0; + uint64_t data = iv_symbols->get_numeric_array_data(*i,size); + if(i_final) + { + uint32_t tag = iv_symbols->get_numeric_array_tag(*i); + rpn_byte_size += 2; + oss << "0x" << std::setw(4) << tag << "\t\t" << "PUSH 0x" + << std::setw(size*2) << data << std::endl; + } + else + { + rpn_byte_size += size; + oss << "0x" << std::setw(size * 2) << data << '\t' << "Numerical Literal (array index)" << std::endl; + } + } else if((*i) & SYMBOL) { std::string name = iv_symbols->find_name(*i); @@ -924,7 +932,8 @@ void Rpn::bin_str(BINSEQ & o_blist, uint32_t i_num_addrs, uint32_t i_addr_num, if ((v & TYPE_MASK) != ARRAY_INDEX) { std::ostringstream errss; - errss << "Rpn::bin_str: Rpn is not array index " << endl; + errss << "Rpn::bin_str: Rpn 0x" << hex << v + << " is not array index " << endl; throw std::invalid_argument(errss.str()); } } @@ -939,7 +948,9 @@ void Rpn::bin_str(BINSEQ & o_blist, uint32_t i_num_addrs, uint32_t i_addr_num, break; default: - std::cerr << "ERROR! Rpn::bit_str() Invalid Rpn type: " << v << std::endl; + std::ostringstream errss; + errss << "Rpn::bin_str: Invalid Rpn type: 0x" << hex << v << endl; + throw std::invalid_argument(errss.str()); break; } } diff --git a/src/usr/hwpf/ifcompiler/initRpn.H b/src/usr/hwpf/ifcompiler/initRpn.H index 5f6fddd32..3d3f4eed9 100755 --- a/src/usr/hwpf/ifcompiler/initRpn.H +++ b/src/usr/hwpf/ifcompiler/initRpn.H @@ -39,6 +39,7 @@ // camvanng 05/22/12 Ability to do simple operations on attributes // in the scom_data column // SW146714 camvanng 06/08/12 Use two bytes to store row rpn sequence byte count +// camvanng 06/27/12 Delete push_attr_enum() // End Change Log ********************************************************************************* /** @@ -124,15 +125,6 @@ namespace init */ void push_array_index(std::string &i_array_idx); - /** - * @brief Add an attribute enum - * - * @param[in] i_attr_enum attribute enum name - * - * @return Void - */ - void push_attr_enum(std::string &i_attr_enum); - Rpn * push_op(IfRpnOp op); //<<< Add an operation to the Rpn sequence /** diff --git a/src/usr/hwpf/ifcompiler/initScom.C b/src/usr/hwpf/ifcompiler/initScom.C index 5e60a5fcd..8cb691a97 100755 --- a/src/usr/hwpf/ifcompiler/initScom.C +++ b/src/usr/hwpf/ifcompiler/initScom.C @@ -45,6 +45,7 @@ // in the scom_data column // SW146714 camvanng 06/08/12 Use two bytes to store row rpn sequence byte count // Handle case where after row_optimize(), there's no Scom to write +// camvanng 06/27/12 Improve error and debug tracing // End Change Log ********************************************************************************* /** @@ -110,7 +111,8 @@ Scom::Scom(BINSEQ::const_iterator & bli, Symbols * i_symbols): else // What's this? { ostringstream errs; - errs << "ERROR: Invalid scom bit length [" << iv_scom_length << "]" << endl; + errs << "ERROR: Scom::Scom: Invalid scom bit length [" + << iv_scom_length << "]" << endl; throw range_error(errs.str()); } } @@ -230,11 +232,11 @@ void Scom::add_col(const string & i_colname) { if (s == "EXPR") { - yyerror("Multiple EXPR columns specified."); + yyerror("Scom:: add_col: Multiple EXPR columns specified."); } else { - yyerror("EXPR must be the last column"); + yyerror("Scom:: add_col: EXPR must be the last column"); } } } @@ -276,7 +278,7 @@ void Scom::add_row_rpn(Rpn * i_rpn) void Scom::add_bit_range(uint32_t start, uint32_t end) { // make sure they are added in order - dbg << "Add bit range " << start << " to " << end << endl; + dbg << "Add bit range " << dec << start << " to " << end << endl; iv_range_list.push_back(RANGE(start,end)); } @@ -357,6 +359,7 @@ string Scom::list_one(RANGE range) oss << hex << setfill('0'); oss << "------------"; oss << " Scom Address: 0x" << setw(16) << iv_scom_addr_hex; + dbg << " Scom Address: 0x" << hex << setfill('0') << setw(16) << iv_scom_addr_hex << endl; if(bitlen) { oss << '~' << dec << range.first; @@ -486,7 +489,8 @@ uint32_t Scom::bin_listing(BINSEQ & blist) for(; i != iv_scom_addr.end(); ++i, ++addr_num) { - //printf("scom address:%s\n",(*i).c_str()); + dbg << "SCOM::bin_listing: SCOM[" << dec << scom_count << "] Address: " + << hex << *i << endl; if(ranges.size()) { for(set<RANGE>::iterator r = ranges.begin(); r != ranges.end(); ++r) @@ -895,7 +899,7 @@ ScomList::ScomList(const string & initfile, FILELIST & defines, ostream & stats, yyin = fopen(initfile.c_str(), "r"); if(!yyin) { - string ers("ERROR: Could not open initfile: "); + string ers("ERROR: ScomList::ScomList: Could not open initfile: "); ers.append(initfile); throw invalid_argument(ers); } @@ -1037,7 +1041,7 @@ void ScomList::clear() void ScomList::set_syntax_version(uint32_t v) { - if(v != 1 && v != 2) yyerror("Invalid Syntax Version"); + if(v != 1 && v != 2) yyerror("ScomList:: set_syntax_version: Invalid Syntax Version"); iv_syntax_version = v; } @@ -1097,12 +1101,12 @@ void ScomList::compile(BINSEQ & bin_seq) } else { - throw range_error("ERROR: No CVS version(s) specified"); + throw range_error("ERROR: ScomList::compile: No CVS version(s) specified"); } } else // syntax version already validated to be 1 or 2 - so if we get here it was never set. { - throw range_error("ERROR: No syntax version specified!"); + throw range_error("ERROR: ScomList::compile: No syntax version specified!"); } stats << '*' << setw(20) << "Syntax Version:" << setw(6) << iv_syntax_version << endl; @@ -1288,7 +1292,7 @@ void ScomList::listing(BINSEQ & bin_seq,ostream & olist) b = bin_seq.begin() + offset; if(!(b < bin_seq.end())) { - throw overflow_error("ERROR: ScomList::listing - iterator overflowed sequence"); + throw overflow_error("ERROR: ScomList::listing: iterator overflowed sequence"); } SCOM_LIST l_scom_list; @@ -1458,7 +1462,7 @@ void Scom::set_scom_address(const string & i_scom_addr) if(iv_scom_addr.size()) { - yyerror("SCOM Address already set!"); + yyerror("Scom::set_scom_address: SCOM Address already set!"); } else { @@ -1485,7 +1489,7 @@ void Scom::dup_scom_address(const string & i_scom_addr) if (l_num1 >= l_num2) { std::ostringstream oss; - oss << "Invalid scom address range: " << i_scom_addr; + oss << "Scom::dup_scom_address: Invalid scom address range: " << i_scom_addr; yyerror(oss.str().c_str()); } @@ -1559,7 +1563,7 @@ void Scom::set_scom_suffix(const string & i_scom_addr) if(iv_scom_addr.size() == 0) { std::ostringstream oss; - oss << "No base scom address to append suffix " << i_scom_addr; + oss << "Scom::set_scom_suffix: No base scom address to append suffix " << i_scom_addr; yyerror(oss.str().c_str()); } else @@ -1583,7 +1587,7 @@ void Scom::set_scom_address_bin(const string & i_scom_addr) if(iv_scom_addr_bin.size()) { - yyerror("Binary SCOM Address already set!"); + yyerror("Scom::set_scom_address_bin: Binary SCOM Address already set!"); } else { @@ -1610,7 +1614,8 @@ void Scom::dup_scom_address_bin(const string & i_scom_addr) if (l_num1 >= l_num2) { std::ostringstream oss; - oss << "Invalid binary scom address range: " << i_scom_addr; + oss << "Scom::dup_scom_address_bin: Invalid binary scom address range: " + << i_scom_addr; yyerror(oss.str().c_str()); } @@ -1684,7 +1689,8 @@ void Scom::set_scom_suffix_bin(const string & i_scom_addr) if(iv_scom_addr_bin.size() == 0) { std::ostringstream oss; - oss << "No base binary scom address to append suffix " << i_scom_addr; + oss << "Scom::set_scom_suffix_bin: No base binary scom address to append suffix " + << i_scom_addr; yyerror(oss.str().c_str()); } else @@ -1707,7 +1713,8 @@ void Scom::append_scom_address_bin() if (0 != (iv_scom_addr_bin.at(i).size() % 4)) { std::ostringstream oss; - oss << "Binary scom address " << iv_scom_addr_bin.at(i) << " is a partial hex!"; + oss << "Scom::append_scom_address_bin: Binary scom address " + << iv_scom_addr_bin.at(i) << " is a partial hex!"; yyerror(oss.str().c_str()); break; } @@ -1755,3 +1762,16 @@ string Scom::dec2binString(uint64_t i_num, size_t i_str_size) return string(l_buf + l_idx, l_buf + l_size); } +string Scom::addr_listing() +{ + std::stringstream l_ss; + l_ss << "\t\t\tSCOM Addresses" << endl; + //l_ss << std::hex << std::setfill('0'); + + for (size_t i = 0; i < iv_scom_addr.size(); i++) + { + //l_ss << "0x" << std::setw(16) << op_id << "\t\t" << OP_TXT[op_id] << std::endl; + l_ss << iv_scom_addr.at(i) << endl; + } + return l_ss.str(); +} diff --git a/src/usr/hwpf/ifcompiler/initScom.H b/src/usr/hwpf/ifcompiler/initScom.H index 8a19b6844..db899a5ef 100755 --- a/src/usr/hwpf/ifcompiler/initScom.H +++ b/src/usr/hwpf/ifcompiler/initScom.H @@ -1,17 +1,26 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: /afs/awd/projects/eclipz/KnowledgeBase/.cvsroot/eclipz/ifcompiler/initScom.H,v $ -// -// IBM CONFIDENTIAL -// -// COPYRIGHT International Business Machines Corp. 2010,2010 -// -//UNDEFINED -// -// Origin: UNDEFINED -// -// IBM_PROLOG_END_TAG +/* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/usr/hwpf/ifcompiler/initScom.H $ + * + * IBM CONFIDENTIAL + * + * COPYRIGHT International Business Machines Corp. 2010-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_TAG + */ #if !defined(INITSPY_H) #define INITSPY_H @@ -33,6 +42,7 @@ // camvanng 04/16/12 Support defines for SCOM address // Support defines for bits, scom_data and attribute columns // Delete obsolete code for defines support +// camvanng 06/27/12 Improve error and debug tracing // End Change Log ********************************************************************************* /** @@ -223,6 +233,11 @@ namespace init */ string dec2binString(uint64_t i_num, size_t i_str_size); + /** + * @brief Return scom address strings + */ + string addr_listing(); + private: // functions string list_one(RANGE range); diff --git a/src/usr/hwpf/ifcompiler/initSymbols.C b/src/usr/hwpf/ifcompiler/initSymbols.C index 3a14f0fe0..7967c06d3 100755 --- a/src/usr/hwpf/ifcompiler/initSymbols.C +++ b/src/usr/hwpf/ifcompiler/initSymbols.C @@ -1,17 +1,26 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: /afs/awd/projects/eclipz/KnowledgeBase/.cvsroot/eclipz/ifcompiler/initSymbols.C,v $ -// -// IBM CONFIDENTIAL -// -// COPYRIGHT International Business Machines Corp. 2010,2010 -// -//UNDEFINED -// -// Origin: UNDEFINED -// -// IBM_PROLOG_END_TAG +/* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/usr/hwpf/ifcompiler/initSymbols.C $ + * + * IBM CONFIDENTIAL + * + * COPYRIGHT International Business Machines Corp. 2010-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_TAG + */ // Change Log ************************************************************************************* // // Flag Track Userid Date Description @@ -29,6 +38,8 @@ // Support defines for bits, scom_data and attribute columns // Delete obsolete code for defines support // camvanng 05/07/12 Support for associated target attributes +// camvanng 06/27/12 Improve error and debug tracing +// Add get_numeric_array_data() // End Change Log ********************************************************************************* /** @@ -67,7 +78,8 @@ Symbols::Symbols(FILELIST & i_filenames) if(!infs) { errss.str(""); - errss << "ERROR - Could not open " << *fn; + errss << "ERROR! Symbols::Symbols: Could not open " + << *fn << endl; throw invalid_argument(errss.str()); } while(getline(infs,fileline)) @@ -575,6 +587,29 @@ uint64_t Symbols::get_numeric_data(uint32_t i_rpn_id, uint32_t & o_size) } // ------------------------------------------------------------------------------------------------ + +uint64_t Symbols::get_numeric_array_data(uint32_t i_rpn_id, uint32_t & o_size) +{ + uint64_t data = 0; + o_size = 0; + uint32_t offset = i_rpn_id - Rpn::ARRAY_INDEX; + if(offset < iv_lits.size()) + { + LIT_DATA d = iv_lits[offset]; + data = d.first; + o_size = d.second; + } + else + { + ostringstream err; + err << hex; + err << "ERROR! - Symbols::get_numeric_array_data() invalid arg rpn_id = " << i_rpn_id << endl; + throw invalid_argument(err.str()); + } + return data; +} + +// ------------------------------------------------------------------------------------------------ uint64_t Symbols::get_attr_enum_val(string & i_attr_enum) { return iv_attr_enum[i_attr_enum]; diff --git a/src/usr/hwpf/ifcompiler/initSymbols.H b/src/usr/hwpf/ifcompiler/initSymbols.H index 92bd518ee..fcb527e3e 100755 --- a/src/usr/hwpf/ifcompiler/initSymbols.H +++ b/src/usr/hwpf/ifcompiler/initSymbols.H @@ -1,17 +1,26 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: /afs/awd/projects/eclipz/KnowledgeBase/.cvsroot/eclipz/ifcompiler/initSymbols.H,v $ -// -// IBM CONFIDENTIAL -// -// COPYRIGHT International Business Machines Corp. 2010,2010 -// -//UNDEFINED -// -// Origin: UNDEFINED -// -// IBM_PROLOG_END_TAG +/* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/usr/hwpf/ifcompiler/initSymbols.H $ + * + * IBM CONFIDENTIAL + * + * COPYRIGHT International Business Machines Corp. 2010-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_TAG + */ #if !defined(INITSYMBOLS_H) #define INITSYMBOLS_H @@ -30,6 +39,7 @@ // Support defines for bits, scom_data and attribute columns // Delete obsolete code for defines support // camvanng 05/07/12 Support for associated target attributes +// camvanng 06/27/12 Add get_numeric_array_data() // End Change Log ********************************************************************************* /** @@ -159,6 +169,14 @@ namespace init uint64_t get_numeric_data(uint32_t i_rpn_id, uint32_t & o_size); /** + * Get the literal data value from the Rpn id returned by find_numeric_array_lit() + * @param uint32_t Rpn id + * @param uint32_t for returned byte size + * @returns uint64_t data + */ + uint64_t get_numeric_array_data(uint32_t i_rpn_id, uint32_t & o_size); + + /** * Get the attribute enum value for the attr enum * @param string attribute enum name * @returns uint64_t value |