1 /* Print in infix form a struct expression.
3 Copyright (C) 1986-2017 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
23 #include "expression.h"
26 #include "parser-defs.h"
27 #include "user-regs.h" /* For user_reg_map_regnum_to_name. */
36 print_expression (struct expression
*exp
, struct ui_file
*stream
)
40 print_subexp (exp
, &pc
, stream
, PREC_NULL
);
43 /* Print the subexpression of EXP that starts in position POS, on STREAM.
44 PREC is the precedence of the surrounding operator;
45 if the precedence of the main operator of this subexpression is less,
46 parentheses are needed here. */
49 print_subexp (struct expression
*exp
, int *pos
,
50 struct ui_file
*stream
, enum precedence prec
)
52 exp
->language_defn
->la_exp_desc
->print_subexp (exp
, pos
, stream
, prec
);
55 /* Standard implementation of print_subexp for use in language_defn
58 print_subexp_standard (struct expression
*exp
, int *pos
,
59 struct ui_file
*stream
, enum precedence prec
)
62 const struct op_print
*op_print_tab
;
66 int assign_modify
= 0;
67 enum exp_opcode opcode
;
68 enum precedence myprec
= PREC_NULL
;
69 /* Set to 1 for a right-associative operator. */
74 op_print_tab
= exp
->language_defn
->la_op_print_tab
;
76 opcode
= exp
->elts
[pc
].opcode
;
83 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
89 fputs_filtered (type_name_no_tag (exp
->elts
[pc
+ 1].type
), stream
);
90 fputs_filtered ("::", stream
);
91 nargs
= longest_to_int (exp
->elts
[pc
+ 2].longconst
);
92 (*pos
) += 4 + BYTES_TO_EXP_ELEM (nargs
+ 1);
93 fputs_filtered (&exp
->elts
[pc
+ 3].string
, stream
);
98 struct value_print_options opts
;
100 get_no_prettyformat_print_options (&opts
);
102 value_print (value_from_longest (exp
->elts
[pc
+ 1].type
,
103 exp
->elts
[pc
+ 2].longconst
),
110 struct value_print_options opts
;
112 get_no_prettyformat_print_options (&opts
);
114 value_print (value_from_double (exp
->elts
[pc
+ 1].type
,
115 exp
->elts
[pc
+ 2].doubleconst
),
122 const struct block
*b
;
125 b
= exp
->elts
[pc
+ 1].block
;
127 && BLOCK_FUNCTION (b
) != NULL
128 && SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b
)) != NULL
)
130 fputs_filtered (SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b
)), stream
);
131 fputs_filtered ("::", stream
);
133 fputs_filtered (SYMBOL_PRINT_NAME (exp
->elts
[pc
+ 2].symbol
), stream
);
137 case OP_VAR_MSYM_VALUE
:
140 fputs_filtered (MSYMBOL_PRINT_NAME (exp
->elts
[pc
+ 2].msymbol
), stream
);
144 case OP_FUNC_STATIC_VAR
:
146 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
147 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
148 fputs_filtered (&exp
->elts
[pc
+ 1].string
, stream
);
152 case OP_VAR_ENTRY_VALUE
:
155 fprintf_filtered (stream
, "%s@entry",
156 SYMBOL_PRINT_NAME (exp
->elts
[pc
+ 1].symbol
));
162 fprintf_filtered (stream
, "$%d",
163 longest_to_int (exp
->elts
[pc
+ 1].longconst
));
168 const char *name
= &exp
->elts
[pc
+ 2].string
;
170 (*pos
) += 3 + BYTES_TO_EXP_ELEM (exp
->elts
[pc
+ 1].longconst
+ 1);
171 fprintf_filtered (stream
, "$%s", name
);
177 fprintf_filtered (stream
, "%s",
178 longest_to_int (exp
->elts
[pc
+ 1].longconst
)
184 fprintf_filtered (stream
, "$%s",
185 internalvar_name (exp
->elts
[pc
+ 1].internalvar
));
190 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
191 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
192 fputs_filtered (" (", stream
);
193 for (tem
= 0; tem
< nargs
; tem
++)
196 fputs_filtered (", ", stream
);
197 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
199 fputs_filtered (")", stream
);
203 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
204 (*pos
) += 3 + BYTES_TO_EXP_ELEM (nargs
+ 1);
205 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
210 struct value_print_options opts
;
212 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
213 (*pos
) += 3 + BYTES_TO_EXP_ELEM (nargs
+ 1);
214 /* LA_PRINT_STRING will print using the current repeat count threshold.
215 If necessary, we can temporarily set it to zero, or pass it as an
216 additional parameter to LA_PRINT_STRING. -fnf */
217 get_user_print_options (&opts
);
218 LA_PRINT_STRING (stream
, builtin_type (exp
->gdbarch
)->builtin_char
,
219 (gdb_byte
*) &exp
->elts
[pc
+ 2].string
, nargs
,
224 case OP_OBJC_NSSTRING
: /* Objective-C Foundation Class
225 NSString constant. */
227 struct value_print_options opts
;
229 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
230 (*pos
) += 3 + BYTES_TO_EXP_ELEM (nargs
+ 1);
231 fputs_filtered ("@\"", stream
);
232 get_user_print_options (&opts
);
233 LA_PRINT_STRING (stream
, builtin_type (exp
->gdbarch
)->builtin_char
,
234 (gdb_byte
*) &exp
->elts
[pc
+ 2].string
, nargs
,
236 fputs_filtered ("\"", stream
);
240 case OP_OBJC_MSGCALL
:
241 { /* Objective C message (method) call. */
245 nargs
= longest_to_int (exp
->elts
[pc
+ 2].longconst
);
246 fprintf_unfiltered (stream
, "[");
247 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
248 if (0 == target_read_string (exp
->elts
[pc
+ 1].longconst
,
249 &selector
, 1024, NULL
))
251 error (_("bad selector"));
258 s
= (char *) alloca (strlen (selector
) + 1);
259 strcpy (s
, selector
);
260 for (tem
= 0; tem
< nargs
; tem
++)
262 nextS
= strchr (s
, ':');
263 gdb_assert (nextS
); /* Make sure we found ':'. */
265 fprintf_unfiltered (stream
, " %s: ", s
);
267 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
272 fprintf_unfiltered (stream
, " %s", selector
);
274 fprintf_unfiltered (stream
, "]");
275 /* "selector" was malloc'd by target_read_string. Free it. */
282 nargs
= longest_to_int (exp
->elts
[pc
+ 2].longconst
);
283 nargs
-= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
286 if (exp
->elts
[pc
+ 4].opcode
== OP_LONG
287 && exp
->elts
[pc
+ 5].type
288 == builtin_type (exp
->gdbarch
)->builtin_char
289 && exp
->language_defn
->la_language
== language_c
)
291 /* Attempt to print C character arrays using string syntax.
292 Walk through the args, picking up one character from each
293 of the OP_LONG expression elements. If any array element
294 does not match our expection of what we should find for
295 a simple string, revert back to array printing. Note that
296 the last expression element is an explicit null terminator
297 byte, which doesn't get printed. */
298 tempstr
= (char *) alloca (nargs
);
302 if (exp
->elts
[pc
].opcode
!= OP_LONG
303 || exp
->elts
[pc
+ 1].type
304 != builtin_type (exp
->gdbarch
)->builtin_char
)
306 /* Not a simple array of char, use regular array
314 longest_to_int (exp
->elts
[pc
+ 2].longconst
);
321 struct value_print_options opts
;
323 get_user_print_options (&opts
);
324 LA_PRINT_STRING (stream
, builtin_type (exp
->gdbarch
)->builtin_char
,
325 (gdb_byte
*) tempstr
, nargs
- 1, NULL
, 0, &opts
);
330 fputs_filtered (" {", stream
);
331 for (tem
= 0; tem
< nargs
; tem
++)
335 fputs_filtered (", ", stream
);
337 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
339 fputs_filtered ("}", stream
);
344 if ((int) prec
> (int) PREC_COMMA
)
345 fputs_filtered ("(", stream
);
346 /* Print the subexpressions, forcing parentheses
347 around any binary operations within them.
348 This is more parentheses than are strictly necessary,
349 but it looks clearer. */
350 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
351 fputs_filtered (" ? ", stream
);
352 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
353 fputs_filtered (" : ", stream
);
354 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
355 if ((int) prec
> (int) PREC_COMMA
)
356 fputs_filtered (")", stream
);
360 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
361 fputs_filtered ("(", stream
);
362 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
363 fputs_filtered (opcode
== TERNOP_SLICE
? " : " : " UP ", stream
);
364 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
365 fputs_filtered (")", stream
);
368 case STRUCTOP_STRUCT
:
369 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
370 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
371 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
372 fputs_filtered (".", stream
);
373 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
376 /* Will not occur for Modula-2. */
378 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
379 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
380 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
381 fputs_filtered ("->", stream
);
382 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
385 case STRUCTOP_MEMBER
:
386 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
387 fputs_filtered (".*", stream
);
388 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
392 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
393 fputs_filtered ("->*", stream
);
394 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
397 case BINOP_SUBSCRIPT
:
398 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
399 fputs_filtered ("[", stream
);
400 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
401 fputs_filtered ("]", stream
);
404 case UNOP_POSTINCREMENT
:
405 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
406 fputs_filtered ("++", stream
);
409 case UNOP_POSTDECREMENT
:
410 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
411 fputs_filtered ("--", stream
);
416 if ((int) prec
> (int) PREC_PREFIX
)
417 fputs_filtered ("(", stream
);
418 fputs_filtered ("(", stream
);
419 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
420 fputs_filtered (") ", stream
);
421 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
422 if ((int) prec
> (int) PREC_PREFIX
)
423 fputs_filtered (")", stream
);
427 if ((int) prec
> (int) PREC_PREFIX
)
428 fputs_filtered ("(", 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 if ((int) prec
> (int) PREC_PREFIX
)
434 fputs_filtered (")", stream
);
437 case UNOP_DYNAMIC_CAST
:
438 case UNOP_REINTERPRET_CAST
:
439 fputs_filtered (opcode
== UNOP_DYNAMIC_CAST
? "dynamic_cast"
440 : "reinterpret_cast", stream
);
441 fputs_filtered ("<", stream
);
442 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
443 fputs_filtered ("> (", stream
);
444 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
445 fputs_filtered (")", stream
);
450 if ((int) prec
> (int) PREC_PREFIX
)
451 fputs_filtered ("(", stream
);
452 if (TYPE_CODE (exp
->elts
[pc
+ 1].type
) == TYPE_CODE_FUNC
453 && exp
->elts
[pc
+ 3].opcode
== OP_LONG
)
455 struct value_print_options opts
;
457 /* We have a minimal symbol fn, probably. It's encoded
458 as a UNOP_MEMVAL (function-type) of an OP_LONG (int, address).
459 Swallow the OP_LONG (including both its opcodes); ignore
460 its type; print the value in the type of the MEMVAL. */
462 val
= value_at_lazy (exp
->elts
[pc
+ 1].type
,
463 (CORE_ADDR
) exp
->elts
[pc
+ 5].longconst
);
464 get_no_prettyformat_print_options (&opts
);
465 value_print (val
, stream
, &opts
);
469 fputs_filtered ("{", stream
);
470 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
471 fputs_filtered ("} ", stream
);
472 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
474 if ((int) prec
> (int) PREC_PREFIX
)
475 fputs_filtered (")", stream
);
478 case UNOP_MEMVAL_TYPE
:
479 if ((int) prec
> (int) PREC_PREFIX
)
480 fputs_filtered ("(", stream
);
481 fputs_filtered ("{", stream
);
482 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
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
);
567 enum range_type range_type
;
569 range_type
= (enum range_type
)
570 longest_to_int (exp
->elts
[pc
+ 1].longconst
);
573 fputs_filtered ("RANGE(", stream
);
574 if (range_type
== HIGH_BOUND_DEFAULT
575 || range_type
== NONE_BOUND_DEFAULT
)
576 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
577 fputs_filtered ("..", stream
);
578 if (range_type
== LOW_BOUND_DEFAULT
579 || range_type
== NONE_BOUND_DEFAULT
)
580 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
581 fputs_filtered (")", stream
);
589 for (tem
= 0; op_print_tab
[tem
].opcode
!= OP_NULL
; tem
++)
590 if (op_print_tab
[tem
].opcode
== opcode
)
592 op_str
= op_print_tab
[tem
].string
;
593 myprec
= op_print_tab
[tem
].precedence
;
594 assoc
= op_print_tab
[tem
].right_assoc
;
597 if (op_print_tab
[tem
].opcode
!= opcode
)
598 /* Not found; don't try to keep going because we don't know how
599 to interpret further elements. For example, this happens
600 if opcode is OP_TYPE. */
601 error (_("Invalid expression"));
604 /* Note that PREC_BUILTIN will always emit parentheses. */
605 if ((int) myprec
< (int) prec
)
606 fputs_filtered ("(", stream
);
607 if ((int) opcode
> (int) BINOP_END
)
611 /* Unary postfix operator. */
612 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
613 fputs_filtered (op_str
, stream
);
617 /* Unary prefix operator. */
618 fputs_filtered (op_str
, stream
);
619 if (myprec
== PREC_BUILTIN_FUNCTION
)
620 fputs_filtered ("(", stream
);
621 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
622 if (myprec
== PREC_BUILTIN_FUNCTION
)
623 fputs_filtered (")", stream
);
628 /* Binary operator. */
629 /* Print left operand.
630 If operator is right-associative,
631 increment precedence for this operand. */
632 print_subexp (exp
, pos
, stream
,
633 (enum precedence
) ((int) myprec
+ assoc
));
634 /* Print the operator itself. */
636 fprintf_filtered (stream
, " %s= ", op_str
);
637 else if (op_str
[0] == ',')
638 fprintf_filtered (stream
, "%s ", op_str
);
640 fprintf_filtered (stream
, " %s ", op_str
);
641 /* Print right operand.
642 If operator is left-associative,
643 increment precedence for this operand. */
644 print_subexp (exp
, pos
, stream
,
645 (enum precedence
) ((int) myprec
+ !assoc
));
648 if ((int) myprec
< (int) prec
)
649 fputs_filtered (")", stream
);
652 /* Return the operator corresponding to opcode OP as
653 a string. NULL indicates that the opcode was not found in the
654 current language table. */
656 op_string (enum exp_opcode op
)
659 const struct op_print
*op_print_tab
;
661 op_print_tab
= current_language
->la_op_print_tab
;
662 for (tem
= 0; op_print_tab
[tem
].opcode
!= OP_NULL
; tem
++)
663 if (op_print_tab
[tem
].opcode
== op
)
664 return op_print_tab
[tem
].string
;
668 /* Support for dumping the raw data from expressions in a human readable
671 static int dump_subexp_body (struct expression
*exp
, struct ui_file
*, int);
673 /* Name for OPCODE, when it appears in expression EXP. */
676 op_name (struct expression
*exp
, enum exp_opcode opcode
)
678 return exp
->language_defn
->la_exp_desc
->op_name (opcode
);
681 /* Default name for the standard operator OPCODE (i.e., one defined in
682 the definition of enum exp_opcode). */
685 op_name_standard (enum exp_opcode opcode
)
693 xsnprintf (buf
, sizeof (buf
), "<unknown %d>", opcode
);
699 #include "std-operator.def"
704 /* Print a raw dump of expression EXP to STREAM.
705 NOTE, if non-NULL, is printed as extra explanatory text. */
708 dump_raw_expression (struct expression
*exp
, struct ui_file
*stream
,
715 fprintf_filtered (stream
, "Dump of expression @ ");
716 gdb_print_host_address (exp
, stream
);
718 fprintf_filtered (stream
, ", %s:", note
);
719 fprintf_filtered (stream
, "\n\tLanguage %s, %d elements, %ld bytes each.\n",
720 exp
->language_defn
->la_name
, exp
->nelts
,
721 (long) sizeof (union exp_element
));
722 fprintf_filtered (stream
, "\t%5s %20s %16s %s\n", "Index", "Opcode",
723 "Hex Value", "String Value");
724 for (elt
= 0; elt
< exp
->nelts
; elt
++)
726 fprintf_filtered (stream
, "\t%5d ", elt
);
728 const char *opcode_name
= op_name (exp
, exp
->elts
[elt
].opcode
);
729 fprintf_filtered (stream
, "%20s ", opcode_name
);
731 print_longest (stream
, 'd', 0, exp
->elts
[elt
].longconst
);
732 fprintf_filtered (stream
, " ");
734 for (eltscan
= (char *) &exp
->elts
[elt
],
735 eltsize
= sizeof (union exp_element
);
739 fprintf_filtered (stream
, "%c",
740 isprint (*eltscan
) ? (*eltscan
& 0xFF) : '.');
742 fprintf_filtered (stream
, "\n");
746 /* Dump the subexpression of prefix expression EXP whose operator is at
747 position ELT onto STREAM. Returns the position of the next
748 subexpression in EXP. */
751 dump_subexp (struct expression
*exp
, struct ui_file
*stream
, int elt
)
753 static int indent
= 0;
756 fprintf_filtered (stream
, "\n");
757 fprintf_filtered (stream
, "\t%5d ", elt
);
759 for (i
= 1; i
<= indent
; i
++)
760 fprintf_filtered (stream
, " ");
763 fprintf_filtered (stream
, "%-20s ", op_name (exp
, exp
->elts
[elt
].opcode
));
765 elt
= dump_subexp_body (exp
, stream
, elt
);
772 /* Dump the operands of prefix expression EXP whose opcode is at
773 position ELT onto STREAM. Returns the position of the next
774 subexpression in EXP. */
777 dump_subexp_body (struct expression
*exp
, struct ui_file
*stream
, int elt
)
779 return exp
->language_defn
->la_exp_desc
->dump_subexp_body (exp
, stream
, elt
);
782 /* Default value for subexp_body in exp_descriptor vector. */
785 dump_subexp_body_standard (struct expression
*exp
,
786 struct ui_file
*stream
, int elt
)
788 int opcode
= exp
->elts
[elt
++].opcode
;
794 elt
= dump_subexp (exp
, stream
, elt
);
804 case BINOP_LOGICAL_AND
:
805 case BINOP_LOGICAL_OR
:
806 case BINOP_BITWISE_AND
:
807 case BINOP_BITWISE_IOR
:
808 case BINOP_BITWISE_XOR
:
818 case BINOP_SUBSCRIPT
:
823 case BINOP_ASSIGN_MODIFY
:
827 case STRUCTOP_MEMBER
:
829 elt
= dump_subexp (exp
, stream
, elt
);
832 case UNOP_LOGICAL_NOT
:
833 case UNOP_COMPLEMENT
:
836 case UNOP_PREINCREMENT
:
837 case UNOP_POSTINCREMENT
:
838 case UNOP_PREDECREMENT
:
839 case UNOP_POSTDECREMENT
:
852 elt
= dump_subexp (exp
, stream
, elt
);
855 fprintf_filtered (stream
, "Type @");
856 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
857 fprintf_filtered (stream
, " (");
858 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
859 fprintf_filtered (stream
, "), value %ld (0x%lx)",
860 (long) exp
->elts
[elt
+ 1].longconst
,
861 (long) exp
->elts
[elt
+ 1].longconst
);
865 fprintf_filtered (stream
, "Type @");
866 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
867 fprintf_filtered (stream
, " (");
868 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
869 fprintf_filtered (stream
, "), value %g",
870 (double) exp
->elts
[elt
+ 1].doubleconst
);
874 fprintf_filtered (stream
, "Block @");
875 gdb_print_host_address (exp
->elts
[elt
].block
, stream
);
876 fprintf_filtered (stream
, ", symbol @");
877 gdb_print_host_address (exp
->elts
[elt
+ 1].symbol
, stream
);
878 fprintf_filtered (stream
, " (%s)",
879 SYMBOL_PRINT_NAME (exp
->elts
[elt
+ 1].symbol
));
882 case OP_VAR_MSYM_VALUE
:
883 fprintf_filtered (stream
, "Objfile @");
884 gdb_print_host_address (exp
->elts
[elt
].objfile
, stream
);
885 fprintf_filtered (stream
, ", msymbol @");
886 gdb_print_host_address (exp
->elts
[elt
+ 1].msymbol
, stream
);
887 fprintf_filtered (stream
, " (%s)",
888 MSYMBOL_PRINT_NAME (exp
->elts
[elt
+ 1].msymbol
));
891 case OP_VAR_ENTRY_VALUE
:
892 fprintf_filtered (stream
, "Entry value of symbol @");
893 gdb_print_host_address (exp
->elts
[elt
].symbol
, stream
);
894 fprintf_filtered (stream
, " (%s)",
895 SYMBOL_PRINT_NAME (exp
->elts
[elt
].symbol
));
899 fprintf_filtered (stream
, "History element %ld",
900 (long) exp
->elts
[elt
].longconst
);
904 fprintf_filtered (stream
, "Register $%s", &exp
->elts
[elt
+ 1].string
);
905 elt
+= 3 + BYTES_TO_EXP_ELEM (exp
->elts
[elt
].longconst
+ 1);
908 fprintf_filtered (stream
, "Internal var @");
909 gdb_print_host_address (exp
->elts
[elt
].internalvar
, stream
);
910 fprintf_filtered (stream
, " (%s)",
911 internalvar_name (exp
->elts
[elt
].internalvar
));
918 nargs
= longest_to_int (exp
->elts
[elt
].longconst
);
920 fprintf_filtered (stream
, "Number of args: %d", nargs
);
923 for (i
= 1; i
<= nargs
+ 1; i
++)
924 elt
= dump_subexp (exp
, stream
, elt
);
932 lower
= longest_to_int (exp
->elts
[elt
].longconst
);
933 upper
= longest_to_int (exp
->elts
[elt
+ 1].longconst
);
935 fprintf_filtered (stream
, "Bounds [%d:%d]", lower
, upper
);
938 for (i
= 1; i
<= upper
- lower
+ 1; i
++)
939 elt
= dump_subexp (exp
, stream
, elt
);
942 case UNOP_DYNAMIC_CAST
:
943 case UNOP_REINTERPRET_CAST
:
945 case UNOP_MEMVAL_TYPE
:
946 fprintf_filtered (stream
, " (");
947 elt
= dump_subexp (exp
, stream
, elt
);
948 fprintf_filtered (stream
, ")");
949 elt
= dump_subexp (exp
, stream
, elt
);
953 fprintf_filtered (stream
, "Type @");
954 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
955 fprintf_filtered (stream
, " (");
956 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
957 fprintf_filtered (stream
, ")");
958 elt
= dump_subexp (exp
, stream
, elt
+ 2);
961 fprintf_filtered (stream
, "Type @");
962 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
963 fprintf_filtered (stream
, " (");
964 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
965 fprintf_filtered (stream
, ")");
970 fprintf_filtered (stream
, "Typeof (");
971 elt
= dump_subexp (exp
, stream
, elt
);
972 fprintf_filtered (stream
, ")");
975 fprintf_filtered (stream
, "typeid (");
976 elt
= dump_subexp (exp
, stream
, elt
);
977 fprintf_filtered (stream
, ")");
979 case STRUCTOP_STRUCT
:
985 len
= longest_to_int (exp
->elts
[elt
].longconst
);
986 elem_name
= &exp
->elts
[elt
+ 1].string
;
988 fprintf_filtered (stream
, "Element name: `%.*s'", len
, elem_name
);
989 elt
= dump_subexp (exp
, stream
, elt
+ 3 + BYTES_TO_EXP_ELEM (len
+ 1));
997 fprintf_filtered (stream
, "Type @");
998 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
999 fprintf_filtered (stream
, " (");
1000 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
1001 fprintf_filtered (stream
, ") ");
1003 len
= longest_to_int (exp
->elts
[elt
+ 1].longconst
);
1004 elem_name
= &exp
->elts
[elt
+ 2].string
;
1006 fprintf_filtered (stream
, "Field name: `%.*s'", len
, elem_name
);
1007 elt
+= 4 + BYTES_TO_EXP_ELEM (len
+ 1);
1011 case OP_FUNC_STATIC_VAR
:
1013 int len
= longest_to_int (exp
->elts
[elt
].longconst
);
1014 const char *var_name
= &exp
->elts
[elt
+ 1].string
;
1015 fprintf_filtered (stream
, "Field name: `%.*s'", len
, var_name
);
1016 elt
+= 3 + BYTES_TO_EXP_ELEM (len
+ 1);
1024 len
= exp
->elts
[elt
++].longconst
;
1025 fprintf_filtered (stream
, "%s TypeInstance: ", plongest (len
));
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 fputs_filtered (", ", stream
);
1037 /* Ending LEN and ending TYPE_INSTANCE. */
1039 elt
= dump_subexp (exp
, stream
, elt
);
1044 LONGEST len
= exp
->elts
[elt
].longconst
;
1045 LONGEST type
= exp
->elts
[elt
+ 1].longconst
;
1047 fprintf_filtered (stream
, "Language-specific string type: %s",
1053 /* Skip string content. */
1054 elt
+= BYTES_TO_EXP_ELEM (len
);
1056 /* Skip length and ending OP_STRING. */
1062 enum range_type range_type
;
1064 range_type
= (enum range_type
)
1065 longest_to_int (exp
->elts
[elt
].longconst
);
1070 case BOTH_BOUND_DEFAULT
:
1071 fputs_filtered ("Range '..'", stream
);
1073 case LOW_BOUND_DEFAULT
:
1074 fputs_filtered ("Range '..EXP'", stream
);
1076 case HIGH_BOUND_DEFAULT
:
1077 fputs_filtered ("Range 'EXP..'", stream
);
1079 case NONE_BOUND_DEFAULT
:
1080 fputs_filtered ("Range 'EXP..EXP'", stream
);
1083 fputs_filtered ("Invalid Range!", stream
);
1087 if (range_type
== HIGH_BOUND_DEFAULT
1088 || range_type
== NONE_BOUND_DEFAULT
)
1089 elt
= dump_subexp (exp
, stream
, elt
);
1090 if (range_type
== LOW_BOUND_DEFAULT
1091 || range_type
== NONE_BOUND_DEFAULT
)
1092 elt
= dump_subexp (exp
, stream
, elt
);
1098 case MULTI_SUBSCRIPT
:
1099 case OP_F77_UNDETERMINED_ARGLIST
:
1105 fprintf_filtered (stream
, "Unknown format");
1112 dump_prefix_expression (struct expression
*exp
, struct ui_file
*stream
)
1116 fprintf_filtered (stream
, "Dump of expression @ ");
1117 gdb_print_host_address (exp
, stream
);
1118 fputs_filtered (", after conversion to prefix form:\nExpression: `", stream
);
1119 print_expression (exp
, stream
);
1120 fprintf_filtered (stream
, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",
1121 exp
->language_defn
->la_name
, exp
->nelts
,
1122 (long) sizeof (union exp_element
));
1123 fputs_filtered ("\n", stream
);
1125 for (elt
= 0; elt
< exp
->nelts
;)
1126 elt
= dump_subexp (exp
, stream
, elt
);
1127 fputs_filtered ("\n", stream
);