1 /* Print in infix form a struct expression.
3 Copyright (C) 1986-2018 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
23 #include "expression.h"
26 #include "parser-defs.h"
27 #include "user-regs.h" /* For user_reg_map_regnum_to_name. */
36 print_expression (struct expression *exp, struct ui_file *stream)
40 print_subexp (exp, &pc, stream, PREC_NULL);
43 /* Print the subexpression of EXP that starts in position POS, on STREAM.
44 PREC is the precedence of the surrounding operator;
45 if the precedence of the main operator of this subexpression is less,
46 parentheses are needed here. */
49 print_subexp (struct expression *exp, int *pos,
50 struct ui_file *stream, enum precedence prec)
52 exp->language_defn->la_exp_desc->print_subexp (exp, pos, stream, prec);
55 /* Standard implementation of print_subexp for use in language_defn
58 print_subexp_standard (struct expression *exp, int *pos,
59 struct ui_file *stream, enum precedence prec)
62 const struct op_print *op_print_tab;
66 int assign_modify = 0;
67 enum exp_opcode opcode;
68 enum precedence myprec = PREC_NULL;
69 /* Set to 1 for a right-associative operator. */
74 op_print_tab = exp->language_defn->la_op_print_tab;
76 opcode = exp->elts[pc].opcode;
83 type_print (exp->elts[pc + 1].type, "", stream, 0);
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_no_prettyformat_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_no_prettyformat_print_options (&opts);
114 value_print (value_from_contents (exp->elts[pc + 1].type,
115 exp->elts[pc + 2].floatconst),
122 const struct block *b;
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_MSYM_VALUE:
140 fputs_filtered (MSYMBOL_PRINT_NAME (exp->elts[pc + 2].msymbol), stream);
144 case OP_FUNC_STATIC_VAR:
146 tem = longest_to_int (exp->elts[pc + 1].longconst);
147 (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
148 fputs_filtered (&exp->elts[pc + 1].string, stream);
152 case OP_VAR_ENTRY_VALUE:
155 fprintf_filtered (stream, "%s@entry",
156 SYMBOL_PRINT_NAME (exp->elts[pc + 1].symbol));
162 fprintf_filtered (stream, "$%d",
163 longest_to_int (exp->elts[pc + 1].longconst));
168 const char *name = &exp->elts[pc + 2].string;
170 (*pos) += 3 + BYTES_TO_EXP_ELEM (exp->elts[pc + 1].longconst + 1);
171 fprintf_filtered (stream, "$%s", name);
177 fprintf_filtered (stream, "%s",
178 longest_to_int (exp->elts[pc + 1].longconst)
184 fprintf_filtered (stream, "$%s",
185 internalvar_name (exp->elts[pc + 1].internalvar));
189 case OP_F77_UNDETERMINED_ARGLIST:
191 nargs = longest_to_int (exp->elts[pc + 1].longconst);
192 print_subexp (exp, pos, stream, PREC_SUFFIX);
193 fputs_filtered (" (", stream);
194 for (tem = 0; tem < nargs; tem++)
197 fputs_filtered (", ", stream);
198 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
200 fputs_filtered (")", stream);
204 nargs = longest_to_int (exp->elts[pc + 1].longconst);
205 (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
206 fputs_filtered (&exp->elts[pc + 2].string, stream);
211 struct value_print_options opts;
213 nargs = longest_to_int (exp->elts[pc + 1].longconst);
214 (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
215 /* LA_PRINT_STRING will print using the current repeat count threshold.
216 If necessary, we can temporarily set it to zero, or pass it as an
217 additional parameter to LA_PRINT_STRING. -fnf */
218 get_user_print_options (&opts);
219 LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char,
220 (gdb_byte *) &exp->elts[pc + 2].string, nargs,
225 case OP_OBJC_NSSTRING: /* Objective-C Foundation Class
226 NSString constant. */
228 struct value_print_options opts;
230 nargs = longest_to_int (exp->elts[pc + 1].longconst);
231 (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
232 fputs_filtered ("@\"", stream);
233 get_user_print_options (&opts);
234 LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char,
235 (gdb_byte *) &exp->elts[pc + 2].string, nargs,
237 fputs_filtered ("\"", stream);
241 case OP_OBJC_MSGCALL:
242 { /* Objective C message (method) call. */
246 nargs = longest_to_int (exp->elts[pc + 2].longconst);
247 fprintf_unfiltered (stream, "[");
248 print_subexp (exp, pos, stream, PREC_SUFFIX);
249 if (0 == target_read_string (exp->elts[pc + 1].longconst,
250 &selector, 1024, NULL))
252 error (_("bad selector"));
259 s = (char *) alloca (strlen (selector) + 1);
260 strcpy (s, selector);
261 for (tem = 0; tem < nargs; tem++)
263 nextS = strchr (s, ':');
264 gdb_assert (nextS); /* Make sure we found ':'. */
266 fprintf_unfiltered (stream, " %s: ", s);
268 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
273 fprintf_unfiltered (stream, " %s", selector);
275 fprintf_unfiltered (stream, "]");
276 /* "selector" was malloc'd by target_read_string. Free it. */
283 nargs = longest_to_int (exp->elts[pc + 2].longconst);
284 nargs -= longest_to_int (exp->elts[pc + 1].longconst);
287 if (exp->elts[pc + 4].opcode == OP_LONG
288 && exp->elts[pc + 5].type
289 == builtin_type (exp->gdbarch)->builtin_char
290 && exp->language_defn->la_language == language_c)
292 /* Attempt to print C character arrays using string syntax.
293 Walk through the args, picking up one character from each
294 of the OP_LONG expression elements. If any array element
295 does not match our expection of what we should find for
296 a simple string, revert back to array printing. Note that
297 the last expression element is an explicit null terminator
298 byte, which doesn't get printed. */
299 tempstr = (char *) alloca (nargs);
303 if (exp->elts[pc].opcode != OP_LONG
304 || exp->elts[pc + 1].type
305 != builtin_type (exp->gdbarch)->builtin_char)
307 /* Not a simple array of char, use regular array
315 longest_to_int (exp->elts[pc + 2].longconst);
322 struct value_print_options opts;
324 get_user_print_options (&opts);
325 LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char,
326 (gdb_byte *) tempstr, nargs - 1, NULL, 0, &opts);
331 fputs_filtered (" {", stream);
332 for (tem = 0; tem < nargs; tem++)
336 fputs_filtered (", ", stream);
338 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
340 fputs_filtered ("}", stream);
345 if ((int) prec > (int) PREC_COMMA)
346 fputs_filtered ("(", stream);
347 /* Print the subexpressions, forcing parentheses
348 around any binary operations within them.
349 This is more parentheses than are strictly necessary,
350 but it looks clearer. */
351 print_subexp (exp, pos, stream, PREC_HYPER);
352 fputs_filtered (" ? ", stream);
353 print_subexp (exp, pos, stream, PREC_HYPER);
354 fputs_filtered (" : ", stream);
355 print_subexp (exp, pos, stream, PREC_HYPER);
356 if ((int) prec > (int) PREC_COMMA)
357 fputs_filtered (")", stream);
361 print_subexp (exp, pos, stream, PREC_SUFFIX);
362 fputs_filtered ("(", stream);
363 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
364 fputs_filtered (opcode == TERNOP_SLICE ? " : " : " UP ", stream);
365 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
366 fputs_filtered (")", stream);
369 case STRUCTOP_STRUCT:
370 tem = longest_to_int (exp->elts[pc + 1].longconst);
371 (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
372 print_subexp (exp, pos, stream, PREC_SUFFIX);
373 fputs_filtered (".", stream);
374 fputs_filtered (&exp->elts[pc + 2].string, stream);
377 /* Will not occur for Modula-2. */
379 tem = longest_to_int (exp->elts[pc + 1].longconst);
380 (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
381 print_subexp (exp, pos, stream, PREC_SUFFIX);
382 fputs_filtered ("->", stream);
383 fputs_filtered (&exp->elts[pc + 2].string, stream);
386 case STRUCTOP_MEMBER:
387 print_subexp (exp, pos, stream, PREC_SUFFIX);
388 fputs_filtered (".*", stream);
389 print_subexp (exp, pos, stream, PREC_SUFFIX);
393 print_subexp (exp, pos, stream, PREC_SUFFIX);
394 fputs_filtered ("->*", stream);
395 print_subexp (exp, pos, stream, PREC_SUFFIX);
398 case BINOP_SUBSCRIPT:
399 print_subexp (exp, pos, stream, PREC_SUFFIX);
400 fputs_filtered ("[", stream);
401 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
402 fputs_filtered ("]", stream);
405 case UNOP_POSTINCREMENT:
406 print_subexp (exp, pos, stream, PREC_SUFFIX);
407 fputs_filtered ("++", stream);
410 case UNOP_POSTDECREMENT:
411 print_subexp (exp, pos, stream, PREC_SUFFIX);
412 fputs_filtered ("--", stream);
417 if ((int) prec > (int) PREC_PREFIX)
418 fputs_filtered ("(", stream);
419 fputs_filtered ("(", stream);
420 type_print (exp->elts[pc + 1].type, "", stream, 0);
421 fputs_filtered (") ", stream);
422 print_subexp (exp, pos, stream, PREC_PREFIX);
423 if ((int) prec > (int) PREC_PREFIX)
424 fputs_filtered (")", stream);
428 if ((int) prec > (int) PREC_PREFIX)
429 fputs_filtered ("(", stream);
430 fputs_filtered ("(", stream);
431 print_subexp (exp, pos, stream, PREC_PREFIX);
432 fputs_filtered (") ", stream);
433 print_subexp (exp, pos, stream, PREC_PREFIX);
434 if ((int) prec > (int) PREC_PREFIX)
435 fputs_filtered (")", stream);
438 case UNOP_DYNAMIC_CAST:
439 case UNOP_REINTERPRET_CAST:
440 fputs_filtered (opcode == UNOP_DYNAMIC_CAST ? "dynamic_cast"
441 : "reinterpret_cast", stream);
442 fputs_filtered ("<", stream);
443 print_subexp (exp, pos, stream, PREC_PREFIX);
444 fputs_filtered ("> (", stream);
445 print_subexp (exp, pos, stream, PREC_PREFIX);
446 fputs_filtered (")", stream);
451 if ((int) prec > (int) PREC_PREFIX)
452 fputs_filtered ("(", stream);
453 if (TYPE_CODE (exp->elts[pc + 1].type) == TYPE_CODE_FUNC
454 && exp->elts[pc + 3].opcode == OP_LONG)
456 struct value_print_options opts;
458 /* We have a minimal symbol fn, probably. It's encoded
459 as a UNOP_MEMVAL (function-type) of an OP_LONG (int, address).
460 Swallow the OP_LONG (including both its opcodes); ignore
461 its type; print the value in the type of the MEMVAL. */
463 val = value_at_lazy (exp->elts[pc + 1].type,
464 (CORE_ADDR) exp->elts[pc + 5].longconst);
465 get_no_prettyformat_print_options (&opts);
466 value_print (val, stream, &opts);
470 fputs_filtered ("{", stream);
471 type_print (exp->elts[pc + 1].type, "", stream, 0);
472 fputs_filtered ("} ", stream);
473 print_subexp (exp, pos, stream, PREC_PREFIX);
475 if ((int) prec > (int) PREC_PREFIX)
476 fputs_filtered (")", stream);
479 case UNOP_MEMVAL_TYPE:
480 if ((int) prec > (int) PREC_PREFIX)
481 fputs_filtered ("(", stream);
482 fputs_filtered ("{", stream);
483 print_subexp (exp, pos, stream, PREC_PREFIX);
484 fputs_filtered ("} ", stream);
485 print_subexp (exp, pos, stream, PREC_PREFIX);
486 if ((int) prec > (int) PREC_PREFIX)
487 fputs_filtered (")", stream);
490 case BINOP_ASSIGN_MODIFY:
491 opcode = exp->elts[pc + 1].opcode;
493 myprec = PREC_ASSIGN;
497 for (tem = 0; op_print_tab[tem].opcode != OP_NULL; tem++)
498 if (op_print_tab[tem].opcode == opcode)
500 op_str = op_print_tab[tem].string;
503 if (op_print_tab[tem].opcode != opcode)
504 /* Not found; don't try to keep going because we don't know how
505 to interpret further elements. */
506 error (_("Invalid expression"));
513 if (exp->language_defn->la_name_of_this)
514 fputs_filtered (exp->language_defn->la_name_of_this, stream);
516 fprintf_filtered (stream, _("<language %s has no 'this'>"),
517 exp->language_defn->la_name);
522 case MULTI_SUBSCRIPT:
524 nargs = longest_to_int (exp->elts[pc + 1].longconst);
525 print_subexp (exp, pos, stream, PREC_SUFFIX);
526 fprintf_unfiltered (stream, " [");
527 for (tem = 0; tem < nargs; tem++)
530 fprintf_unfiltered (stream, ", ");
531 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
533 fprintf_unfiltered (stream, "]");
538 fprintf_unfiltered (stream, "VAL(");
539 type_print (exp->elts[pc + 1].type, "", stream, 0);
540 fprintf_unfiltered (stream, ",");
541 print_subexp (exp, pos, stream, PREC_PREFIX);
542 fprintf_unfiltered (stream, ")");
547 type_instance_flags flags
548 = (type_instance_flag_value) longest_to_int (exp->elts[pc + 1].longconst);
549 LONGEST count = exp->elts[pc + 2].longconst;
555 fputs_unfiltered ("TypeInstance(", stream);
558 type_print (exp->elts[(*pos)++].type, "", stream, 0);
560 fputs_unfiltered (",", stream);
562 fputs_unfiltered (",", stream);
563 /* Ending COUNT and ending TYPE_INSTANCE. */
565 print_subexp (exp, pos, stream, PREC_PREFIX);
567 if (flags & TYPE_INSTANCE_FLAG_CONST)
568 fputs_unfiltered (",const", stream);
569 if (flags & TYPE_INSTANCE_FLAG_VOLATILE)
570 fputs_unfiltered (",volatile", stream);
572 fputs_unfiltered (")", stream);
578 enum range_type range_type;
580 range_type = (enum range_type)
581 longest_to_int (exp->elts[pc + 1].longconst);
584 fputs_filtered ("RANGE(", stream);
585 if (range_type == HIGH_BOUND_DEFAULT
586 || range_type == NONE_BOUND_DEFAULT)
587 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
588 fputs_filtered ("..", stream);
589 if (range_type == LOW_BOUND_DEFAULT
590 || range_type == NONE_BOUND_DEFAULT)
591 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
592 fputs_filtered (")", stream);
600 for (tem = 0; op_print_tab[tem].opcode != OP_NULL; tem++)
601 if (op_print_tab[tem].opcode == opcode)
603 op_str = op_print_tab[tem].string;
604 myprec = op_print_tab[tem].precedence;
605 assoc = op_print_tab[tem].right_assoc;
608 if (op_print_tab[tem].opcode != opcode)
609 /* Not found; don't try to keep going because we don't know how
610 to interpret further elements. For example, this happens
611 if opcode is OP_TYPE. */
612 error (_("Invalid expression"));
615 /* Note that PREC_BUILTIN will always emit parentheses. */
616 if ((int) myprec < (int) prec)
617 fputs_filtered ("(", stream);
618 if ((int) opcode > (int) BINOP_END)
622 /* Unary postfix operator. */
623 print_subexp (exp, pos, stream, PREC_SUFFIX);
624 fputs_filtered (op_str, stream);
628 /* Unary prefix operator. */
629 fputs_filtered (op_str, stream);
630 if (myprec == PREC_BUILTIN_FUNCTION)
631 fputs_filtered ("(", stream);
632 print_subexp (exp, pos, stream, PREC_PREFIX);
633 if (myprec == PREC_BUILTIN_FUNCTION)
634 fputs_filtered (")", stream);
639 /* Binary operator. */
640 /* Print left operand.
641 If operator is right-associative,
642 increment precedence for this operand. */
643 print_subexp (exp, pos, stream,
644 (enum precedence) ((int) myprec + assoc));
645 /* Print the operator itself. */
647 fprintf_filtered (stream, " %s= ", op_str);
648 else if (op_str[0] == ',')
649 fprintf_filtered (stream, "%s ", op_str);
651 fprintf_filtered (stream, " %s ", op_str);
652 /* Print right operand.
653 If operator is left-associative,
654 increment precedence for this operand. */
655 print_subexp (exp, pos, stream,
656 (enum precedence) ((int) myprec + !assoc));
659 if ((int) myprec < (int) prec)
660 fputs_filtered (")", stream);
663 /* Return the operator corresponding to opcode OP as
664 a string. NULL indicates that the opcode was not found in the
665 current language table. */
667 op_string (enum exp_opcode op)
670 const struct op_print *op_print_tab;
672 op_print_tab = current_language->la_op_print_tab;
673 for (tem = 0; op_print_tab[tem].opcode != OP_NULL; tem++)
674 if (op_print_tab[tem].opcode == op)
675 return op_print_tab[tem].string;
679 /* Support for dumping the raw data from expressions in a human readable
682 static int dump_subexp_body (struct expression *exp, struct ui_file *, int);
684 /* Name for OPCODE, when it appears in expression EXP. */
687 op_name (struct expression *exp, enum exp_opcode opcode)
689 return exp->language_defn->la_exp_desc->op_name (opcode);
692 /* Default name for the standard operator OPCODE (i.e., one defined in
693 the definition of enum exp_opcode). */
696 op_name_standard (enum exp_opcode opcode)
704 xsnprintf (buf, sizeof (buf), "<unknown %d>", opcode);
710 #include "std-operator.def"
715 /* Print a raw dump of expression EXP to STREAM.
716 NOTE, if non-NULL, is printed as extra explanatory text. */
719 dump_raw_expression (struct expression *exp, struct ui_file *stream,
726 fprintf_filtered (stream, "Dump of expression @ ");
727 gdb_print_host_address (exp, stream);
729 fprintf_filtered (stream, ", %s:", note);
730 fprintf_filtered (stream, "\n\tLanguage %s, %d elements, %ld bytes each.\n",
731 exp->language_defn->la_name, exp->nelts,
732 (long) sizeof (union exp_element));
733 fprintf_filtered (stream, "\t%5s %20s %16s %s\n", "Index", "Opcode",
734 "Hex Value", "String Value");
735 for (elt = 0; elt < exp->nelts; elt++)
737 fprintf_filtered (stream, "\t%5d ", elt);
739 const char *opcode_name = op_name (exp, exp->elts[elt].opcode);
740 fprintf_filtered (stream, "%20s ", opcode_name);
742 print_longest (stream, 'd', 0, exp->elts[elt].longconst);
743 fprintf_filtered (stream, " ");
745 for (eltscan = (char *) &exp->elts[elt],
746 eltsize = sizeof (union exp_element);
750 fprintf_filtered (stream, "%c",
751 isprint (*eltscan) ? (*eltscan & 0xFF) : '.');
753 fprintf_filtered (stream, "\n");
757 /* Dump the subexpression of prefix expression EXP whose operator is at
758 position ELT onto STREAM. Returns the position of the next
759 subexpression in EXP. */
762 dump_subexp (struct expression *exp, struct ui_file *stream, int elt)
764 static int indent = 0;
767 fprintf_filtered (stream, "\n");
768 fprintf_filtered (stream, "\t%5d ", elt);
770 for (i = 1; i <= indent; i++)
771 fprintf_filtered (stream, " ");
774 fprintf_filtered (stream, "%-20s ", op_name (exp, exp->elts[elt].opcode));
776 elt = dump_subexp_body (exp, stream, elt);
783 /* Dump the operands of prefix expression EXP whose opcode is at
784 position ELT onto STREAM. Returns the position of the next
785 subexpression in EXP. */
788 dump_subexp_body (struct expression *exp, struct ui_file *stream, int elt)
790 return exp->language_defn->la_exp_desc->dump_subexp_body (exp, stream, elt);
793 /* Default value for subexp_body in exp_descriptor vector. */
796 dump_subexp_body_standard (struct expression *exp,
797 struct ui_file *stream, int elt)
799 int opcode = exp->elts[elt++].opcode;
805 elt = dump_subexp (exp, stream, elt);
815 case BINOP_LOGICAL_AND:
816 case BINOP_LOGICAL_OR:
817 case BINOP_BITWISE_AND:
818 case BINOP_BITWISE_IOR:
819 case BINOP_BITWISE_XOR:
829 case BINOP_SUBSCRIPT:
834 case BINOP_ASSIGN_MODIFY:
838 case STRUCTOP_MEMBER:
840 elt = dump_subexp (exp, stream, elt);
843 case UNOP_LOGICAL_NOT:
844 case UNOP_COMPLEMENT:
847 case UNOP_PREINCREMENT:
848 case UNOP_POSTINCREMENT:
849 case UNOP_PREDECREMENT:
850 case UNOP_POSTDECREMENT:
863 elt = dump_subexp (exp, stream, elt);
866 fprintf_filtered (stream, "Type @");
867 gdb_print_host_address (exp->elts[elt].type, stream);
868 fprintf_filtered (stream, " (");
869 type_print (exp->elts[elt].type, NULL, stream, 0);
870 fprintf_filtered (stream, "), value %ld (0x%lx)",
871 (long) exp->elts[elt + 1].longconst,
872 (long) exp->elts[elt + 1].longconst);
876 fprintf_filtered (stream, "Type @");
877 gdb_print_host_address (exp->elts[elt].type, stream);
878 fprintf_filtered (stream, " (");
879 type_print (exp->elts[elt].type, NULL, stream, 0);
880 fprintf_filtered (stream, "), value ");
881 print_floating (exp->elts[elt + 1].floatconst,
882 exp->elts[elt].type, stream);
886 fprintf_filtered (stream, "Block @");
887 gdb_print_host_address (exp->elts[elt].block, stream);
888 fprintf_filtered (stream, ", symbol @");
889 gdb_print_host_address (exp->elts[elt + 1].symbol, stream);
890 fprintf_filtered (stream, " (%s)",
891 SYMBOL_PRINT_NAME (exp->elts[elt + 1].symbol));
894 case OP_VAR_MSYM_VALUE:
895 fprintf_filtered (stream, "Objfile @");
896 gdb_print_host_address (exp->elts[elt].objfile, stream);
897 fprintf_filtered (stream, ", msymbol @");
898 gdb_print_host_address (exp->elts[elt + 1].msymbol, stream);
899 fprintf_filtered (stream, " (%s)",
900 MSYMBOL_PRINT_NAME (exp->elts[elt + 1].msymbol));
903 case OP_VAR_ENTRY_VALUE:
904 fprintf_filtered (stream, "Entry value of symbol @");
905 gdb_print_host_address (exp->elts[elt].symbol, stream);
906 fprintf_filtered (stream, " (%s)",
907 SYMBOL_PRINT_NAME (exp->elts[elt].symbol));
911 fprintf_filtered (stream, "History element %ld",
912 (long) exp->elts[elt].longconst);
916 fprintf_filtered (stream, "Register $%s", &exp->elts[elt + 1].string);
917 elt += 3 + BYTES_TO_EXP_ELEM (exp->elts[elt].longconst + 1);
920 fprintf_filtered (stream, "Internal var @");
921 gdb_print_host_address (exp->elts[elt].internalvar, stream);
922 fprintf_filtered (stream, " (%s)",
923 internalvar_name (exp->elts[elt].internalvar));
927 case OP_F77_UNDETERMINED_ARGLIST:
931 nargs = longest_to_int (exp->elts[elt].longconst);
933 fprintf_filtered (stream, "Number of args: %d", nargs);
936 for (i = 1; i <= nargs + 1; i++)
937 elt = dump_subexp (exp, stream, elt);
945 lower = longest_to_int (exp->elts[elt].longconst);
946 upper = longest_to_int (exp->elts[elt + 1].longconst);
948 fprintf_filtered (stream, "Bounds [%d:%d]", lower, upper);
951 for (i = 1; i <= upper - lower + 1; i++)
952 elt = dump_subexp (exp, stream, elt);
955 case UNOP_DYNAMIC_CAST:
956 case UNOP_REINTERPRET_CAST:
958 case UNOP_MEMVAL_TYPE:
959 fprintf_filtered (stream, " (");
960 elt = dump_subexp (exp, stream, elt);
961 fprintf_filtered (stream, ")");
962 elt = dump_subexp (exp, stream, elt);
966 fprintf_filtered (stream, "Type @");
967 gdb_print_host_address (exp->elts[elt].type, stream);
968 fprintf_filtered (stream, " (");
969 type_print (exp->elts[elt].type, NULL, stream, 0);
970 fprintf_filtered (stream, ")");
971 elt = dump_subexp (exp, stream, elt + 2);
974 fprintf_filtered (stream, "Type @");
975 gdb_print_host_address (exp->elts[elt].type, stream);
976 fprintf_filtered (stream, " (");
977 type_print (exp->elts[elt].type, NULL, stream, 0);
978 fprintf_filtered (stream, ")");
983 fprintf_filtered (stream, "Typeof (");
984 elt = dump_subexp (exp, stream, elt);
985 fprintf_filtered (stream, ")");
988 fprintf_filtered (stream, "typeid (");
989 elt = dump_subexp (exp, stream, elt);
990 fprintf_filtered (stream, ")");
992 case STRUCTOP_STRUCT:
998 len = longest_to_int (exp->elts[elt].longconst);
999 elem_name = &exp->elts[elt + 1].string;
1001 fprintf_filtered (stream, "Element name: `%.*s'", len, elem_name);
1002 elt = dump_subexp (exp, stream, elt + 3 + BYTES_TO_EXP_ELEM (len + 1));
1010 fprintf_filtered (stream, "Type @");
1011 gdb_print_host_address (exp->elts[elt].type, stream);
1012 fprintf_filtered (stream, " (");
1013 type_print (exp->elts[elt].type, NULL, stream, 0);
1014 fprintf_filtered (stream, ") ");
1016 len = longest_to_int (exp->elts[elt + 1].longconst);
1017 elem_name = &exp->elts[elt + 2].string;
1019 fprintf_filtered (stream, "Field name: `%.*s'", len, elem_name);
1020 elt += 4 + BYTES_TO_EXP_ELEM (len + 1);
1024 case OP_FUNC_STATIC_VAR:
1026 int len = longest_to_int (exp->elts[elt].longconst);
1027 const char *var_name = &exp->elts[elt + 1].string;
1028 fprintf_filtered (stream, "Field name: `%.*s'", len, var_name);
1029 elt += 3 + BYTES_TO_EXP_ELEM (len + 1);
1035 type_instance_flags flags
1036 = (type_instance_flag_value) longest_to_int (exp->elts[elt++].longconst);
1037 LONGEST len = exp->elts[elt++].longconst;
1038 fprintf_filtered (stream, "%s TypeInstance: ", plongest (len));
1041 fprintf_filtered (stream, "Type @");
1042 gdb_print_host_address (exp->elts[elt].type, stream);
1043 fprintf_filtered (stream, " (");
1044 type_print (exp->elts[elt].type, NULL, stream, 0);
1045 fprintf_filtered (stream, ")");
1048 fputs_filtered (", ", stream);
1051 fprintf_filtered (stream, " Flags: %s (", hex_string (flags));
1053 auto print_one = [&] (const char *mod)
1056 fputs_filtered (" ", stream);
1058 fprintf_filtered (stream, "%s", mod);
1060 if (flags & TYPE_INSTANCE_FLAG_CONST)
1061 print_one ("const");
1062 if (flags & TYPE_INSTANCE_FLAG_VOLATILE)
1063 print_one ("volatile");
1064 fprintf_filtered (stream, ")");
1066 /* Ending LEN and ending TYPE_INSTANCE. */
1068 elt = dump_subexp (exp, stream, elt);
1073 LONGEST len = exp->elts[elt].longconst;
1074 LONGEST type = exp->elts[elt + 1].longconst;
1076 fprintf_filtered (stream, "Language-specific string type: %s",
1082 /* Skip string content. */
1083 elt += BYTES_TO_EXP_ELEM (len);
1085 /* Skip length and ending OP_STRING. */
1091 enum range_type range_type;
1093 range_type = (enum range_type)
1094 longest_to_int (exp->elts[elt].longconst);
1099 case BOTH_BOUND_DEFAULT:
1100 fputs_filtered ("Range '..'", stream);
1102 case LOW_BOUND_DEFAULT:
1103 fputs_filtered ("Range '..EXP'", stream);
1105 case HIGH_BOUND_DEFAULT:
1106 fputs_filtered ("Range 'EXP..'", stream);
1108 case NONE_BOUND_DEFAULT:
1109 fputs_filtered ("Range 'EXP..EXP'", stream);
1112 fputs_filtered ("Invalid Range!", stream);
1116 if (range_type == HIGH_BOUND_DEFAULT
1117 || range_type == NONE_BOUND_DEFAULT)
1118 elt = dump_subexp (exp, stream, elt);
1119 if (range_type == LOW_BOUND_DEFAULT
1120 || range_type == NONE_BOUND_DEFAULT)
1121 elt = dump_subexp (exp, stream, elt);
1127 case MULTI_SUBSCRIPT:
1133 fprintf_filtered (stream, "Unknown format");
1140 dump_prefix_expression (struct expression *exp, struct ui_file *stream)
1144 fprintf_filtered (stream, "Dump of expression @ ");
1145 gdb_print_host_address (exp, stream);
1146 fputs_filtered (", after conversion to prefix form:\nExpression: `", stream);
1147 print_expression (exp, stream);
1148 fprintf_filtered (stream, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",
1149 exp->language_defn->la_name, exp->nelts,
1150 (long) sizeof (union exp_element));
1151 fputs_filtered ("\n", stream);
1153 for (elt = 0; elt < exp->nelts;)
1154 elt = dump_subexp (exp, stream, elt);
1155 fputs_filtered ("\n", stream);