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_VAR_ENTRY_VALUE
:
147 fprintf_filtered (stream
, "%s@entry",
148 SYMBOL_PRINT_NAME (exp
->elts
[pc
+ 1].symbol
));
154 fprintf_filtered (stream
, "$%d",
155 longest_to_int (exp
->elts
[pc
+ 1].longconst
));
160 const char *name
= &exp
->elts
[pc
+ 2].string
;
162 (*pos
) += 3 + BYTES_TO_EXP_ELEM (exp
->elts
[pc
+ 1].longconst
+ 1);
163 fprintf_filtered (stream
, "$%s", name
);
169 fprintf_filtered (stream
, "%s",
170 longest_to_int (exp
->elts
[pc
+ 1].longconst
)
176 fprintf_filtered (stream
, "$%s",
177 internalvar_name (exp
->elts
[pc
+ 1].internalvar
));
182 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
183 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
184 fputs_filtered (" (", stream
);
185 for (tem
= 0; tem
< nargs
; tem
++)
188 fputs_filtered (", ", stream
);
189 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
191 fputs_filtered (")", stream
);
195 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
196 (*pos
) += 3 + BYTES_TO_EXP_ELEM (nargs
+ 1);
197 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
202 struct value_print_options opts
;
204 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
205 (*pos
) += 3 + BYTES_TO_EXP_ELEM (nargs
+ 1);
206 /* LA_PRINT_STRING will print using the current repeat count threshold.
207 If necessary, we can temporarily set it to zero, or pass it as an
208 additional parameter to LA_PRINT_STRING. -fnf */
209 get_user_print_options (&opts
);
210 LA_PRINT_STRING (stream
, builtin_type (exp
->gdbarch
)->builtin_char
,
211 (gdb_byte
*) &exp
->elts
[pc
+ 2].string
, nargs
,
216 case OP_OBJC_NSSTRING
: /* Objective-C Foundation Class
217 NSString constant. */
219 struct value_print_options opts
;
221 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
222 (*pos
) += 3 + BYTES_TO_EXP_ELEM (nargs
+ 1);
223 fputs_filtered ("@\"", stream
);
224 get_user_print_options (&opts
);
225 LA_PRINT_STRING (stream
, builtin_type (exp
->gdbarch
)->builtin_char
,
226 (gdb_byte
*) &exp
->elts
[pc
+ 2].string
, nargs
,
228 fputs_filtered ("\"", stream
);
232 case OP_OBJC_MSGCALL
:
233 { /* Objective C message (method) call. */
237 nargs
= longest_to_int (exp
->elts
[pc
+ 2].longconst
);
238 fprintf_unfiltered (stream
, "[");
239 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
240 if (0 == target_read_string (exp
->elts
[pc
+ 1].longconst
,
241 &selector
, 1024, NULL
))
243 error (_("bad selector"));
250 s
= (char *) alloca (strlen (selector
) + 1);
251 strcpy (s
, selector
);
252 for (tem
= 0; tem
< nargs
; tem
++)
254 nextS
= strchr (s
, ':');
255 gdb_assert (nextS
); /* Make sure we found ':'. */
257 fprintf_unfiltered (stream
, " %s: ", s
);
259 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
264 fprintf_unfiltered (stream
, " %s", selector
);
266 fprintf_unfiltered (stream
, "]");
267 /* "selector" was malloc'd by target_read_string. Free it. */
274 nargs
= longest_to_int (exp
->elts
[pc
+ 2].longconst
);
275 nargs
-= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
278 if (exp
->elts
[pc
+ 4].opcode
== OP_LONG
279 && exp
->elts
[pc
+ 5].type
280 == builtin_type (exp
->gdbarch
)->builtin_char
281 && exp
->language_defn
->la_language
== language_c
)
283 /* Attempt to print C character arrays using string syntax.
284 Walk through the args, picking up one character from each
285 of the OP_LONG expression elements. If any array element
286 does not match our expection of what we should find for
287 a simple string, revert back to array printing. Note that
288 the last expression element is an explicit null terminator
289 byte, which doesn't get printed. */
290 tempstr
= (char *) alloca (nargs
);
294 if (exp
->elts
[pc
].opcode
!= OP_LONG
295 || exp
->elts
[pc
+ 1].type
296 != builtin_type (exp
->gdbarch
)->builtin_char
)
298 /* Not a simple array of char, use regular array
306 longest_to_int (exp
->elts
[pc
+ 2].longconst
);
313 struct value_print_options opts
;
315 get_user_print_options (&opts
);
316 LA_PRINT_STRING (stream
, builtin_type (exp
->gdbarch
)->builtin_char
,
317 (gdb_byte
*) tempstr
, nargs
- 1, NULL
, 0, &opts
);
322 fputs_filtered (" {", stream
);
323 for (tem
= 0; tem
< nargs
; tem
++)
327 fputs_filtered (", ", stream
);
329 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
331 fputs_filtered ("}", stream
);
336 if ((int) prec
> (int) PREC_COMMA
)
337 fputs_filtered ("(", stream
);
338 /* Print the subexpressions, forcing parentheses
339 around any binary operations within them.
340 This is more parentheses than are strictly necessary,
341 but it looks clearer. */
342 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
343 fputs_filtered (" ? ", stream
);
344 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
345 fputs_filtered (" : ", stream
);
346 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
347 if ((int) prec
> (int) PREC_COMMA
)
348 fputs_filtered (")", stream
);
352 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
353 fputs_filtered ("(", stream
);
354 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
355 fputs_filtered (opcode
== TERNOP_SLICE
? " : " : " UP ", stream
);
356 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
357 fputs_filtered (")", stream
);
360 case STRUCTOP_STRUCT
:
361 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
362 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
363 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
364 fputs_filtered (".", stream
);
365 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
368 /* Will not occur for Modula-2. */
370 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
371 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
372 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
373 fputs_filtered ("->", stream
);
374 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
377 case STRUCTOP_MEMBER
:
378 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
379 fputs_filtered (".*", stream
);
380 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
384 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
385 fputs_filtered ("->*", stream
);
386 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
389 case BINOP_SUBSCRIPT
:
390 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
391 fputs_filtered ("[", stream
);
392 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
393 fputs_filtered ("]", stream
);
396 case UNOP_POSTINCREMENT
:
397 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
398 fputs_filtered ("++", stream
);
401 case UNOP_POSTDECREMENT
:
402 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
403 fputs_filtered ("--", stream
);
408 if ((int) prec
> (int) PREC_PREFIX
)
409 fputs_filtered ("(", stream
);
410 fputs_filtered ("(", stream
);
411 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
412 fputs_filtered (") ", stream
);
413 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
414 if ((int) prec
> (int) PREC_PREFIX
)
415 fputs_filtered (")", stream
);
419 if ((int) prec
> (int) PREC_PREFIX
)
420 fputs_filtered ("(", stream
);
421 fputs_filtered ("(", stream
);
422 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
423 fputs_filtered (") ", stream
);
424 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
425 if ((int) prec
> (int) PREC_PREFIX
)
426 fputs_filtered (")", stream
);
429 case UNOP_DYNAMIC_CAST
:
430 case UNOP_REINTERPRET_CAST
:
431 fputs_filtered (opcode
== UNOP_DYNAMIC_CAST
? "dynamic_cast"
432 : "reinterpret_cast", stream
);
433 fputs_filtered ("<", stream
);
434 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
435 fputs_filtered ("> (", stream
);
436 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
437 fputs_filtered (")", stream
);
442 if ((int) prec
> (int) PREC_PREFIX
)
443 fputs_filtered ("(", stream
);
444 if (TYPE_CODE (exp
->elts
[pc
+ 1].type
) == TYPE_CODE_FUNC
445 && exp
->elts
[pc
+ 3].opcode
== OP_LONG
)
447 struct value_print_options opts
;
449 /* We have a minimal symbol fn, probably. It's encoded
450 as a UNOP_MEMVAL (function-type) of an OP_LONG (int, address).
451 Swallow the OP_LONG (including both its opcodes); ignore
452 its type; print the value in the type of the MEMVAL. */
454 val
= value_at_lazy (exp
->elts
[pc
+ 1].type
,
455 (CORE_ADDR
) exp
->elts
[pc
+ 5].longconst
);
456 get_no_prettyformat_print_options (&opts
);
457 value_print (val
, stream
, &opts
);
461 fputs_filtered ("{", stream
);
462 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
463 fputs_filtered ("} ", stream
);
464 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
466 if ((int) prec
> (int) PREC_PREFIX
)
467 fputs_filtered (")", stream
);
470 case UNOP_MEMVAL_TYPE
:
471 if ((int) prec
> (int) PREC_PREFIX
)
472 fputs_filtered ("(", stream
);
473 fputs_filtered ("{", stream
);
474 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
475 fputs_filtered ("} ", stream
);
476 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
477 if ((int) prec
> (int) PREC_PREFIX
)
478 fputs_filtered (")", stream
);
481 case BINOP_ASSIGN_MODIFY
:
482 opcode
= exp
->elts
[pc
+ 1].opcode
;
484 myprec
= PREC_ASSIGN
;
488 for (tem
= 0; op_print_tab
[tem
].opcode
!= OP_NULL
; tem
++)
489 if (op_print_tab
[tem
].opcode
== opcode
)
491 op_str
= op_print_tab
[tem
].string
;
494 if (op_print_tab
[tem
].opcode
!= opcode
)
495 /* Not found; don't try to keep going because we don't know how
496 to interpret further elements. */
497 error (_("Invalid expression"));
504 if (exp
->language_defn
->la_name_of_this
)
505 fputs_filtered (exp
->language_defn
->la_name_of_this
, stream
);
507 fprintf_filtered (stream
, _("<language %s has no 'this'>"),
508 exp
->language_defn
->la_name
);
513 case MULTI_SUBSCRIPT
:
515 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
516 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
517 fprintf_unfiltered (stream
, " [");
518 for (tem
= 0; tem
< nargs
; tem
++)
521 fprintf_unfiltered (stream
, ", ");
522 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
524 fprintf_unfiltered (stream
, "]");
529 fprintf_unfiltered (stream
, "VAL(");
530 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
531 fprintf_unfiltered (stream
, ",");
532 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
533 fprintf_unfiltered (stream
, ")");
538 LONGEST count
= exp
->elts
[pc
+ 1].longconst
;
542 fputs_unfiltered ("TypesInstance(", stream
);
545 type_print (exp
->elts
[(*pos
)++].type
, "", stream
, 0);
547 fputs_unfiltered (",", stream
);
549 fputs_unfiltered (",", stream
);
550 /* Ending COUNT and ending TYPE_INSTANCE. */
552 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
553 fputs_unfiltered (")", stream
);
559 enum range_type range_type
;
561 range_type
= (enum range_type
)
562 longest_to_int (exp
->elts
[pc
+ 1].longconst
);
565 fputs_filtered ("RANGE(", stream
);
566 if (range_type
== HIGH_BOUND_DEFAULT
567 || range_type
== NONE_BOUND_DEFAULT
)
568 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
569 fputs_filtered ("..", stream
);
570 if (range_type
== LOW_BOUND_DEFAULT
571 || range_type
== NONE_BOUND_DEFAULT
)
572 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
573 fputs_filtered (")", stream
);
581 for (tem
= 0; op_print_tab
[tem
].opcode
!= OP_NULL
; tem
++)
582 if (op_print_tab
[tem
].opcode
== opcode
)
584 op_str
= op_print_tab
[tem
].string
;
585 myprec
= op_print_tab
[tem
].precedence
;
586 assoc
= op_print_tab
[tem
].right_assoc
;
589 if (op_print_tab
[tem
].opcode
!= opcode
)
590 /* Not found; don't try to keep going because we don't know how
591 to interpret further elements. For example, this happens
592 if opcode is OP_TYPE. */
593 error (_("Invalid expression"));
596 /* Note that PREC_BUILTIN will always emit parentheses. */
597 if ((int) myprec
< (int) prec
)
598 fputs_filtered ("(", stream
);
599 if ((int) opcode
> (int) BINOP_END
)
603 /* Unary postfix operator. */
604 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
605 fputs_filtered (op_str
, stream
);
609 /* Unary prefix operator. */
610 fputs_filtered (op_str
, stream
);
611 if (myprec
== PREC_BUILTIN_FUNCTION
)
612 fputs_filtered ("(", stream
);
613 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
614 if (myprec
== PREC_BUILTIN_FUNCTION
)
615 fputs_filtered (")", stream
);
620 /* Binary operator. */
621 /* Print left operand.
622 If operator is right-associative,
623 increment precedence for this operand. */
624 print_subexp (exp
, pos
, stream
,
625 (enum precedence
) ((int) myprec
+ assoc
));
626 /* Print the operator itself. */
628 fprintf_filtered (stream
, " %s= ", op_str
);
629 else if (op_str
[0] == ',')
630 fprintf_filtered (stream
, "%s ", op_str
);
632 fprintf_filtered (stream
, " %s ", op_str
);
633 /* Print right operand.
634 If operator is left-associative,
635 increment precedence for this operand. */
636 print_subexp (exp
, pos
, stream
,
637 (enum precedence
) ((int) myprec
+ !assoc
));
640 if ((int) myprec
< (int) prec
)
641 fputs_filtered (")", stream
);
644 /* Return the operator corresponding to opcode OP as
645 a string. NULL indicates that the opcode was not found in the
646 current language table. */
648 op_string (enum exp_opcode op
)
651 const struct op_print
*op_print_tab
;
653 op_print_tab
= current_language
->la_op_print_tab
;
654 for (tem
= 0; op_print_tab
[tem
].opcode
!= OP_NULL
; tem
++)
655 if (op_print_tab
[tem
].opcode
== op
)
656 return op_print_tab
[tem
].string
;
660 /* Support for dumping the raw data from expressions in a human readable
663 static int dump_subexp_body (struct expression
*exp
, struct ui_file
*, int);
665 /* Name for OPCODE, when it appears in expression EXP. */
668 op_name (struct expression
*exp
, enum exp_opcode opcode
)
670 return exp
->language_defn
->la_exp_desc
->op_name (opcode
);
673 /* Default name for the standard operator OPCODE (i.e., one defined in
674 the definition of enum exp_opcode). */
677 op_name_standard (enum exp_opcode opcode
)
685 xsnprintf (buf
, sizeof (buf
), "<unknown %d>", opcode
);
691 #include "std-operator.def"
696 /* Print a raw dump of expression EXP to STREAM.
697 NOTE, if non-NULL, is printed as extra explanatory text. */
700 dump_raw_expression (struct expression
*exp
, struct ui_file
*stream
,
707 fprintf_filtered (stream
, "Dump of expression @ ");
708 gdb_print_host_address (exp
, stream
);
710 fprintf_filtered (stream
, ", %s:", note
);
711 fprintf_filtered (stream
, "\n\tLanguage %s, %d elements, %ld bytes each.\n",
712 exp
->language_defn
->la_name
, exp
->nelts
,
713 (long) sizeof (union exp_element
));
714 fprintf_filtered (stream
, "\t%5s %20s %16s %s\n", "Index", "Opcode",
715 "Hex Value", "String Value");
716 for (elt
= 0; elt
< exp
->nelts
; elt
++)
718 fprintf_filtered (stream
, "\t%5d ", elt
);
720 const char *opcode_name
= op_name (exp
, exp
->elts
[elt
].opcode
);
721 fprintf_filtered (stream
, "%20s ", opcode_name
);
723 print_longest (stream
, 'd', 0, exp
->elts
[elt
].longconst
);
724 fprintf_filtered (stream
, " ");
726 for (eltscan
= (char *) &exp
->elts
[elt
],
727 eltsize
= sizeof (union exp_element
);
731 fprintf_filtered (stream
, "%c",
732 isprint (*eltscan
) ? (*eltscan
& 0xFF) : '.');
734 fprintf_filtered (stream
, "\n");
738 /* Dump the subexpression of prefix expression EXP whose operator is at
739 position ELT onto STREAM. Returns the position of the next
740 subexpression in EXP. */
743 dump_subexp (struct expression
*exp
, struct ui_file
*stream
, int elt
)
745 static int indent
= 0;
748 fprintf_filtered (stream
, "\n");
749 fprintf_filtered (stream
, "\t%5d ", elt
);
751 for (i
= 1; i
<= indent
; i
++)
752 fprintf_filtered (stream
, " ");
755 fprintf_filtered (stream
, "%-20s ", op_name (exp
, exp
->elts
[elt
].opcode
));
757 elt
= dump_subexp_body (exp
, stream
, elt
);
764 /* Dump the operands of prefix expression EXP whose opcode is at
765 position ELT onto STREAM. Returns the position of the next
766 subexpression in EXP. */
769 dump_subexp_body (struct expression
*exp
, struct ui_file
*stream
, int elt
)
771 return exp
->language_defn
->la_exp_desc
->dump_subexp_body (exp
, stream
, elt
);
774 /* Default value for subexp_body in exp_descriptor vector. */
777 dump_subexp_body_standard (struct expression
*exp
,
778 struct ui_file
*stream
, int elt
)
780 int opcode
= exp
->elts
[elt
++].opcode
;
786 elt
= dump_subexp (exp
, stream
, elt
);
796 case BINOP_LOGICAL_AND
:
797 case BINOP_LOGICAL_OR
:
798 case BINOP_BITWISE_AND
:
799 case BINOP_BITWISE_IOR
:
800 case BINOP_BITWISE_XOR
:
810 case BINOP_SUBSCRIPT
:
815 case BINOP_ASSIGN_MODIFY
:
819 case STRUCTOP_MEMBER
:
821 elt
= dump_subexp (exp
, stream
, elt
);
824 case UNOP_LOGICAL_NOT
:
825 case UNOP_COMPLEMENT
:
828 case UNOP_PREINCREMENT
:
829 case UNOP_POSTINCREMENT
:
830 case UNOP_PREDECREMENT
:
831 case UNOP_POSTDECREMENT
:
844 elt
= dump_subexp (exp
, stream
, elt
);
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 %ld (0x%lx)",
852 (long) exp
->elts
[elt
+ 1].longconst
,
853 (long) exp
->elts
[elt
+ 1].longconst
);
857 fprintf_filtered (stream
, "Type @");
858 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
859 fprintf_filtered (stream
, " (");
860 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
861 fprintf_filtered (stream
, "), value %g",
862 (double) exp
->elts
[elt
+ 1].doubleconst
);
866 fprintf_filtered (stream
, "Block @");
867 gdb_print_host_address (exp
->elts
[elt
].block
, stream
);
868 fprintf_filtered (stream
, ", symbol @");
869 gdb_print_host_address (exp
->elts
[elt
+ 1].symbol
, stream
);
870 fprintf_filtered (stream
, " (%s)",
871 SYMBOL_PRINT_NAME (exp
->elts
[elt
+ 1].symbol
));
874 case OP_VAR_MSYM_VALUE
:
875 fprintf_filtered (stream
, "Objfile @");
876 gdb_print_host_address (exp
->elts
[elt
].objfile
, stream
);
877 fprintf_filtered (stream
, ", msymbol @");
878 gdb_print_host_address (exp
->elts
[elt
+ 1].msymbol
, stream
);
879 fprintf_filtered (stream
, " (%s)",
880 MSYMBOL_PRINT_NAME (exp
->elts
[elt
+ 1].msymbol
));
883 case OP_VAR_ENTRY_VALUE
:
884 fprintf_filtered (stream
, "Entry value of symbol @");
885 gdb_print_host_address (exp
->elts
[elt
].symbol
, stream
);
886 fprintf_filtered (stream
, " (%s)",
887 SYMBOL_PRINT_NAME (exp
->elts
[elt
].symbol
));
891 fprintf_filtered (stream
, "History element %ld",
892 (long) exp
->elts
[elt
].longconst
);
896 fprintf_filtered (stream
, "Register $%s", &exp
->elts
[elt
+ 1].string
);
897 elt
+= 3 + BYTES_TO_EXP_ELEM (exp
->elts
[elt
].longconst
+ 1);
900 fprintf_filtered (stream
, "Internal var @");
901 gdb_print_host_address (exp
->elts
[elt
].internalvar
, stream
);
902 fprintf_filtered (stream
, " (%s)",
903 internalvar_name (exp
->elts
[elt
].internalvar
));
910 nargs
= longest_to_int (exp
->elts
[elt
].longconst
);
912 fprintf_filtered (stream
, "Number of args: %d", nargs
);
915 for (i
= 1; i
<= nargs
+ 1; i
++)
916 elt
= dump_subexp (exp
, stream
, elt
);
924 lower
= longest_to_int (exp
->elts
[elt
].longconst
);
925 upper
= longest_to_int (exp
->elts
[elt
+ 1].longconst
);
927 fprintf_filtered (stream
, "Bounds [%d:%d]", lower
, upper
);
930 for (i
= 1; i
<= upper
- lower
+ 1; i
++)
931 elt
= dump_subexp (exp
, stream
, elt
);
934 case UNOP_DYNAMIC_CAST
:
935 case UNOP_REINTERPRET_CAST
:
937 case UNOP_MEMVAL_TYPE
:
938 fprintf_filtered (stream
, " (");
939 elt
= dump_subexp (exp
, stream
, elt
);
940 fprintf_filtered (stream
, ")");
941 elt
= dump_subexp (exp
, stream
, elt
);
945 fprintf_filtered (stream
, "Type @");
946 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
947 fprintf_filtered (stream
, " (");
948 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
949 fprintf_filtered (stream
, ")");
950 elt
= dump_subexp (exp
, stream
, elt
+ 2);
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
, ")");
962 fprintf_filtered (stream
, "Typeof (");
963 elt
= dump_subexp (exp
, stream
, elt
);
964 fprintf_filtered (stream
, ")");
967 fprintf_filtered (stream
, "typeid (");
968 elt
= dump_subexp (exp
, stream
, elt
);
969 fprintf_filtered (stream
, ")");
971 case STRUCTOP_STRUCT
:
977 len
= longest_to_int (exp
->elts
[elt
].longconst
);
978 elem_name
= &exp
->elts
[elt
+ 1].string
;
980 fprintf_filtered (stream
, "Element name: `%.*s'", len
, elem_name
);
981 elt
= dump_subexp (exp
, stream
, elt
+ 3 + BYTES_TO_EXP_ELEM (len
+ 1));
989 fprintf_filtered (stream
, "Type @");
990 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
991 fprintf_filtered (stream
, " (");
992 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
993 fprintf_filtered (stream
, ") ");
995 len
= longest_to_int (exp
->elts
[elt
+ 1].longconst
);
996 elem_name
= &exp
->elts
[elt
+ 2].string
;
998 fprintf_filtered (stream
, "Field name: `%.*s'", len
, elem_name
);
999 elt
+= 4 + BYTES_TO_EXP_ELEM (len
+ 1);
1006 len
= exp
->elts
[elt
++].longconst
;
1007 fprintf_filtered (stream
, "%s TypeInstance: ", plongest (len
));
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
, ")");
1017 fputs_filtered (", ", stream
);
1019 /* Ending LEN and ending TYPE_INSTANCE. */
1021 elt
= dump_subexp (exp
, stream
, elt
);
1026 LONGEST len
= exp
->elts
[elt
].longconst
;
1027 LONGEST type
= exp
->elts
[elt
+ 1].longconst
;
1029 fprintf_filtered (stream
, "Language-specific string type: %s",
1035 /* Skip string content. */
1036 elt
+= BYTES_TO_EXP_ELEM (len
);
1038 /* Skip length and ending OP_STRING. */
1044 enum range_type range_type
;
1046 range_type
= (enum range_type
)
1047 longest_to_int (exp
->elts
[elt
].longconst
);
1052 case BOTH_BOUND_DEFAULT
:
1053 fputs_filtered ("Range '..'", stream
);
1055 case LOW_BOUND_DEFAULT
:
1056 fputs_filtered ("Range '..EXP'", stream
);
1058 case HIGH_BOUND_DEFAULT
:
1059 fputs_filtered ("Range 'EXP..'", stream
);
1061 case NONE_BOUND_DEFAULT
:
1062 fputs_filtered ("Range 'EXP..EXP'", stream
);
1065 fputs_filtered ("Invalid Range!", stream
);
1069 if (range_type
== HIGH_BOUND_DEFAULT
1070 || range_type
== NONE_BOUND_DEFAULT
)
1071 elt
= dump_subexp (exp
, stream
, elt
);
1072 if (range_type
== LOW_BOUND_DEFAULT
1073 || range_type
== NONE_BOUND_DEFAULT
)
1074 elt
= dump_subexp (exp
, stream
, elt
);
1080 case MULTI_SUBSCRIPT
:
1081 case OP_F77_UNDETERMINED_ARGLIST
:
1087 fprintf_filtered (stream
, "Unknown format");
1094 dump_prefix_expression (struct expression
*exp
, struct ui_file
*stream
)
1098 fprintf_filtered (stream
, "Dump of expression @ ");
1099 gdb_print_host_address (exp
, stream
);
1100 fputs_filtered (", after conversion to prefix form:\nExpression: `", stream
);
1101 print_expression (exp
, stream
);
1102 fprintf_filtered (stream
, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",
1103 exp
->language_defn
->la_name
, exp
->nelts
,
1104 (long) sizeof (union exp_element
));
1105 fputs_filtered ("\n", stream
);
1107 for (elt
= 0; elt
< exp
->nelts
;)
1108 elt
= dump_subexp (exp
, stream
, elt
);
1109 fputs_filtered ("\n", stream
);