Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH 1/6] Remove OP_LABELED.
Date: Thu, 01 Nov 2012 07:47:00 -0000	[thread overview]
Message-ID: <1351756007-18242-2-git-send-email-yao@codesourcery.com> (raw)
In-Reply-To: <1351756007-18242-1-git-send-email-yao@codesourcery.com>

This patch is to remove OP_LABELED.  Once OP_LABELED is removed,
function get_label always return NULL, so this function can be removed
as well, and its caller can be simplified.

Indentation will be done in follow-up patch.

gdb:

2012-11-01  Yao Qi  <yao@codesourcery.com>

	* std-operator.def: Remove OP_LABELED.

	* eval.c: Remove the declaration of 'get_label'.
	(get_label): Remove.
	(evaluate_struct_tuple): Remove code handling OP_LABELED.
	* expprint.c (print_subexp_standard): Likewise.
	(dump_subexp_body_standard): Likewise.
	* parse.c (operator_length_standard): Likewise.
---
 gdb/eval.c           |   86 --------------------------------------------------
 gdb/expprint.c       |   16 ---------
 gdb/parse.c          |    1 -
 gdb/std-operator.def |   13 -------
 4 files changed, 0 insertions(+), 116 deletions(-)

diff --git a/gdb/eval.c b/gdb/eval.c
index 26e0cc8..011b3fe 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -56,8 +56,6 @@ static struct value *evaluate_subexp_for_sizeof (struct expression *, int *);
 static struct value *evaluate_subexp_for_address (struct expression *,
 						  int *, enum noside);
 
-static char *get_label (struct expression *, int *);
-
 static struct value *evaluate_struct_tuple (struct value *,
 					    struct expression *, int *,
 					    enum noside, int);
@@ -280,25 +278,6 @@ extract_field_op (struct expression *exp, int *subexp)
   return result;
 }
 
