1 /* Print in infix form a struct expression.
3 Copyright (C) 1986-2014 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. */
37 print_expression (struct expression
*exp
, struct ui_file
*stream
)
41 print_subexp (exp
, &pc
, stream
, PREC_NULL
);
44 /* Print the subexpression of EXP that starts in position POS, on STREAM.
45 PREC is the precedence of the surrounding operator;
46 if the precedence of the main operator of this subexpression is less,
47 parentheses are needed here. */
50 print_subexp (struct expression
*exp
, int *pos
,
51 struct ui_file
*stream
, enum precedence prec
)
53 exp
->language_defn
->la_exp_desc
->print_subexp (exp
, pos
, stream
, prec
);
56 /* Standard implementation of print_subexp for use in language_defn
59 print_subexp_standard (struct expression
*exp
, int *pos
,
60 struct ui_file
*stream
, enum precedence prec
)
63 const struct op_print
*op_print_tab
;
67 int assign_modify
= 0;
68 enum exp_opcode opcode
;
69 enum precedence myprec
= PREC_NULL
;
70 /* Set to 1 for a right-associative operator. */
75 op_print_tab
= exp
->language_defn
->la_op_print_tab
;
77 opcode
= exp
->elts
[pc
].opcode
;
84 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
90 fputs_filtered (type_name_no_tag (exp
->elts
[pc
+ 1].type
), stream
);
91 fputs_filtered ("::", stream
);
92 nargs
= longest_to_int (exp
->elts
[pc
+ 2].longconst
);
93 (*pos
) += 4 + BYTES_TO_EXP_ELEM (nargs
+ 1);
94 fputs_filtered (&exp
->elts
[pc
+ 3].string
, stream
);
99 struct value_print_options opts
;
101 get_no_prettyformat_print_options (&opts
);
103 value_print (value_from_longest (exp
->elts
[pc
+ 1].type
,
104 exp
->elts
[pc
+ 2].longconst
),
111 struct value_print_options opts
;
113 get_no_prettyformat_print_options (&opts
);
115 value_print (value_from_double (exp
->elts
[pc
+ 1].type
,
116 exp
->elts
[pc
+ 2].doubleconst
),
123 const struct block
*b
;
126 b
= exp
->elts
[pc
+ 1].block
;
128 && BLOCK_FUNCTION (b
) != NULL
129 && SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b
)) != NULL
)
131 fputs_filtered (SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b
)), stream
);
132 fputs_filtered ("::", stream
);
134 fputs_filtered (SYMBOL_PRINT_NAME (exp
->elts
[pc
+ 2].symbol
), stream
);
138 case OP_VAR_ENTRY_VALUE
:
141 fprintf_filtered (stream
, "%s@entry",
142 SYMBOL_PRINT_NAME (exp
->elts
[pc
+ 1].symbol
));
148 fprintf_filtered (stream
, "$%d",
149 longest_to_int (exp
->elts
[pc
+ 1].longconst
));
154 const char *name
= &exp
->elts
[pc
+ 2].string
;
156 (*pos
) += 3 + BYTES_TO_EXP_ELEM (exp
->elts
[pc
+ 1].longconst
+ 1);
157 fprintf_filtered (stream
, "$%s", name
);
163 fprintf_filtered (stream
, "%s",
164 longest_to_int (exp
->elts
[pc
+ 1].longconst
)
170 fprintf_filtered (stream
, "$%s",
171 internalvar_name (exp
->elts
[pc
+ 1].internalvar
));
176 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
177 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
178 fputs_filtered (" (", stream
);
179 for (tem
= 0; tem
< nargs
; tem
++)
182 fputs_filtered (", ", stream
);
183 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
185 fputs_filtered (")", stream
);
189 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
190 (*pos
) += 3 + BYTES_TO_EXP_ELEM (nargs
+ 1);
191 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
196 struct value_print_options opts
;
198 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
199 (*pos
) += 3 + BYTES_TO_EXP_ELEM (nargs
+ 1);
200 /* LA_PRINT_STRING will print using the current repeat count threshold.
201 If necessary, we can temporarily set it to zero, or pass it as an
202 additional parameter to LA_PRINT_STRING. -fnf */
203 get_user_print_options (&opts
);
204 LA_PRINT_STRING (stream
, builtin_type (exp
->gdbarch
)->builtin_char
,
205 (gdb_byte
*) &exp
->elts
[pc
+ 2].string
, nargs
,
210 case OP_OBJC_NSSTRING
: /* Objective-C Foundation Class
211 NSString constant. */
213 struct value_print_options opts
;
215 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
216 (*pos
) += 3 + BYTES_TO_EXP_ELEM (nargs
+ 1);
217 fputs_filtered ("@\"", stream
);
218 get_user_print_options (&opts
);
219 LA_PRINT_STRING (stream
, builtin_type (exp
->gdbarch
)->builtin_char
,
220 (gdb_byte
*) &exp
->elts
[pc
+ 2].string
, nargs
,
222 fputs_filtered ("\"", stream
);
226 case OP_OBJC_MSGCALL
:
227 { /* Objective C message (method) call. */
231 nargs
= longest_to_int (exp
->elts
[pc
+ 2].longconst
);
232 fprintf_unfiltered (stream
, "[");
233 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
234 if (0 == target_read_string (exp
->elts
[pc
+ 1].longconst
,
235 &selector
, 1024, NULL
))
237 error (_("bad selector"));
244 s
= alloca (strlen (selector
) + 1);
245 strcpy (s
, selector
);
246 for (tem
= 0; tem
< nargs
; tem
++)
248 nextS
= strchr (s
, ':');
249 gdb_assert (nextS
); /* Make sure we found ':'. */
251 fprintf_unfiltered (stream
, " %s: ", s
);
253 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
258 fprintf_unfiltered (stream
, " %s", selector
);
260 fprintf_unfiltered (stream
, "]");
261 /* "selector" was malloc'd by target_read_string. Free it. */
268 nargs
= longest_to_int (exp
->elts
[pc
+ 2].longconst
);
269 nargs
-= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
272 if (exp
->elts
[pc
+ 4].opcode
== OP_LONG
273 && exp
->elts
[pc
+ 5].type
274 == builtin_type (exp
->gdbarch
)->builtin_char
275 && exp
->language_defn
->la_language
== language_c
)
277 /* Attempt to print C character arrays using string syntax.
278 Walk through the args, picking up one character from each
279 of the OP_LONG expression elements. If any array element
280 does not match our expection of what we should find for
281 a simple string, revert back to array printing. Note that
282 the last expression element is an explicit null terminator
283 byte, which doesn't get printed. */
284 tempstr
= alloca (nargs
);
288 if (exp
->elts
[pc
].opcode
!= OP_LONG
289 || exp
->elts
[pc
+ 1].type
290 != builtin_type (exp
->gdbarch
)->builtin_char
)
292 /* Not a simple array of char, use regular array
300 longest_to_int (exp
->elts
[pc
+ 2].longconst
);
307 struct value_print_options opts
;
309 get_user_print_options (&opts
);
310 LA_PRINT_STRING (stream
, builtin_type (exp
->gdbarch
)->builtin_char
,
311 (gdb_byte
*) tempstr
, nargs
- 1, NULL
, 0, &opts
);
316 fputs_filtered (" {", stream
);
317 for (tem
= 0; tem
< nargs
; tem
++)
321 fputs_filtered (", ", stream
);
323 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
325 fputs_filtered ("}", stream
);
330 if ((int) prec
> (int) PREC_COMMA
)
331 fputs_filtered ("(", stream
);
332 /* Print the subexpressions, forcing parentheses
333 around any binary operations within them.
334 This is more parentheses than are strictly necessary,
335 but it looks clearer. */
336 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
337 fputs_filtered (" ? ", stream
);
338 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
339 fputs_filtered (" : ", stream
);
340 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
341 if ((int) prec
> (int) PREC_COMMA
)
342 fputs_filtered (")", stream
);
346 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
347 fputs_filtered ("(", stream
);
348 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
349 fputs_filtered (opcode
== TERNOP_SLICE
? " : " : " UP ", stream
);
350 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
351 fputs_filtered (")", stream
);
354 case STRUCTOP_STRUCT
:
355 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
356 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
357 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
358 fputs_filtered (".", stream
);
359 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
362 /* Will not occur for Modula-2. */
364 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
365 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
366 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
367 fputs_filtered ("->", stream
);
368 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
371 case STRUCTOP_MEMBER
:
372 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
373 fputs_filtered (".*", stream
);
374 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
378 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
379 fputs_filtered ("->*", stream
);
380 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
383 case BINOP_SUBSCRIPT
:
384 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
385 fputs_filtered ("[", stream
);
386 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
387 fputs_filtered ("]", stream
);
390 case UNOP_POSTINCREMENT
:
391 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
392 fputs_filtered ("++", stream
);
395 case UNOP_POSTDECREMENT
:
396 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
397 fputs_filtered ("--", stream
);
402 if ((int) prec
> (int) PREC_PREFIX
)
403 fputs_filtered ("(", stream
);
404 fputs_filtered ("(", stream
);
405 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
406 fputs_filtered (") ", stream
);
407 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
408 if ((int) prec
> (int) PREC_PREFIX
)
409 fputs_filtered (")", stream
);
413 if ((int) prec
> (int) PREC_PREFIX
)
414 fputs_filtered ("(", stream
);
415 fputs_filtered ("(", stream
);
416 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
417 fputs_filtered (") ", stream
);
418 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
419 if ((int) prec
> (int) PREC_PREFIX
)
420 fputs_filtered (")", stream
);
423 case UNOP_DYNAMIC_CAST
:
424 case UNOP_REINTERPRET_CAST
:
425 fputs_filtered (opcode
== UNOP_DYNAMIC_CAST
? "dynamic_cast"
426 : "reinterpret_cast", stream
);
427 fputs_filtered ("<", stream
);
428 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
429 fputs_filtered ("> (", stream
);
430 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
431 fputs_filtered (")", stream
);
436 if ((int) prec
> (int) PREC_PREFIX
)
437 fputs_filtered ("(", stream
);
438 if (TYPE_CODE (exp
->elts
[pc
+ 1].type
) == TYPE_CODE_FUNC
439 && exp
->elts
[pc
+ 3].opcode
== OP_LONG
)
441 struct value_print_options opts
;
443 /* We have a minimal symbol fn, probably. It's encoded
444 as a UNOP_MEMVAL (function-type) of an OP_LONG (int, address).
445 Swallow the OP_LONG (including both its opcodes); ignore
446 its type; print the value in the type of the MEMVAL. */
448 val
= value_at_lazy (exp
->elts
[pc
+ 1].type
,
449 (CORE_ADDR
) exp
->elts
[pc
+ 5].longconst
);
450 get_no_prettyformat_print_options (&opts
);
451 value_print (val
, stream
, &opts
);
455 fputs_filtered ("{", stream
);
456 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
457 fputs_filtered ("} ", stream
);
458 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
460 if ((int) prec
> (int) PREC_PREFIX
)
461 fputs_filtered (")", stream
);
464 case UNOP_MEMVAL_TYPE
:
465 if ((int) prec
> (int) PREC_PREFIX
)
466 fputs_filtered ("(", stream
);
467 fputs_filtered ("{", stream
);
468 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
469 fputs_filtered ("} ", stream
);
470 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
471 if ((int) prec
> (int) PREC_PREFIX
)
472 fputs_filtered (")", stream
);
475 case UNOP_MEMVAL_TLS
:
477 if ((int) prec
> (int) PREC_PREFIX
)
478 fputs_filtered ("(", stream
);
479 fputs_filtered ("{", stream
);
480 type_print (exp
->elts
[pc
+ 2].type
, "", stream
, 0);
481 fputs_filtered ("} ", stream
);
482 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
483 if ((int) prec
> (int) PREC_PREFIX
)
484 fputs_filtered (")", stream
);
487 case BINOP_ASSIGN_MODIFY
:
488 opcode
= exp
->elts
[pc
+ 1].opcode
;
490 myprec
= PREC_ASSIGN
;
494 for (tem
= 0; op_print_tab
[tem
].opcode
!= OP_NULL
; tem
++)
495 if (op_print_tab
[tem
].opcode
== opcode
)
497 op_str
= op_print_tab
[tem
].string
;
500 if (op_print_tab
[tem
].opcode
!= opcode
)
501 /* Not found; don't try to keep going because we don't know how
502 to interpret further elements. */
503 error (_("Invalid expression"));
510 if (exp
->language_defn
->la_name_of_this
)
511 fputs_filtered (exp
->language_defn
->la_name_of_this
, stream
);
513 fprintf_filtered (stream
, _("<language %s has no 'this'>"),
514 exp
->language_defn
->la_name
);
519 case MULTI_SUBSCRIPT
:
521 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
522 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
523 fprintf_unfiltered (stream
, " [");
524 for (tem
= 0; tem
< nargs
; tem
++)
527 fprintf_unfiltered (stream
, ", ");
528 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
530 fprintf_unfiltered (stream
, "]");
535 fprintf_unfiltered (stream
, "VAL(");
536 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
537 fprintf_unfiltered (stream
, ",");
538 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
539 fprintf_unfiltered (stream
, ")");
544 LONGEST count
= exp
->elts
[pc
+ 1].longconst
;
548 fputs_unfiltered ("TypesInstance(", stream
);
551 type_print (exp
->elts
[(*pos
)++].type
, "", stream
, 0);
553 fputs_unfiltered (",", stream
);
555 fputs_unfiltered (",", stream
);
556 /* Ending COUNT and ending TYPE_INSTANCE. */
558 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
559 fputs_unfiltered (")", stream
);
567 for (tem
= 0; op_print_tab
[tem
].opcode
!= OP_NULL
; tem
++)
568 if (op_print_tab
[tem
].opcode
== opcode
)
570 op_str
= op_print_tab
[tem
].string
;
571 myprec
= op_print_tab
[tem
].precedence
;
572 assoc
= op_print_tab
[tem
].right_assoc
;
575 if (op_print_tab
[tem
].opcode
!= opcode
)
576 /* Not found; don't try to keep going because we don't know how
577 to interpret further elements. For example, this happens
578 if opcode is OP_TYPE. */
579 error (_("Invalid expression"));
582 /* Note that PREC_BUILTIN will always emit parentheses. */
583 if ((int) myprec
< (int) prec
)
584 fputs_filtered ("(", stream
);
585 if ((int) opcode
> (int) BINOP_END
)
589 /* Unary postfix operator. */
590 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
591 fputs_filtered (op_str
, stream
);
595 /* Unary prefix operator. */
596 fputs_filtered (op_str
, stream
);
597 if (myprec
== PREC_BUILTIN_FUNCTION
)
598 fputs_filtered ("(", stream
);
599 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
600 if (myprec
== PREC_BUILTIN_FUNCTION
)
601 fputs_filtered (")", stream
);
606 /* Binary operator. */
607 /* Print left operand.
608 If operator is right-associative,
609 increment precedence for this operand. */
610 print_subexp (exp
, pos
, stream
,
611 (enum precedence
) ((int) myprec
+ assoc
));
612 /* Print the operator itself. */
614 fprintf_filtered (stream
, " %s= ", op_str
);
615 else if (op_str
[0] == ',')
616 fprintf_filtered (stream
, "%s ", op_str
);
618 fprintf_filtered (stream
, " %s ", op_str
);
619 /* Print right operand.
620 If operator is left-associative,
621 increment precedence for this operand. */
622 print_subexp (exp
, pos
, stream
,
623 (enum precedence
) ((int) myprec
+ !assoc
));
626 if ((int) myprec
< (int) prec
)
627 fputs_filtered (")", stream
);
630 /* Return the operator corresponding to opcode OP as
631 a string. NULL indicates that the opcode was not found in the
632 current language table. */
634 op_string (enum exp_opcode op
)
637 const struct op_print
*op_print_tab
;
639 op_print_tab
= current_language
->la_op_print_tab
;
640 for (tem
= 0; op_print_tab
[tem
].opcode
!= OP_NULL
; tem
++)
641 if (op_print_tab
[tem
].opcode
== op
)
642 return op_print_tab
[tem
].string
;
646 /* Support for dumping the raw data from expressions in a human readable
649 static int dump_subexp_body (struct expression
*exp
, struct ui_file
*, int);
651 /* Name for OPCODE, when it appears in expression EXP. */
654 op_name (struct expression
*exp
, enum exp_opcode opcode
)
656 return exp
->language_defn
->la_exp_desc
->op_name (opcode
);
659 /* Default name for the standard operator OPCODE (i.e., one defined in
660 the definition of enum exp_opcode). */
663 op_name_standard (enum exp_opcode opcode
)
671 xsnprintf (buf
, sizeof (buf
), "<unknown %d>", opcode
);
677 #include "std-operator.def"
682 /* Print a raw dump of expression EXP to STREAM.
683 NOTE, if non-NULL, is printed as extra explanatory text. */
686 dump_raw_expression (struct expression
*exp
, struct ui_file
*stream
,
694 fprintf_filtered (stream
, "Dump of expression @ ");
695 gdb_print_host_address (exp
, stream
);
697 fprintf_filtered (stream
, ", %s:", note
);
698 fprintf_filtered (stream
, "\n\tLanguage %s, %d elements, %ld bytes each.\n",
699 exp
->language_defn
->la_name
, exp
->nelts
,
700 (long) sizeof (union exp_element
));
701 fprintf_filtered (stream
, "\t%5s %20s %16s %s\n", "Index", "Opcode",
702 "Hex Value", "String Value");
703 for (elt
= 0; elt
< exp
->nelts
; elt
++)
705 fprintf_filtered (stream
, "\t%5d ", elt
);
706 opcode_name
= op_name (exp
, exp
->elts
[elt
].opcode
);
708 fprintf_filtered (stream
, "%20s ", opcode_name
);
709 print_longest (stream
, 'd', 0, exp
->elts
[elt
].longconst
);
710 fprintf_filtered (stream
, " ");
712 for (eltscan
= (char *) &exp
->elts
[elt
],
713 eltsize
= sizeof (union exp_element
);
717 fprintf_filtered (stream
, "%c",
718 isprint (*eltscan
) ? (*eltscan
& 0xFF) : '.');
720 fprintf_filtered (stream
, "\n");
724 /* Dump the subexpression of prefix expression EXP whose operator is at
725 position ELT onto STREAM. Returns the position of the next
726 subexpression in EXP. */
729 dump_subexp (struct expression
*exp
, struct ui_file
*stream
, int elt
)
731 static int indent
= 0;
734 fprintf_filtered (stream
, "\n");
735 fprintf_filtered (stream
, "\t%5d ", elt
);
737 for (i
= 1; i
<= indent
; i
++)
738 fprintf_filtered (stream
, " ");
741 fprintf_filtered (stream
, "%-20s ", op_name (exp
, exp
->elts
[elt
].opcode
));
743 elt
= dump_subexp_body (exp
, stream
, elt
);
750 /* Dump the operands of prefix expression EXP whose opcode is at
751 position ELT onto STREAM. Returns the position of the next
752 subexpression in EXP. */
755 dump_subexp_body (struct expression
*exp
, struct ui_file
*stream
, int elt
)
757 return exp
->language_defn
->la_exp_desc
->dump_subexp_body (exp
, stream
, elt
);
760 /* Default value for subexp_body in exp_descriptor vector. */
763 dump_subexp_body_standard (struct expression
*exp
,
764 struct ui_file
*stream
, int elt
)
766 int opcode
= exp
->elts
[elt
++].opcode
;
772 elt
= dump_subexp (exp
, stream
, elt
);
782 case BINOP_LOGICAL_AND
:
783 case BINOP_LOGICAL_OR
:
784 case BINOP_BITWISE_AND
:
785 case BINOP_BITWISE_IOR
:
786 case BINOP_BITWISE_XOR
:
796 case BINOP_SUBSCRIPT
:
801 case BINOP_ASSIGN_MODIFY
:
805 case STRUCTOP_MEMBER
:
807 elt
= dump_subexp (exp
, stream
, elt
);
810 case UNOP_LOGICAL_NOT
:
811 case UNOP_COMPLEMENT
:
814 case UNOP_PREINCREMENT
:
815 case UNOP_POSTINCREMENT
:
816 case UNOP_PREDECREMENT
:
817 case UNOP_POSTDECREMENT
:
830 elt
= dump_subexp (exp
, stream
, elt
);
833 fprintf_filtered (stream
, "Type @");
834 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
835 fprintf_filtered (stream
, " (");
836 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
837 fprintf_filtered (stream
, "), value %ld (0x%lx)",
838 (long) exp
->elts
[elt
+ 1].longconst
,
839 (long) exp
->elts
[elt
+ 1].longconst
);
843 fprintf_filtered (stream
, "Type @");
844 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
845 fprintf_filtered (stream
, " (");
846 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
847 fprintf_filtered (stream
, "), value %g",
848 (double) exp
->elts
[elt
+ 1].doubleconst
);
852 fprintf_filtered (stream
, "Block @");
853 gdb_print_host_address (exp
->elts
[elt
].block
, stream
);
854 fprintf_filtered (stream
, ", symbol @");
855 gdb_print_host_address (exp
->elts
[elt
+ 1].symbol
, stream
);
856 fprintf_filtered (stream
, " (%s)",
857 SYMBOL_PRINT_NAME (exp
->elts
[elt
+ 1].symbol
));
860 case OP_VAR_ENTRY_VALUE
:
861 fprintf_filtered (stream
, "Entry value of symbol @");
862 gdb_print_host_address (exp
->elts
[elt
].symbol
, stream
);
863 fprintf_filtered (stream
, " (%s)",
864 SYMBOL_PRINT_NAME (exp
->elts
[elt
].symbol
));
868 fprintf_filtered (stream
, "History element %ld",
869 (long) exp
->elts
[elt
].longconst
);
873 fprintf_filtered (stream
, "Register $%s", &exp
->elts
[elt
+ 1].string
);
874 elt
+= 3 + BYTES_TO_EXP_ELEM (exp
->elts
[elt
].longconst
+ 1);
877 fprintf_filtered (stream
, "Internal var @");
878 gdb_print_host_address (exp
->elts
[elt
].internalvar
, stream
);
879 fprintf_filtered (stream
, " (%s)",
880 internalvar_name (exp
->elts
[elt
].internalvar
));
887 nargs
= longest_to_int (exp
->elts
[elt
].longconst
);
889 fprintf_filtered (stream
, "Number of args: %d", nargs
);
892 for (i
= 1; i
<= nargs
+ 1; i
++)
893 elt
= dump_subexp (exp
, stream
, elt
);
901 lower
= longest_to_int (exp
->elts
[elt
].longconst
);
902 upper
= longest_to_int (exp
->elts
[elt
+ 1].longconst
);
904 fprintf_filtered (stream
, "Bounds [%d:%d]", lower
, upper
);
907 for (i
= 1; i
<= upper
- lower
+ 1; i
++)
908 elt
= dump_subexp (exp
, stream
, elt
);
911 case UNOP_DYNAMIC_CAST
:
912 case UNOP_REINTERPRET_CAST
:
914 case UNOP_MEMVAL_TYPE
:
915 fprintf_filtered (stream
, " (");
916 elt
= dump_subexp (exp
, stream
, elt
);
917 fprintf_filtered (stream
, ")");
918 elt
= dump_subexp (exp
, stream
, elt
);
922 fprintf_filtered (stream
, "Type @");
923 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
924 fprintf_filtered (stream
, " (");
925 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
926 fprintf_filtered (stream
, ")");
927 elt
= dump_subexp (exp
, stream
, elt
+ 2);
929 case UNOP_MEMVAL_TLS
:
930 fprintf_filtered (stream
, "TLS type @");
931 gdb_print_host_address (exp
->elts
[elt
+ 1].type
, stream
);
932 fprintf_filtered (stream
, " (__thread /* \"%s\" */ ",
933 (exp
->elts
[elt
].objfile
== NULL
? "(null)"
934 : objfile_name (exp
->elts
[elt
].objfile
)));
935 type_print (exp
->elts
[elt
+ 1].type
, NULL
, stream
, 0);
936 fprintf_filtered (stream
, ")");
937 elt
= dump_subexp (exp
, stream
, elt
+ 3);
940 fprintf_filtered (stream
, "Type @");
941 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
942 fprintf_filtered (stream
, " (");
943 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
944 fprintf_filtered (stream
, ")");
949 fprintf_filtered (stream
, "Typeof (");
950 elt
= dump_subexp (exp
, stream
, elt
);
951 fprintf_filtered (stream
, ")");
954 fprintf_filtered (stream
, "typeid (");
955 elt
= dump_subexp (exp
, stream
, elt
);
956 fprintf_filtered (stream
, ")");
958 case STRUCTOP_STRUCT
:
964 len
= longest_to_int (exp
->elts
[elt
].longconst
);
965 elem_name
= &exp
->elts
[elt
+ 1].string
;
967 fprintf_filtered (stream
, "Element name: `%.*s'", len
, elem_name
);
968 elt
= dump_subexp (exp
, stream
, elt
+ 3 + BYTES_TO_EXP_ELEM (len
+ 1));
976 fprintf_filtered (stream
, "Type @");
977 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
978 fprintf_filtered (stream
, " (");
979 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
980 fprintf_filtered (stream
, ") ");
982 len
= longest_to_int (exp
->elts
[elt
+ 1].longconst
);
983 elem_name
= &exp
->elts
[elt
+ 2].string
;
985 fprintf_filtered (stream
, "Field name: `%.*s'", len
, elem_name
);
986 elt
+= 4 + BYTES_TO_EXP_ELEM (len
+ 1);
993 len
= exp
->elts
[elt
++].longconst
;
994 fprintf_filtered (stream
, "%s TypeInstance: ", plongest (len
));
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
, ")");
1004 fputs_filtered (", ", stream
);
1006 /* Ending LEN and ending TYPE_INSTANCE. */
1008 elt
= dump_subexp (exp
, stream
, elt
);
1013 LONGEST len
= exp
->elts
[elt
].longconst
;
1014 LONGEST type
= exp
->elts
[elt
+ 1].longconst
;
1016 fprintf_filtered (stream
, "Language-specific string type: %s",
1022 /* Skip string content. */
1023 elt
+= BYTES_TO_EXP_ELEM (len
);
1025 /* Skip length and ending OP_STRING. */
1031 case MULTI_SUBSCRIPT
:
1032 case OP_F77_UNDETERMINED_ARGLIST
:
1038 fprintf_filtered (stream
, "Unknown format");
1045 dump_prefix_expression (struct expression
*exp
, struct ui_file
*stream
)
1049 fprintf_filtered (stream
, "Dump of expression @ ");
1050 gdb_print_host_address (exp
, stream
);
1051 fputs_filtered (", after conversion to prefix form:\nExpression: `", stream
);
1052 print_expression (exp
, stream
);
1053 fprintf_filtered (stream
, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",
1054 exp
->language_defn
->la_name
, exp
->nelts
,
1055 (long) sizeof (union exp_element
));
1056 fputs_filtered ("\n", stream
);
1058 for (elt
= 0; elt
< exp
->nelts
;)
1059 elt
= dump_subexp (exp
, stream
, elt
);
1060 fputs_filtered ("\n", stream
);