aboutsummaryrefslogtreecommitdiff
path: root/gdb/expprint.c
diff options
context:
space:
mode:
authorPaul N. Hilfinger <hilfinger@adacore.com>2003-09-24 08:29:42 +0000
committerPaul N. Hilfinger <hilfinger@adacore.com>2003-09-24 08:29:42 +0000
commit24daaebce8a29b276319001e01a278bb388cfa06 (patch)
tree7f3f72b67a280de7ae5ea093de5a3db18ede1453 /gdb/expprint.c
parentd38eb334b68b539208df5647c1b2990e8b1a8cc3 (diff)
downloadgdb-24daaebce8a29b276319001e01a278bb388cfa06.zip
gdb-24daaebce8a29b276319001e01a278bb388cfa06.tar.gz
gdb-24daaebce8a29b276319001e01a278bb388cfa06.tar.bz2
* parser-defs.h (operator_length): Declare.
* parse.c (length_of_subexp): Use operator_length to get operator lengths and arities for operators. Move most code to new operator_length function. (operator_length): New function absorbing most code from length_of_subexp. (prefixify_subexp): Remove large case and use operator_length instead. (parse_exp_1): Use renamings: dump_prefix_expression => dump_raw_expression and dump_postfix_expression => dump_prefix_expression. * expression.h (dump_prefix_expression): Rename to ... (dump_raw_expression): New name. (dump_postfix_expression): Rename to ... (dump_prefix_expression): New name. * expprint.c (dump_subexp): Make global. Add comment. Move most existing code to dump_subexp_body. (dump_subexp_body): New function. (dump_prefix_expression): Rename to dump_raw_expression. Remove attempt to print the expression via print_expression: it can't work before the expression is prefixified. (dump_raw_expression): Renamed from dump_prefix_expression. (dump_postfix_expression): Rename to dump_prefix_expression, since that's what it does. Remove 'note' parameter, since this routine must be used on prefixified expression. (dump_prefix_expression): Renamed from dump_postfix_expression.
Diffstat (limited to 'gdb/expprint.c')
-rw-r--r--gdb/expprint.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/gdb/expprint.c b/gdb/expprint.c
index a3001b1..8db4c36 100644
--- a/gdb/expprint.c
+++ b/gdb/expprint.c
@@ -548,6 +548,7 @@ op_string (enum exp_opcode op)
form. */
static char *op_name (int opcode);
+static int dump_subexp_body (struct expression *exp, struct ui_file *, int);
static char *
op_name (int opcode)
@@ -737,8 +738,8 @@ op_name (int opcode)
}
void
-dump_prefix_expression (struct expression *exp, struct ui_file *stream,
- char *note)
+dump_raw_expression (struct expression *exp, struct ui_file *stream,
+ char *note)
{
int elt;
char *opcode_name;
@@ -747,11 +748,6 @@ dump_prefix_expression (struct expression *exp, struct ui_file *stream,
fprintf_filtered (stream, "Dump of expression @ ");
gdb_print_host_address (exp, stream);
- fprintf_filtered (stream, ", %s:\nExpression: `", note);
- if (exp->elts[0].opcode != OP_TYPE)
- print_expression (exp, stream);
- else
- fprintf_filtered (stream, "Type printing not yet supported....");
fprintf_filtered (stream, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",
exp->language_defn->la_name, exp->nelts,
(long) sizeof (union exp_element));
@@ -778,10 +774,11 @@ dump_prefix_expression (struct expression *exp, struct ui_file *stream,
}
}
-static int dump_subexp (struct expression *exp, struct ui_file *stream,
- int elt);
+/* Dump the subexpression of prefix expression EXP whose operator is at
+ position ELT onto STREAM. Returns the position of the next
+ subexpression in EXP. */
-static int
+int
dump_subexp (struct expression *exp, struct ui_file *stream, int elt)
{
static int indent = 0;
@@ -796,7 +793,23 @@ dump_subexp (struct expression *exp, struct ui_file *stream, int elt)
fprintf_filtered (stream, "%-20s ", op_name (exp->elts[elt].opcode));
- switch (exp->elts[elt++].opcode)
+ elt = dump_subexp_body (exp, stream, elt);
+
+ indent -= 2;
+
+ return elt;
+}
+
+/* Dump the operands of prefix expression EXP whose opcode is at
+ position ELT onto STREAM. Returns the position of the next
+ subexpression in EXP. */
+
+static int
+dump_subexp_body (struct expression *exp, struct ui_file *stream, int elt)
+{
+ int opcode = exp->elts[elt++].opcode;
+
+ switch (opcode)
{
case TERNOP_COND:
case TERNOP_SLICE:
@@ -914,7 +927,7 @@ dump_subexp (struct expression *exp, struct ui_file *stream, int elt)
break;
case OP_FUNCALL:
{
- int nargs;
+ int i, nargs;
nargs = longest_to_int (exp->elts[elt].longconst);
@@ -1006,20 +1019,17 @@ dump_subexp (struct expression *exp, struct ui_file *stream, int elt)
fprintf_filtered (stream, "Unknown format");
}
- indent -= 2;
-
return elt;
}
void
-dump_postfix_expression (struct expression *exp, struct ui_file *stream,
- char *note)
+dump_prefix_expression (struct expression *exp, struct ui_file *stream)
{
int elt;
fprintf_filtered (stream, "Dump of expression @ ");
gdb_print_host_address (exp, stream);
- fprintf_filtered (stream, ", %s:\nExpression: `", note);
+ fputs_filtered (", after conversion to prefix form:\nExpression: `", stream);
if (exp->elts[0].opcode != OP_TYPE)
print_expression (exp, stream);
else