# line 2 "../../../common/mdb/mdb_grammar.y" /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END * */ /* * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #pragma ident "%Z%%M% %I% %E% SMI" #include #include #include #include #include #include #include #include #include /* * Utility routines to fetch values from the target's virtual address space * and object file, respectively. These are called from the handlers for * the * /.../ and % /.../ code below. */ static void vfetch(void *buf, size_t nbytes, uintptr_t addr) { if (mdb_tgt_vread(mdb.m_target, buf, nbytes, addr) != nbytes) yyperror("failed to read from address %p", addr); } static void ffetch(void *buf, size_t nbytes, uintptr_t addr) { if (mdb_tgt_fread(mdb.m_target, buf, nbytes, addr) != nbytes) yyperror("failed to read from address %p", addr); } /* * Because we define YYMAXDEPTH as zero below, we have to provide a YYEXPAND() * function to expand our yys and yyv variables. For simplicity, we currently * define these structures statically; a more complex solution can be defined if * it is ever needed. If we return 'val', yacc assumes resize has failed. */ static int yyexpand(int val) { return (val ? val : YYMAXDEPTH); } #define YYEXPAND yyexpand /* * This will cause the rest of the yacc code to assume that yys and yyv are * pointers, not static arrays. */ #undef YYMAXDEPTH #define YYMAXDEPTH 0 # line 81 "../../../common/mdb/mdb_grammar.y" typedef union #ifdef __cplusplus YYSTYPE #endif { char *l_string; char l_char; uintmax_t l_immediate; mdb_var_t *l_var; mdb_idcmd_t *l_dcmd; } YYSTYPE; # define MDB_TOK_SYMBOL 257 # define MDB_TOK_STRING 258 # define MDB_TOK_CHAR 259 # define MDB_TOK_IMMEDIATE 260 # define MDB_TOK_DCMD 261 # define MDB_TOK_VAR_REF 262 # define MDB_TOK_LEXPR 263 # define MDB_TOK_REXPR 264 # define MDB_TOK_COR1_DEREF 265 # define MDB_TOK_COR2_DEREF 266 # define MDB_TOK_COR4_DEREF 267 # define MDB_TOK_COR8_DEREF 268 # define MDB_TOK_OBJ1_DEREF 269 # define MDB_TOK_OBJ2_DEREF 270 # define MDB_TOK_OBJ4_DEREF 271 # define MDB_TOK_OBJ8_DEREF 272 # define MDB_TOK_EQUAL 273 # define MDB_TOK_NOTEQUAL 274 # define MDB_TOK_LSHIFT 275 # define MDB_TOK_RSHIFT 276 # define MDB_COR_VALUE 277 # define MDB_OBJ_VALUE 278 # define MDB_INT_NEGATE 279 # define MDB_BIT_COMPLEMENT 280 # define MDB_LOG_NEGATE 281 # define MDB_VAR_REFERENCE 282 #include #ifdef __STDC__ #include #include #define YYCONST const #else #include #include #define YYCONST #endif #include #if defined(__cplusplus) || defined(__STDC__) #if defined(__cplusplus) && defined(__EXTERN_C__) extern "C" { #endif #ifndef yyerror #if defined(__cplusplus) void yyerror(YYCONST char *); #endif #endif #ifndef yylex int yylex(void); #endif int yyparse(void); #if defined(__cplusplus) && defined(__EXTERN_C__) } #endif #endif #define yyclearin yychar = -1 #define yyerrok yyerrflag = 0 extern int yychar; extern int yyerrflag; YYSTYPE yylval; YYSTYPE yyval; typedef int yytabelem; #ifndef YYMAXDEPTH #define YYMAXDEPTH 150 #endif #if YYMAXDEPTH > 0 int yy_yys[YYMAXDEPTH], *yys = yy_yys; YYSTYPE yy_yyv[YYMAXDEPTH], *yyv = yy_yyv; #else /* user does initial allocation */ int *yys; YYSTYPE *yyv; #endif static int yymaxdepth = YYMAXDEPTH; # define YYERRCODE 256 # line 432 "../../../common/mdb/mdb_grammar.y" static YYCONST yytabelem yyexca[] ={ -1, 1, 0, -1, -2, 0, }; # define YYNPROD 65 # define YYLAST 495 static YYCONST yytabelem yyact[]={ 29, 21, 104, 14, 27, 80, 22, 103, 9, 25, 57, 19, 40, 29, 101, 102, 100, 8, 77, 99, 29, 2, 55, 6, 47, 21, 37, 14, 27, 46, 22, 1, 9, 25, 5, 19, 0, 32, 55, 37, 47, 48, 0, 0, 0, 46, 44, 42, 45, 30, 32, 35, 0, 31, 34, 0, 0, 79, 0, 0, 26, 0, 30, 0, 35, 0, 31, 34, 0, 30, 0, 40, 0, 55, 37, 47, 48, 0, 0, 0, 46, 44, 33, 45, 26, 32, 55, 0, 47, 48, 0, 0, 20, 46, 44, 33, 45, 50, 0, 35, 0, 31, 34, 39, 55, 0, 47, 48, 0, 38, 0, 46, 44, 0, 45, 55, 20, 47, 48, 3, 0, 98, 46, 44, 41, 45, 55, 49, 47, 48, 33, 0, 50, 46, 44, 0, 45, 0, 0, 55, 0, 47, 48, 37, 0, 50, 46, 44, 55, 45, 47, 81, 0, 0, 32, 46, 44, 55, 45, 47, 0, 72, 49, 50, 46, 44, 96, 45, 35, 0, 31, 34, 7, 0, 50, 49, 95, 43, 0, 55, 0, 47, 0, 0, 0, 50, 46, 44, 0, 45, 0, 0, 107, 49, 73, 74, 75, 76, 0, 33, 0, 0, 106, 0, 49, 108, 0, 0, 0, 0, 0, 78, 0, 0, 0, 0, 112, 0, 0, 0, 0, 0, 0, 24, 0, 0, 28, 0, 23, 0, 97, 10, 11, 12, 13, 15, 16, 17, 18, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 28, 36, 23, 0, 105, 10, 11, 12, 13, 15, 16, 17, 18, 0, 36, 0, 0, 0, 0, 109, 0, 0, 0, 0, 0, 0, 51, 52, 53, 54, 113, 114, 0, 0, 0, 117, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 52, 53, 54, 116, 0, 0, 0, 0, 0, 0, 0, 0, 51, 52, 53, 54, 0, 0, 0, 0, 0, 115, 0, 0, 0, 0, 0, 0, 0, 0, 51, 52, 53, 54, 0, 0, 0, 0, 0, 0, 0, 51, 52, 53, 54, 0, 0, 0, 0, 0, 0, 0, 51, 52, 53, 54, 36, 0, 0, 0, 0, 0, 0, 0, 0, 51, 52, 53, 54, 0, 0, 0, 0, 0, 51, 52, 53, 54, 4, 0, 0, 0, 0, 0, 56, 53, 54, 0, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 0, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 110, 0, 0, 0, 111 }; static YYCONST yytabelem yypact[]={ -10000000, -10,-10000000, -21, 3, -34, -248,-10000000,-10000000, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34,-10000000,-10000000,-10000000,-10000000,-10000000,-10000000,-10000000, -10000000,-10000000,-10000000,-10000000,-10000000,-10000000,-10000000,-10000000, 10, 107, -253, -21, -34,-10000000, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, 38, 10,-10000000,-10000000, -10000000,-10000000,-10000000,-10000000,-10000000,-10000000,-10000000,-10000000,-10000000,-10000000, -10000000, 80, -244, -244, -244, -244, -244, -256,-10000000,-10000000, -10000000, 10, 38, -13, -13,-10000000,-10000000, 113, 91, 104, 122, 122, 144, 144,-10000000, -21, 10,-10000000,-10000000, -34, -10000000,-10000000,-10000000, -34,-10000000,-10000000, -21, 10, 10,-10000000, 69, 51, 10,-10000000,-10000000,-10000000,-10000000,-10000000 }; static YYCONST yytabelem yypgo[]={ 0, 390, 17, 31, 21, 172, 119, 109, 161, 18 }; static YYCONST yytabelem yyr1[]={ 0, 3, 3, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 2, 2, 2, 2, 2, 2, 2, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; static YYCONST yytabelem yyr2[]={ 0, 0, 5, 2, 2, 7, 9, 13, 11, 5, 11, 9, 7, 3, 7, 3, 5, 5, 5, 5, 5, 5, 3, 0, 5, 0, 9, 5, 5, 5, 0, 9, 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7, 3, 3, 3, 3, 3, 2 }; static YYCONST yytabelem yychk[]={ -10000000, -3, -4, -6, -1, 44, 33, -5, -2, 42, 265, 266, 267, 268, 37, 269, 270, 271, 272, 45, 126, 35, 40, 262, 257, 43, 94, 38, 260, 10, 59, 63, 47, 92, 64, 61, 261, 36, -7, 124, 33, -6, 44, -5, 43, 45, 42, 37, 38, 124, 94, 273, 274, 275, 276, 35, -1, 258, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -8, -8, -8, -8, -8, -9, -5, -2, 258, -7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -6, -7, -5, 41, 263, 260, 258, 259, 263, 258, -5, -6, -7, -7, -5, -1, -1, -7, -5, -5, 264, 264, -5 }; static YYCONST yytabelem yydef[]={ 1, -2, 2, 23, 0, 0, 0, 13, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 59, 60, 61, 62, 63, 64, 3, 4, 25, 25, 25, 25, 25, 30, 22, 0, 0, 0, 23, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 0, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 0, 16, 17, 18, 19, 20, 21, 5, 14, 24, 0, 23, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 23, 0, 12, 58, 0, 27, 28, 29, 0, 32, 6, 23, 0, 0, 11, 0, 0, 0, 10, 8, 26, 31, 7 }; typedef struct #ifdef __cplusplus yytoktype #endif { #ifdef __cplusplus const #endif char *t_name; int t_val; } yytoktype; #ifndef YYDEBUG # define YYDEBUG 0 /* don't allow debugging */ #endif #if YYDEBUG yytoktype yytoks[] = { "MDB_TOK_SYMBOL", 257, "MDB_TOK_STRING", 258, "MDB_TOK_CHAR", 259, "MDB_TOK_IMMEDIATE", 260, "MDB_TOK_DCMD", 261, "MDB_TOK_VAR_REF", 262, "MDB_TOK_LEXPR", 263, "MDB_TOK_REXPR", 264, "MDB_TOK_COR1_DEREF", 265, "MDB_TOK_COR2_DEREF", 266, "MDB_TOK_COR4_DEREF", 267, "MDB_TOK_COR8_DEREF", 268, "MDB_TOK_OBJ1_DEREF", 269, "MDB_TOK_OBJ2_DEREF", 270, "MDB_TOK_OBJ4_DEREF", 271, "MDB_TOK_OBJ8_DEREF", 272, "|", 124, "^", 94, "&", 38, "MDB_TOK_EQUAL", 273, "MDB_TOK_NOTEQUAL", 274, "MDB_TOK_LSHIFT", 275, "MDB_TOK_RSHIFT", 276, "-", 45, "+", 43, "*", 42, "%", 37, "#", 35, "MDB_COR_VALUE", 277, "MDB_OBJ_VALUE", 278, "MDB_INT_NEGATE", 279, "MDB_BIT_COMPLEMENT", 280, "MDB_LOG_NEGATE", 281, "MDB_VAR_REFERENCE", 282, "-unknown-", -1 /* ends search */ }; #ifdef __cplusplus const #endif char * yyreds[] = { "-no such reduction-", "statement_list : /* empty */", "statement_list : statement_list statement", "terminator : '\n'", "terminator : ';'", "statement : pipeline shell_pipe terminator", "statement : expression pipeline shell_pipe terminator", "statement : expression ',' expression pipeline shell_pipe terminator", "statement : ',' expression pipeline shell_pipe terminator", "statement : expression terminator", "statement : expression ',' expression shell_pipe terminator", "statement : ',' expression shell_pipe terminator", "statement : '!' MDB_TOK_STRING terminator", "statement : terminator", "pipeline : pipeline '|' command", "pipeline : command", "command : '?' format_list", "command : '/' format_list", "command : '\\' format_list", "command : '@' format_list", "command : '=' format_list", "command : MDB_TOK_DCMD argument_list", "command : '$'", "shell_pipe : /* empty */", "shell_pipe : '!' MDB_TOK_STRING", "format_list : /* empty */", "format_list : format_list MDB_TOK_LEXPR expression MDB_TOK_REXPR", "format_list : format_list MDB_TOK_IMMEDIATE", "format_list : format_list MDB_TOK_STRING", "format_list : format_list MDB_TOK_CHAR", "argument_list : /* empty */", "argument_list : argument_list MDB_TOK_LEXPR expression MDB_TOK_REXPR", "argument_list : argument_list MDB_TOK_STRING", "expression : expression '+' expression", "expression : expression '-' expression", "expression : expression '*' expression", "expression : expression '%' expression", "expression : expression '&' expression", "expression : expression '|' expression", "expression : expression '^' expression", "expression : expression MDB_TOK_EQUAL expression", "expression : expression MDB_TOK_NOTEQUAL expression", "expression : expression MDB_TOK_LSHIFT expression", "expression : expression MDB_TOK_RSHIFT expression", "expression : expression '#' expression", "expression : '*' expression", "expression : MDB_TOK_COR1_DEREF expression", "expression : MDB_TOK_COR2_DEREF expression", "expression : MDB_TOK_COR4_DEREF expression", "expression : MDB_TOK_COR8_DEREF expression", "expression : '%' expression", "expression : MDB_TOK_OBJ1_DEREF expression", "expression : MDB_TOK_OBJ2_DEREF expression", "expression : MDB_TOK_OBJ4_DEREF expression", "expression : MDB_TOK_OBJ8_DEREF expression", "expression : '-' expression", "expression : '~' expression", "expression : '#' expression", "expression : '(' expression ')'", "expression : MDB_TOK_VAR_REF", "expression : MDB_TOK_SYMBOL", "expression : '+'", "expression : '^'", "expression : '&'", "expression : MDB_TOK_IMMEDIATE", }; #endif /* YYDEBUG */ # line 1 "/usr/share/lib/ccs/yaccpar" /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 1993 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ #pragma ident "%Z%%M% %I% %E% SMI" /* ** Skeleton parser driver for yacc output */ /* ** yacc user known macros and defines */ #define YYERROR goto yyerrlab #define YYACCEPT return(0) #define YYABORT return(1) #define YYBACKUP( newtoken, newvalue )\ {\ if ( yychar >= 0 || ( yyr2[ yytmp ] >> 1 ) != 1 )\ {\ yyerror( "syntax error - cannot backup" );\ goto yyerrlab;\ }\ yychar = newtoken;\ yystate = *yyps;\ yylval = newvalue;\ goto yynewstate;\ } #define YYRECOVERING() (!!yyerrflag) #define YYNEW(type) malloc(sizeof(type) * yynewmax) #define YYCOPY(to, from, type) \ (type *) memcpy(to, (char *) from, yymaxdepth * sizeof (type)) #define YYENLARGE( from, type) \ (type *) realloc((char *) from, yynewmax * sizeof(type)) #ifndef YYDEBUG # define YYDEBUG 1 /* make debugging available */ #endif /* ** user known globals */ int yydebug; /* set to 1 to get debugging */ /* ** driver internal defines */ #define YYFLAG (-10000000) /* ** global variables used by the parser */ YYSTYPE *yypv; /* top of value stack */ int *yyps; /* top of state stack */ int yystate; /* current state */ int yytmp; /* extra var (lasts between blocks) */ int yynerrs; /* number of errors */ int yyerrflag; /* error recovery flag */ int yychar; /* current input token number */ #ifdef YYNMBCHARS #define YYLEX() yycvtok(yylex()) /* ** yycvtok - return a token if i is a wchar_t value that exceeds 255. ** If i<255, i itself is the token. If i>255 but the neither ** of the 30th or 31st bit is on, i is already a token. */ #if defined(__STDC__) || defined(__cplusplus) int yycvtok(int i) #else int yycvtok(i) int i; #endif { int first = 0; int last = YYNMBCHARS - 1; int mid; wchar_t j; if(i&0x60000000){/*Must convert to a token. */ if( yymbchars[last].character < i ){ return i;/*Giving up*/ } while ((last>=first)&&(first>=0)) {/*Binary search loop*/ mid = (first+last)/2; j = yymbchars[mid].character; if( j==i ){/*Found*/ return yymbchars[mid].tvalue; }else if( j= 0; yy_i++ ) { if ( yytoks[yy_i].t_val == yychar ) break; } printf( "%s\n", yytoks[yy_i].t_name ); } } #endif /* YYDEBUG */ if ( ++yy_ps >= &yys[ yymaxdepth ] ) /* room on stack? */ { /* ** reallocate and recover. Note that pointers ** have to be reset, or bad things will happen */ long yyps_index = (yy_ps - yys); long yypv_index = (yy_pv - yyv); long yypvt_index = (yypvt - yyv); int yynewmax; #ifdef YYEXPAND yynewmax = YYEXPAND(yymaxdepth); #else yynewmax = 2 * yymaxdepth; /* double table size */ if (yymaxdepth == YYMAXDEPTH) /* first time growth */ { char *newyys = (char *)YYNEW(int); char *newyyv = (char *)YYNEW(YYSTYPE); if (newyys != 0 && newyyv != 0) { yys = YYCOPY(newyys, yys, int); yyv = YYCOPY(newyyv, yyv, YYSTYPE); } else yynewmax = 0; /* failed */ } else /* not first time */ { yys = YYENLARGE(yys, int); yyv = YYENLARGE(yyv, YYSTYPE); if (yys == 0 || yyv == 0) yynewmax = 0; /* failed */ } #endif if (yynewmax <= yymaxdepth) /* tables not expanded */ { yyerror( "yacc stack overflow" ); YYABORT; } yymaxdepth = yynewmax; yy_ps = yys + yyps_index; yy_pv = yyv + yypv_index; yypvt = yyv + yypvt_index; } *yy_ps = yy_state; *++yy_pv = yyval; /* ** we have a new state - find out what to do */ yy_newstate: if ( ( yy_n = yypact[ yy_state ] ) <= YYFLAG ) goto yydefault; /* simple state */ #if YYDEBUG /* ** if debugging, need to mark whether new token grabbed */ yytmp = yychar < 0; #endif if ( ( yychar < 0 ) && ( ( yychar = YYLEX() ) < 0 ) ) yychar = 0; /* reached EOF */ #if YYDEBUG if ( yydebug && yytmp ) { register int yy_i; printf( "Received token " ); if ( yychar == 0 ) printf( "end-of-file\n" ); else if ( yychar < 0 ) printf( "-none-\n" ); else { for ( yy_i = 0; yytoks[yy_i].t_val >= 0; yy_i++ ) { if ( yytoks[yy_i].t_val == yychar ) break; } printf( "%s\n", yytoks[yy_i].t_name ); } } #endif /* YYDEBUG */ if ( ( ( yy_n += yychar ) < 0 ) || ( yy_n >= YYLAST ) ) goto yydefault; if ( yychk[ yy_n = yyact[ yy_n ] ] == yychar ) /*valid shift*/ { yychar = -1; yyval = yylval; yy_state = yy_n; if ( yyerrflag > 0 ) yyerrflag--; goto yy_stack; } yydefault: if ( ( yy_n = yydef[ yy_state ] ) == -2 ) { #if YYDEBUG yytmp = yychar < 0; #endif if ( ( yychar < 0 ) && ( ( yychar = YYLEX() ) < 0 ) ) yychar = 0; /* reached EOF */ #if YYDEBUG if ( yydebug && yytmp ) { register int yy_i; printf( "Received token " ); if ( yychar == 0 ) printf( "end-of-file\n" ); else if ( yychar < 0 ) printf( "-none-\n" ); else { for ( yy_i = 0; yytoks[yy_i].t_val >= 0; yy_i++ ) { if ( yytoks[yy_i].t_val == yychar ) { break; } } printf( "%s\n", yytoks[yy_i].t_name ); } } #endif /* YYDEBUG */ /* ** look through exception table */ { register YYCONST int *yyxi = yyexca; while ( ( *yyxi != -1 ) || ( yyxi[1] != yy_state ) ) { yyxi += 2; } while ( ( *(yyxi += 2) >= 0 ) && ( *yyxi != yychar ) ) ; if ( ( yy_n = yyxi[1] ) < 0 ) YYACCEPT; } } /* ** check for syntax error */ if ( yy_n == 0 ) /* have an error */ { /* no worry about speed here! */ switch ( yyerrflag ) { case 0: /* new error */ yyerror( "syntax error" ); goto skip_init; yyerrlab: /* ** get globals into registers. ** we have a user generated syntax type error */ yy_pv = yypv; yy_ps = yyps; yy_state = yystate; skip_init: yynerrs++; /* FALLTHRU */ case 1: case 2: /* incompletely recovered error */ /* try again... */ yyerrflag = 3; /* ** find state where "error" is a legal ** shift action */ while ( yy_ps >= yys ) { yy_n = yypact[ *yy_ps ] + YYERRCODE; if ( yy_n >= 0 && yy_n < YYLAST && yychk[yyact[yy_n]] == YYERRCODE) { /* ** simulate shift of "error" */ yy_state = yyact[ yy_n ]; goto yy_stack; } /* ** current state has no shift on ** "error", pop stack */ #if YYDEBUG # define _POP_ "Error recovery pops state %d, uncovers state %d\n" if ( yydebug ) printf( _POP_, *yy_ps, yy_ps[-1] ); # undef _POP_ #endif yy_ps--; yy_pv--; } /* ** there is no state on stack with "error" as ** a valid shift. give up. */ YYABORT; case 3: /* no shift yet; eat a token */ #if YYDEBUG /* ** if debugging, look up token in list of ** pairs. 0 and negative shouldn't occur, ** but since timing doesn't matter when ** debugging, it doesn't hurt to leave the ** tests here. */ if ( yydebug ) { register int yy_i; printf( "Error recovery discards " ); if ( yychar == 0 ) printf( "token end-of-file\n" ); else if ( yychar < 0 ) printf( "token -none-\n" ); else { for ( yy_i = 0; yytoks[yy_i].t_val >= 0; yy_i++ ) { if ( yytoks[yy_i].t_val == yychar ) { break; } } printf( "token %s\n", yytoks[yy_i].t_name ); } } #endif /* YYDEBUG */ if ( yychar == 0 ) /* reached EOF. quit */ YYABORT; yychar = -1; goto yy_newstate; } }/* end if ( yy_n == 0 ) */ /* ** reduction by production yy_n ** put stack tops, etc. so things right after switch */ #if YYDEBUG /* ** if debugging, print the string that is the user's ** specification of the reduction which is just about ** to be done. */ if ( yydebug ) printf( "Reduce by (%d) \"%s\"\n", yy_n, yyreds[ yy_n ] ); #endif yytmp = yy_n; /* value to switch over */ yypvt = yy_pv; /* $vars top of value stack */ /* ** Look in goto table for next state ** Sorry about using yy_state here as temporary ** register variable, but why not, if it works... ** If yyr2[ yy_n ] doesn't have the low order bit ** set, then there is no action to be done for ** this reduction. So, no saving & unsaving of ** registers done. The only difference between the ** code just after the if and the body of the if is ** the goto yy_stack in the body. This way the test ** can be made before the choice of what to do is needed. */ { /* length of production doubled with extra bit */ register int yy_len = yyr2[ yy_n ]; if ( !( yy_len & 01 ) ) { yy_len >>= 1; yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] + *( yy_ps -= yy_len ) + 1; if ( yy_state >= YYLAST || yychk[ yy_state = yyact[ yy_state ] ] != -yy_n ) { yy_state = yyact[ yypgo[ yy_n ] ]; } goto yy_stack; } yy_len >>= 1; yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] + *( yy_ps -= yy_len ) + 1; if ( yy_state >= YYLAST || yychk[ yy_state = yyact[ yy_state ] ] != -yy_n ) { yy_state = yyact[ yypgo[ yy_n ] ]; } } /* save until reenter driver code */ yystate = yy_state; yyps = yy_ps; yypv = yy_pv; } /* ** code supplied by user is placed in this switch */ switch( yytmp ) { case 2: # line 126 "../../../common/mdb/mdb_grammar.y" { return (0); } break; case 5: # line 132 "../../../common/mdb/mdb_grammar.y" { if (!mdb_call(mdb_nv_get_value(mdb.m_dot), 1, 0)) return (0); } break; case 6: # line 137 "../../../common/mdb/mdb_grammar.y" { if (!mdb_call(yypvt[-3].l_immediate, 1, DCMD_ADDRSPEC)) return (0); } break; case 7: # line 142 "../../../common/mdb/mdb_grammar.y" { if (!mdb_call(yypvt[-5].l_immediate, yypvt[-3].l_immediate, DCMD_ADDRSPEC | DCMD_LOOP)) return (0); } break; case 8: # line 147 "../../../common/mdb/mdb_grammar.y" { if (!mdb_call(mdb_nv_get_value(mdb.m_dot), yypvt[-3].l_immediate, DCMD_LOOP)) return (0); } break; case 9: # line 153 "../../../common/mdb/mdb_grammar.y" { mdb_frame_t *pfp = mdb_frame_pipe(); /* * The handling of naked expressions is slightly tricky: * in a string context, we want to just set dot to the * expression value. In a pipe context, we also set * dot but need to record the address in the right- * hand command's addrv and update any vcbs that are * active. Otherwise, on the command-line, we have to * support this as an alias for executing the previous * command with the new value of dot. Sigh. */ if (mdb_iob_isastr(mdb.m_in)) { mdb_nv_set_value(mdb.m_dot, yypvt[-1].l_immediate); mdb.m_incr = 0; } else if (pfp != NULL && pfp->f_pcmd != NULL) { mdb_addrvec_unshift(&pfp->f_pcmd->c_addrv, (uintptr_t)yypvt[-1].l_immediate); mdb_vcb_update(pfp, (uintptr_t)yypvt[-1].l_immediate); mdb_nv_set_value(mdb.m_dot, yypvt[-1].l_immediate); } else { mdb_list_move(&mdb.m_lastc, &mdb.m_frame->f_cmds); if (!mdb_call(yypvt[-1].l_immediate, 1, DCMD_ADDRSPEC)) return (0); } } break; case 10: # line 181 "../../../common/mdb/mdb_grammar.y" { mdb_list_move(&mdb.m_lastc, &mdb.m_frame->f_cmds); if (!mdb_call(yypvt[-4].l_immediate, yypvt[-2].l_immediate, DCMD_ADDRSPEC | DCMD_LOOP)) return (0); } break; case 11: # line 187 "../../../common/mdb/mdb_grammar.y" { uintmax_t dot = mdb_dot_incr(","); mdb_list_move(&mdb.m_lastc, &mdb.m_frame->f_cmds); if (!mdb_call(dot, yypvt[-2].l_immediate, DCMD_LOOP)) return (0); } break; case 12: # line 194 "../../../common/mdb/mdb_grammar.y" { if (mdb_iob_isapipe(mdb.m_in)) yyerror("syntax error"); mdb_shell_exec(yypvt[-1].l_string); } break; case 13: # line 200 "../../../common/mdb/mdb_grammar.y" { if ((mdb.m_flags & MDB_FL_REPLAST) && !mdb_iob_isastr(mdb.m_in)) { uintmax_t dot = mdb_dot_incr("\\n"); /* * If a bare terminator is encountered, execute * the previous command if -o repeatlast is set * and stdin is not an mdb_eval() string. */ mdb_list_move(&mdb.m_lastc, &mdb.m_frame->f_cmds); if (!mdb_call(dot, 1, 0)) return (0); } } break; case 14: # line 217 "../../../common/mdb/mdb_grammar.y" { mdb_cmd_create(yypvt[-0].l_dcmd, &mdb.m_frame->f_argvec); } break; case 15: # line 218 "../../../common/mdb/mdb_grammar.y" { mdb_cmd_create(yypvt[-0].l_dcmd, &mdb.m_frame->f_argvec); } break; case 16: # line 221 "../../../common/mdb/mdb_grammar.y" { yyval.l_dcmd = mdb_dcmd_lookup("?"); } break; case 17: # line 222 "../../../common/mdb/mdb_grammar.y" { yyval.l_dcmd = mdb_dcmd_lookup("/"); } break; case 18: # line 223 "../../../common/mdb/mdb_grammar.y" { yyval.l_dcmd = mdb_dcmd_lookup("\\"); } break; case 19: # line 224 "../../../common/mdb/mdb_grammar.y" { yyval.l_dcmd = mdb_dcmd_lookup("@"); } break; case 20: # line 225 "../../../common/mdb/mdb_grammar.y" { yyval.l_dcmd = mdb_dcmd_lookup("="); } break; case 21: # line 226 "../../../common/mdb/mdb_grammar.y" { yyval.l_dcmd = yypvt[-1].l_dcmd; } break; case 22: # line 227 "../../../common/mdb/mdb_grammar.y" { yyval.l_dcmd = mdb_dcmd_lookup("$?"); } break; case 24: # line 231 "../../../common/mdb/mdb_grammar.y" { mdb_shell_pipe(yypvt[-0].l_string); } break; case 26: # line 235 "../../../common/mdb/mdb_grammar.y" { mdb_arg_t arg; arg.a_type = MDB_TYPE_IMMEDIATE; arg.a_un.a_val = yypvt[-1].l_immediate; mdb_argvec_append(&mdb.m_frame->f_argvec, &arg); } break; case 27: # line 244 "../../../common/mdb/mdb_grammar.y" { mdb_arg_t arg; arg.a_type = MDB_TYPE_IMMEDIATE; arg.a_un.a_val = yypvt[-0].l_immediate; mdb_argvec_append(&mdb.m_frame->f_argvec, &arg); } break; case 28: # line 253 "../../../common/mdb/mdb_grammar.y" { mdb_arg_t arg; arg.a_type = MDB_TYPE_STRING; arg.a_un.a_str = yypvt[-0].l_string; mdb_argvec_append(&mdb.m_frame->f_argvec, &arg); } break; case 29: # line 262 "../../../common/mdb/mdb_grammar.y" { mdb_arg_t arg; arg.a_type = MDB_TYPE_CHAR; arg.a_un.a_char = yypvt[-0].l_char; mdb_argvec_append(&mdb.m_frame->f_argvec, &arg); } break; case 31: # line 273 "../../../common/mdb/mdb_grammar.y" { mdb_arg_t arg; arg.a_type = MDB_TYPE_IMMEDIATE; arg.a_un.a_val = yypvt[-1].l_immediate; mdb_argvec_append(&mdb.m_frame->f_argvec, &arg); } break; case 32: # line 282 "../../../common/mdb/mdb_grammar.y" { mdb_arg_t arg; arg.a_type = MDB_TYPE_STRING; arg.a_un.a_str = yypvt[-0].l_string; mdb_argvec_append(&mdb.m_frame->f_argvec, &arg); } break; case 33: # line 292 "../../../common/mdb/mdb_grammar.y" { yyval.l_immediate = yypvt[-2].l_immediate + yypvt[-0].l_immediate; } break; case 34: # line 293 "../../../common/mdb/mdb_grammar.y" { yyval.l_immediate = yypvt[-2].l_immediate - yypvt[-0].l_immediate; } break; case 35: # line 294 "../../../common/mdb/mdb_grammar.y" { yyval.l_immediate = yypvt[-2].l_immediate * yypvt[-0].l_immediate; } break; case 36: # line 296 "../../../common/mdb/mdb_grammar.y" { if (yypvt[-0].l_immediate == 0UL) yyerror("attempted to divide by zero"); yyval.l_immediate = (intmax_t)yypvt[-2].l_immediate / (intmax_t)yypvt[-0].l_immediate; } break; case 37: # line 303 "../../../common/mdb/mdb_grammar.y" { yyval.l_immediate = yypvt[-2].l_immediate & yypvt[-0].l_immediate; } break; case 38: # line 304 "../../../common/mdb/mdb_grammar.y" { yyval.l_immediate = yypvt[-2].l_immediate | yypvt[-0].l_immediate; } break; case 39: # line 305 "../../../common/mdb/mdb_grammar.y" { yyval.l_immediate = yypvt[-2].l_immediate ^ yypvt[-0].l_immediate; } break; case 40: # line 307 "../../../common/mdb/mdb_grammar.y" { yyval.l_immediate = (yypvt[-2].l_immediate == yypvt[-0].l_immediate); } break; case 41: # line 308 "../../../common/mdb/mdb_grammar.y" { yyval.l_immediate = (yypvt[-2].l_immediate != yypvt[-0].l_immediate); } break; case 42: # line 310 "../../../common/mdb/mdb_grammar.y" { yyval.l_immediate = yypvt[-2].l_immediate << yypvt[-0].l_immediate; } break; case 43: # line 311 "../../../common/mdb/mdb_grammar.y" { yyval.l_immediate = yypvt[-2].l_immediate >> yypvt[-0].l_immediate; } break; case 44: # line 313 "../../../common/mdb/mdb_grammar.y" { if (yypvt[-0].l_immediate == 0UL) yyerror("attempted to divide by zero"); yyval.l_immediate = ((intptr_t)(yypvt[-2].l_immediate + (yypvt[-0].l_immediate - 1)) / (intptr_t)yypvt[-0].l_immediate) * yypvt[-0].l_immediate; } break; case 45: # line 320 "../../../common/mdb/mdb_grammar.y" { uintptr_t value; vfetch(&value, sizeof (value), yypvt[-0].l_immediate); yyval.l_immediate = value; } break; case 46: # line 327 "../../../common/mdb/mdb_grammar.y" { uint8_t value; vfetch(&value, sizeof (value), yypvt[-0].l_immediate); yyval.l_immediate = value; } break; case 47: # line 334 "../../../common/mdb/mdb_grammar.y" { uint16_t value; vfetch(&value, sizeof (value), yypvt[-0].l_immediate); yyval.l_immediate = value; } break; case 48: # line 341 "../../../common/mdb/mdb_grammar.y" { uint32_t value; vfetch(&value, sizeof (value), yypvt[-0].l_immediate); yyval.l_immediate = value; } break; case 49: # line 348 "../../../common/mdb/mdb_grammar.y" { uint64_t value; vfetch(&value, sizeof (value), yypvt[-0].l_immediate); yyval.l_immediate = value; } break; case 50: # line 355 "../../../common/mdb/mdb_grammar.y" { uintptr_t value; ffetch(&value, sizeof (value), yypvt[-0].l_immediate); yyval.l_immediate = value; } break; case 51: # line 362 "../../../common/mdb/mdb_grammar.y" { uint8_t value; ffetch(&value, sizeof (value), yypvt[-0].l_immediate); yyval.l_immediate = value; } break; case 52: # line 369 "../../../common/mdb/mdb_grammar.y" { uint16_t value; ffetch(&value, sizeof (value), yypvt[-0].l_immediate); yyval.l_immediate = value; } break; case 53: # line 376 "../../../common/mdb/mdb_grammar.y" { uint32_t value; ffetch(&value, sizeof (value), yypvt[-0].l_immediate); yyval.l_immediate = value; } break; case 54: # line 383 "../../../common/mdb/mdb_grammar.y" { uint64_t value; ffetch(&value, sizeof (value), yypvt[-0].l_immediate); yyval.l_immediate = value; } break; case 55: # line 390 "../../../common/mdb/mdb_grammar.y" { yyval.l_immediate = -yypvt[-0].l_immediate; } break; case 56: # line 391 "../../../common/mdb/mdb_grammar.y" { yyval.l_immediate = ~yypvt[-0].l_immediate; } break; case 57: # line 392 "../../../common/mdb/mdb_grammar.y" { yyval.l_immediate = !yypvt[-0].l_immediate; } break; case 58: # line 393 "../../../common/mdb/mdb_grammar.y" { yyval.l_immediate = yypvt[-1].l_immediate; } break; case 59: # line 395 "../../../common/mdb/mdb_grammar.y" { yyval.l_immediate = mdb_nv_get_value(yypvt[-0].l_var); } break; case 60: # line 399 "../../../common/mdb/mdb_grammar.y" { if (strcmp(yypvt[-0].l_string, ".") == 0) { yyval.l_immediate = mdb_nv_get_value(mdb.m_dot); strfree(yypvt[-0].l_string); } else { const char *obj = MDB_TGT_OBJ_EVERY, *name = yypvt[-0].l_string; char *s = (char *)yypvt[-0].l_string; GElf_Sym sym; if ((s = strrsplit(s, '`')) != NULL) { name = s; obj = yypvt[-0].l_string; } if (mdb_tgt_lookup_by_name(mdb.m_target, obj, name, &sym, NULL) == -1) { strfree(yypvt[-0].l_string); yyperror("failed to dereference " "symbol"); } strfree(yypvt[-0].l_string); yyval.l_immediate = (uintmax_t)sym.st_value; } } break; case 61: # line 426 "../../../common/mdb/mdb_grammar.y" { yyval.l_immediate = mdb_dot_incr("+"); } break; case 62: # line 427 "../../../common/mdb/mdb_grammar.y" { yyval.l_immediate = mdb_dot_decr("^"); } break; case 63: # line 428 "../../../common/mdb/mdb_grammar.y" { yyval.l_immediate = mdb.m_raddr; } break; # line 556 "/usr/share/lib/ccs/yaccpar" } goto yystack; /* reset registers in driver code */ }