1 /* Print in infix form a struct expression.
3 Copyright (C) 1986, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
4 1998, 1999, 2000, 2003, 2007, 2008 Free 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"
40 print_expression (struct expression *exp, struct ui_file *stream)
43 print_subexp (exp, &pc, stream, PREC_NULL);
46 /* Print the subexpression of EXP that starts in position POS, on STREAM.
47 PREC is the precedence of the surrounding operator;
48 if the precedence of the main operator of this subexpression is less,
49 parentheses are needed here. */
52 print_subexp (struct expression *exp, int *pos,
53 struct ui_file *stream, enum precedence prec)
55 exp->language_defn->la_exp_desc->print_subexp (exp, pos, stream, prec);
58 /* Standard implementation of print_subexp for use in language_defn
61 print_subexp_standard (struct expression *exp, int *pos,
62 struct ui_file *stream, enum precedence prec)
65 const struct op_print *op_print_tab;
69 int assign_modify = 0;
70 enum exp_opcode opcode;
71 enum precedence myprec = PREC_NULL;
72 /* Set to 1 for a right-associative operator. */
77 op_print_tab = exp->language_defn->la_op_print_tab;
79 opcode = exp->elts[pc].opcode;
87 fputs_filtered (type_name_no_tag (exp->elts[pc + 1].type), stream);
88 fputs_filtered ("::", stream);
89 nargs = longest_to_int (exp->elts[pc + 2].longconst);
90 (*pos) += 4 + BYTES_TO_EXP_ELEM (nargs + 1);
91 fputs_filtered (&exp->elts[pc + 3].string, stream);
96 value_print (value_from_longest (exp->elts[pc + 1].type,
97 exp->elts[pc + 2].longconst),
98 stream, 0, Val_no_prettyprint);
103 value_print (value_from_double (exp->elts[pc + 1].type,
104 exp->elts[pc + 2].doubleconst),
105 stream, 0, Val_no_prettyprint);
112 b = exp->elts[pc + 1].block;
114 && BLOCK_FUNCTION (b) != NULL
115 && SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b)) != NULL)
117 fputs_filtered (SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b)), stream);
118 fputs_filtered ("::", stream);
120 fputs_filtered (SYMBOL_PRINT_NAME (exp->elts[pc + 2].symbol), stream);
126 fprintf_filtered (stream, "$%d",
127 longest_to_int (exp->elts[pc + 1].longconst));
132 const char *name = &exp->elts[pc + 2].string;
133 (*pos) += 3 + BYTES_TO_EXP_ELEM (exp->elts[pc + 1].longconst + 1);
134 fprintf_filtered (stream, "$%s", name);
140 fprintf_filtered (stream, "%s",
141 longest_to_int (exp->elts[pc + 1].longconst)
147 fprintf_filtered (stream, "$%s",
148 internalvar_name (exp->elts[pc + 1].internalvar));
153 nargs = longest_to_int (exp->elts[pc + 1].longconst);
154 print_subexp (exp, pos, stream, PREC_SUFFIX);
155 fputs_filtered (" (", stream);
156 for (tem = 0; tem < nargs; tem++)
159 fputs_filtered (", ", stream);
160 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
162 fputs_filtered (")", stream);
166 nargs = longest_to_int (exp->elts[pc + 1].longconst);
167 (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
168 fputs_filtered (&exp->elts[pc + 2].string, stream);
172 nargs = longest_to_int (exp->elts[pc + 1].longconst);
173 (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
174 /* LA_PRINT_STRING will print using the current repeat count threshold.
175 If necessary, we can temporarily set it to zero, or pass it as an
176 additional parameter to LA_PRINT_STRING. -fnf */
177 LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0);
181 nargs = longest_to_int (exp->elts[pc + 1].longconst);
183 += 3 + BYTES_TO_EXP_ELEM ((nargs + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT);
184 fprintf_unfiltered (stream, "B'<unimplemented>'");
187 case OP_OBJC_NSSTRING: /* Objective-C Foundation Class NSString constant. */
188 nargs = longest_to_int (exp->elts[pc + 1].longconst);
189 (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
190 fputs_filtered ("@\"", stream);
191 LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0);
192 fputs_filtered ("\"", stream);
195 case OP_OBJC_MSGCALL:
196 { /* Objective C message (method) call. */
199 nargs = longest_to_int (exp->elts[pc + 2].longconst);
200 fprintf_unfiltered (stream, "[");
201 print_subexp (exp, pos, stream, PREC_SUFFIX);
202 if (0 == target_read_string (exp->elts[pc + 1].longconst,
203 &selector, 1024, NULL))
205 error (_("bad selector"));
211 s = alloca (strlen (selector) + 1);
212 strcpy (s, selector);
213 for (tem = 0; tem < nargs; tem++)
215 nextS = strchr (s, ':');
216 gdb_assert (nextS); /* Make sure we found ':'. */
218 fprintf_unfiltered (stream, " %s: ", s);
220 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
225 fprintf_unfiltered (stream, " %s", selector);
227 fprintf_unfiltered (stream, "]");
228 /* "selector" was malloc'd by target_read_string. Free it. */
235 nargs = longest_to_int (exp->elts[pc + 2].longconst);
236 nargs -= longest_to_int (exp->elts[pc + 1].longconst);
239 if (exp->elts[pc + 4].opcode == OP_LONG
240 && exp->elts[pc + 5].type
241 == builtin_type (exp->gdbarch)->builtin_char
242 && exp->language_defn->la_language == language_c)
244 /* Attempt to print C character arrays using string syntax.
245 Walk through the args, picking up one character from each
246 of the OP_LONG expression elements. If any array element
247 does not match our expection of what we should find for
248 a simple string, revert back to array printing. Note that
249 the last expression element is an explicit null terminator
250 byte, which doesn't get printed. */
251 tempstr = alloca (nargs);
255 if (exp->elts[pc].opcode != OP_LONG
256 || exp->elts[pc + 1].type
257 != builtin_type (exp->gdbarch)->builtin_char)
259 /* Not a simple array of char, use regular array printing. */
266 longest_to_int (exp->elts[pc + 2].longconst);
273 LA_PRINT_STRING (stream, tempstr, nargs - 1, 1, 0);
278 fputs_filtered (" {", stream);
279 for (tem = 0; tem < nargs; tem++)
283 fputs_filtered (", ", stream);
285 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
287 fputs_filtered ("}", stream);
292 tem = longest_to_int (exp->elts[pc + 1].longconst);
293 (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
294 /* Gcc support both these syntaxes. Unsure which is preferred. */
296 fputs_filtered (&exp->elts[pc + 2].string, stream);
297 fputs_filtered (": ", stream);
299 fputs_filtered (".", stream);
300 fputs_filtered (&exp->elts[pc + 2].string, stream);
301 fputs_filtered ("=", stream);
303 print_subexp (exp, pos, stream, PREC_SUFFIX);
307 if ((int) prec > (int) PREC_COMMA)
308 fputs_filtered ("(", stream);
309 /* Print the subexpressions, forcing parentheses
310 around any binary operations within them.
311 This is more parentheses than are strictly necessary,
312 but it looks clearer. */
313 print_subexp (exp, pos, stream, PREC_HYPER);
314 fputs_filtered (" ? ", stream);
315 print_subexp (exp, pos, stream, PREC_HYPER);
316 fputs_filtered (" : ", stream);
317 print_subexp (exp, pos, stream, PREC_HYPER);
318 if ((int) prec > (int) PREC_COMMA)
319 fputs_filtered (")", stream);
323 case TERNOP_SLICE_COUNT:
324 print_subexp (exp, pos, stream, PREC_SUFFIX);
325 fputs_filtered ("(", stream);
326 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
327 fputs_filtered (opcode == TERNOP_SLICE ? " : " : " UP ", stream);
328 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
329 fputs_filtered (")", stream);
332 case STRUCTOP_STRUCT:
333 tem = longest_to_int (exp->elts[pc + 1].longconst);
334 (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
335 print_subexp (exp, pos, stream, PREC_SUFFIX);
336 fputs_filtered (".", stream);
337 fputs_filtered (&exp->elts[pc + 2].string, stream);
340 /* Will not occur for Modula-2 */
342 tem = longest_to_int (exp->elts[pc + 1].longconst);
343 (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
344 print_subexp (exp, pos, stream, PREC_SUFFIX);
345 fputs_filtered ("->", stream);
346 fputs_filtered (&exp->elts[pc + 2].string, stream);
349 case STRUCTOP_MEMBER:
350 print_subexp (exp, pos, stream, PREC_SUFFIX);
351 fputs_filtered (".*", stream);
352 print_subexp (exp, pos, stream, PREC_SUFFIX);
356 print_subexp (exp, pos, stream, PREC_SUFFIX);
357 fputs_filtered ("->*", stream);
358 print_subexp (exp, pos, stream, PREC_SUFFIX);
361 case BINOP_SUBSCRIPT:
362 print_subexp (exp, pos, stream, PREC_SUFFIX);
363 fputs_filtered ("[", stream);
364 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
365 fputs_filtered ("]", stream);
368 case UNOP_POSTINCREMENT:
369 print_subexp (exp, pos, stream, PREC_SUFFIX);
370 fputs_filtered ("++", stream);
373 case UNOP_POSTDECREMENT:
374 print_subexp (exp, pos, stream, PREC_SUFFIX);
375 fputs_filtered ("--", stream);
380 if ((int) prec > (int) PREC_PREFIX)
381 fputs_filtered ("(", stream);
382 fputs_filtered ("(", stream);
383 type_print (exp->elts[pc + 1].type, "", stream, 0);
384 fputs_filtered (") ", stream);
385 print_subexp (exp, pos, stream, PREC_PREFIX);
386 if ((int) prec > (int) PREC_PREFIX)
387 fputs_filtered (")", stream);
392 if ((int) prec > (int) PREC_PREFIX)
393 fputs_filtered ("(", stream);
394 if (TYPE_CODE (exp->elts[pc + 1].type) == TYPE_CODE_FUNC &&
395 exp->elts[pc + 3].opcode == OP_LONG)
397 /* We have a minimal symbol fn, probably. It's encoded
398 as a UNOP_MEMVAL (function-type) of an OP_LONG (int, address).
399 Swallow the OP_LONG (including both its opcodes); ignore
400 its type; print the value in the type of the MEMVAL. */
402 val = value_at_lazy (exp->elts[pc + 1].type,
403 (CORE_ADDR) exp->elts[pc + 5].longconst);
404 value_print (val, stream, 0, Val_no_prettyprint);
408 fputs_filtered ("{", stream);
409 type_print (exp->elts[pc + 1].type, "", stream, 0);
410 fputs_filtered ("} ", stream);
411 print_subexp (exp, pos, stream, PREC_PREFIX);
413 if ((int) prec > (int) PREC_PREFIX)
414 fputs_filtered (")", stream);
417 case UNOP_MEMVAL_TLS:
419 if ((int) prec > (int) PREC_PREFIX)
420 fputs_filtered ("(", stream);
421 fputs_filtered ("{", stream);
422 type_print (exp->elts[pc + 2].type, "", stream, 0);
423 fputs_filtered ("} ", stream);
424 print_subexp (exp, pos, stream, PREC_PREFIX);
425 if ((int) prec > (int) PREC_PREFIX)
426 fputs_filtered (")", stream);
429 case BINOP_ASSIGN_MODIFY:
430 opcode = exp->elts[pc + 1].opcode;
432 myprec = PREC_ASSIGN;
436 for (tem = 0; op_print_tab[tem].opcode != OP_NULL; tem++)
437 if (op_print_tab[tem].opcode == opcode)
439 op_str = op_print_tab[tem].string;
442 if (op_print_tab[tem].opcode != opcode)
443 /* Not found; don't try to keep going because we don't know how
444 to interpret further elements. */
445 error (_("Invalid expression"));
452 fputs_filtered ("this", stream);
455 /* Objective-C ops */
459 fputs_filtered ("self", stream); /* The ObjC equivalent of "this". */
464 case MULTI_SUBSCRIPT:
466 nargs = longest_to_int (exp->elts[pc + 1].longconst);
467 print_subexp (exp, pos, stream, PREC_SUFFIX);
468 fprintf_unfiltered (stream, " [");
469 for (tem = 0; tem < nargs; tem++)
472 fprintf_unfiltered (stream, ", ");
473 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
475 fprintf_unfiltered (stream, "]");
480 fprintf_unfiltered (stream, "VAL(");
481 type_print (exp->elts[pc + 1].type, "", stream, 0);
482 fprintf_unfiltered (stream, ",");
483 print_subexp (exp, pos, stream, PREC_PREFIX);
484 fprintf_unfiltered (stream, ")");
489 error (_("print_subexp: Not implemented."));
495 for (tem = 0; op_print_tab[tem].opcode != OP_NULL; tem++)
496 if (op_print_tab[tem].opcode == opcode)
498 op_str = op_print_tab[tem].string;
499 myprec = op_print_tab[tem].precedence;
500 assoc = op_print_tab[tem].right_assoc;
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. For example, this happens
506 if opcode is OP_TYPE. */
507 error (_("Invalid expression"));
510 /* Note that PREC_BUILTIN will always emit parentheses. */
511 if ((int) myprec < (int) prec)
512 fputs_filtered ("(", stream);
513 if ((int) opcode > (int) BINOP_END)
517 /* Unary postfix operator. */
518 print_subexp (exp, pos, stream, PREC_SUFFIX);
519 fputs_filtered (op_str, stream);
523 /* Unary prefix operator. */
524 fputs_filtered (op_str, stream);
525 if (myprec == PREC_BUILTIN_FUNCTION)
526 fputs_filtered ("(", stream);
527 print_subexp (exp, pos, stream, PREC_PREFIX);
528 if (myprec == PREC_BUILTIN_FUNCTION)
529 fputs_filtered (")", stream);
534 /* Binary operator. */
535 /* Print left operand.
536 If operator is right-associative,
537 increment precedence for this operand. */
538 print_subexp (exp, pos, stream,
539 (enum precedence) ((int) myprec + assoc));
540 /* Print the operator itself. */
542 fprintf_filtered (stream, " %s= ", op_str);
543 else if (op_str[0] == ',')
544 fprintf_filtered (stream, "%s ", op_str);
546 fprintf_filtered (stream, " %s ", op_str);
547 /* Print right operand.
548 If operator is left-associative,
549 increment precedence for this operand. */
550 print_subexp (exp, pos, stream,
551 (enum precedence) ((int) myprec + !assoc));
554 if ((int) myprec < (int) prec)
555 fputs_filtered (")", stream);
558 /* Return the operator corresponding to opcode OP as
559 a string. NULL indicates that the opcode was not found in the
560 current language table. */
562 op_string (enum exp_opcode op)
565 const struct op_print *op_print_tab;
567 op_print_tab = current_language->la_op_print_tab;
568 for (tem = 0; op_print_tab[tem].opcode != OP_NULL; tem++)
569 if (op_print_tab[tem].opcode == op)
570 return op_print_tab[tem].string;
574 /* Support for dumping the raw data from expressions in a human readable
577 static char *op_name (struct expression *, enum exp_opcode);
578 static int dump_subexp_body (struct expression *exp, struct ui_file *, int);
580 /* Name for OPCODE, when it appears in expression EXP. */
583 op_name (struct expression *exp, enum exp_opcode opcode)
585 return exp->language_defn->la_exp_desc->op_name (opcode);
588 /* Default name for the standard operator OPCODE (i.e., one defined in
589 the definition of enum exp_opcode). */
592 op_name_standard (enum exp_opcode opcode)
600 sprintf (buf, "<unknown %d>", opcode);
621 case BINOP_LOGICAL_AND:
622 return "BINOP_LOGICAL_AND";
623 case BINOP_LOGICAL_OR:
624 return "BINOP_LOGICAL_OR";
625 case BINOP_BITWISE_AND:
626 return "BINOP_BITWISE_AND";
627 case BINOP_BITWISE_IOR:
628 return "BINOP_BITWISE_IOR";
629 case BINOP_BITWISE_XOR:
630 return "BINOP_BITWISE_XOR";
632 return "BINOP_EQUAL";
634 return "BINOP_NOTEQUAL";
644 return "BINOP_REPEAT";
646 return "BINOP_ASSIGN";
648 return "BINOP_COMMA";
649 case BINOP_SUBSCRIPT:
650 return "BINOP_SUBSCRIPT";
651 case MULTI_SUBSCRIPT:
652 return "MULTI_SUBSCRIPT";
659 case STRUCTOP_MEMBER:
660 return "STRUCTOP_MEMBER";
662 return "STRUCTOP_MPTR";
664 return "BINOP_INTDIV";
665 case BINOP_ASSIGN_MODIFY:
666 return "BINOP_ASSIGN_MODIFY";
674 return "BINOP_CONCAT";
676 return "BINOP_RANGE";
680 return "TERNOP_COND";
682 return "TERNOP_SLICE";
683 case TERNOP_SLICE_COUNT:
684 return "TERNOP_SLICE_COUNT";
690 return "OP_VAR_VALUE";
694 return "OP_REGISTER";
696 return "OP_INTERNALVAR";
702 return "OP_BITSTRING";
708 return "UNOP_MEMVAL";
709 case UNOP_MEMVAL_TLS:
710 return "UNOP_MEMVAL_TLS";
713 case UNOP_LOGICAL_NOT:
714 return "UNOP_LOGICAL_NOT";
715 case UNOP_COMPLEMENT:
716 return "UNOP_COMPLEMENT";
721 case UNOP_PREINCREMENT:
722 return "UNOP_PREINCREMENT";
723 case UNOP_POSTINCREMENT:
724 return "UNOP_POSTINCREMENT";
725 case UNOP_PREDECREMENT:
726 return "UNOP_PREDECREMENT";
727 case UNOP_POSTDECREMENT:
728 return "UNOP_POSTDECREMENT";
730 return "UNOP_SIZEOF";
736 return "UNOP_LENGTH";
762 return "OP_M2_STRING";
763 case STRUCTOP_STRUCT:
764 return "STRUCTOP_STRUCT";
766 return "STRUCTOP_PTR";
770 return "OP_OBJC_SELF";
781 dump_raw_expression (struct expression *exp, struct ui_file *stream,
789 fprintf_filtered (stream, "Dump of expression @ ");
790 gdb_print_host_address (exp, stream);
791 fprintf_filtered (stream, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",
792 exp->language_defn->la_name, exp->nelts,
793 (long) sizeof (union exp_element));
794 fprintf_filtered (stream, "\t%5s %20s %16s %s\n", "Index", "Opcode",
795 "Hex Value", "String Value");
796 for (elt = 0; elt < exp->nelts; elt++)
798 fprintf_filtered (stream, "\t%5d ", elt);
799 opcode_name = op_name (exp, exp->elts[elt].opcode);
801 fprintf_filtered (stream, "%20s ", opcode_name);
802 print_longest (stream, 'd', 0, exp->elts[elt].longconst);
803 fprintf_filtered (stream, " ");
805 for (eltscan = (char *) &exp->elts[elt],
806 eltsize = sizeof (union exp_element);
810 fprintf_filtered (stream, "%c",
811 isprint (*eltscan) ? (*eltscan & 0xFF) : '.');
813 fprintf_filtered (stream, "\n");
817 /* Dump the subexpression of prefix expression EXP whose operator is at
818 position ELT onto STREAM. Returns the position of the next
819 subexpression in EXP. */
822 dump_subexp (struct expression *exp, struct ui_file *stream, int elt)
824 static int indent = 0;
827 fprintf_filtered (stream, "\n");
828 fprintf_filtered (stream, "\t%5d ", elt);
830 for (i = 1; i <= indent; i++)
831 fprintf_filtered (stream, " ");
834 fprintf_filtered (stream, "%-20s ", op_name (exp, exp->elts[elt].opcode));
836 elt = dump_subexp_body (exp, stream, elt);
843 /* Dump the operands of prefix expression EXP whose opcode is at
844 position ELT onto STREAM. Returns the position of the next
845 subexpression in EXP. */
848 dump_subexp_body (struct expression *exp, struct ui_file *stream, int elt)
850 return exp->language_defn->la_exp_desc->dump_subexp_body (exp, stream, elt);
853 /* Default value for subexp_body in exp_descriptor vector. */
856 dump_subexp_body_standard (struct expression *exp,
857 struct ui_file *stream, int elt)
859 int opcode = exp->elts[elt++].opcode;
865 case TERNOP_SLICE_COUNT:
866 elt = dump_subexp (exp, stream, elt);
875 case BINOP_LOGICAL_AND:
876 case BINOP_LOGICAL_OR:
877 case BINOP_BITWISE_AND:
878 case BINOP_BITWISE_IOR:
879 case BINOP_BITWISE_XOR:
889 case BINOP_SUBSCRIPT:
894 case BINOP_ASSIGN_MODIFY:
902 case STRUCTOP_MEMBER:
904 elt = dump_subexp (exp, stream, elt);
906 case UNOP_LOGICAL_NOT:
907 case UNOP_COMPLEMENT:
910 case UNOP_PREINCREMENT:
911 case UNOP_POSTINCREMENT:
912 case UNOP_PREDECREMENT:
913 case UNOP_POSTDECREMENT:
932 elt = dump_subexp (exp, stream, elt);
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, "), value %ld (0x%lx)",
940 (long) exp->elts[elt + 1].longconst,
941 (long) exp->elts[elt + 1].longconst);
945 fprintf_filtered (stream, "Type @");
946 gdb_print_host_address (exp->elts[elt].type, stream);
947 fprintf_filtered (stream, " (");
948 type_print (exp->elts[elt].type, NULL, stream, 0);
949 fprintf_filtered (stream, "), value %g",
950 (double) exp->elts[elt + 1].doubleconst);
954 fprintf_filtered (stream, "Block @");
955 gdb_print_host_address (exp->elts[elt].block, stream);
956 fprintf_filtered (stream, ", symbol @");
957 gdb_print_host_address (exp->elts[elt + 1].symbol, stream);
958 fprintf_filtered (stream, " (%s)",
959 SYMBOL_PRINT_NAME (exp->elts[elt + 1].symbol));
963 fprintf_filtered (stream, "History element %ld",
964 (long) exp->elts[elt].longconst);
968 fprintf_filtered (stream, "Register $%s", &exp->elts[elt + 1].string);
969 elt += 3 + BYTES_TO_EXP_ELEM (exp->elts[elt].longconst + 1);
972 fprintf_filtered (stream, "Internal var @");
973 gdb_print_host_address (exp->elts[elt].internalvar, stream);
974 fprintf_filtered (stream, " (%s)",
975 exp->elts[elt].internalvar->name);
982 nargs = longest_to_int (exp->elts[elt].longconst);
984 fprintf_filtered (stream, "Number of args: %d", nargs);
987 for (i = 1; i <= nargs + 1; i++)
988 elt = dump_subexp (exp, stream, elt);
996 lower = longest_to_int (exp->elts[elt].longconst);
997 upper = longest_to_int (exp->elts[elt + 1].longconst);
999 fprintf_filtered (stream, "Bounds [%d:%d]", lower, upper);
1002 for (i = 1; i <= upper - lower + 1; i++)
1003 elt = dump_subexp (exp, stream, elt);
1008 fprintf_filtered (stream, "Type @");
1009 gdb_print_host_address (exp->elts[elt].type, stream);
1010 fprintf_filtered (stream, " (");
1011 type_print (exp->elts[elt].type, NULL, stream, 0);
1012 fprintf_filtered (stream, ")");
1013 elt = dump_subexp (exp, stream, elt + 2);
1015 case UNOP_MEMVAL_TLS:
1016 fprintf_filtered (stream, "TLS type @");
1017 gdb_print_host_address (exp->elts[elt + 1].type, stream);
1018 fprintf_filtered (stream, " (__thread /* \"%s\" */ ",
1019 (exp->elts[elt].objfile == NULL ? "(null)"
1020 : exp->elts[elt].objfile->name));
1021 type_print (exp->elts[elt + 1].type, NULL, stream, 0);
1022 fprintf_filtered (stream, ")");
1023 elt = dump_subexp (exp, stream, elt + 3);
1026 fprintf_filtered (stream, "Type @");
1027 gdb_print_host_address (exp->elts[elt].type, stream);
1028 fprintf_filtered (stream, " (");
1029 type_print (exp->elts[elt].type, NULL, stream, 0);
1030 fprintf_filtered (stream, ")");
1033 case STRUCTOP_STRUCT:
1039 len = longest_to_int (exp->elts[elt].longconst);
1040 elem_name = &exp->elts[elt + 1].string;
1042 fprintf_filtered (stream, "Element name: `%.*s'", len, elem_name);
1043 elt = dump_subexp (exp, stream, elt + 3 + BYTES_TO_EXP_ELEM (len + 1));
1051 fprintf_filtered (stream, "Type @");
1052 gdb_print_host_address (exp->elts[elt].type, stream);
1053 fprintf_filtered (stream, " (");
1054 type_print (exp->elts[elt].type, NULL, stream, 0);
1055 fprintf_filtered (stream, ") ");
1057 len = longest_to_int (exp->elts[elt + 1].longconst);
1058 elem_name = &exp->elts[elt + 2].string;
1060 fprintf_filtered (stream, "Field name: `%.*s'", len, elem_name);
1061 elt += 4 + BYTES_TO_EXP_ELEM (len + 1);
1066 case MULTI_SUBSCRIPT:
1067 case OP_F77_UNDETERMINED_ARGLIST:
1076 fprintf_filtered (stream, "Unknown format");
1083 dump_prefix_expression (struct expression *exp, struct ui_file *stream)
1087 fprintf_filtered (stream, "Dump of expression @ ");
1088 gdb_print_host_address (exp, stream);
1089 fputs_filtered (", after conversion to prefix form:\nExpression: `", stream);
1090 if (exp->elts[0].opcode != OP_TYPE)
1091 print_expression (exp, stream);
1093 fputs_filtered ("Type printing not yet supported....", stream);
1094 fprintf_filtered (stream, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",
1095 exp->language_defn->la_name, exp->nelts,
1096 (long) sizeof (union exp_element));
1097 fputs_filtered ("\n", stream);
1099 for (elt = 0; elt < exp->nelts;)
1100 elt = dump_subexp (exp, stream, elt);
1101 fputs_filtered ("\n", stream);