1 /* Print in infix form a struct expression.
3 Copyright (C) 1986, 1988-1989, 1991-2000, 2003, 2007-2012 Free
4 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"
41 print_expression (struct expression
*exp
, struct ui_file
*stream
)
45 print_subexp (exp
, &pc
, stream
, PREC_NULL
);
48 /* Print the subexpression of EXP that starts in position POS, on STREAM.
49 PREC is the precedence of the surrounding operator;
50 if the precedence of the main operator of this subexpression is less,
51 parentheses are needed here. */
54 print_subexp (struct expression
*exp
, int *pos
,
55 struct ui_file
*stream
, enum precedence prec
)
57 exp
->language_defn
->la_exp_desc
->print_subexp (exp
, pos
, stream
, prec
);
60 /* Standard implementation of print_subexp for use in language_defn
63 print_subexp_standard (struct expression
*exp
, int *pos
,
64 struct ui_file
*stream
, enum precedence prec
)
67 const struct op_print
*op_print_tab
;
71 int assign_modify
= 0;
72 enum exp_opcode opcode
;
73 enum precedence myprec
= PREC_NULL
;
74 /* Set to 1 for a right-associative operator. */
79 op_print_tab
= exp
->language_defn
->la_op_print_tab
;
81 opcode
= exp
->elts
[pc
].opcode
;
88 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
94 fputs_filtered (type_name_no_tag (exp
->elts
[pc
+ 1].type
), stream
);
95 fputs_filtered ("::", stream
);
96 nargs
= longest_to_int (exp
->elts
[pc
+ 2].longconst
);
97 (*pos
) += 4 + BYTES_TO_EXP_ELEM (nargs
+ 1);
98 fputs_filtered (&exp
->elts
[pc
+ 3].string
, stream
);
103 struct value_print_options opts
;
105 get_raw_print_options (&opts
);
107 value_print (value_from_longest (exp
->elts
[pc
+ 1].type
,
108 exp
->elts
[pc
+ 2].longconst
),
115 struct value_print_options opts
;
117 get_raw_print_options (&opts
);
119 value_print (value_from_double (exp
->elts
[pc
+ 1].type
,
120 exp
->elts
[pc
+ 2].doubleconst
),
130 b
= exp
->elts
[pc
+ 1].block
;
132 && BLOCK_FUNCTION (b
) != NULL
133 && SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b
)) != NULL
)
135 fputs_filtered (SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b
)), stream
);
136 fputs_filtered ("::", stream
);
138 fputs_filtered (SYMBOL_PRINT_NAME (exp
->elts
[pc
+ 2].symbol
), stream
);
142 case OP_VAR_ENTRY_VALUE
:
145 fprintf_filtered (stream
, "%s@entry",
146 SYMBOL_PRINT_NAME (exp
->elts
[pc
+ 1].symbol
));
152 fprintf_filtered (stream
, "$%d",
153 longest_to_int (exp
->elts
[pc
+ 1].longconst
));
158 const char *name
= &exp
->elts
[pc
+ 2].string
;
160 (*pos
) += 3 + BYTES_TO_EXP_ELEM (exp
->elts
[pc
+ 1].longconst
+ 1);
161 fprintf_filtered (stream
, "$%s", name
);
167 fprintf_filtered (stream
, "%s",
168 longest_to_int (exp
->elts
[pc
+ 1].longconst
)
174 fprintf_filtered (stream
, "$%s",
175 internalvar_name (exp
->elts
[pc
+ 1].internalvar
));
180 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
181 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
182 fputs_filtered (" (", stream
);
183 for (tem
= 0; tem
< nargs
; tem
++)
186 fputs_filtered (", ", stream
);
187 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
189 fputs_filtered (")", stream
);
193 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
194 (*pos
) += 3 + BYTES_TO_EXP_ELEM (nargs
+ 1);
195 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
200 struct value_print_options opts
;
202 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
203 (*pos
) += 3 + BYTES_TO_EXP_ELEM (nargs
+ 1);
204 /* LA_PRINT_STRING will print using the current repeat count threshold.
205 If necessary, we can temporarily set it to zero, or pass it as an
206 additional parameter to LA_PRINT_STRING. -fnf */
207 get_user_print_options (&opts
);
208 LA_PRINT_STRING (stream
, builtin_type (exp
->gdbarch
)->builtin_char
,
209 &exp
->elts
[pc
+ 2].string
, nargs
, NULL
, 0, &opts
);
213 case OP_OBJC_NSSTRING
: /* Objective-C Foundation Class
214 NSString constant. */
216 struct value_print_options opts
;
218 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
219 (*pos
) += 3 + BYTES_TO_EXP_ELEM (nargs
+ 1);
220 fputs_filtered ("@\"", stream
);
221 get_user_print_options (&opts
);
222 LA_PRINT_STRING (stream
, builtin_type (exp
->gdbarch
)->builtin_char
,
223 &exp
->elts
[pc
+ 2].string
, nargs
, NULL
, 0, &opts
);
224 fputs_filtered ("\"", stream
);
228 case OP_OBJC_MSGCALL
:
229 { /* Objective C message (method) call. */
233 nargs
= longest_to_int (exp
->elts
[pc
+ 2].longconst
);
234 fprintf_unfiltered (stream
, "[");
235 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
236 if (0 == target_read_string (exp
->elts
[pc
+ 1].longconst
,
237 &selector
, 1024, NULL
))
239 error (_("bad selector"));
246 s
= alloca (strlen (selector
) + 1);
247 strcpy (s
, selector
);
248 for (tem
= 0; tem
< nargs
; tem
++)
250 nextS
= strchr (s
, ':');
251 gdb_assert (nextS
); /* Make sure we found ':'. */
253 fprintf_unfiltered (stream
, " %s: ", s
);
255 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
260 fprintf_unfiltered (stream
, " %s", selector
);
262 fprintf_unfiltered (stream
, "]");
263 /* "selector" was malloc'd by target_read_string. Free it. */
270 nargs
= longest_to_int (exp
->elts
[pc
+ 2].longconst
);
271 nargs
-= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
274 if (exp
->elts
[pc
+ 4].opcode
== OP_LONG
275 && exp
->elts
[pc
+ 5].type
276 == builtin_type (exp
->gdbarch
)->builtin_char
277 && exp
->language_defn
->la_language
== language_c
)
279 /* Attempt to print C character arrays using string syntax.
280 Walk through the args, picking up one character from each
281 of the OP_LONG expression elements. If any array element
282 does not match our expection of what we should find for
283 a simple string, revert back to array printing. Note that
284 the last expression element is an explicit null terminator
285 byte, which doesn't get printed. */
286 tempstr
= alloca (nargs
);
290 if (exp
->elts
[pc
].opcode
!= OP_LONG
291 || exp
->elts
[pc
+ 1].type
292 != builtin_type (exp
->gdbarch
)->builtin_char
)
294 /* Not a simple array of char, use regular array
302 longest_to_int (exp
->elts
[pc
+ 2].longconst
);
309 struct value_print_options opts
;
311 get_user_print_options (&opts
);
312 LA_PRINT_STRING (stream
, builtin_type (exp
->gdbarch
)->builtin_char
,
313 tempstr
, nargs
- 1, NULL
, 0, &opts
);
318 fputs_filtered (" {", stream
);
319 for (tem
= 0; tem
< nargs
; tem
++)
323 fputs_filtered (", ", stream
);
325 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
327 fputs_filtered ("}", stream
);
332 if ((int) prec
> (int) PREC_COMMA
)
333 fputs_filtered ("(", stream
);
334 /* Print the subexpressions, forcing parentheses
335 around any binary operations within them.
336 This is more parentheses than are strictly necessary,
337 but it looks clearer. */
338 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
339 fputs_filtered (" ? ", stream
);
340 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
341 fputs_filtered (" : ", stream
);
342 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
343 if ((int) prec
> (int) PREC_COMMA
)
344 fputs_filtered (")", stream
);
348 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
349 fputs_filtered ("(", stream
);
350 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
351 fputs_filtered (opcode
== TERNOP_SLICE
? " : " : " UP ", stream
);
352 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
353 fputs_filtered (")", stream
);
356 case STRUCTOP_STRUCT
:
357 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
358 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
359 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
360 fputs_filtered (".", stream
);
361 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
364 /* Will not occur for Modula-2. */
366 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
367 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
368 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
369 fputs_filtered ("->", stream
);
370 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
373 case STRUCTOP_MEMBER
:
374 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
375 fputs_filtered (".*", stream
);
376 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
380 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
381 fputs_filtered ("->*", stream
);
382 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
385 case BINOP_SUBSCRIPT
:
386 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
387 fputs_filtered ("[", stream
);
388 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
389 fputs_filtered ("]", stream
);
392 case UNOP_POSTINCREMENT
:
393 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
394 fputs_filtered ("++", stream
);
397 case UNOP_POSTDECREMENT
:
398 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
399 fputs_filtered ("--", stream
);
404 if ((int) prec
> (int) PREC_PREFIX
)
405 fputs_filtered ("(", stream
);
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
);
410 if ((int) prec
> (int) PREC_PREFIX
)
411 fputs_filtered (")", stream
);
415 if ((int) prec
> (int) PREC_PREFIX
)
416 fputs_filtered ("(", stream
);
417 fputs_filtered ("(", stream
);
418 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
419 fputs_filtered (") ", stream
);
420 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
421 if ((int) prec
> (int) PREC_PREFIX
)
422 fputs_filtered (")", stream
);
425 case UNOP_DYNAMIC_CAST
:
426 case UNOP_REINTERPRET_CAST
:
427 fputs_filtered (opcode
== UNOP_DYNAMIC_CAST
? "dynamic_cast"
428 : "reinterpret_cast", stream
);
429 fputs_filtered ("<", stream
);
430 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
431 fputs_filtered ("> (", stream
);
432 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
433 fputs_filtered (")", stream
);
438 if ((int) prec
> (int) PREC_PREFIX
)
439 fputs_filtered ("(", stream
);
440 if (TYPE_CODE (exp
->elts
[pc
+ 1].type
) == TYPE_CODE_FUNC
441 && exp
->elts
[pc
+ 3].opcode
== OP_LONG
)
443 struct value_print_options opts
;
445 /* We have a minimal symbol fn, probably. It's encoded
446 as a UNOP_MEMVAL (function-type) of an OP_LONG (int, address).
447 Swallow the OP_LONG (including both its opcodes); ignore
448 its type; print the value in the type of the MEMVAL. */
450 val
= value_at_lazy (exp
->elts
[pc
+ 1].type
,
451 (CORE_ADDR
) exp
->elts
[pc
+ 5].longconst
);
452 get_raw_print_options (&opts
);
453 value_print (val
, stream
, &opts
);
457 fputs_filtered ("{", stream
);
458 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
459 fputs_filtered ("} ", stream
);
460 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
462 if ((int) prec
> (int) PREC_PREFIX
)
463 fputs_filtered (")", stream
);
466 case UNOP_MEMVAL_TYPE
:
467 if ((int) prec
> (int) PREC_PREFIX
)
468 fputs_filtered ("(", stream
);
469 fputs_filtered ("{", stream
);
470 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
471 fputs_filtered ("} ", stream
);
472 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
473 if ((int) prec
> (int) PREC_PREFIX
)
474 fputs_filtered (")", stream
);
477 case UNOP_MEMVAL_TLS
:
479 if ((int) prec
> (int) PREC_PREFIX
)
480 fputs_filtered ("(", stream
);
481 fputs_filtered ("{", stream
);
482 type_print (exp
->elts
[pc
+ 2].type
, "", stream
, 0);
483 fputs_filtered ("} ", stream
);
484 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
485 if ((int) prec
> (int) PREC_PREFIX
)
486 fputs_filtered (")", stream
);
489 case BINOP_ASSIGN_MODIFY
:
490 opcode
= exp
->elts
[pc
+ 1].opcode
;
492 myprec
= PREC_ASSIGN
;
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
;
502 if (op_print_tab
[tem
].opcode
!= opcode
)
503 /* Not found; don't try to keep going because we don't know how
504 to interpret further elements. */
505 error (_("Invalid expression"));
512 if (exp
->language_defn
->la_name_of_this
)
513 fputs_filtered (exp
->language_defn
->la_name_of_this
, stream
);
515 fprintf_filtered (stream
, _("<language %s has no 'this'>"),
516 exp
->language_defn
->la_name
);
521 case MULTI_SUBSCRIPT
:
523 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
524 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
525 fprintf_unfiltered (stream
, " [");
526 for (tem
= 0; tem
< nargs
; tem
++)
529 fprintf_unfiltered (stream
, ", ");
530 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
532 fprintf_unfiltered (stream
, "]");
537 fprintf_unfiltered (stream
, "VAL(");
538 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
539 fprintf_unfiltered (stream
, ",");
540 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
541 fprintf_unfiltered (stream
, ")");
546 LONGEST count
= exp
->elts
[pc
+ 1].longconst
;
550 fputs_unfiltered ("TypesInstance(", stream
);
553 type_print (exp
->elts
[(*pos
)++].type
, "", stream
, 0);
555 fputs_unfiltered (",", stream
);
557 fputs_unfiltered (",", stream
);
558 /* Ending COUNT and ending TYPE_INSTANCE. */
560 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
561 fputs_unfiltered (")", stream
);
569 for (tem
= 0; op_print_tab
[tem
].opcode
!= OP_NULL
; tem
++)
570 if (op_print_tab
[tem
].opcode
== opcode
)
572 op_str
= op_print_tab
[tem
].string
;
573 myprec
= op_print_tab
[tem
].precedence
;
574 assoc
= op_print_tab
[tem
].right_assoc
;
577 if (op_print_tab
[tem
].opcode
!= opcode
)
578 /* Not found; don't try to keep going because we don't know how
579 to interpret further elements. For example, this happens
580 if opcode is OP_TYPE. */
581 error (_("Invalid expression"));
584 /* Note that PREC_BUILTIN will always emit parentheses. */
585 if ((int) myprec
< (int) prec
)
586 fputs_filtered ("(", stream
);
587 if ((int) opcode
> (int) BINOP_END
)
591 /* Unary postfix operator. */
592 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
593 fputs_filtered (op_str
, stream
);
597 /* Unary prefix operator. */
598 fputs_filtered (op_str
, stream
);
599 if (myprec
== PREC_BUILTIN_FUNCTION
)
600 fputs_filtered ("(", stream
);
601 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
602 if (myprec
== PREC_BUILTIN_FUNCTION
)
603 fputs_filtered (")", stream
);
608 /* Binary operator. */
609 /* Print left operand.
610 If operator is right-associative,
611 increment precedence for this operand. */
612 print_subexp (exp
, pos
, stream
,
613 (enum precedence
) ((int) myprec
+ assoc
));
614 /* Print the operator itself. */
616 fprintf_filtered (stream
, " %s= ", op_str
);
617 else if (op_str
[0] == ',')
618 fprintf_filtered (stream
, "%s ", op_str
);
620 fprintf_filtered (stream
, " %s ", op_str
);
621 /* Print right operand.
622 If operator is left-associative,
623 increment precedence for this operand. */
624 print_subexp (exp
, pos
, stream
,
625 (enum precedence
) ((int) myprec
+ !assoc
));
628 if ((int) myprec
< (int) prec
)
629 fputs_filtered (")", stream
);
632 /* Return the operator corresponding to opcode OP as
633 a string. NULL indicates that the opcode was not found in the
634 current language table. */
636 op_string (enum exp_opcode op
)
639 const struct op_print
*op_print_tab
;
641 op_print_tab
= current_language
->la_op_print_tab
;
642 for (tem
= 0; op_print_tab
[tem
].opcode
!= OP_NULL
; tem
++)
643 if (op_print_tab
[tem
].opcode
== op
)
644 return op_print_tab
[tem
].string
;
648 /* Support for dumping the raw data from expressions in a human readable
651 static int dump_subexp_body (struct expression
*exp
, struct ui_file
*, int);
653 /* Name for OPCODE, when it appears in expression EXP. */
656 op_name (struct expression
*exp
, enum exp_opcode opcode
)
658 return exp
->language_defn
->la_exp_desc
->op_name (opcode
);
661 /* Default name for the standard operator OPCODE (i.e., one defined in
662 the definition of enum exp_opcode). */
665 op_name_standard (enum exp_opcode opcode
)
673 sprintf (buf
, "<unknown %d>", opcode
);
679 #include "std-operator.def"
684 /* Print a raw dump of expression EXP to STREAM.
685 NOTE, if non-NULL, is printed as extra explanatory text. */
688 dump_raw_expression (struct expression
*exp
, struct ui_file
*stream
,
696 fprintf_filtered (stream
, "Dump of expression @ ");
697 gdb_print_host_address (exp
, stream
);
699 fprintf_filtered (stream
, ", %s:", note
);
700 fprintf_filtered (stream
, "\n\tLanguage %s, %d elements, %ld bytes each.\n",
701 exp
->language_defn
->la_name
, exp
->nelts
,
702 (long) sizeof (union exp_element
));
703 fprintf_filtered (stream
, "\t%5s %20s %16s %s\n", "Index", "Opcode",
704 "Hex Value", "String Value");
705 for (elt
= 0; elt
< exp
->nelts
; elt
++)
707 fprintf_filtered (stream
, "\t%5d ", elt
);
708 opcode_name
= op_name (exp
, exp
->elts
[elt
].opcode
);
710 fprintf_filtered (stream
, "%20s ", opcode_name
);
711 print_longest (stream
, 'd', 0, exp
->elts
[elt
].longconst
);
712 fprintf_filtered (stream
, " ");
714 for (eltscan
= (char *) &exp
->elts
[elt
],
715 eltsize
= sizeof (union exp_element
);
719 fprintf_filtered (stream
, "%c",
720 isprint (*eltscan
) ? (*eltscan
& 0xFF) : '.');
722 fprintf_filtered (stream
, "\n");
726 /* Dump the subexpression of prefix expression EXP whose operator is at
727 position ELT onto STREAM. Returns the position of the next
728 subexpression in EXP. */
731 dump_subexp (struct expression
*exp
, struct ui_file
*stream
, int elt
)
733 static int indent
= 0;
736 fprintf_filtered (stream
, "\n");
737 fprintf_filtered (stream
, "\t%5d ", elt
);
739 for (i
= 1; i
<= indent
; i
++)
740 fprintf_filtered (stream
, " ");
743 fprintf_filtered (stream
, "%-20s ", op_name (exp
, exp
->elts
[elt
].opcode
));
745 elt
= dump_subexp_body (exp
, stream
, elt
);
752 /* Dump the operands of prefix expression EXP whose opcode is at
753 position ELT onto STREAM. Returns the position of the next
754 subexpression in EXP. */
757 dump_subexp_body (struct expression
*exp
, struct ui_file
*stream
, int elt
)
759 return exp
->language_defn
->la_exp_desc
->dump_subexp_body (exp
, stream
, elt
);
762 /* Default value for subexp_body in exp_descriptor vector. */
765 dump_subexp_body_standard (struct expression
*exp
,
766 struct ui_file
*stream
, int elt
)
768 int opcode
= exp
->elts
[elt
++].opcode
;
774 elt
= dump_subexp (exp
, stream
, elt
);
784 case BINOP_LOGICAL_AND
:
785 case BINOP_LOGICAL_OR
:
786 case BINOP_BITWISE_AND
:
787 case BINOP_BITWISE_IOR
:
788 case BINOP_BITWISE_XOR
:
798 case BINOP_SUBSCRIPT
:
803 case BINOP_ASSIGN_MODIFY
:
809 case STRUCTOP_MEMBER
:
811 elt
= dump_subexp (exp
, stream
, elt
);
814 case UNOP_LOGICAL_NOT
:
815 case UNOP_COMPLEMENT
:
818 case UNOP_PREINCREMENT
:
819 case UNOP_POSTINCREMENT
:
820 case UNOP_PREDECREMENT
:
821 case UNOP_POSTDECREMENT
:
834 elt
= dump_subexp (exp
, stream
, elt
);
837 fprintf_filtered (stream
, "Type @");
838 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
839 fprintf_filtered (stream
, " (");
840 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
841 fprintf_filtered (stream
, "), value %ld (0x%lx)",
842 (long) exp
->elts
[elt
+ 1].longconst
,
843 (long) exp
->elts
[elt
+ 1].longconst
);
847 fprintf_filtered (stream
, "Type @");
848 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
849 fprintf_filtered (stream
, " (");
850 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
851 fprintf_filtered (stream
, "), value %g",
852 (double) exp
->elts
[elt
+ 1].doubleconst
);
856 fprintf_filtered (stream
, "Block @");
857 gdb_print_host_address (exp
->elts
[elt
].block
, stream
);
858 fprintf_filtered (stream
, ", symbol @");
859 gdb_print_host_address (exp
->elts
[elt
+ 1].symbol
, stream
);
860 fprintf_filtered (stream
, " (%s)",
861 SYMBOL_PRINT_NAME (exp
->elts
[elt
+ 1].symbol
));
864 case OP_VAR_ENTRY_VALUE
:
865 fprintf_filtered (stream
, "Entry value of symbol @");
866 gdb_print_host_address (exp
->elts
[elt
].symbol
, stream
);
867 fprintf_filtered (stream
, " (%s)",
868 SYMBOL_PRINT_NAME (exp
->elts
[elt
].symbol
));
872 fprintf_filtered (stream
, "History element %ld",
873 (long) exp
->elts
[elt
].longconst
);
877 fprintf_filtered (stream
, "Register $%s", &exp
->elts
[elt
+ 1].string
);
878 elt
+= 3 + BYTES_TO_EXP_ELEM (exp
->elts
[elt
].longconst
+ 1);
881 fprintf_filtered (stream
, "Internal var @");
882 gdb_print_host_address (exp
->elts
[elt
].internalvar
, stream
);
883 fprintf_filtered (stream
, " (%s)",
884 internalvar_name (exp
->elts
[elt
].internalvar
));
891 nargs
= longest_to_int (exp
->elts
[elt
].longconst
);
893 fprintf_filtered (stream
, "Number of args: %d", nargs
);
896 for (i
= 1; i
<= nargs
+ 1; i
++)
897 elt
= dump_subexp (exp
, stream
, elt
);
905 lower
= longest_to_int (exp
->elts
[elt
].longconst
);
906 upper
= longest_to_int (exp
->elts
[elt
+ 1].longconst
);
908 fprintf_filtered (stream
, "Bounds [%d:%d]", lower
, upper
);
911 for (i
= 1; i
<= upper
- lower
+ 1; i
++)
912 elt
= dump_subexp (exp
, stream
, elt
);
915 case UNOP_DYNAMIC_CAST
:
916 case UNOP_REINTERPRET_CAST
:
918 case UNOP_MEMVAL_TYPE
:
919 fprintf_filtered (stream
, " (");
920 elt
= dump_subexp (exp
, stream
, elt
);
921 fprintf_filtered (stream
, ")");
922 elt
= dump_subexp (exp
, stream
, elt
);
926 fprintf_filtered (stream
, "Type @");
927 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
928 fprintf_filtered (stream
, " (");
929 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
930 fprintf_filtered (stream
, ")");
931 elt
= dump_subexp (exp
, stream
, elt
+ 2);
933 case UNOP_MEMVAL_TLS
:
934 fprintf_filtered (stream
, "TLS type @");
935 gdb_print_host_address (exp
->elts
[elt
+ 1].type
, stream
);
936 fprintf_filtered (stream
, " (__thread /* \"%s\" */ ",
937 (exp
->elts
[elt
].objfile
== NULL
? "(null)"
938 : exp
->elts
[elt
].objfile
->name
));
939 type_print (exp
->elts
[elt
+ 1].type
, NULL
, stream
, 0);
940 fprintf_filtered (stream
, ")");
941 elt
= dump_subexp (exp
, stream
, elt
+ 3);
944 fprintf_filtered (stream
, "Type @");
945 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
946 fprintf_filtered (stream
, " (");
947 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
948 fprintf_filtered (stream
, ")");
953 fprintf_filtered (stream
, "Typeof (");
954 elt
= dump_subexp (exp
, stream
, elt
);
955 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);
992 len
= exp
->elts
[elt
++].longconst
;
993 fprintf_filtered (stream
, "%s TypeInstance: ", plongest (len
));
996 fprintf_filtered (stream
, "Type @");
997 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
998 fprintf_filtered (stream
, " (");
999 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
1000 fprintf_filtered (stream
, ")");
1003 fputs_filtered (", ", stream
);
1005 /* Ending LEN and ending TYPE_INSTANCE. */
1007 elt
= dump_subexp (exp
, stream
, elt
);
1012 case MULTI_SUBSCRIPT
:
1013 case OP_F77_UNDETERMINED_ARGLIST
:
1020 fprintf_filtered (stream
, "Unknown format");
1027 dump_prefix_expression (struct expression
*exp
, struct ui_file
*stream
)
1031 fprintf_filtered (stream
, "Dump of expression @ ");
1032 gdb_print_host_address (exp
, stream
);
1033 fputs_filtered (", after conversion to prefix form:\nExpression: `", stream
);
1034 print_expression (exp
, stream
);
1035 fprintf_filtered (stream
, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",
1036 exp
->language_defn
->la_name
, exp
->nelts
,
1037 (long) sizeof (union exp_element
));
1038 fputs_filtered ("\n", stream
);
1040 for (elt
= 0; elt
< exp
->nelts
;)
1041 elt
= dump_subexp (exp
, stream
, elt
);
1042 fputs_filtered ("\n", stream
);