1 /* Print in infix form a struct expression.
3 Copyright (C) 1986, 1988-1989, 1991-2000, 2003, 2007-2012 Free
4 Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
24 #include "expression.h"
27 #include "parser-defs.h"
28 #include "user-regs.h" /* For user_reg_map_regnum_to_name. */
30 #include "gdb_string.h"
33 #include "gdb_assert.h"
41 print_expression (struct expression *exp, struct ui_file *stream)
45 print_subexp (exp, &pc, stream, PREC_NULL);
48 /* Print the subexpression of EXP that starts in position POS, on STREAM.
49 PREC is the precedence of the surrounding operator;
50 if the precedence of the main operator of this subexpression is less,
51 parentheses are needed here. */
54 print_subexp (struct expression *exp, int *pos,
55 struct ui_file *stream, enum precedence prec)
57 exp->language_defn->la_exp_desc->print_subexp (exp, pos, stream, prec);
60 /* Standard implementation of print_subexp for use in language_defn
63 print_subexp_standard (struct expression *exp, int *pos,
64 struct ui_file *stream, enum precedence prec)
67 const struct op_print *op_print_tab;
71 int assign_modify = 0;
72 enum exp_opcode opcode;
73 enum precedence myprec = PREC_NULL;
74 /* Set to 1 for a right-associative operator. */
79 op_print_tab = exp->language_defn->la_op_print_tab;
81 opcode = exp->elts[pc].opcode;
89 fputs_filtered (type_name_no_tag (exp->elts[pc + 1].type), stream);
90 fputs_filtered ("::", stream);
91 nargs = longest_to_int (exp->elts[pc + 2].longconst);
92 (*pos) += 4 + BYTES_TO_EXP_ELEM (nargs + 1);
93 fputs_filtered (&exp->elts[pc + 3].string, stream);
98 struct value_print_options opts;
100 get_raw_print_options (&opts);
102 value_print (value_from_longest (exp->elts[pc + 1].type,
103 exp->elts[pc + 2].longconst),
110 struct value_print_options opts;
112 get_raw_print_options (&opts);
114 value_print (value_from_double (exp->elts[pc + 1].type,
115 exp->elts[pc + 2].doubleconst),
125 b = exp->elts[pc + 1].block;
127 && BLOCK_FUNCTION (b) != NULL
128 && SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b)) != NULL)
130 fputs_filtered (SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b)), stream);
131 fputs_filtered ("::", stream);
133 fputs_filtered (SYMBOL_PRINT_NAME (exp->elts[pc + 2].symbol), stream);
137 case OP_VAR_ENTRY_VALUE:
140 fprintf_filtered (stream, "%s@entry",
141 SYMBOL_PRINT_NAME (exp->elts[pc + 1].symbol));
147 fprintf_filtered (stream, "$%d",
148 longest_to_int (exp->elts[pc + 1].longconst));
153 const char *name = &exp->elts[pc + 2].string;
155 (*pos) += 3 + BYTES_TO_EXP_ELEM (exp->elts[pc + 1].longconst + 1);
156 fprintf_filtered (stream, "$%s", name);
162 fprintf_filtered (stream, "%s",
163 longest_to_int (exp->elts[pc + 1].longconst)
169 fprintf_filtered (stream, "$%s",
170 internalvar_name (exp->elts[pc + 1].internalvar));
175 nargs = longest_to_int (exp->elts[pc + 1].longconst);
176 print_subexp (exp, pos, stream, PREC_SUFFIX);
177 fputs_filtered (" (", stream);
178 for (tem = 0; tem < nargs; tem++)
181 fputs_filtered (", ", stream);
182 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
184 fputs_filtered (")", stream);
188 nargs = longest_to_int (exp->elts[pc + 1].longconst);
189 (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
190 fputs_filtered (&exp->elts[pc + 2].string, stream);
195 struct value_print_options opts;
197 nargs = longest_to_int (exp->elts[pc + 1].longconst);
198 (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
199 /* LA_PRINT_STRING will print using the current repeat count threshold.
200 If necessary, we can temporarily set it to zero, or pass it as an
201 additional parameter to LA_PRINT_STRING. -fnf */
202 get_user_print_options (&opts);
203 LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char,
204 &exp->elts[pc + 2].string, nargs, NULL, 0, &opts);
209 nargs = longest_to_int (exp->elts[pc + 1].longconst);
211 += 3 + BYTES_TO_EXP_ELEM ((nargs + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT);
212 fprintf_unfiltered (stream, "B'<unimplemented>'");
215 case OP_OBJC_NSSTRING: /* Objective-C Foundation Class
216 NSString constant. */
218 struct value_print_options opts;
220 nargs = longest_to_int (exp->elts[pc + 1].longconst);
221 (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
222 fputs_filtered ("@\"", stream);
223 get_user_print_options (&opts);
224 LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char,
225 &exp->elts[pc + 2].string, nargs, NULL, 0, &opts);
226 fputs_filtered ("\"", stream);
230 case OP_OBJC_MSGCALL:
231 { /* Objective C message (method) call. */
235 nargs = longest_to_int (exp->elts[pc + 2].longconst);
236 fprintf_unfiltered (stream, "[");
237 print_subexp (exp, pos, stream, PREC_SUFFIX);
238 if (0 == target_read_string (exp->elts[pc + 1].longconst,
239 &selector, 1024, NULL))
241 error (_("bad selector"));
248 s = alloca (strlen (selector) + 1);
249 strcpy (s, selector);
250 for (tem = 0; tem < nargs; tem++)
252 nextS = strchr (s, ':');
253 gdb_assert (nextS); /* Make sure we found ':'. */
255 fprintf_unfiltered (stream, " %s: ", s);
257 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
262 fprintf_unfiltered (stream, " %s", selector);
264 fprintf_unfiltered (stream, "]");
265 /* "selector" was malloc'd by target_read_string. Free it. */
272 nargs = longest_to_int (exp->elts[pc + 2].longconst);
273 nargs -= longest_to_int (exp->elts[pc + 1].longconst);
276 if (exp->elts[pc + 4].opcode == OP_LONG
277 && exp->elts[pc + 5].type
278 == builtin_type (exp->gdbarch)->builtin_char
279 && exp->language_defn->la_language == language_c)
281 /* Attempt to print C character arrays using string syntax.
282 Walk through the args, picking up one character from each
283 of the OP_LONG expression elements. If any array element
284 does not match our expection of what we should find for
285 a simple string, revert back to array printing. Note that
286 the last expression element is an explicit null terminator
287 byte, which doesn't get printed. */
288 tempstr = alloca (nargs);
292 if (exp->elts[pc].opcode != OP_LONG
293 || exp->elts[pc + 1].type
294 != builtin_type (exp->gdbarch)->builtin_char)
296 /* Not a simple array of char, use regular array
304 longest_to_int (exp->elts[pc + 2].longconst);
311 struct value_print_options opts;
313 get_user_print_options (&opts);
314 LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char,
315 tempstr, nargs - 1, NULL, 0, &opts);
320 fputs_filtered (" {", stream);
321 for (tem = 0; tem < nargs; tem++)
325 fputs_filtered (", ", stream);
327 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
329 fputs_filtered ("}", stream);
334 tem = longest_to_int (exp->elts[pc + 1].longconst);
335 (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
336 /* Gcc support both these syntaxes. Unsure which is preferred. */
338 fputs_filtered (&exp->elts[pc + 2].string, stream);
339 fputs_filtered (": ", stream);
341 fputs_filtered (".", stream);
342 fputs_filtered (&exp->elts[pc + 2].string, stream);
343 fputs_filtered ("=", stream);
345 print_subexp (exp, pos, stream, PREC_SUFFIX);
349 if ((int) prec > (int) PREC_COMMA)
350 fputs_filtered ("(", stream);
351 /* Print the subexpressions, forcing parentheses
352 around any binary operations within them.
353 This is more parentheses than are strictly necessary,
354 but it looks clearer. */
355 print_subexp (exp, pos, stream, PREC_HYPER);
356 fputs_filtered (" ? ", stream);
357 print_subexp (exp, pos, stream, PREC_HYPER);
358 fputs_filtered (" : ", stream);
359 print_subexp (exp, pos, stream, PREC_HYPER);
360 if ((int) prec > (int) PREC_COMMA)
361 fputs_filtered (")", stream);
365 case TERNOP_SLICE_COUNT:
366 print_subexp (exp, pos, stream, PREC_SUFFIX);
367 fputs_filtered ("(", stream);
368 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
369 fputs_filtered (opcode == TERNOP_SLICE ? " : " : " UP ", stream);
370 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
371 fputs_filtered (")", stream);
374 case STRUCTOP_STRUCT:
375 tem = longest_to_int (exp->elts[pc + 1].longconst);
376 (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
377 print_subexp (exp, pos, stream, PREC_SUFFIX);
378 fputs_filtered (".", stream);
379 fputs_filtered (&exp->elts[pc + 2].string, stream);
382 /* Will not occur for Modula-2. */
384 tem = longest_to_int (exp->elts[pc + 1].longconst);
385 (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
386 print_subexp (exp, pos, stream, PREC_SUFFIX);
387 fputs_filtered ("->", stream);
388 fputs_filtered (&exp->elts[pc + 2].string, stream);
391 case STRUCTOP_MEMBER:
392 print_subexp (exp, pos, stream, PREC_SUFFIX);
393 fputs_filtered (".*", stream);
394 print_subexp (exp, pos, stream, PREC_SUFFIX);
398 print_subexp (exp, pos, stream, PREC_SUFFIX);
399 fputs_filtered ("->*", stream);
400 print_subexp (exp, pos, stream, PREC_SUFFIX);
403 case BINOP_SUBSCRIPT:
404 print_subexp (exp, pos, stream, PREC_SUFFIX);
405 fputs_filtered ("[", stream);
406 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
407 fputs_filtered ("]", stream);
410 case UNOP_POSTINCREMENT:
411 print_subexp (exp, pos, stream, PREC_SUFFIX);
412 fputs_filtered ("++", stream);
415 case UNOP_POSTDECREMENT:
416 print_subexp (exp, pos, stream, PREC_SUFFIX);
417 fputs_filtered ("--", stream);
422 if ((int) prec > (int) PREC_PREFIX)
423 fputs_filtered ("(", stream);
424 fputs_filtered ("(", stream);
425 type_print (exp->elts[pc + 1].type, "", stream, 0);
426 fputs_filtered (") ", stream);
427 print_subexp (exp, pos, stream, PREC_PREFIX);
428 if ((int) prec > (int) PREC_PREFIX)
429 fputs_filtered (")", stream);
432 case UNOP_DYNAMIC_CAST:
433 case UNOP_REINTERPRET_CAST:
434 fputs_filtered (opcode == UNOP_DYNAMIC_CAST ? "dynamic_cast"
435 : "reinterpret_cast", stream);
436 fputs_filtered ("<", stream);
438 type_print (exp->elts[pc + 1].type, "", stream, 0);
439 fputs_filtered ("> (", stream);
440 print_subexp (exp, pos, stream, PREC_PREFIX);
441 fputs_filtered (")", stream);
446 if ((int) prec > (int) PREC_PREFIX)
447 fputs_filtered ("(", stream);
448 if (TYPE_CODE (exp->elts[pc + 1].type) == TYPE_CODE_FUNC
449 && exp->elts[pc + 3].opcode == OP_LONG)
451 struct value_print_options opts;
453 /* We have a minimal symbol fn, probably. It's encoded
454 as a UNOP_MEMVAL (function-type) of an OP_LONG (int, address).
455 Swallow the OP_LONG (including both its opcodes); ignore
456 its type; print the value in the type of the MEMVAL. */
458 val = value_at_lazy (exp->elts[pc + 1].type,
459 (CORE_ADDR) exp->elts[pc + 5].longconst);
460 get_raw_print_options (&opts);
461 value_print (val, stream, &opts);
465 fputs_filtered ("{", stream);
466 type_print (exp->elts[pc + 1].type, "", stream, 0);
467 fputs_filtered ("} ", stream);
468 print_subexp (exp, pos, stream, PREC_PREFIX);
470 if ((int) prec > (int) PREC_PREFIX)
471 fputs_filtered (")", stream);
474 case UNOP_MEMVAL_TLS:
476 if ((int) prec > (int) PREC_PREFIX)
477 fputs_filtered ("(", stream);
478 fputs_filtered ("{", stream);
479 type_print (exp->elts[pc + 2].type, "", stream, 0);
480 fputs_filtered ("} ", stream);
481 print_subexp (exp, pos, stream, PREC_PREFIX);
482 if ((int) prec > (int) PREC_PREFIX)
483 fputs_filtered (")", stream);
486 case BINOP_ASSIGN_MODIFY:
487 opcode = exp->elts[pc + 1].opcode;
489 myprec = PREC_ASSIGN;
493 for (tem = 0; op_print_tab[tem].opcode != OP_NULL; tem++)
494 if (op_print_tab[tem].opcode == opcode)
496 op_str = op_print_tab[tem].string;
499 if (op_print_tab[tem].opcode != opcode)
500 /* Not found; don't try to keep going because we don't know how
501 to interpret further elements. */
502 error (_("Invalid expression"));
509 if (exp->language_defn->la_name_of_this)
510 fputs_filtered (exp->language_defn->la_name_of_this, stream);
512 fprintf_filtered (stream, _("<language %s has no 'this'>"),
513 exp->language_defn->la_name);
518 case MULTI_SUBSCRIPT:
520 nargs = longest_to_int (exp->elts[pc + 1].longconst);
521 print_subexp (exp, pos, stream, PREC_SUFFIX);
522 fprintf_unfiltered (stream, " [");
523 for (tem = 0; tem < nargs; tem++)
526 fprintf_unfiltered (stream, ", ");
527 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
529 fprintf_unfiltered (stream, "]");
534 fprintf_unfiltered (stream, "VAL(");
535 type_print (exp->elts[pc + 1].type, "", stream, 0);
536 fprintf_unfiltered (stream, ",");
537 print_subexp (exp, pos, stream, PREC_PREFIX);
538 fprintf_unfiltered (stream, ")");
543 LONGEST count = exp->elts[pc + 1].longconst;
547 fputs_unfiltered ("TypesInstance(", stream);
550 type_print (exp->elts[(*pos)++].type, "", stream, 0);
552 fputs_unfiltered (",", stream);
554 fputs_unfiltered (",", stream);
555 /* Ending COUNT and ending TYPE_INSTANCE. */
557 print_subexp (exp, pos, stream, PREC_PREFIX);
558 fputs_unfiltered (")", stream);
566 for (tem = 0; op_print_tab[tem].opcode != OP_NULL; tem++)
567 if (op_print_tab[tem].opcode == opcode)
569 op_str = op_print_tab[tem].string;
570 myprec = op_print_tab[tem].precedence;
571 assoc = op_print_tab[tem].right_assoc;
574 if (op_print_tab[tem].opcode != opcode)
575 /* Not found; don't try to keep going because we don't know how
576 to interpret further elements. For example, this happens
577 if opcode is OP_TYPE. */
578 error (_("Invalid expression"));
581 /* Note that PREC_BUILTIN will always emit parentheses. */
582 if ((int) myprec < (int) prec)
583 fputs_filtered ("(", stream);
584 if ((int) opcode > (int) BINOP_END)
588 /* Unary postfix operator. */
589 print_subexp (exp, pos, stream, PREC_SUFFIX);
590 fputs_filtered (op_str, stream);
594 /* Unary prefix operator. */
595 fputs_filtered (op_str, stream);
596 if (myprec == PREC_BUILTIN_FUNCTION)
597 fputs_filtered ("(", stream);
598 print_subexp (exp, pos, stream, PREC_PREFIX);
599 if (myprec == PREC_BUILTIN_FUNCTION)
600 fputs_filtered (")", stream);
605 /* Binary operator. */
606 /* Print left operand.
607 If operator is right-associative,
608 increment precedence for this operand. */
609 print_subexp (exp, pos, stream,
610 (enum precedence) ((int) myprec + assoc));
611 /* Print the operator itself. */
613 fprintf_filtered (stream, " %s= ", op_str);
614 else if (op_str[0] == ',')
615 fprintf_filtered (stream, "%s ", op_str);
617 fprintf_filtered (stream, " %s ", op_str);
618 /* Print right operand.
619 If operator is left-associative,
620 increment precedence for this operand. */
621 print_subexp (exp, pos, stream,
622 (enum precedence) ((int) myprec + !assoc));
625 if ((int) myprec < (int) prec)
626 fputs_filtered (")", stream);
629 /* Return the operator corresponding to opcode OP as
630 a string. NULL indicates that the opcode was not found in the
631 current language table. */
633 op_string (enum exp_opcode op)
636 const struct op_print *op_print_tab;
638 op_print_tab = current_language->la_op_print_tab;
639 for (tem = 0; op_print_tab[tem].opcode != OP_NULL; tem++)
640 if (op_print_tab[tem].opcode == op)
641 return op_print_tab[tem].string;
645 /* Support for dumping the raw data from expressions in a human readable
648 static int dump_subexp_body (struct expression *exp, struct ui_file *, int);
650 /* Name for OPCODE, when it appears in expression EXP. */
653 op_name (struct expression *exp, enum exp_opcode opcode)
655 return exp->language_defn->la_exp_desc->op_name (opcode);
658 /* Default name for the standard operator OPCODE (i.e., one defined in
659 the definition of enum exp_opcode). */
662 op_name_standard (enum exp_opcode opcode)
670 sprintf (buf, "<unknown %d>", opcode);
676 #include "std-operator.def"
681 /* Print a raw dump of expression EXP to STREAM.
682 NOTE, if non-NULL, is printed as extra explanatory text. */
685 dump_raw_expression (struct expression *exp, struct ui_file *stream,
693 fprintf_filtered (stream, "Dump of expression @ ");
694 gdb_print_host_address (exp, stream);
696 fprintf_filtered (stream, ", %s:", note);
697 fprintf_filtered (stream, "\n\tLanguage %s, %d elements, %ld bytes each.\n",
698 exp->language_defn->la_name, exp->nelts,
699 (long) sizeof (union exp_element));
700 fprintf_filtered (stream, "\t%5s %20s %16s %s\n", "Index", "Opcode",
701 "Hex Value", "String Value");
702 for (elt = 0; elt < exp->nelts; elt++)
704 fprintf_filtered (stream, "\t%5d ", elt);
705 opcode_name = op_name (exp, exp->elts[elt].opcode);
707 fprintf_filtered (stream, "%20s ", opcode_name);
708 print_longest (stream, 'd', 0, exp->elts[elt].longconst);
709 fprintf_filtered (stream, " ");
711 for (eltscan = (char *) &exp->elts[elt],
712 eltsize = sizeof (union exp_element);
716 fprintf_filtered (stream, "%c",
717 isprint (*eltscan) ? (*eltscan & 0xFF) : '.');
719 fprintf_filtered (stream, "\n");
723 /* Dump the subexpression of prefix expression EXP whose operator is at
724 position ELT onto STREAM. Returns the position of the next
725 subexpression in EXP. */
728 dump_subexp (struct expression *exp, struct ui_file *stream, int elt)
730 static int indent = 0;
733 fprintf_filtered (stream, "\n");
734 fprintf_filtered (stream, "\t%5d ", elt);
736 for (i = 1; i <= indent; i++)
737 fprintf_filtered (stream, " ");
740 fprintf_filtered (stream, "%-20s ", op_name (exp, exp->elts[elt].opcode));
742 elt = dump_subexp_body (exp, stream, elt);
749 /* Dump the operands of prefix expression EXP whose opcode is at
750 position ELT onto STREAM. Returns the position of the next
751 subexpression in EXP. */
754 dump_subexp_body (struct expression *exp, struct ui_file *stream, int elt)
756 return exp->language_defn->la_exp_desc->dump_subexp_body (exp, stream, elt);
759 /* Default value for subexp_body in exp_descriptor vector. */
762 dump_subexp_body_standard (struct expression *exp,
763 struct ui_file *stream, int elt)
765 int opcode = exp->elts[elt++].opcode;
771 case TERNOP_SLICE_COUNT:
772 elt = dump_subexp (exp, stream, elt);
782 case BINOP_LOGICAL_AND:
783 case BINOP_LOGICAL_OR:
784 case BINOP_BITWISE_AND:
785 case BINOP_BITWISE_IOR:
786 case BINOP_BITWISE_XOR:
796 case BINOP_SUBSCRIPT:
801 case BINOP_ASSIGN_MODIFY:
807 case STRUCTOP_MEMBER:
809 elt = dump_subexp (exp, stream, elt);
812 case UNOP_LOGICAL_NOT:
813 case UNOP_COMPLEMENT:
816 case UNOP_PREINCREMENT:
817 case UNOP_POSTINCREMENT:
818 case UNOP_PREDECREMENT:
819 case UNOP_POSTDECREMENT:
832 elt = dump_subexp (exp, stream, elt);
835 fprintf_filtered (stream, "Type @");
836 gdb_print_host_address (exp->elts[elt].type, stream);
837 fprintf_filtered (stream, " (");
838 type_print (exp->elts[elt].type, NULL, stream, 0);
839 fprintf_filtered (stream, "), value %ld (0x%lx)",
840 (long) exp->elts[elt + 1].longconst,
841 (long) exp->elts[elt + 1].longconst);
845 fprintf_filtered (stream, "Type @");
846 gdb_print_host_address (exp->elts[elt].type, stream);
847 fprintf_filtered (stream, " (");
848 type_print (exp->elts[elt].type, NULL, stream, 0);
849 fprintf_filtered (stream, "), value %g",
850 (double) exp->elts[elt + 1].doubleconst);
854 fprintf_filtered (stream, "Block @");
855 gdb_print_host_address (exp->elts[elt].block, stream);
856 fprintf_filtered (stream, ", symbol @");
857 gdb_print_host_address (exp->elts[elt + 1].symbol, stream);
858 fprintf_filtered (stream, " (%s)",
859 SYMBOL_PRINT_NAME (exp->elts[elt + 1].symbol));
862 case OP_VAR_ENTRY_VALUE:
863 fprintf_filtered (stream, "Entry value of symbol @");
864 gdb_print_host_address (exp->elts[elt].symbol, stream);
865 fprintf_filtered (stream, " (%s)",
866 SYMBOL_PRINT_NAME (exp->elts[elt].symbol));
870 fprintf_filtered (stream, "History element %ld",
871 (long) exp->elts[elt].longconst);
875 fprintf_filtered (stream, "Register $%s", &exp->elts[elt + 1].string);
876 elt += 3 + BYTES_TO_EXP_ELEM (exp->elts[elt].longconst + 1);
879 fprintf_filtered (stream, "Internal var @");
880 gdb_print_host_address (exp->elts[elt].internalvar, stream);
881 fprintf_filtered (stream, " (%s)",
882 internalvar_name (exp->elts[elt].internalvar));
889 nargs = longest_to_int (exp->elts[elt].longconst);
891 fprintf_filtered (stream, "Number of args: %d", nargs);
894 for (i = 1; i <= nargs + 1; i++)
895 elt = dump_subexp (exp, stream, elt);
903 lower = longest_to_int (exp->elts[elt].longconst);
904 upper = longest_to_int (exp->elts[elt + 1].longconst);
906 fprintf_filtered (stream, "Bounds [%d:%d]", lower, upper);
909 for (i = 1; i <= upper - lower + 1; i++)
910 elt = dump_subexp (exp, stream, elt);
915 case UNOP_DYNAMIC_CAST:
916 case UNOP_REINTERPRET_CAST:
917 fprintf_filtered (stream, "Type @");
918 gdb_print_host_address (exp->elts[elt].type, stream);
919 fprintf_filtered (stream, " (");
920 type_print (exp->elts[elt].type, NULL, stream, 0);
921 fprintf_filtered (stream, ")");
922 elt = dump_subexp (exp, stream, elt + 2);
924 case UNOP_MEMVAL_TLS:
925 fprintf_filtered (stream, "TLS type @");
926 gdb_print_host_address (exp->elts[elt + 1].type, stream);
927 fprintf_filtered (stream, " (__thread /* \"%s\" */ ",
928 (exp->elts[elt].objfile == NULL ? "(null)"
929 : exp->elts[elt].objfile->name));
930 type_print (exp->elts[elt + 1].type, NULL, stream, 0);
931 fprintf_filtered (stream, ")");
932 elt = dump_subexp (exp, stream, elt + 3);
935 fprintf_filtered (stream, "Type @");
936 gdb_print_host_address (exp->elts[elt].type, stream);
937 fprintf_filtered (stream, " (");
938 type_print (exp->elts[elt].type, NULL, stream, 0);
939 fprintf_filtered (stream, ")");
942 case STRUCTOP_STRUCT:
948 len = longest_to_int (exp->elts[elt].longconst);
949 elem_name = &exp->elts[elt + 1].string;
951 fprintf_filtered (stream, "Element name: `%.*s'", len, elem_name);
952 elt = dump_subexp (exp, stream, elt + 3 + BYTES_TO_EXP_ELEM (len + 1));
960 fprintf_filtered (stream, "Type @");
961 gdb_print_host_address (exp->elts[elt].type, stream);
962 fprintf_filtered (stream, " (");
963 type_print (exp->elts[elt].type, NULL, stream, 0);
964 fprintf_filtered (stream, ") ");
966 len = longest_to_int (exp->elts[elt + 1].longconst);
967 elem_name = &exp->elts[elt + 2].string;
969 fprintf_filtered (stream, "Field name: `%.*s'", len, elem_name);
970 elt += 4 + BYTES_TO_EXP_ELEM (len + 1);
977 len = exp->elts[elt++].longconst;
978 fprintf_filtered (stream, "%s TypeInstance: ", plongest (len));
981 fprintf_filtered (stream, "Type @");
982 gdb_print_host_address (exp->elts[elt].type, stream);
983 fprintf_filtered (stream, " (");
984 type_print (exp->elts[elt].type, NULL, stream, 0);
985 fprintf_filtered (stream, ")");
988 fputs_filtered (", ", stream);
990 /* Ending LEN and ending TYPE_INSTANCE. */
992 elt = dump_subexp (exp, stream, elt);
997 case MULTI_SUBSCRIPT:
998 case OP_F77_UNDETERMINED_ARGLIST:
1007 fprintf_filtered (stream, "Unknown format");
1014 dump_prefix_expression (struct expression *exp, struct ui_file *stream)
1018 fprintf_filtered (stream, "Dump of expression @ ");
1019 gdb_print_host_address (exp, stream);
1020 fputs_filtered (", after conversion to prefix form:\nExpression: `", stream);
1021 if (exp->elts[0].opcode != OP_TYPE)
1022 print_expression (exp, stream);
1024 fputs_filtered ("Type printing not yet supported....", stream);
1025 fprintf_filtered (stream, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",
1026 exp->language_defn->la_name, exp->nelts,
1027 (long) sizeof (union exp_element));
1028 fputs_filtered ("\n", stream);
1030 for (elt = 0; elt < exp->nelts;)
1031 elt = dump_subexp (exp, stream, elt);
1032 fputs_filtered ("\n", stream);