aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2020-11-30 01:37:10 -0700
committerTom Tromey <tom@tromey.com>2020-11-30 01:37:10 -0700
commit88b91969e1ae5d23f81b86ae6cd3c85b284c6294 (patch)
tree33a677f9adac503851cc9e659d7e2b896e11dddd /gdb
parent1cd49c43f340e4de62922356ed859ee806e52f6f (diff)
downloadbinutils-88b91969e1ae5d23f81b86ae6cd3c85b284c6294.zip
binutils-88b91969e1ae5d23f81b86ae6cd3c85b284c6294.tar.gz
binutils-88b91969e1ae5d23f81b86ae6cd3c85b284c6294.tar.bz2
Remove per-language op_name functions
enum exp_opcode is created from all the .def files, but then each language is required to implement its own op_name function to turn an enum value to a string. This seemed over-complicated to me, and this patch removes the per-language functions in favor of simply using the .def names for all languages. Note that op_name is only used for dumping expressions, which is a maintainer/debug feature. Furthermore, I don't think there was any case where the .def name and the string name differed. gdb/ChangeLog 2020-11-30 Tom Tromey <tom@tromey.com> * rust-lang.c (rust_op_name): Remove. (exp_descriptor_rust): Update. * parser-defs.h (op_name_standard): Don't declare. (struct exp_descriptor) <op_name>: Remove. * parse.c (exp_descriptor_standard): Update. * opencl-lang.c (exp_descriptor_opencl): Update. * m2-lang.c (m2_language::exp_descriptor_modula2): Update. * f-lang.c (op_name_f): Remove. (f_language::exp_descriptor_tab): Update. * expression.h (op_name): Update. * expprint.c (op_name): Rewrite. (op_name_standard): Remove. (dump_raw_expression, dump_subexp): Update. * c-lang.c (exp_descriptor_c): Update. * ax-gdb.c (gen_expr): Update. * ada-lang.c (ada_op_name): Remove. (ada_exp_descriptor): Update.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog20
-rw-r--r--gdb/ada-lang.c24
-rw-r--r--gdb/ax-gdb.c2
-rw-r--r--gdb/c-lang.c1
-rw-r--r--gdb/expprint.c23
-rw-r--r--gdb/expression.h2
-rw-r--r--gdb/f-lang.c19
-rw-r--r--gdb/m2-lang.c1
-rw-r--r--gdb/opencl-lang.c1
-rw-r--r--gdb/parse.c1
-rw-r--r--gdb/parser-defs.h8
-rw-r--r--gdb/rust-lang.c17
12 files changed, 27 insertions, 92 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 813305d..b6c4862 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,25 @@
2020-11-30 Tom Tromey <tom@tromey.com>
+ * rust-lang.c (rust_op_name): Remove.
+ (exp_descriptor_rust): Update.
+ * parser-defs.h (op_name_standard): Don't declare.
+ (struct exp_descriptor) <op_name>: Remove.
+ * parse.c (exp_descriptor_standard): Update.
+ * opencl-lang.c (exp_descriptor_opencl): Update.
+ * m2-lang.c (m2_language::exp_descriptor_modula2): Update.
+ * f-lang.c (op_name_f): Remove.
+ (f_language::exp_descriptor_tab): Update.
+ * expression.h (op_name): Update.
+ * expprint.c (op_name): Rewrite.
+ (op_name_standard): Remove.
+ (dump_raw_expression, dump_subexp): Update.
+ * c-lang.c (exp_descriptor_c): Update.
+ * ax-gdb.c (gen_expr): Update.
+ * ada-lang.c (ada_op_name): Remove.
+ (ada_exp_descriptor): Update.
+
+2020-11-30 Tom Tromey <tom@tromey.com>
+
* eval.c (init_array_element): Remove.
(evaluate_subexp_standard) <OP_ARRAY>: Remove "index_pc".
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 714227d..9066711 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -127,8 +127,6 @@ static void replace_operator_with_call (expression_up *, int, int, int,
static int possible_user_operator_p (enum exp_opcode, struct value **);
-static const char *ada_op_name (enum exp_opcode);
-
static const char *ada_decoded_op_name (enum exp_opcode);
static int numeric_type_p (struct type *);
@@ -13289,27 +13287,6 @@ ada_operator_check (struct expression *exp, int pos,
return 0;
}
-static const 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. */
@@ -13601,7 +13578,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 601c752..cea37da 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -2266,7 +2266,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 624aea52f..2a17e00 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -846,7 +846,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 29e6237..f1cf62e 100644
--- a/gdb/expprint.c
+++ b/gdb/expprint.c
@@ -685,26 +685,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. */
-
-const char *
-op_name (struct expression *exp, enum exp_opcode opcode)
-{
- if (opcode >= OP_UNUSED_LAST)
- {
- char *cell = get_print_cell ();
- xsnprintf (cell, PRINT_CELL_SIZE, "unknown opcode: %u",
- unsigned (opcode));
- return cell;
- }
- return exp->language_defn->expression_ops ()->op_name (opcode);
-}
-
/* Default name for the standard operator OPCODE (i.e., one defined in
the definition of enum exp_opcode). */
const char *
-op_name_standard (enum exp_opcode opcode)
+op_name (enum exp_opcode opcode)
{
switch (opcode)
{
@@ -719,6 +704,8 @@ op_name_standard (enum exp_opcode opcode)
case name: \
return #name ;
#include "std-operator.def"
+#include "ada-operator.def"
+#include "fortran-operator.def"
#undef OP
}
}
@@ -747,7 +734,7 @@ dump_raw_expression (struct expression *exp, struct ui_file *stream,
{
fprintf_filtered (stream, "\t%5d ", elt);
- const char *opcode_name = op_name (exp, exp->elts[elt].opcode);
+ const char *opcode_name = op_name (exp->elts[elt].opcode);
fprintf_filtered (stream, "%20s ", opcode_name);
print_longest (stream, 'd', 0, exp->elts[elt].longconst);
@@ -782,7 +769,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 8de7123..a8bfac1 100644
--- a/gdb/expression.h
+++ b/gdb/expression.h
@@ -171,7 +171,7 @@ extern struct value *evaluate_subexp_do_call (expression *exp,
extern void print_expression (struct expression *, struct ui_file *);
-extern const char *op_name (struct expression *exp, enum exp_opcode opcode);
+extern const char *op_name (enum exp_opcode opcode);
extern const char *op_string (enum exp_opcode);
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 4171c96..6771758 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -1072,24 +1072,6 @@ print_subexp_f (struct expression *exp, int *pos,
}
}
-/* Special expression names for Fortran. */
-
-static const char *
-op_name_f (enum exp_opcode opcode)
-{
- switch (opcode)
- {
- default:
- return op_name_standard (opcode);
-
-#define OP(name) \
- case name: \
- return #name ;
-#include "fortran-operator.def"
-#undef OP
- }
-}
-
/* Special expression dumping for Fortran. */
static int
@@ -1159,7 +1141,6 @@ const struct exp_descriptor f_language::exp_descriptor_tab =
print_subexp_f,
operator_length_f,
operator_check_f,
- op_name_f,
dump_subexp_body_f,
evaluate_subexp_f
};
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index 1155469..2576dca 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -167,7 +167,6 @@ const struct exp_descriptor m2_language::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 830a6ac..ca3a82b 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -948,7 +948,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 8b9dfba..c34b608 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -59,7 +59,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 bc6fc2f..1721605 100644
--- a/gdb/parser-defs.h
+++ b/gdb/parser-defs.h
@@ -355,8 +355,6 @@ extern int operator_check_standard (struct expression *exp, int pos,
(struct objfile *objfile, void *data),
void *data);
-extern const char *op_name_standard (enum exp_opcode);
-
extern bool parse_float (const char *p, int len,
const struct type *type, gdb_byte *data);
@@ -417,12 +415,6 @@ struct exp_descriptor
void *data),
void *data);
- /* Name of this operator for dumping purposes.
- The returned value should never be NULL, even if EXP_OPCODE is
- an unknown opcode (a string containing an image of the numeric
- value of the opcode can be returned, for instance). */
- const 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). */
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index fb2f2d5..b89fd30 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -1680,22 +1680,6 @@ rust_operator_length (const struct expression *exp, int pc, int *oplenp,
*argsp = args;
}
-/* op_name implementation for Rust. */
-
-static const char *
-rust_op_name (enum exp_opcode opcode)
-{
- switch (opcode)
- {
- case OP_AGGREGATE:
- return "OP_AGGREGATE";
- case OP_OTHERS:
- return "OP_OTHERS";
- default:
- return op_name_standard (opcode);
- }
-}
-
/* dump_subexp_body implementation for Rust. */
static int
@@ -1869,7 +1853,6 @@ static const struct exp_descriptor exp_descriptor_rust =
rust_print_subexp,
rust_operator_length,
rust_operator_check,
- rust_op_name,
rust_dump_subexp_body,
rust_evaluate_subexp
};