1 /* Print in infix form a struct expression.
3 Copyright 1986, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
4 1998, 1999, 2000, 2003 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., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
26 #include "expression.h"
29 #include "parser-defs.h"
30 #include "frame.h" /* For frame_map_regnum_to_name. */
32 #include "gdb_string.h"
38 /* Prototypes for local functions */
40 static void print_subexp (struct expression
*, int *, struct ui_file
*,
44 print_expression (struct expression
*exp
, struct ui_file
*stream
)
47 print_subexp (exp
, &pc
, stream
, PREC_NULL
);
50 /* Print the subexpression of EXP that starts in position POS, on STREAM.
51 PREC is the precedence of the surrounding operator;
52 if the precedence of the main operator of this subexpression is less,
53 parentheses are needed here. */
56 print_subexp (register struct expression
*exp
, register int *pos
,
57 struct ui_file
*stream
, enum precedence prec
)
59 register unsigned tem
;
60 register const struct op_print
*op_print_tab
;
63 register char *op_str
;
64 int assign_modify
= 0;
65 enum exp_opcode opcode
;
66 enum precedence myprec
= PREC_NULL
;
67 /* Set to 1 for a right-associative operator. */
72 op_print_tab
= exp
->language_defn
->la_op_print_tab
;
74 opcode
= exp
->elts
[pc
].opcode
;
82 fputs_filtered (type_name_no_tag (exp
->elts
[pc
+ 1].type
), stream
);
83 fputs_filtered ("::", stream
);
84 nargs
= longest_to_int (exp
->elts
[pc
+ 2].longconst
);
85 (*pos
) += 4 + BYTES_TO_EXP_ELEM (nargs
+ 1);
86 fputs_filtered (&exp
->elts
[pc
+ 3].string
, stream
);
91 value_print (value_from_longest (exp
->elts
[pc
+ 1].type
,
92 exp
->elts
[pc
+ 2].longconst
),
93 stream
, 0, Val_no_prettyprint
);
98 value_print (value_from_double (exp
->elts
[pc
+ 1].type
,
99 exp
->elts
[pc
+ 2].doubleconst
),
100 stream
, 0, Val_no_prettyprint
);
107 b
= exp
->elts
[pc
+ 1].block
;
109 && BLOCK_FUNCTION (b
) != NULL
110 && SYMBOL_SOURCE_NAME (BLOCK_FUNCTION (b
)) != NULL
)
112 fputs_filtered (SYMBOL_SOURCE_NAME (BLOCK_FUNCTION (b
)), stream
);
113 fputs_filtered ("::", stream
);
115 fputs_filtered (SYMBOL_SOURCE_NAME (exp
->elts
[pc
+ 2].symbol
), stream
);
121 fprintf_filtered (stream
, "$%d",
122 longest_to_int (exp
->elts
[pc
+ 1].longconst
));
127 int regnum
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
129 fprintf_filtered (stream
, "$%s", frame_map_regnum_to_name (regnum
));
135 fprintf_filtered (stream
, "%s",
136 longest_to_int (exp
->elts
[pc
+ 1].longconst
)
142 fprintf_filtered (stream
, "$%s",
143 internalvar_name (exp
->elts
[pc
+ 1].internalvar
));
148 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
149 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
150 fputs_filtered (" (", stream
);
151 for (tem
= 0; tem
< nargs
; tem
++)
154 fputs_filtered (", ", stream
);
155 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
157 fputs_filtered (")", stream
);
162 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
163 (*pos
) += 3 + BYTES_TO_EXP_ELEM (nargs
+ 1);
164 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
168 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
169 (*pos
) += 3 + BYTES_TO_EXP_ELEM (nargs
+ 1);
170 /* LA_PRINT_STRING will print using the current repeat count threshold.
171 If necessary, we can temporarily set it to zero, or pass it as an
172 additional parameter to LA_PRINT_STRING. -fnf */
173 LA_PRINT_STRING (stream
, &exp
->elts
[pc
+ 2].string
, nargs
, 1, 0);
177 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
179 += 3 + BYTES_TO_EXP_ELEM ((nargs
+ HOST_CHAR_BIT
- 1) / HOST_CHAR_BIT
);
180 fprintf_unfiltered (stream
, "B'<unimplemented>'");
183 case OP_OBJC_NSSTRING
: /* Objective-C Foundation Class NSString constant. */
184 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
185 (*pos
) += 3 + BYTES_TO_EXP_ELEM (nargs
+ 1);
186 fputs_filtered ("@\"", stream
);
187 LA_PRINT_STRING (stream
, &exp
->elts
[pc
+ 2].string
, nargs
, 1, 0);
188 fputs_filtered ("\"", stream
);
191 case OP_OBJC_MSGCALL
:
192 { /* Objective C message (method) call. */
195 nargs
= longest_to_int (exp
->elts
[pc
+ 2].longconst
);
196 fprintf_unfiltered (stream
, "[");
197 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
198 if (0 == target_read_string (exp
->elts
[pc
+ 1].longconst
,
199 &selector
, 1024, NULL
))
201 error ("bad selector");
207 s
= alloca (strlen (selector
) + 1);
208 strcpy (s
, selector
);
209 for (tem
= 0; tem
< nargs
; tem
++)
211 nextS
= strchr (s
, ':');
213 fprintf_unfiltered (stream
, " %s: ", s
);
215 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
220 fprintf_unfiltered (stream
, " %s", selector
);
222 fprintf_unfiltered (stream
, "]");
223 /* "selector" was malloc'd by target_read_string. Free it. */
230 nargs
= longest_to_int (exp
->elts
[pc
+ 2].longconst
);
231 nargs
-= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
234 if (exp
->elts
[pc
+ 4].opcode
== OP_LONG
235 && exp
->elts
[pc
+ 5].type
== builtin_type_char
236 && exp
->language_defn
->la_language
== language_c
)
238 /* Attempt to print C character arrays using string syntax.
239 Walk through the args, picking up one character from each
240 of the OP_LONG expression elements. If any array element
241 does not match our expection of what we should find for
242 a simple string, revert back to array printing. Note that
243 the last expression element is an explicit null terminator
244 byte, which doesn't get printed. */
245 tempstr
= alloca (nargs
);
249 if (exp
->elts
[pc
].opcode
!= OP_LONG
250 || exp
->elts
[pc
+ 1].type
!= builtin_type_char
)
252 /* Not a simple array of char, use regular array printing. */
259 longest_to_int (exp
->elts
[pc
+ 2].longconst
);
266 LA_PRINT_STRING (stream
, tempstr
, nargs
- 1, 1, 0);
271 fputs_filtered (" {", stream
);
272 for (tem
= 0; tem
< nargs
; tem
++)
276 fputs_filtered (", ", stream
);
278 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
280 fputs_filtered ("}", stream
);
285 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
286 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
287 /* Gcc support both these syntaxes. Unsure which is preferred. */
289 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
290 fputs_filtered (": ", stream
);
292 fputs_filtered (".", stream
);
293 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
294 fputs_filtered ("=", stream
);
296 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
300 if ((int) prec
> (int) PREC_COMMA
)
301 fputs_filtered ("(", stream
);
302 /* Print the subexpressions, forcing parentheses
303 around any binary operations within them.
304 This is more parentheses than are strictly necessary,
305 but it looks clearer. */
306 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
307 fputs_filtered (" ? ", stream
);
308 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
309 fputs_filtered (" : ", stream
);
310 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
311 if ((int) prec
> (int) PREC_COMMA
)
312 fputs_filtered (")", stream
);
316 case TERNOP_SLICE_COUNT
:
317 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
318 fputs_filtered ("(", stream
);
319 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
320 fputs_filtered (opcode
== TERNOP_SLICE
? " : " : " UP ", stream
);
321 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
322 fputs_filtered (")", stream
);
325 case STRUCTOP_STRUCT
:
326 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
327 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
328 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
329 fputs_filtered (".", stream
);
330 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
333 /* Will not occur for Modula-2 */
335 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
336 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
337 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
338 fputs_filtered ("->", stream
);
339 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
342 case BINOP_SUBSCRIPT
:
343 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
344 fputs_filtered ("[", stream
);
345 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
346 fputs_filtered ("]", stream
);
349 case UNOP_POSTINCREMENT
:
350 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
351 fputs_filtered ("++", stream
);
354 case UNOP_POSTDECREMENT
:
355 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
356 fputs_filtered ("--", stream
);
361 if ((int) prec
> (int) PREC_PREFIX
)
362 fputs_filtered ("(", stream
);
363 fputs_filtered ("(", stream
);
364 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
365 fputs_filtered (") ", stream
);
366 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
367 if ((int) prec
> (int) PREC_PREFIX
)
368 fputs_filtered (")", stream
);
373 if ((int) prec
> (int) PREC_PREFIX
)
374 fputs_filtered ("(", stream
);
375 if (TYPE_CODE (exp
->elts
[pc
+ 1].type
) == TYPE_CODE_FUNC
&&
376 exp
->elts
[pc
+ 3].opcode
== OP_LONG
)
378 /* We have a minimal symbol fn, probably. It's encoded
379 as a UNOP_MEMVAL (function-type) of an OP_LONG (int, address).
380 Swallow the OP_LONG (including both its opcodes); ignore
381 its type; print the value in the type of the MEMVAL. */
383 val
= value_at_lazy (exp
->elts
[pc
+ 1].type
,
384 (CORE_ADDR
) exp
->elts
[pc
+ 5].longconst
,
386 value_print (val
, stream
, 0, Val_no_prettyprint
);
390 fputs_filtered ("{", stream
);
391 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
392 fputs_filtered ("} ", stream
);
393 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
395 if ((int) prec
> (int) PREC_PREFIX
)
396 fputs_filtered (")", stream
);
399 case BINOP_ASSIGN_MODIFY
:
400 opcode
= exp
->elts
[pc
+ 1].opcode
;
402 myprec
= PREC_ASSIGN
;
406 for (tem
= 0; op_print_tab
[tem
].opcode
!= OP_NULL
; tem
++)
407 if (op_print_tab
[tem
].opcode
== opcode
)
409 op_str
= op_print_tab
[tem
].string
;
412 if (op_print_tab
[tem
].opcode
!= opcode
)
413 /* Not found; don't try to keep going because we don't know how
414 to interpret further elements. */
415 error ("Invalid expression");
422 fputs_filtered ("this", stream
);
425 /* Objective-C ops */
429 fputs_filtered ("self", stream
); /* The ObjC equivalent of "this". */
434 case MULTI_SUBSCRIPT
:
436 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
437 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
438 fprintf_unfiltered (stream
, " [");
439 for (tem
= 0; tem
< nargs
; tem
++)
442 fprintf_unfiltered (stream
, ", ");
443 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
445 fprintf_unfiltered (stream
, "]");
450 fprintf_unfiltered (stream
, "VAL(");
451 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
452 fprintf_unfiltered (stream
, ",");
453 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
454 fprintf_unfiltered (stream
, ")");
459 error ("print_subexp: Not implemented.");
465 for (tem
= 0; op_print_tab
[tem
].opcode
!= OP_NULL
; tem
++)
466 if (op_print_tab
[tem
].opcode
== opcode
)
468 op_str
= op_print_tab
[tem
].string
;
469 myprec
= op_print_tab
[tem
].precedence
;
470 assoc
= op_print_tab
[tem
].right_assoc
;
473 if (op_print_tab
[tem
].opcode
!= opcode
)
474 /* Not found; don't try to keep going because we don't know how
475 to interpret further elements. For example, this happens
476 if opcode is OP_TYPE. */
477 error ("Invalid expression");
480 /* Note that PREC_BUILTIN will always emit parentheses. */
481 if ((int) myprec
< (int) prec
)
482 fputs_filtered ("(", stream
);
483 if ((int) opcode
> (int) BINOP_END
)
487 /* Unary postfix operator. */
488 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
489 fputs_filtered (op_str
, stream
);
493 /* Unary prefix operator. */
494 fputs_filtered (op_str
, stream
);
495 if (myprec
== PREC_BUILTIN_FUNCTION
)
496 fputs_filtered ("(", stream
);
497 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
498 if (myprec
== PREC_BUILTIN_FUNCTION
)
499 fputs_filtered (")", stream
);
504 /* Binary operator. */
505 /* Print left operand.
506 If operator is right-associative,
507 increment precedence for this operand. */
508 print_subexp (exp
, pos
, stream
,
509 (enum precedence
) ((int) myprec
+ assoc
));
510 /* Print the operator itself. */
512 fprintf_filtered (stream
, " %s= ", op_str
);
513 else if (op_str
[0] == ',')
514 fprintf_filtered (stream
, "%s ", op_str
);
516 fprintf_filtered (stream
, " %s ", op_str
);
517 /* Print right operand.
518 If operator is left-associative,
519 increment precedence for this operand. */
520 print_subexp (exp
, pos
, stream
,
521 (enum precedence
) ((int) myprec
+ !assoc
));
524 if ((int) myprec
< (int) prec
)
525 fputs_filtered (")", stream
);
528 /* Return the operator corresponding to opcode OP as
529 a string. NULL indicates that the opcode was not found in the
530 current language table. */
532 op_string (enum exp_opcode op
)
535 register const struct op_print
*op_print_tab
;
537 op_print_tab
= current_language
->la_op_print_tab
;
538 for (tem
= 0; op_print_tab
[tem
].opcode
!= OP_NULL
; tem
++)
539 if (op_print_tab
[tem
].opcode
== op
)
540 return op_print_tab
[tem
].string
;
544 /* Support for dumping the raw data from expressions in a human readable
547 static char *op_name (int opcode
);
558 sprintf (buf
, "<unknown %d>", opcode
);
579 case BINOP_LOGICAL_AND
:
580 return "BINOP_LOGICAL_AND";
581 case BINOP_LOGICAL_OR
:
582 return "BINOP_LOGICAL_OR";
583 case BINOP_BITWISE_AND
:
584 return "BINOP_BITWISE_AND";
585 case BINOP_BITWISE_IOR
:
586 return "BINOP_BITWISE_IOR";
587 case BINOP_BITWISE_XOR
:
588 return "BINOP_BITWISE_XOR";
590 return "BINOP_EQUAL";
592 return "BINOP_NOTEQUAL";
602 return "BINOP_REPEAT";
604 return "BINOP_ASSIGN";
606 return "BINOP_COMMA";
607 case BINOP_SUBSCRIPT
:
608 return "BINOP_SUBSCRIPT";
609 case MULTI_SUBSCRIPT
:
610 return "MULTI_SUBSCRIPT";
617 case STRUCTOP_MEMBER
:
618 return "STRUCTOP_MEMBER";
620 return "STRUCTOP_MPTR";
622 return "BINOP_INTDIV";
623 case BINOP_ASSIGN_MODIFY
:
624 return "BINOP_ASSIGN_MODIFY";
632 return "BINOP_CONCAT";
634 return "BINOP_RANGE";
638 return "TERNOP_COND";
640 return "TERNOP_SLICE";
641 case TERNOP_SLICE_COUNT
:
642 return "TERNOP_SLICE_COUNT";
648 return "OP_VAR_VALUE";
652 return "OP_REGISTER";
654 return "OP_INTERNALVAR";
660 return "OP_BITSTRING";
666 return "UNOP_MEMVAL";
669 case UNOP_LOGICAL_NOT
:
670 return "UNOP_LOGICAL_NOT";
671 case UNOP_COMPLEMENT
:
672 return "UNOP_COMPLEMENT";
677 case UNOP_PREINCREMENT
:
678 return "UNOP_PREINCREMENT";
679 case UNOP_POSTINCREMENT
:
680 return "UNOP_POSTINCREMENT";
681 case UNOP_PREDECREMENT
:
682 return "UNOP_PREDECREMENT";
683 case UNOP_POSTDECREMENT
:
684 return "UNOP_POSTDECREMENT";
686 return "UNOP_SIZEOF";
692 return "UNOP_LENGTH";
718 return "OP_M2_STRING";
719 case STRUCTOP_STRUCT
:
720 return "STRUCTOP_STRUCT";
722 return "STRUCTOP_PTR";
726 return "OP_OBJC_SELF";
737 dump_prefix_expression (struct expression
*exp
, struct ui_file
*stream
,
745 fprintf_filtered (stream
, "Dump of expression @ ");
746 gdb_print_host_address (exp
, stream
);
747 fprintf_filtered (stream
, ", %s:\nExpression: `", note
);
748 if (exp
->elts
[0].opcode
!= OP_TYPE
)
749 print_expression (exp
, stream
);
751 fprintf_filtered (stream
, "Type printing not yet supported....");
752 fprintf_filtered (stream
, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",
753 exp
->language_defn
->la_name
, exp
->nelts
,
754 (long) sizeof (union exp_element
));
755 fprintf_filtered (stream
, "\t%5s %20s %16s %s\n", "Index", "Opcode",
756 "Hex Value", "String Value");
757 for (elt
= 0; elt
< exp
->nelts
; elt
++)
759 fprintf_filtered (stream
, "\t%5d ", elt
);
760 opcode_name
= op_name (exp
->elts
[elt
].opcode
);
762 fprintf_filtered (stream
, "%20s ", opcode_name
);
763 print_longest (stream
, 'd', 0, exp
->elts
[elt
].longconst
);
764 fprintf_filtered (stream
, " ");
766 for (eltscan
= (char *) &exp
->elts
[elt
],
767 eltsize
= sizeof (union exp_element
);
771 fprintf_filtered (stream
, "%c",
772 isprint (*eltscan
) ? (*eltscan
& 0xFF) : '.');
774 fprintf_filtered (stream
, "\n");
778 static int dump_subexp (struct expression
*exp
, struct ui_file
*stream
,
782 dump_subexp (struct expression
*exp
, struct ui_file
*stream
, int elt
)
784 static int indent
= 0;
787 fprintf_filtered (stream
, "\n");
788 fprintf_filtered (stream
, "\t%5d ", elt
);
790 for (i
= 1; i
<= indent
; i
++)
791 fprintf_filtered (stream
, " ");
794 fprintf_filtered (stream
, "%-20s ", op_name (exp
->elts
[elt
].opcode
));
796 switch (exp
->elts
[elt
++].opcode
)
800 case TERNOP_SLICE_COUNT
:
801 elt
= dump_subexp (exp
, stream
, elt
);
810 case BINOP_LOGICAL_AND
:
811 case BINOP_LOGICAL_OR
:
812 case BINOP_BITWISE_AND
:
813 case BINOP_BITWISE_IOR
:
814 case BINOP_BITWISE_XOR
:
824 case BINOP_SUBSCRIPT
:
829 case BINOP_ASSIGN_MODIFY
:
837 elt
= dump_subexp (exp
, stream
, elt
);
839 case UNOP_LOGICAL_NOT
:
840 case UNOP_COMPLEMENT
:
843 case UNOP_PREINCREMENT
:
844 case UNOP_POSTINCREMENT
:
845 case UNOP_PREDECREMENT
:
846 case UNOP_POSTDECREMENT
:
865 elt
= dump_subexp (exp
, stream
, elt
);
868 fprintf_filtered (stream
, "Type @");
869 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
870 fprintf_filtered (stream
, " (");
871 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
872 fprintf_filtered (stream
, "), value %ld (0x%lx)",
873 (long) exp
->elts
[elt
+ 1].longconst
,
874 (long) exp
->elts
[elt
+ 1].longconst
);
878 fprintf_filtered (stream
, "Type @");
879 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
880 fprintf_filtered (stream
, " (");
881 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
882 fprintf_filtered (stream
, "), value %g",
883 (double) exp
->elts
[elt
+ 1].doubleconst
);
887 fprintf_filtered (stream
, "Block @");
888 gdb_print_host_address (exp
->elts
[elt
].block
, stream
);
889 fprintf_filtered (stream
, ", symbol @");
890 gdb_print_host_address (exp
->elts
[elt
+ 1].symbol
, stream
);
891 fprintf_filtered (stream
, " (%s)",
892 SYMBOL_NAME (exp
->elts
[elt
+ 1].symbol
));
896 fprintf_filtered (stream
, "History element %ld",
897 (long) exp
->elts
[elt
].longconst
);
901 fprintf_filtered (stream
, "Register %ld",
902 (long) exp
->elts
[elt
].longconst
);
906 fprintf_filtered (stream
, "Internal var @");
907 gdb_print_host_address (exp
->elts
[elt
].internalvar
, stream
);
908 fprintf_filtered (stream
, " (%s)",
909 exp
->elts
[elt
].internalvar
->name
);
916 nargs
= longest_to_int (exp
->elts
[elt
].longconst
);
918 fprintf_filtered (stream
, "Number of args: %d", nargs
);
921 for (i
= 1; i
<= nargs
+ 1; i
++)
922 elt
= dump_subexp (exp
, stream
, elt
);
930 lower
= longest_to_int (exp
->elts
[elt
].longconst
);
931 upper
= longest_to_int (exp
->elts
[elt
+ 1].longconst
);
933 fprintf_filtered (stream
, "Bounds [%d:%d]", lower
, upper
);
936 for (i
= 1; i
<= upper
- lower
+ 1; i
++)
937 elt
= dump_subexp (exp
, stream
, elt
);
942 fprintf_filtered (stream
, "Type @");
943 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
944 fprintf_filtered (stream
, " (");
945 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
946 fprintf_filtered (stream
, ")");
947 elt
= dump_subexp (exp
, stream
, elt
+ 2);
950 fprintf_filtered (stream
, "Type @");
951 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
952 fprintf_filtered (stream
, " (");
953 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
954 fprintf_filtered (stream
, ")");
957 case STRUCTOP_STRUCT
:
963 len
= longest_to_int (exp
->elts
[elt
].longconst
);
964 elem_name
= &exp
->elts
[elt
+ 1].string
;
966 fprintf_filtered (stream
, "Element name: `%.*s'", len
, elem_name
);
967 elt
= dump_subexp (exp
, stream
, elt
+ 3 + BYTES_TO_EXP_ELEM (len
+ 1));
975 fprintf_filtered (stream
, "Type @");
976 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
977 fprintf_filtered (stream
, " (");
978 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
979 fprintf_filtered (stream
, ") ");
981 len
= longest_to_int (exp
->elts
[elt
+ 1].longconst
);
982 elem_name
= &exp
->elts
[elt
+ 2].string
;
984 fprintf_filtered (stream
, "Field name: `%.*s'", len
, elem_name
);
985 elt
+= 4 + BYTES_TO_EXP_ELEM (len
+ 1);
990 case STRUCTOP_MEMBER
:
992 case MULTI_SUBSCRIPT
:
993 case OP_F77_UNDETERMINED_ARGLIST
:
1003 fprintf_filtered (stream
, "Unknown format");
1012 dump_postfix_expression (struct expression
*exp
, struct ui_file
*stream
,
1017 fprintf_filtered (stream
, "Dump of expression @ ");
1018 gdb_print_host_address (exp
, stream
);
1019 fprintf_filtered (stream
, ", %s:\nExpression: `", note
);
1020 if (exp
->elts
[0].opcode
!= OP_TYPE
)
1021 print_expression (exp
, stream
);
1023 fputs_filtered ("Type printing not yet supported....", stream
);
1024 fprintf_filtered (stream
, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",
1025 exp
->language_defn
->la_name
, exp
->nelts
,
1026 (long) sizeof (union exp_element
));
1027 fputs_filtered ("\n", stream
);
1029 for (elt
= 0; elt
< exp
->nelts
;)
1030 elt
= dump_subexp (exp
, stream
, elt
);
1031 fputs_filtered ("\n", stream
);