This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFC 2/2] Remove op_name callback in struct exp_descriptor.
- From: Joel Brobecker <brobecker at adacore dot com>
- To: gdb-patches at sourceware dot org
- Cc: Joel Brobecker <brobecker at adacore dot com>
- Date: Fri, 16 Mar 2012 16:21:01 -0700
- Subject: [RFC 2/2] Remove op_name callback in struct exp_descriptor.
- References: <1331940061-10739-1-git-send-email-brobecker@adacore.com>
This callback really isn't necessary anymore, since all opcodes are
now defined within one single file. So it's easy to write a function
that prints the image of the opcode without having to know the language.
This patch does the following:
* Delete function "op_name";
* Rename "op_name_standard" into "op_name", and update all callers;
* Remove the "op_name" callback from struct exp_descriptor and
update all instantiations.
gdb/ChangeLog:
* parser-defs.h (op_name_standard): Delete declaration.
(struct exp_descriptor): Remove field "op_name".
* expression.h (op_name): Update declaration.
* expprint.c (op_name): Delete.
(op_name_standard): Renamed into "op_name".
(dump_raw_expression, dump_subexp): Update call to op_name.
* c-lang.c (exp_descriptor_c): Remove entry for field "op_name".
* jv-lang.c (exp_descriptor_java): Likewise.
* m2-lang.c (exp_descriptor_modula2): Ditto.
* opencl-lang.c (exp_descriptor_opencl): Ditto.
* parse.c (exp_descriptor_standard): Ditto.
* ada-lang.c (ada_op_name): Delete.
(ada_exp_descriptor): Remove entry for field "op_name".
* ax-gdb.c (gen_expr): Update call to op_name.
---
gdb/ada-lang.c | 24 ------------------------
gdb/ax-gdb.c | 2 +-
gdb/c-lang.c | 1 -
gdb/expprint.c | 14 +++-----------
gdb/expression.h | 2 +-
gdb/jv-lang.c | 1 -
gdb/m2-lang.c | 1 -
gdb/opencl-lang.c | 1 -
gdb/parse.c | 1 -
gdb/parser-defs.h | 5 -----
10 files changed, 5 insertions(+), 47 deletions(-)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index c8c388b..85d7907 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -132,8 +132,6 @@ static void replace_operator_with_call (struct expression **, int, int, int,
static int possible_user_operator_p (enum exp_opcode, struct value **);
-static char *ada_op_name (enum exp_opcode);
-
static const char *ada_decoded_op_name (enum exp_opcode);
static int numeric_type_p (struct type *);
@@ -12685,27 +12683,6 @@ ada_operator_check (struct expression *exp, int pos,
return 0;
}
-static char *
-ada_op_name (enum exp_opcode opcode)
-{
- switch (opcode)
- {
- default:
- return op_name_standard (opcode);
-
-#define OP_DEFN(op, len, args, binop) case op: return #op;
- ADA_OPERATORS;
-#undef OP_DEFN
-
- case OP_AGGREGATE:
- return "OP_AGGREGATE";
- case OP_CHOICES:
- return "OP_CHOICES";
- case OP_NAME:
- return "OP_NAME";
- }
-}
-
/* As for operator_length, but assumes PC is pointing at the first
element of the operator, and gives meaningful results only for the
Ada-specific operators, returning 0 for *OPLENP and *ARGSP otherwise. */
@@ -13078,7 +13055,6 @@ static const struct exp_descriptor ada_exp_descriptor = {
ada_print_subexp,
ada_operator_length,
ada_operator_check,
- ada_op_name,
ada_dump_subexp_body,
ada_evaluate_subexp
};
diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
index aaefed6..e543f69 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -2217,7 +2217,7 @@ gen_expr (struct expression *exp, union exp_element **pc,
default:
error (_("Unsupported operator %s (%d) in expression."),
- op_name (exp, op), op);
+ op_name (op), op);
}
}
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index b43d1af..6dcb99c 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -822,7 +822,6 @@ const struct exp_descriptor exp_descriptor_c =
print_subexp_standard,
operator_length_standard,
operator_check_standard,
- op_name_standard,
dump_subexp_body_standard,
evaluate_subexp_c
};
diff --git a/gdb/expprint.c b/gdb/expprint.c
index 2f97cc0..9fdde9b 100644
--- a/gdb/expprint.c
+++ b/gdb/expprint.c
@@ -649,19 +649,11 @@ op_string (enum exp_opcode op)
static int dump_subexp_body (struct expression *exp, struct ui_file *, int);
-/* Name for OPCODE, when it appears in expression EXP. */
-
-char *
-op_name (struct expression *exp, enum exp_opcode opcode)
-{
- return exp->language_defn->la_exp_desc->op_name (opcode);
-}
-
/* Default name for the standard operator OPCODE (i.e., one defined in
the definition of enum exp_opcode). */
char *
-op_name_standard (enum exp_opcode opcode)
+op_name (enum exp_opcode opcode)
{
switch (opcode)
{
@@ -704,7 +696,7 @@ dump_raw_expression (struct expression *exp, struct ui_file *stream,
for (elt = 0; elt < exp->nelts; elt++)
{
fprintf_filtered (stream, "\t%5d ", elt);
- opcode_name = op_name (exp, exp->elts[elt].opcode);
+ opcode_name = op_name (exp->elts[elt].opcode);
fprintf_filtered (stream, "%20s ", opcode_name);
print_longest (stream, 'd', 0, exp->elts[elt].longconst);
@@ -739,7 +731,7 @@ dump_subexp (struct expression *exp, struct ui_file *stream, int elt)
fprintf_filtered (stream, " ");
indent += 2;
- fprintf_filtered (stream, "%-20s ", op_name (exp, exp->elts[elt].opcode));
+ fprintf_filtered (stream, "%-20s ", op_name (exp->elts[elt].opcode));
elt = dump_subexp_body (exp, stream, elt);
diff --git a/gdb/expression.h b/gdb/expression.h
index f45b705..3553b51 100644
--- a/gdb/expression.h
+++ b/gdb/expression.h
@@ -129,7 +129,7 @@ extern struct value *evaluate_subexp_standard
extern void print_expression (struct expression *, struct ui_file *);
-extern char *op_name (struct expression *exp, enum exp_opcode opcode);
+extern char *op_name (enum exp_opcode opcode);
extern char *op_string (enum exp_opcode);
diff --git a/gdb/jv-lang.c b/gdb/jv-lang.c
index 280a3af..b6514bb 100644
--- a/gdb/jv-lang.c
+++ b/gdb/jv-lang.c
@@ -1156,7 +1156,6 @@ const struct exp_descriptor exp_descriptor_java =
print_subexp_standard,
operator_length_standard,
operator_check_standard,
- op_name_standard,
dump_subexp_body_standard,
evaluate_subexp_java
};
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index c76d3ea..2a194cd 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -360,7 +360,6 @@ const struct exp_descriptor exp_descriptor_modula2 =
print_subexp_standard,
operator_length_standard,
operator_check_standard,
- op_name_standard,
dump_subexp_body_standard,
evaluate_subexp_modula2
};
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index d5cd058..0c13e26 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -983,7 +983,6 @@ const struct exp_descriptor exp_descriptor_opencl =
print_subexp_standard,
operator_length_standard,
operator_check_standard,
- op_name_standard,
dump_subexp_body_standard,
evaluate_subexp_opencl
};
diff --git a/gdb/parse.c b/gdb/parse.c
index e0fa1f3..6a52762 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -62,7 +62,6 @@ const struct exp_descriptor exp_descriptor_standard =
print_subexp_standard,
operator_length_standard,
operator_check_standard,
- op_name_standard,
dump_subexp_body_standard,
evaluate_subexp_standard
};
diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h
index 16b40ac..e5121a4 100644
--- a/gdb/parser-defs.h
+++ b/gdb/parser-defs.h
@@ -195,8 +195,6 @@ extern int operator_check_standard (struct expression *exp, int pos,
(struct objfile *objfile, void *data),
void *data);
-extern char *op_name_standard (enum exp_opcode);
-
extern struct type *follow_types (struct type *);
extern void null_post_parser (struct expression **, int);
@@ -281,9 +279,6 @@ struct exp_descriptor
void *data),
void *data);
- /* Name of this operator for dumping purposes. */
- char *(*op_name) (enum exp_opcode);
-
/* Dump the rest of this (prefix) expression after the operator
itself has been printed. See dump_subexp_body_standard in
(expprint.c). */
--
1.7.1