summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2011-10-11 15:24:11 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2011-10-11 15:24:11 +0000
commit941b2081b1fd085fff7d323448672cedf18258db (patch)
tree9ce9ac187478148ba6cf153185277a57eef997f2
parent3c4d7e1201c0e8fb4b9a3e4f297c5b4a18bf38db (diff)
gdb/
Revert this part of: 2011-10-09 Jan Kratochvil <jan.kratochvil@redhat.com> Support @entry in input expressions. * c-exp.y (ENTRY, unknown_cpp_name): New. (exp: UNKNOWN_CPP_NAME): Change to `exp: unknown_cpp_name'. (unknown_cpp_name: UNKNOWN_CPP_NAME, unknown_cpp_name: ENTRY) (variable: name_not_typename '@' ENTRY, name: ENTRY) (name_not_typename: ENTRY): New. (yylex): Recognize ENTRY. Reimplement @entry in input expressions. * c-exp.y (ENTRY): New. (variable: name_not_typename ENTRY): New. (lex_one_token): Optionally return ENTRY instead of the '@' lex. gdb/testsuite/ Reimplement @entry in input expressions. * gdb.base/exprs.c (v_int_array_init): New variable. * gdb.base/exprs.exp (print v_int_array_init) (print *v_int_array_init@1, print *v_int_array_init@2) (print v_int_array_init[0]@1, print v_int_array_init[0]@2) (print v_int_array_init[1]@1): New tests.
-rw-r--r--gdb/ChangeLog17
-rw-r--r--gdb/c-exp.y36
-rw-r--r--gdb/testsuite/ChangeLog9
-rw-r--r--gdb/testsuite/gdb.base/exprs.c5
-rw-r--r--gdb/testsuite/gdb.base/exprs.exp8
5 files changed, 57 insertions, 18 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 8bdc21ffd8..ccd0530e97 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,20 @@
+2011-10-11 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Revert this part of:
+ 2011-10-09 Jan Kratochvil <jan.kratochvil@redhat.com>
+ Support @entry in input expressions.
+ * c-exp.y (ENTRY, unknown_cpp_name): New.
+ (exp: UNKNOWN_CPP_NAME): Change to `exp: unknown_cpp_name'.
+ (unknown_cpp_name: UNKNOWN_CPP_NAME, unknown_cpp_name: ENTRY)
+ (variable: name_not_typename '@' ENTRY, name: ENTRY)
+ (name_not_typename: ENTRY): New.
+ (yylex): Recognize ENTRY.
+
+ Reimplement @entry in input expressions.
+ * c-exp.y (ENTRY): New.
+ (variable: name_not_typename ENTRY): New.
+ (lex_one_token): Optionally return ENTRY instead of the '@' lex.
+
2011-10-11 Pedro Alves <pedro@codesourcery.com>
* linux-nat.c (linux_handle_extended_wait): Always dump both the
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 5cc1e9614e..b850179f16 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -186,7 +186,6 @@ static struct stoken operator_stoken (const char *);
%token <tsval> STRING
%token <tsval> CHAR
%token <ssym> NAME /* BLOCKNAME defined below to give it higher precedence. */
-%token <ssym> ENTRY
%token <ssym> UNKNOWN_CPP_NAME
%token <voidval> COMPLETE
%token <tsym> TYPENAME
@@ -195,9 +194,6 @@ static struct stoken operator_stoken (const char *);
%type <ssym> name_not_typename
%type <tsym> typename
-/* It is UNKNOWN_CPP_NAME or ENTRY, depending on the context. */
-%type <ssym> unknown_cpp_name
-
/* A NAME_OR_INT is a symbol which is not known in the symbol table,
but which would parse as a valid number in the current input radix.
E.g. "c" when input_radix==16. Depending on the parse, it will be
@@ -212,6 +208,7 @@ static struct stoken operator_stoken (const char *);
%token NEW DELETE
%type <sval> operator
%token REINTERPRET_CAST DYNAMIC_CAST STATIC_CAST CONST_CAST
+%token ENTRY
/* Special type cases, put in to allow the parser to distinguish different
legal basetypes. */
@@ -396,7 +393,7 @@ exp : exp '('
write_exp_elt_opcode (OP_FUNCALL); }
;
-exp : unknown_cpp_name '('
+exp : UNKNOWN_CPP_NAME '('
{
/* This could potentially be a an argument defined
lookup function (Koenig). */
@@ -419,10 +416,6 @@ exp : unknown_cpp_name '('
}
;
-unknown_cpp_name : UNKNOWN_CPP_NAME
- | ENTRY
- ;
-
lcurly : '{'
{ start_arglist (); }
;
@@ -764,7 +757,7 @@ block : block COLONCOLON name
$$ = SYMBOL_BLOCK_VALUE (tem); }
;
-variable: name_not_typename '@' ENTRY
+variable: name_not_typename ENTRY
{ struct symbol *sym = $1.sym;
if (sym == NULL || !SYMBOL_IS_ARGUMENT (sym)
@@ -1340,13 +1333,11 @@ name : NAME { $$ = $1.stoken; }
| TYPENAME { $$ = $1.stoken; }
| NAME_OR_INT { $$ = $1.stoken; }
| UNKNOWN_CPP_NAME { $$ = $1.stoken; }
- | ENTRY { $$ = $1.stoken; }
| operator { $$ = $1; }
;
name_not_typename : NAME
| BLOCKNAME
- | ENTRY
/* These would be useful if name_not_typename was useful, but it is just
a fake for "variable", so these cause reduce/reduce conflicts because
the parser can't tell whether NAME_OR_INT is a name_not_typename (=variable,
@@ -2249,6 +2240,21 @@ lex_one_token (void)
return toktype;
}
+ case '@':
+ {
+ char *p = &tokstart[1];
+ size_t len = strlen ("entry");
+
+ while (isspace (*p))
+ p++;
+ if (strncmp (p, "entry", len) == 0 && !isalnum (p[len])
+ && p[len] != '_')
+ {
+ lexptr = &p[len];
+ return ENTRY;
+ }
+ }
+ /* FALLTHRU */
case '+':
case '-':
case '*':
@@ -2259,7 +2265,6 @@ lex_one_token (void)
case '^':
case '~':
case '!':
- case '@':
case '<':
case '>':
case '?':
@@ -2550,11 +2555,6 @@ yylex (void)
current.token = lex_one_token ();
if (current.token == NAME)
current.token = classify_name (expression_context_block);
- if ((current.token == NAME || current.token == UNKNOWN_CPP_NAME)
- && yylval.sval.length == strlen ("entry")
- && strncmp (yylval.sval.ptr, "entry", strlen ("entry")) == 0)
- current.token = ENTRY;
-
if (parse_language->la_language != language_cplus
|| (current.token != TYPENAME && current.token != COLONCOLON))
return current.token;
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index ddedefac69..0e6c4c9bdc 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2011-10-11 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Reimplement @entry in input expressions.
+ * gdb.base/exprs.c (v_int_array_init): New variable.
+ * gdb.base/exprs.exp (print v_int_array_init)
+ (print *v_int_array_init@1, print *v_int_array_init@2)
+ (print v_int_array_init[0]@1, print v_int_array_init[0]@2)
+ (print v_int_array_init[1]@1): New tests.
+
2011-10-10 Joseph Myers <joseph@codesourcery.com>
* gdb.cp/gdb2495.exp: Do not include directories in filename in
diff --git a/gdb/testsuite/gdb.base/exprs.c b/gdb/testsuite/gdb.base/exprs.c
index b35c3a58d2..34d27809df 100644
--- a/gdb/testsuite/gdb.base/exprs.c
+++ b/gdb/testsuite/gdb.base/exprs.c
@@ -75,6 +75,11 @@ unsigned long v_unsigned_long_array[2];
float v_float_array[2];
double v_double_array[2];
+
+/**** initialized array *******/
+
+int v_int_array_init[2] = { 10, 20 };
+
/**** pointers *******/
char *v_char_pointer;
diff --git a/gdb/testsuite/gdb.base/exprs.exp b/gdb/testsuite/gdb.base/exprs.exp
index 8c9762f486..ca17bd2391 100644
--- a/gdb/testsuite/gdb.base/exprs.exp
+++ b/gdb/testsuite/gdb.base/exprs.exp
@@ -262,3 +262,11 @@ gdb_test "print v_int--" "\\$\[0-9\]* = 3"
gdb_test "print --v_int" "\\$\[0-9\]* = 1"
gdb_test "print v_int++ = 5" "Left operand of assignment is not an lvalue."
gdb_test "print v_int-- = 5" "Left operand of assignment is not an lvalue."
+
+# initialized array
+gdb_test {print v_int_array_init} { = \{10, 20\}}
+gdb_test {print *v_int_array_init@1} { = \{10\}}
+gdb_test {print *v_int_array_init@2} { = \{10, 20\}}
+gdb_test {print v_int_array_init[0]@1} { = \{10\}}
+gdb_test {print v_int_array_init[0]@2} { = \{10, 20\}}
+gdb_test {print v_int_array_init[1]@1} { = \{20\}}