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 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 2 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, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
26 #include "expression.h"
29 #include "parser-defs.h"
30 #include "user-regs.h" /* For user_reg_map_regnum_to_name. */
32 #include "gdb_string.h"
41 print_expression (struct expression *exp, struct ui_file *stream)
44 print_subexp (exp, &pc, stream, PREC_NULL);
47 /* Print the subexpression of EXP that starts in position POS, on STREAM.
48 PREC is the precedence of the surrounding operator;
49 if the precedence of the main operator of this subexpression is less,
50 parentheses are needed here. */
53 print_subexp (struct expression *exp, int *pos,
54 struct ui_file *stream, enum precedence prec)
56 exp->language_defn->la_exp_desc->print_subexp (exp, pos, stream, prec);
59 /* Standard implementation of print_subexp for use in language_defn
62 print_subexp_standard (struct expression *exp, int *pos,
63 struct ui_file *stream, enum precedence prec)
66 const struct op_print *op_print_tab;
70 int assign_modify = 0;
71 enum exp_opcode opcode;
72 enum precedence myprec = PREC_NULL;
73 /* Set to 1 for a right-associative operator. */
78 op_print_tab = exp->language_defn->la_op_print_tab;
80 opcode = exp->elts[pc].opcode;
88 fputs_filtered (type_name_no_tag (exp->elts[pc + 1].type), stream);
89 fputs_filtered ("::", stream);
90 nargs = longest_to_int (exp->elts[pc + 2].longconst);
91 (*pos) += 4 + BYTES_TO_EXP_ELEM (nargs + 1);
92 fputs_filtered (&exp->elts[pc + 3].string, stream);
97 value_print (value_from_longest (exp->elts[pc + 1].type,
98 exp->elts[pc + 2].longconst),
99 stream, 0, Val_no_prettyprint);
104 value_print (value_from_double (exp->elts[pc + 1].type,
105 exp->elts[pc + 2].doubleconst),
106 stream, 0, Val_no_prettyprint);
113 b = exp->elts[pc + 1].block;
115 && BLOCK_FUNCTION (b) != NULL
116 && SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b)) != NULL)
118 fputs_filtered (SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b)), stream);
119 fputs_filtered ("::", stream);
121 fputs_filtered (SYMBOL_PRINT_NAME (exp->elts[pc + 2].symbol), stream);
127 fprintf_filtered (stream, "$%d",
128 longest_to_int (exp->elts[pc + 1].longconst));
133 int regnum = longest_to_int (exp->elts[pc + 1].longconst);
134 const char *name = user_reg_map_regnum_to_name (current_gdbarch,
137 fprintf_filtered (stream, "$%s", name);
143 fprintf_filtered (stream, "%s",
144 longest_to_int (exp->elts[pc + 1].longconst)
150 fprintf_filtered (stream, "$%s",
151 internalvar_name (exp->elts[pc + 1].internalvar));
156 nargs = longest_to_int (exp->elts[pc + 1].longconst);
157 print_subexp (exp, pos, stream, PREC_SUFFIX);
158 fputs_filtered (" (", stream);
159 for (tem = 0; tem < nargs; tem++)
162 fputs_filtered (", ", stream);
163 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
165 fputs_filtered (")", stream);
170 nargs = longest_to_int (exp->elts[pc + 1].longconst);
171 (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
172 fputs_filtered (&exp->elts[pc + 2].string, stream);
176 nargs = longest_to_int (exp->elts[pc + 1].longconst);
177 (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
178 /* LA_PRINT_STRING will print using the current repeat count threshold.
179 If necessary, we can temporarily set it to zero, or pass it as an
180 additional parameter to LA_PRINT_STRING. -fnf */
181 LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0);
185 nargs = longest_to_int (exp->elts[pc + 1].longconst);
187 += 3 + BYTES_TO_EXP_ELEM ((nargs + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT);
188 fprintf_unfiltered (stream, "B'<unimplemented>'");
191 case OP_OBJC_NSSTRING: /* Objective-C Foundation Class NSString constant. */
192 nargs = longest_to_int (exp->elts[pc + 1].longconst);
193 (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
194 fputs_filtered ("@\"", stream);
195 LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0);
196 fputs_filtered ("\"", stream);
199 case OP_OBJC_MSGCALL:
200 { /* Objective C message (method) call. */
203 nargs = longest_to_int (exp->elts[pc + 2].longconst);
204 fprintf_unfiltered (stream, "[");
205 print_subexp (exp, pos, stream, PREC_SUFFIX);
206 if (0 == target_read_string (exp->elts[pc + 1].longconst,
207 &selector, 1024, NULL))
209 error (_("bad selector"));
215 s = alloca (strlen (selector) + 1);
216 strcpy (s, selector);
217 for (tem = 0; tem < nargs; tem++)
219 nextS = strchr (s, ':');
221 fprintf_unfiltered (stream, " %s: ", s);
223 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
228 fprintf_unfiltered (stream, " %s", selector);
230 fprintf_unfiltered (stream, "]");
231 /* "selector" was malloc'd by target_read_string. Free it. */
238 nargs = longest_to_int (exp->elts[pc + 2].longconst);
239 nargs -= longest_to_int (exp->elts[pc + 1].longconst);
242 if (exp->elts[pc + 4].opcode == OP_LONG
243 && exp->elts[pc + 5].type == builtin_type_char
244 && exp->language_defn->la_language == language_c)
246 /* Attempt to print C character arrays using string syntax.
247 Walk through the args, picking up one character from each
248 of the OP_LONG expression elements. If any array element
249 does not match our expection of what we should find for
250 a simple string, revert back to array printing. Note that
251 the last expression element is an explicit null terminator
252 byte, which doesn't get printed. */
253 tempstr = alloca (nargs);
257 if (exp->elts[pc].opcode != OP_LONG
258 || exp->elts[pc + 1].type != builtin_type_char)
260 /* Not a simple array of char, use regular array printing. */
267 longest_to_int (exp->elts[pc + 2].longconst);
274 LA_PRINT_STRING (stream, tempstr, nargs - 1, 1, 0);
279 fputs_filtered (" {", stream);
280 for (tem = 0; tem < nargs; tem++)
284 fputs_filtered (", ", stream);
286 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
288 fputs_filtered ("}", stream);
293 tem = longest_to_int (exp->elts[pc + 1].longconst);
294 (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
295 /* Gcc support both these syntaxes. Unsure which is preferred. */
297 fputs_filtered (&exp->elts[pc + 2].string, stream);
298 fputs_filtered (": ", stream);
300 fputs_filtered (".", stream);
301 fputs_filtered (&exp->elts[pc + 2].string, stream);
302 fputs_filtered ("=", stream);
304 print_subexp (exp, pos, stream, PREC_SUFFIX);
308 if ((int) prec > (int) PREC_COMMA)
309 fputs_filtered ("(", stream);
310 /* Print the subexpressions, forcing parentheses
311 around any binary operations within them.
312 This is more parentheses than are strictly necessary,
313 but it looks clearer. */
314 print_subexp (exp, pos, stream, PREC_HYPER);
315 fputs_filtered (" ? ", stream);
316 print_subexp (exp, pos, stream, PREC_HYPER);
317 fputs_filtered (" : ", stream);
318 print_subexp (exp, pos, stream, PREC_HYPER);
319 if ((int) prec > (int) PREC_COMMA)
320 fputs_filtered (")", stream);
324 case TERNOP_SLICE_COUNT:
325 print_subexp (exp, pos, stream, PREC_SUFFIX);
326 fputs_filtered ("(", stream);
327 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
328 fputs_filtered (opcode == TERNOP_SLICE ? " : " : " UP ", stream);
329 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
330 fputs_filtered (")", stream);
333 case STRUCTOP_STRUCT:
334 tem = longest_to_int (exp->elts[pc + 1].longconst);
335 (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
336 print_subexp (exp, pos, stream, PREC_SUFFIX);
337 fputs_filtered (".", stream);
338 fputs_filtered (&exp->elts[pc + 2].string, stream);
341 /* Will not occur for Modula-2 */
343 tem = longest_to_int (exp->elts[pc + 1].longconst);
344 (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
345 print_subexp (exp, pos, stream, PREC_SUFFIX);
346 fputs_filtered ("->", stream);
347 fputs_filtered (&exp->elts[pc + 2].string, stream);
350 case STRUCTOP_MEMBER:
351 print_subexp (exp, pos, stream, PREC_SUFFIX);
352 fputs_filtered (".*", stream);
353 print_subexp (exp, pos, stream, PREC_SUFFIX);
357 print_subexp (exp, pos, stream, PREC_SUFFIX);
358 fputs_filtered ("->*", stream);
359 print_subexp (exp, pos, stream, PREC_SUFFIX);
362 case BINOP_SUBSCRIPT:
363 print_subexp (exp, pos, stream, PREC_SUFFIX);
364 fputs_filtered ("[", stream);
365 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
366 fputs_filtered ("]", stream);
369 case UNOP_POSTINCREMENT:
370 print_subexp (exp, pos, stream, PREC_SUFFIX);
371 fputs_filtered ("++", stream);
374 case UNOP_POSTDECREMENT:
375 print_subexp (exp, pos, stream, PREC_SUFFIX);
376 fputs_filtered ("--", stream);
381 if ((int) prec > (int) PREC_PREFIX)
382 fputs_filtered ("(", stream);
383 fputs_filtered ("(", stream);
384 type_print (exp->elts[pc + 1].type, "", stream, 0);
385 fputs_filtered (") ", stream);
386 print_subexp (exp, pos, stream, PREC_PREFIX);
387 if ((int) prec > (int) PREC_PREFIX)
388 fputs_filtered (")", stream);
393 if ((int) prec > (int) PREC_PREFIX)
394 fputs_filtered ("(", stream);
395 if (TYPE_CODE (exp->elts[pc + 1].type) == TYPE_CODE_FUNC &&
396 exp->elts[pc + 3].opcode == OP_LONG)
398 /* We have a minimal symbol fn, probably. It's encoded
399 as a UNOP_MEMVAL (function-type) of an OP_LONG (int, address).
400 Swallow the OP_LONG (including both its opcodes); ignore
401 its type; print the value in the type of the MEMVAL. */
403 val = value_at_lazy (exp->elts[pc + 1].type,
404 (CORE_ADDR) exp->elts[pc + 5].longconst);
405 value_print (val, stream, 0, Val_no_prettyprint);
409 fputs_filtered ("{", stream);
410 type_print (exp->elts[pc + 1].type, "", stream, 0);
411 fputs_filtered ("} ", stream);
412 print_subexp (exp, pos, stream, PREC_PREFIX);
414 if ((int) prec > (int) PREC_PREFIX)
415 fputs_filtered (")", stream);
418 case UNOP_MEMVAL_TLS:
420 if ((int) prec > (int) PREC_PREFIX)
421 fputs_filtered ("(", stream);
422 fputs_filtered ("{", stream);
423 type_print (exp->elts[pc + 2].type, "", stream, 0);
424 fputs_filtered ("} ", stream);
425 print_subexp (exp, pos, stream, PREC_PREFIX);
426 if ((int) prec > (int) PREC_PREFIX)
427 fputs_filtered (")", stream);
430 case BINOP_ASSIGN_MODIFY:
431 opcode = exp->elts[pc + 1].opcode;
433 myprec = PREC_ASSIGN;
437 for (tem = 0; op_print_tab[tem].opcode != OP_NULL; tem++)
438 if (op_print_tab[tem].opcode == opcode)
440 op_str = op_print_tab[tem].string;
443 if (op_print_tab[tem].opcode != opcode)
444 /* Not found; don't try to keep going because we don't know how
445 to interpret further elements. */
446 error (_("Invalid expression"));
453 fputs_filtered ("this", stream);
456 /* Objective-C ops */
460 fputs_filtered ("self", stream); /* The ObjC equivalent of "this". */
465 case MULTI_SUBSCRIPT:
467 nargs = longest_to_int (exp->elts[pc + 1].longconst);
468 print_subexp (exp, pos, stream, PREC_SUFFIX);
469 fprintf_unfiltered (stream, " [");
470 for (tem = 0; tem < nargs; tem++)
473 fprintf_unfiltered (stream, ", ");
474 print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
476 fprintf_unfiltered (stream, "]");
481 fprintf_unfiltered (stream, "VAL(");
482 type_print (exp->elts[pc + 1].type, "", stream, 0);
483 fprintf_unfiltered (stream, ",");
484 print_subexp (exp, pos, stream, PREC_PREFIX);
485 fprintf_unfiltered (stream, ")");
490 error (_("print_subexp: Not implemented."));
496 for (tem = 0; op_print_tab[tem].opcode != OP_NULL; tem++)
497 if (op_print_tab[tem].opcode == opcode)
499 op_str = op_print_tab[tem].string;
500 myprec = op_print_tab[tem].precedence;
501 assoc = op_print_tab[tem].right_assoc;
504 if (op_print_tab[tem].opcode != opcode)
505 /* Not found; don't try to keep going because we don't know how
506 to interpret further elements. For example, this happens
507 if opcode is OP_TYPE. */
508 error (_("Invalid expression"));
511 /* Note that PREC_BUILTIN will always emit parentheses. */
512 if ((int) myprec < (int) prec)
513 fputs_filtered ("(", stream);
514 if ((int) opcode > (int) BINOP_END)
518 /* Unary postfix operator. */
519 print_subexp (exp, pos, stream, PREC_SUFFIX);
520 fputs_filtered (op_str, stream);
524 /* Unary prefix operator. */
525 fputs_filtered (op_str, stream);
526 if (myprec == PREC_BUILTIN_FUNCTION)
527 fputs_filtered ("(", stream);
528 print_subexp (exp, pos, stream, PREC_PREFIX);
529 if (myprec == PREC_BUILTIN_FUNCTION)
530 fputs_filtered (")", stream);
535 /* Binary operator. */
536 /* Print left operand.
537 If operator is right-associative,
538 increment precedence for this operand. */
539 print_subexp (exp, pos, stream,
540 (enum precedence) ((int) myprec + assoc));
541 /* Print the operator itself. */
543 fprintf_filtered (stream, " %s= ", op_str);
544 else if (op_str[0] == ',')
545 fprintf_filtered (stream, "%s ", op_str);
547 fprintf_filtered (stream, " %s ", op_str);
548 /* Print right operand.
549 If operator is left-associative,
550 increment precedence for this operand. */
551 print_subexp (exp, pos, stream,
552 (enum precedence) ((int) myprec + !assoc));
555 if ((int) myprec < (int) prec)
556 fputs_filtered (")", stream);
559 /* Return the operator corresponding to opcode OP as
560 a string. NULL indicates that the opcode was not found in the
561 current language table. */
563 op_string (enum exp_opcode op)
566 const struct op_print *op_print_tab;
568 op_print_tab = current_language->la_op_print_tab;
569 for (tem = 0; op_print_tab[tem].opcode != OP_NULL; tem++)
570 if (op_print_tab[tem].opcode == op)
571 return op_print_tab[tem].string;
575 /* Support for dumping the raw data from expressions in a human readable
578 static char *op_name (struct expression *, enum exp_opcode);
579 static int dump_subexp_body (struct expression *exp, struct ui_file *, int);
581 /* Name for OPCODE, when it appears in expression EXP. */
584 op_name (struct expression *exp, enum exp_opcode opcode)
586 return exp->language_defn->la_exp_desc->op_name (opcode);
589 /* Default name for the standard operator OPCODE (i.e., one defined in
590 the definition of enum exp_opcode). */
593 op_name_standard (enum exp_opcode opcode)
601 sprintf (buf, "<unknown %d>", opcode);
622 case BINOP_LOGICAL_AND:
623 return "BINOP_LOGICAL_AND";
624 case BINOP_LOGICAL_OR:
625 return "BINOP_LOGICAL_OR";
626 case BINOP_BITWISE_AND:
627 return "BINOP_BITWISE_AND";
628 case BINOP_BITWISE_IOR:
629 return "BINOP_BITWISE_IOR";
630 case BINOP_BITWISE_XOR:
631 return "BINOP_BITWISE_XOR";
633 return "BINOP_EQUAL";
635 return "BINOP_NOTEQUAL";
645 return "BINOP_REPEAT";
647 return "BINOP_ASSIGN";
649 return "BINOP_COMMA";
650 case BINOP_SUBSCRIPT:
651 return "BINOP_SUBSCRIPT";
652 case MULTI_SUBSCRIPT:
653 return "MULTI_SUBSCRIPT";
660 case STRUCTOP_MEMBER:
661 return "STRUCTOP_MEMBER";
663 return "STRUCTOP_MPTR";
665 return "BINOP_INTDIV";
666 case BINOP_ASSIGN_MODIFY:
667 return "BINOP_ASSIGN_MODIFY";
675 return "BINOP_CONCAT";
677 return "BINOP_RANGE";
681 return "TERNOP_COND";
683 return "TERNOP_SLICE";
684 case TERNOP_SLICE_COUNT:
685 return "TERNOP_SLICE_COUNT";
691 return "OP_VAR_VALUE";
695 return "OP_REGISTER";
697 return "OP_INTERNALVAR";
703 return "OP_BITSTRING";
709 return "UNOP_MEMVAL";
710 case UNOP_MEMVAL_TLS:
711 return "UNOP_MEMVAL_TLS";
714 case UNOP_LOGICAL_NOT:
715 return "UNOP_LOGICAL_NOT";
716 case UNOP_COMPLEMENT:
717 return "UNOP_COMPLEMENT";
722 case UNOP_PREINCREMENT:
723 return "UNOP_PREINCREMENT";
724 case UNOP_POSTINCREMENT:
725 return "UNOP_POSTINCREMENT";
726 case UNOP_PREDECREMENT:
727 return "UNOP_PREDECREMENT";
728 case UNOP_POSTDECREMENT:
729 return "UNOP_POSTDECREMENT";
731 return "UNOP_SIZEOF";
737 return "UNOP_LENGTH";
763 return "OP_M2_STRING";
764 case STRUCTOP_STRUCT:
765 return "STRUCTOP_STRUCT";
767 return "STRUCTOP_PTR";
771 return "OP_OBJC_SELF";
782 dump_raw_expression (struct expression *exp, struct ui_file *stream,
790 fprintf_filtered (stream, "Dump of expression @ ");
791 gdb_print_host_address (exp, stream);
792 fprintf_filtered (stream, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",
793 exp->language_defn->la_name, exp->nelts,
794 (long) sizeof (union exp_element));
795 fprintf_filtered (stream, "\t%5s %20s %16s %s\n", "Index", "Opcode",
796 "Hex Value", "String Value");
797 for (elt = 0; elt < exp->nelts; elt++)
799 fprintf_filtered (stream, "\t%5d ", elt);
800 opcode_name = op_name (exp, exp->elts[elt].opcode);
802 fprintf_filtered (stream, "%20s ", opcode_name);
803 print_longest (stream, 'd', 0, exp->elts[elt].longconst);
804 fprintf_filtered (stream, " ");
806 for (eltscan = (char *) &exp->elts[elt],
807 eltsize = sizeof (union exp_element);
811 fprintf_filtered (stream, "%c",
812 isprint (*eltscan) ? (*eltscan & 0xFF) : '.');
814 fprintf_filtered (stream, "\n");
818 /* Dump the subexpression of prefix expression EXP whose operator is at
819 position ELT onto STREAM. Returns the position of the next
820 subexpression in EXP. */
823 dump_subexp (struct expression *exp, struct ui_file *stream, int elt)
825 static int indent = 0;
828 fprintf_filtered (stream, "\n");
829 fprintf_filtered (stream, "\t%5d ", elt);
831 for (i = 1; i <= indent; i++)
832 fprintf_filtered (stream, " ");
835 fprintf_filtered (stream, "%-20s ", op_name (exp, exp->elts[elt].opcode));
837 elt = dump_subexp_body (exp, stream, elt);
844 /* Dump the operands of prefix expression EXP whose opcode is at
845 position ELT onto STREAM. Returns the position of the next
846 subexpression in EXP. */
849 dump_subexp_body (struct expression *exp, struct ui_file *stream, int elt)
851 return exp->language_defn->la_exp_desc->dump_subexp_body (exp, stream, elt);
854 /* Default value for subexp_body in exp_descriptor vector. */
857 dump_subexp_body_standard (struct expression *exp,
858 struct ui_file *stream, int elt)
860 int opcode = exp->elts[elt++].opcode;
866 case TERNOP_SLICE_COUNT:
867 elt = dump_subexp (exp, stream, elt);
876 case BINOP_LOGICAL_AND:
877 case BINOP_LOGICAL_OR:
878 case BINOP_BITWISE_AND:
879 case BINOP_BITWISE_IOR:
880 case BINOP_BITWISE_XOR:
890 case BINOP_SUBSCRIPT:
895 case BINOP_ASSIGN_MODIFY:
903 case STRUCTOP_MEMBER:
905 elt = dump_subexp (exp, stream, elt);
907 case UNOP_LOGICAL_NOT:
908 case UNOP_COMPLEMENT:
911 case UNOP_PREINCREMENT:
912 case UNOP_POSTINCREMENT:
913 case UNOP_PREDECREMENT:
914 case UNOP_POSTDECREMENT:
933 elt = dump_subexp (exp, stream, elt);
936 fprintf_filtered (stream, "Type @");
937 gdb_print_host_address (exp->elts[elt].type, stream);
938 fprintf_filtered (stream, " (");
939 type_print (exp->elts[elt].type, NULL, stream, 0);
940 fprintf_filtered (stream, "), value %ld (0x%lx)",
941 (long) exp->elts[elt + 1].longconst,
942 (long) exp->elts[elt + 1].longconst);
946 fprintf_filtered (stream, "Type @");
947 gdb_print_host_address (exp->elts[elt].type, stream);
948 fprintf_filtered (stream, " (");
949 type_print (exp->elts[elt].type, NULL, stream, 0);
950 fprintf_filtered (stream, "), value %g",
951 (double) exp->elts[elt + 1].doubleconst);
955 fprintf_filtered (stream, "Block @");
956 gdb_print_host_address (exp->elts[elt].block, stream);
957 fprintf_filtered (stream, ", symbol @");
958 gdb_print_host_address (exp->elts[elt + 1].symbol, stream);
959 fprintf_filtered (stream, " (%s)",
960 DEPRECATED_SYMBOL_NAME (exp->elts[elt + 1].symbol));
964 fprintf_filtered (stream, "History element %ld",
965 (long) exp->elts[elt].longconst);
969 fprintf_filtered (stream, "Register %ld",
970 (long) exp->elts[elt].longconst);
974 fprintf_filtered (stream, "Internal var @");
975 gdb_print_host_address (exp->elts[elt].internalvar, stream);
976 fprintf_filtered (stream, " (%s)",
977 exp->elts[elt].internalvar->name);
984 nargs = longest_to_int (exp->elts[elt].longconst);
986 fprintf_filtered (stream, "Number of args: %d", nargs);
989 for (i = 1; i <= nargs + 1; i++)
990 elt = dump_subexp (exp, stream, elt);
998 lower = longest_to_int (exp->elts[elt].longconst);
999 upper = longest_to_int (exp->elts[elt + 1].longconst);
1001 fprintf_filtered (stream, "Bounds [%d:%d]", lower, upper);
1004 for (i = 1; i <= upper - lower + 1; i++)
1005 elt = dump_subexp (exp, stream, elt);
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, ")");
1015 elt = dump_subexp (exp, stream, elt + 2);
1017 case UNOP_MEMVAL_TLS:
1018 fprintf_filtered (stream, "TLS type @");
1019 gdb_print_host_address (exp->elts[elt + 1].type, stream);
1020 fprintf_filtered (stream, " (__thread /* \"%s\" */ ",
1021 (exp->elts[elt].objfile == NULL ? "(null)"
1022 : exp->elts[elt].objfile->name));
1023 type_print (exp->elts[elt + 1].type, NULL, stream, 0);
1024 fprintf_filtered (stream, ")");
1025 elt = dump_subexp (exp, stream, elt + 3);
1028 fprintf_filtered (stream, "Type @");
1029 gdb_print_host_address (exp->elts[elt].type, stream);
1030 fprintf_filtered (stream, " (");
1031 type_print (exp->elts[elt].type, NULL, stream, 0);
1032 fprintf_filtered (stream, ")");
1035 case STRUCTOP_STRUCT:
1041 len = longest_to_int (exp->elts[elt].longconst);
1042 elem_name = &exp->elts[elt + 1].string;
1044 fprintf_filtered (stream, "Element name: `%.*s'", len, elem_name);
1045 elt = dump_subexp (exp, stream, elt + 3 + BYTES_TO_EXP_ELEM (len + 1));
1053 fprintf_filtered (stream, "Type @");
1054 gdb_print_host_address (exp->elts[elt].type, stream);
1055 fprintf_filtered (stream, " (");
1056 type_print (exp->elts[elt].type, NULL, stream, 0);
1057 fprintf_filtered (stream, ") ");
1059 len = longest_to_int (exp->elts[elt + 1].longconst);
1060 elem_name = &exp->elts[elt + 2].string;
1062 fprintf_filtered (stream, "Field name: `%.*s'", len, elem_name);
1063 elt += 4 + BYTES_TO_EXP_ELEM (len + 1);
1068 case MULTI_SUBSCRIPT:
1069 case OP_F77_UNDETERMINED_ARGLIST:
1079 fprintf_filtered (stream, "Unknown format");
1086 dump_prefix_expression (struct expression *exp, struct ui_file *stream)
1090 fprintf_filtered (stream, "Dump of expression @ ");
1091 gdb_print_host_address (exp, stream);
1092 fputs_filtered (", after conversion to prefix form:\nExpression: `", stream);
1093 if (exp->elts[0].opcode != OP_TYPE)
1094 print_expression (exp, stream);
1096 fputs_filtered ("Type printing not yet supported....", stream);
1097 fprintf_filtered (stream, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",
1098 exp->language_defn->la_name, exp->nelts,
1099 (long) sizeof (union exp_element));
1100 fputs_filtered ("\n", stream);
1102 for (elt = 0; elt < exp->nelts;)
1103 elt = dump_subexp (exp, stream, elt);
1104 fputs_filtered ("\n", stream);