-/* If the next expression is an OP_LABELED, skips past it,
-   returning the label.  Otherwise, does nothing and returns NULL.  */
-
-static char *
-get_label (struct expression *exp, int *pos)
-{
-  if (exp->elts[*pos].opcode == OP_LABELED)
-    {
-      int pc = (*pos)++;
-      char *name = &exp->elts[pc + 2].string;
-      int tem = longest_to_int (exp->elts[pc + 1].longconst);
-
-      (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
-      return name;
-    }
-  else
-    return NULL;
-}
-
 /* This function evaluates tuples (in (the deleted) Chill) or
    brace-initializers (in C/C++) for structure types.  */
 
@@ -316,74 +295,10 @@ evaluate_struct_tuple (struct value *struct_val,
 
   while (--nargs >= 0)
     {
-      int pc = *pos;
       struct value *val = NULL;
-      int nlabels = 0;
       int bitpos, bitsize;
       bfd_byte *addr;
-
-      /* Skip past the labels, and count them.  */
-      while (get_label (exp, pos) != NULL)
-	nlabels++;
-
-      do
 	{
-	  char *label = get_label (exp, &pc);
-
-	  if (label)
-	    {
-	      for (fieldno = 0; fieldno < TYPE_NFIELDS (struct_type);
-		   fieldno++)
-		{
-		  const char *field_name =
-		    TYPE_FIELD_NAME (struct_type, fieldno);
-
-		  if (field_name != NULL && strcmp (field_name, label) == 0)
-		    {
-		      variantno = -1;
-		      subfieldno = fieldno;
-		      substruct_type = struct_type;
-		      goto found;
-		    }
-		}
-	      for (fieldno = 0; fieldno < TYPE_NFIELDS (struct_type);
-		   fieldno++)
-		{
-		  const char *field_name =
-		    TYPE_FIELD_NAME (struct_type, fieldno);
-
-		  field_type = TYPE_FIELD_TYPE (struct_type, fieldno);
-		  if ((field_name == 0 || *field_name == '\0')
-		      && TYPE_CODE (field_type) == TYPE_CODE_UNION)
-		    {
-		      variantno = 0;
-		      for (; variantno < TYPE_NFIELDS (field_type);
-			   variantno++)
-			{
-			  substruct_type
-			    = TYPE_FIELD_TYPE (field_type, variantno);
-			  if (TYPE_CODE (substruct_type) == TYPE_CODE_STRUCT)
-			    {
-			      for (subfieldno = 0;
-				 subfieldno < TYPE_NFIELDS (substruct_type);
-				   subfieldno++)
-				{
-				  if (strcmp(TYPE_FIELD_NAME (substruct_type,
-							      subfieldno),
-					     label) == 0)
-				    {
-				      goto found;
-				    }
-				}
-			    }
-			}
-		    }
-		}
-	      error (_("there is no field named %s"), label);
-	    found:
-	      ;
-	    }
-	  else
 	    {
 	      /* Unlabelled tuple element - go to next field.  */
 	      if (variantno >= 0)
@@ -444,7 +359,6 @@ evaluate_struct_tuple (struct value *struct_val,
 	    memcpy (addr, value_contents (val),
 		    TYPE_LENGTH (value_type (val)));
 	}
-      while (--nlabels > 0);
     }
   return struct_val;
 }
diff --git a/gdb/expprint.c b/gdb/expprint.c
index baaa08a..129dfa7 100644
--- a/gdb/expprint.c
+++ b/gdb/expprint.c
@@ -328,21 +328,6 @@ print_subexp_standard (struct expression *exp, int *pos,
 	}
       return;
 
-    case OP_LABELED:
-      tem = longest_to_int (exp->elts[pc + 1].longconst);
-      (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
-      /* Gcc support both these syntaxes.  Unsure which is preferred.  */
-#if 1
-      fputs_filtered (&exp->elts[pc + 2].string, stream);
-      fputs_filtered (": ", stream);
-#else
-      fputs_filtered (".", stream);
-      fputs_filtered (&exp->elts[pc + 2].string, stream);
-      fputs_filtered ("=", stream);
-#endif
-      print_subexp (exp, pos, stream, PREC_SUFFIX);
-      return;
-
     case TERNOP_COND:
       if ((int) prec > (int) PREC_COMMA)
 	fputs_filtered ("(", stream);
@@ -1031,7 +1016,6 @@ dump_subexp_body_standard (struct expression *exp,
     case OP_BOOL:
     case OP_M2_STRING:
     case OP_THIS:
-    case OP_LABELED:
     case OP_NAME:
       fprintf_filtered (stream, "Unknown format");
     }
diff --git a/gdb/parse.c b/gdb/parse.c
index 3ec1e25..afe1c18 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -951,7 +951,6 @@ operator_length_standard (const struct expression *expr, int endpos,
       oplen++;
       break;
 
-    case OP_LABELED:
     case STRUCTOP_STRUCT:
     case STRUCTOP_PTR:
       args = 1;
diff --git a/gdb/std-operator.def b/gdb/std-operator.def
index dcba39f..5df0081 100644
--- a/gdb/std-operator.def
+++ b/gdb/std-operator.def
@@ -286,19 +286,6 @@ OP (OP_OBJC_SELECTOR)
    a string, which, of course, is variable length.  */
 OP (OP_SCOPE)
 
-/* Used to represent named structure field values in brace
-   initializers (or tuples as they are called in (the deleted)
-   Chill).
-
-   The gcc C syntax is NAME:VALUE or .NAME=VALUE, the (the
-   deleted) Chill syntax is .NAME:VALUE.  Multiple labels (as in
-   the (the deleted) Chill syntax .NAME1,.NAME2:VALUE) is
-   represented as if it were .NAME1:(.NAME2:VALUE) (though that is
-   not valid (the deleted) Chill syntax).
-
-   The NAME is represented as for STRUCTOP_STRUCT;  VALUE follows.  */
-OP (OP_LABELED)
-
 /* OP_TYPE is for parsing types, and used with the "ptype" command
    so we can look up types that are qualified by scope, either with
    the GDB "::" operator, or the Modula-2 '.' operator.  */
-- 
1.7.7.6


  parent reply	other threads:[~2012-11-01  7:47 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-01  7:47 [PATCH 0/6] Remove unused operator OP_LABELED Yao Qi
2012-11-01  7:47 ` [PATCH 2/6] Update comment of evaluate_struct_tuple Yao Qi
2012-11-01 15:42   ` Tom Tromey
2012-11-01  7:47 ` [PATCH 4/6] Remove 'substruct_type' and 'subfieldno' Yao Qi
2012-11-01 15:44   ` Tom Tromey
2012-11-01  7:47 ` [PATCH 6/6] Test nested struct assign Yao Qi
2012-11-01 15:47   ` Tom Tromey
2012-11-01  7:47 ` [PATCH 3/6] Remove 'variantno' Yao Qi
2012-11-01 15:44   ` Tom Tromey
2012-11-01  7:47 ` [PATCH 5/6] Indentation Yao Qi
2012-11-01 15:45   ` Tom Tromey
2012-11-01  7:47 ` Yao Qi [this message]
2012-11-01 15:41   ` [PATCH 1/6] Remove OP_LABELED Tom Tromey
2012-11-02 16:43   ` Pedro Alves
2012-11-02 16:49     ` Tom Tromey
2012-11-02 16:51       ` Pedro Alves
2012-11-02 17:09         ` Tom Tromey
2012-11-02 17:25           ` Pedro Alves
2012-11-01 15:47 ` [PATCH 0/6] Remove unused operator OP_LABELED Tom Tromey
2012-11-02  0:20   ` [committed]: " Yao Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1351756007-18242-2-git-send-email-yao@codesourcery.com \
    --to=yao@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox