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 == builtin_type_char
241 && exp->language_defn->la_language == language_c)
243 /* Attempt to print C character arrays using string syntax.
244 Walk through the args, picking up one character from each
245 of the OP_LONG expression elements. If any array element
246 does not match our expection of what we should find for
247 a simple string, revert back to array printing. Note that
248 the last expression element is an explicit null terminator
249 byte, which doesn't get printed. */
250 tempstr = alloca (nargs);
254 if (exp->elts[pc].opcode != OP_LONG
255 || exp->elts[pc + 1].type != builtin_type_char)
257 /* Not a simple array of char, use regular array printing. */
264 longest_to_int (exp->elts[pc + 2].longconst);
271 LA_PRINT_STRING (stream, tempstr, nargs - 1, 1, 0);
276 fputs_filtered (" {", stream);
277 for (tem = 0; tem < nargs; tem++)
281 fputs_filtered (", ", stream);
283 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
285 fputs_filtered ("}", stream);
290 tem = longest_to_int (exp->elts[pc + 1].longconst);
291 (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
292 /* Gcc support both these syntaxes. Unsure which is preferred. */
294 fputs_filtered (&exp->elts[pc + 2].string, stream);
295 fputs_filtered (": ", stream);
297 fputs_filtered (".", stream);
298 fputs_filtered (&exp->elts[pc + 2].string, stream);
299 fputs_filtered ("=", stream);
301 print_subexp (exp, pos, stream, PREC_SUFFIX);
305 if ((int) prec > (int) PREC_COMMA)
306 fputs_filtered ("(", stream);
307 /* Print the subexpressions, forcing parentheses
308 around any binary operations within them.
309 This is more parentheses than are strictly necessary,
310 but it looks clearer. */
311 print_subexp (exp, pos, stream, PREC_HYPER);
312 fputs_filtered (" ? ", stream);
313 print_subexp (exp, pos, stream, PREC_HYPER);
314 fputs_filtered (" : ", stream);
315 print_subexp (exp, pos, stream, PREC_HYPER);
316 if ((int) prec > (int) PREC_COMMA)
317 fputs_filtered (")", stream);
321 case TERNOP_SLICE_COUNT:
322 print_subexp (exp, pos, stream, PREC_SUFFIX);
323 fputs_filtered ("(", stream);
324 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
325 fputs_filtered (opcode == TERNOP_SLICE ? " : " : " UP ", stream);
326 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
327 fputs_filtered (")", stream);
330 case STRUCTOP_STRUCT:
331 tem = longest_to_int (exp->elts[pc + 1].longconst);
332 (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
333 print_subexp (exp, pos, stream, PREC_SUFFIX);
334 fputs_filtered (".", stream);
335 fputs_filtered (&exp->elts[pc + 2].string, stream);
338 /* Will not occur for Modula-2 */
340 tem = longest_to_int (exp->elts[pc + 1].longconst);
341 (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
342 print_subexp (exp, pos, stream, PREC_SUFFIX);
343 fputs_filtered ("->", stream);
344 fputs_filtered (&exp->elts[pc + 2].string, stream);
347 case STRUCTOP_MEMBER:
348 print_subexp (exp, pos, stream, PREC_SUFFIX);
349 fputs_filtered (".*", stream);
350 print_subexp (exp, pos, stream, PREC_SUFFIX);
354 print_subexp (exp, pos, stream, PREC_SUFFIX);
355 fputs_filtered ("->*", stream);
356 print_subexp (exp, pos, stream, PREC_SUFFIX);
359 case BINOP_SUBSCRIPT:
360 print_subexp (exp, pos, stream, PREC_SUFFIX);
361 fputs_filtered ("[", stream);
362 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
363 fputs_filtered ("]", stream);
366 case UNOP_POSTINCREMENT:
367 print_subexp (exp, pos, stream, PREC_SUFFIX);
368 fputs_filtered ("++", stream);
371 case UNOP_POSTDECREMENT:
372 print_subexp (exp, pos, stream, PREC_SUFFIX);
373 fputs_filtered ("--", stream);
378 if ((int) prec > (int) PREC_PREFIX)
379 fputs_filtered ("(", stream);
380 fputs_filtered ("(", stream);
381 type_print (exp->elts[pc + 1].type, "", stream, 0);
382 fputs_filtered (") ", stream);
383 print_subexp (exp, pos, stream, PREC_PREFIX);
384 if ((int) prec > (int) PREC_PREFIX)
385 fputs_filtered (")", stream);
390 if ((int) prec > (int) PREC_PREFIX)
391 fputs_filtered ("(", stream);
392 if (TYPE_CODE (exp->elts[pc + 1].type) == TYPE_CODE_FUNC &&
393 exp->elts[pc + 3].opcode == OP_LONG)
395 /* We have a minimal symbol fn, probably. It's encoded
396 as a UNOP_MEMVAL (function-type) of an OP_LONG (int, address).
397 Swallow the OP_LONG (including both its opcodes); ignore
398 its type; print the value in the type of the MEMVAL. */
400 val = value_at_lazy (exp->elts[pc + 1].type,
401 (CORE_ADDR) exp->elts[pc + 5].longconst);
402 value_print (val, stream, 0, Val_no_prettyprint);
406 fputs_filtered ("{", stream);
407 type_print (exp->elts[pc + 1].type, "", stream, 0);
408 fputs_filtered ("} ", stream);
409 print_subexp (exp, pos, stream, PREC_PREFIX);
411 if ((int) prec > (int) PREC_PREFIX)
412 fputs_filtered (")", stream);
415 case UNOP_MEMVAL_TLS:
417 if ((int) prec > (int) PREC_PREFIX)
418 fputs_filtered ("(", stream);
419 fputs_filtered ("{", stream);
420 type_print (exp->elts[pc + 2].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);
427 case BINOP_ASSIGN_MODIFY:
428 opcode = exp->elts[pc + 1].opcode;
430 myprec = PREC_ASSIGN;
434 for (tem = 0; op_print_tab[tem].opcode != OP_NULL; tem++)
435 if (op_print_tab[tem].opcode == opcode)
437 op_str = op_print_tab[tem].string;
440 if (op_print_tab[tem].opcode != opcode)
441 /* Not found; don't try to keep going because we don't know how
442 to interpret further elements. */
443 error (_("Invalid expression"));
450 fputs_filtered ("this", stream);
453 /* Objective-C ops */
457 fputs_filtered ("self", stream); /* The ObjC equivalent of "this". */
462 case MULTI_SUBSCRIPT:
464 nargs = longest_to_int (exp->elts[pc + 1].longconst);
465 print_subexp (exp, pos, stream, PREC_SUFFIX);
466 fprintf_unfiltered (stream, " [");
467 for (tem = 0; tem < nargs; tem++)
470 fprintf_unfiltered (stream, ", ");
471 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
473 fprintf_unfiltered (stream, "]");
478 fprintf_unfiltered (stream, "VAL(");
479 type_print (exp->elts[pc + 1].type, "", stream, 0);
480 fprintf_unfiltered (stream, ",");
481 print_subexp (exp, pos, stream, PREC_PREFIX);
482 fprintf_unfiltered (stream, ")");
487 error (_("print_subexp: Not implemented."));
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;
497 myprec = op_print_tab[tem].precedence;
498 assoc = op_print_tab[tem].right_assoc;
501 if (op_print_tab[tem].opcode != opcode)
502 /* Not found; don't try to keep going because we don't know how
503 to interpret further elements. For example, this happens
504 if opcode is OP_TYPE. */
505 error (_("Invalid expression"));
508 /* Note that PREC_BUILTIN will always emit parentheses. */
509 if ((int) myprec < (int) prec)
510 fputs_filtered ("(", stream);
511 if ((int) opcode > (int) BINOP_END)
515 /* Unary postfix operator. */
516 print_subexp (exp, pos, stream, PREC_SUFFIX);
517 fputs_filtered (op_str, stream);
521 /* Unary prefix operator. */
522 fputs_filtered (op_str, stream);
523 if (myprec == PREC_BUILTIN_FUNCTION)
524 fputs_filtered ("(", stream);
525 print_subexp (exp, pos, stream, PREC_PREFIX);
526 if (myprec == PREC_BUILTIN_FUNCTION)
527 fputs_filtered (")", stream);
532 /* Binary operator. */
533 /* Print left operand.
534 If operator is right-associative,
535 increment precedence for this operand. */
536 print_subexp (exp, pos, stream,
537 (enum precedence) ((int) myprec + assoc));
538 /* Print the operator itself. */
540 fprintf_filtered (stream, " %s= ", op_str);
541 else if (op_str[0] == ',')
542 fprintf_filtered (stream, "%s ", op_str);
544 fprintf_filtered (stream, " %s ", op_str);
545 /* Print right operand.
546 If operator is left-associative,
547 increment precedence for this operand. */
548 print_subexp (exp, pos, stream,
549 (enum precedence) ((int) myprec + !assoc));
552 if ((int) myprec < (int) prec)
553 fputs_filtered (")", stream);
556 /* Return the operator corresponding to opcode OP as
557 a string. NULL indicates that the opcode was not found in the
558 current language table. */
560 op_string (enum exp_opcode op)
563 const struct op_print *op_print_tab;
565 op_print_tab = current_language->la_op_print_tab;
566 for (tem = 0; op_print_tab[tem].opcode != OP_NULL; tem++)
567 if (op_print_tab[tem].opcode == op)
568 return op_print_tab[tem].string;
572 /* Support for dumping the raw data from expressions in a human readable
575 static char *op_name (struct expression *, enum exp_opcode);
576 static int dump_subexp_body (struct expression *exp, struct ui_file *, int);
578 /* Name for OPCODE, when it appears in expression EXP. */
581 op_name (struct expression *exp, enum exp_opcode opcode)
583 return exp->language_defn->la_exp_desc->op_name (opcode);
586 /* Default name for the standard operator OPCODE (i.e., one defined in
587 the definition of enum exp_opcode). */
590 op_name_standard (enum exp_opcode opcode)
598 sprintf (buf, "<unknown %d>", opcode);
619 case BINOP_LOGICAL_AND:
620 return "BINOP_LOGICAL_AND";
621 case BINOP_LOGICAL_OR:
622 return "BINOP_LOGICAL_OR";
623 case BINOP_BITWISE_AND:
624 return "BINOP_BITWISE_AND";
625 case BINOP_BITWISE_IOR:
626 return "BINOP_BITWISE_IOR";
627 case BINOP_BITWISE_XOR:
628 return "BINOP_BITWISE_XOR";
630 return "BINOP_EQUAL";
632 return "BINOP_NOTEQUAL";
642 return "BINOP_REPEAT";
644 return "BINOP_ASSIGN";
646 return "BINOP_COMMA";
647 case BINOP_SUBSCRIPT:
648 return "BINOP_SUBSCRIPT";
649 case MULTI_SUBSCRIPT:
650 return "MULTI_SUBSCRIPT";
657 case STRUCTOP_MEMBER:
658 return "STRUCTOP_MEMBER";
660 return "STRUCTOP_MPTR";
662 return "BINOP_INTDIV";
663 case BINOP_ASSIGN_MODIFY:
664 return "BINOP_ASSIGN_MODIFY";
672 return "BINOP_CONCAT";
674 return "BINOP_RANGE";
678 return "TERNOP_COND";
680 return "TERNOP_SLICE";
681 case TERNOP_SLICE_COUNT:
682 return "TERNOP_SLICE_COUNT";
688 return "OP_VAR_VALUE";
692 return "OP_REGISTER";
694 return "OP_INTERNALVAR";
700 return "OP_BITSTRING";
706 return "UNOP_MEMVAL";
707 case UNOP_MEMVAL_TLS:
708 return "UNOP_MEMVAL_TLS";
711 case UNOP_LOGICAL_NOT:
712 return "UNOP_LOGICAL_NOT";
713 case UNOP_COMPLEMENT:
714 return "UNOP_COMPLEMENT";
719 case UNOP_PREINCREMENT:
720 return "UNOP_PREINCREMENT";
721 case UNOP_POSTINCREMENT:
722 return "UNOP_POSTINCREMENT";
723 case UNOP_PREDECREMENT:
724 return "UNOP_PREDECREMENT";
725 case UNOP_POSTDECREMENT:
726 return "UNOP_POSTDECREMENT";
728 return "UNOP_SIZEOF";
734 return "UNOP_LENGTH";
760 return "OP_M2_STRING";
761 case STRUCTOP_STRUCT:
762 return "STRUCTOP_STRUCT";
764 return "STRUCTOP_PTR";
768 return "OP_OBJC_SELF";
779 dump_raw_expression (struct expression *exp, struct ui_file *stream,
787 fprintf_filtered (stream, "Dump of expression @ ");
788 gdb_print_host_address (exp, stream);
789 fprintf_filtered (stream, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",
790 exp->language_defn->la_name, exp->nelts,
791 (long) sizeof (union exp_element));
792 fprintf_filtered (stream, "\t%5s %20s %16s %s\n", "Index", "Opcode",
793 "Hex Value", "String Value");
794 for (elt = 0; elt < exp->nelts; elt++)
796 fprintf_filtered (stream, "\t%5d ", elt);
797 opcode_name = op_name (exp, exp->elts[elt].opcode);
799 fprintf_filtered (stream, "%20s ", opcode_name);
800 print_longest (stream, 'd', 0, exp->elts[elt].longconst);
801 fprintf_filtered (stream, " ");
803 for (eltscan = (char *) &exp->elts[elt],
804 eltsize = sizeof (union exp_element);
808 fprintf_filtered (stream, "%c",
809 isprint (*eltscan) ? (*eltscan & 0xFF) : '.');
811 fprintf_filtered (stream, "\n");
815 /* Dump the subexpression of prefix expression EXP whose operator is at
816 position ELT onto STREAM. Returns the position of the next
817 subexpression in EXP. */
820 dump_subexp (struct expression *exp, struct ui_file *stream, int elt)
822 static int indent = 0;
825 fprintf_filtered (stream, "\n");
826 fprintf_filtered (stream, "\t%5d ", elt);
828 for (i = 1; i <= indent; i++)
829 fprintf_filtered (stream, " ");
832 fprintf_filtered (stream, "%-20s ", op_name (exp, exp->elts[elt].opcode));
834 elt = dump_subexp_body (exp, stream, elt);
841 /* Dump the operands of prefix expression EXP whose opcode is at
842 position ELT onto STREAM. Returns the position of the next
843 subexpression in EXP. */
846 dump_subexp_body (struct expression *exp, struct ui_file *stream, int elt)
848 return exp->language_defn->la_exp_desc->dump_subexp_body (exp, stream, elt);
851 /* Default value for subexp_body in exp_descriptor vector. */
854 dump_subexp_body_standard (struct expression *exp,
855 struct ui_file *stream, int elt)
857 int opcode = exp->elts[elt++].opcode;
863 case TERNOP_SLICE_COUNT:
864 elt = dump_subexp (exp, stream, elt);
873 case BINOP_LOGICAL_AND:
874 case BINOP_LOGICAL_OR:
875 case BINOP_BITWISE_AND:
876 case BINOP_BITWISE_IOR:
877 case BINOP_BITWISE_XOR:
887 case BINOP_SUBSCRIPT:
892 case BINOP_ASSIGN_MODIFY:
900 case STRUCTOP_MEMBER:
902 elt = dump_subexp (exp, stream, elt);
904 case UNOP_LOGICAL_NOT:
905 case UNOP_COMPLEMENT:
908 case UNOP_PREINCREMENT:
909 case UNOP_POSTINCREMENT:
910 case UNOP_PREDECREMENT:
911 case UNOP_POSTDECREMENT:
930 elt = dump_subexp (exp, stream, elt);
933 fprintf_filtered (stream, "Type @");
934 gdb_print_host_address (exp->elts[elt].type, stream);
935 fprintf_filtered (stream, " (");
936 type_print (exp->elts[elt].type, NULL, stream, 0);
937 fprintf_filtered (stream, "), value %ld (0x%lx)",
938 (long) exp->elts[elt + 1].longconst,
939 (long) exp->elts[elt + 1].longconst);
943 fprintf_filtered (stream, "Type @");
944 gdb_print_host_address (exp->elts[elt].type, stream);
945 fprintf_filtered (stream, " (");
946 type_print (exp->elts[elt].type, NULL, stream, 0);
947 fprintf_filtered (stream, "), value %g",
948 (double) exp->elts[elt + 1].doubleconst);
952 fprintf_filtered (stream, "Block @");
953 gdb_print_host_address (exp->elts[elt].block, stream);
954 fprintf_filtered (stream, ", symbol @");
955 gdb_print_host_address (exp->elts[elt + 1].symbol, stream);
956 fprintf_filtered (stream, " (%s)",
957 DEPRECATED_SYMBOL_NAME (exp->elts[elt + 1].symbol));
961 fprintf_filtered (stream, "History element %ld",
962 (long) exp->elts[elt].longconst);
966 fprintf_filtered (stream, "Register $%s", &exp->elts[elt + 1].string);
967 elt += 3 + BYTES_TO_EXP_ELEM (exp->elts[elt].longconst + 1);
970 fprintf_filtered (stream, "Internal var @");
971 gdb_print_host_address (exp->elts[elt].internalvar, stream);
972 fprintf_filtered (stream, " (%s)",
973 exp->elts[elt].internalvar->name);
980 nargs = longest_to_int (exp->elts[elt].longconst);
982 fprintf_filtered (stream, "Number of args: %d", nargs);
985 for (i = 1; i <= nargs + 1; i++)
986 elt = dump_subexp (exp, stream, elt);
994 lower = longest_to_int (exp->elts[elt].longconst);
995 upper = longest_to_int (exp->elts[elt + 1].longconst);
997 fprintf_filtered (stream, "Bounds [%d:%d]", lower, upper);
1000 for (i = 1; i <= upper - lower + 1; i++)
1001 elt = dump_subexp (exp, stream, elt);
1006 fprintf_filtered (stream, "Type @");
1007 gdb_print_host_address (exp->elts[elt].type, stream);
1008 fprintf_filtered (stream, " (");
1009 type_print (exp->elts[elt].type, NULL, stream, 0);
1010 fprintf_filtered (stream, ")");
1011 elt = dump_subexp (exp, stream, elt + 2);
1013 case UNOP_MEMVAL_TLS:
1014 fprintf_filtered (stream, "TLS type @");
1015 gdb_print_host_address (exp->elts[elt + 1].type, stream);
1016 fprintf_filtered (stream, " (__thread /* \"%s\" */ ",
1017 (exp->elts[elt].objfile == NULL ? "(null)"
1018 : exp->elts[elt].objfile->name));
1019 type_print (exp->elts[elt + 1].type, NULL, stream, 0);
1020 fprintf_filtered (stream, ")");
1021 elt = dump_subexp (exp, stream, elt + 3);
1024 fprintf_filtered (stream, "Type @");
1025 gdb_print_host_address (exp->elts[elt].type, stream);
1026 fprintf_filtered (stream, " (");
1027 type_print (exp->elts[elt].type, NULL, stream, 0);
1028 fprintf_filtered (stream, ")");
1031 case STRUCTOP_STRUCT:
1037 len = longest_to_int (exp->elts[elt].longconst);
1038 elem_name = &exp->elts[elt + 1].string;
1040 fprintf_filtered (stream, "Element name: `%.*s'", len, elem_name);
1041 elt = dump_subexp (exp, stream, elt + 3 + BYTES_TO_EXP_ELEM (len + 1));
1049 fprintf_filtered (stream, "Type @");
1050 gdb_print_host_address (exp->elts[elt].type, stream);
1051 fprintf_filtered (stream, " (");
1052 type_print (exp->elts[elt].type, NULL, stream, 0);
1053 fprintf_filtered (stream, ") ");
1055 len = longest_to_int (exp->elts[elt + 1].longconst);
1056 elem_name = &exp->elts[elt + 2].string;
1058 fprintf_filtered (stream, "Field name: `%.*s'", len, elem_name);
1059 elt += 4 + BYTES_TO_EXP_ELEM (len + 1);
1064 case MULTI_SUBSCRIPT:
1065 case OP_F77_UNDETERMINED_ARGLIST:
1074 fprintf_filtered (stream, "Unknown format");
1081 dump_prefix_expression (struct expression *exp, struct ui_file *stream)
1085 fprintf_filtered (stream, "Dump of expression @ ");
1086 gdb_print_host_address (exp, stream);
1087 fputs_filtered (", after conversion to prefix form:\nExpression: `", stream);
1088 if (exp->elts[0].opcode != OP_TYPE)
1089 print_expression (exp, stream);
1091 fputs_filtered ("Type printing not yet supported....", stream);
1092 fprintf_filtered (stream, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",
1093 exp->language_defn->la_name, exp->nelts,
1094 (long) sizeof (union exp_element));
1095 fputs_filtered ("\n", stream);
1097 for (elt = 0; elt < exp->nelts;)
1098 elt = dump_subexp (exp, stream, elt);
1099 fputs_filtered ("\n", stream);