1 /* Print in infix form a struct expression.
3 Copyright (C) 1986, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
4 1998, 1999, 2000, 2003, 2007, 2008, 2009, 2010, 2011
5 Free Software Foundation, Inc.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
25 #include "expression.h"
28 #include "parser-defs.h"
29 #include "user-regs.h" /* For user_reg_map_regnum_to_name. */
31 #include "gdb_string.h"
34 #include "gdb_assert.h"
42 print_expression (struct expression
*exp
, struct ui_file
*stream
)
46 print_subexp (exp
, &pc
, stream
, PREC_NULL
);
49 /* Print the subexpression of EXP that starts in position POS, on STREAM.
50 PREC is the precedence of the surrounding operator;
51 if the precedence of the main operator of this subexpression is less,
52 parentheses are needed here. */
55 print_subexp (struct expression
*exp
, int *pos
,
56 struct ui_file
*stream
, enum precedence prec
)
58 exp
->language_defn
->la_exp_desc
->print_subexp (exp
, pos
, stream
, prec
);
61 /* Standard implementation of print_subexp for use in language_defn
64 print_subexp_standard (struct expression
*exp
, int *pos
,
65 struct ui_file
*stream
, enum precedence prec
)
68 const struct op_print
*op_print_tab
;
72 int assign_modify
= 0;
73 enum exp_opcode opcode
;
74 enum precedence myprec
= PREC_NULL
;
75 /* Set to 1 for a right-associative operator. */
80 op_print_tab
= exp
->language_defn
->la_op_print_tab
;
82 opcode
= exp
->elts
[pc
].opcode
;
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_raw_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_raw_print_options (&opts
);
115 value_print (value_from_double (exp
->elts
[pc
+ 1].type
,
116 exp
->elts
[pc
+ 2].doubleconst
),
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
:
143 fprintf_filtered (stream
, "%s@entry",
144 SYMBOL_PRINT_NAME (exp
->elts
[pc
+ 1].symbol
));
150 fprintf_filtered (stream
, "$%d",
151 longest_to_int (exp
->elts
[pc
+ 1].longconst
));
156 const char *name
= &exp
->elts
[pc
+ 2].string
;
158 (*pos
) += 3 + BYTES_TO_EXP_ELEM (exp
->elts
[pc
+ 1].longconst
+ 1);
159 fprintf_filtered (stream
, "$%s", name
);
165 fprintf_filtered (stream
, "%s",
166 longest_to_int (exp
->elts
[pc
+ 1].longconst
)
172 fprintf_filtered (stream
, "$%s",
173 internalvar_name (exp
->elts
[pc
+ 1].internalvar
));
178 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
179 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
180 fputs_filtered (" (", stream
);
181 for (tem
= 0; tem
< nargs
; tem
++)
184 fputs_filtered (", ", stream
);
185 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
187 fputs_filtered (")", stream
);
191 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
192 (*pos
) += 3 + BYTES_TO_EXP_ELEM (nargs
+ 1);
193 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
198 struct value_print_options opts
;
200 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
201 (*pos
) += 3 + BYTES_TO_EXP_ELEM (nargs
+ 1);
202 /* LA_PRINT_STRING will print using the current repeat count threshold.
203 If necessary, we can temporarily set it to zero, or pass it as an
204 additional parameter to LA_PRINT_STRING. -fnf */
205 get_user_print_options (&opts
);
206 LA_PRINT_STRING (stream
, builtin_type (exp
->gdbarch
)->builtin_char
,
207 &exp
->elts
[pc
+ 2].string
, nargs
, NULL
, 0, &opts
);
212 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
214 += 3 + BYTES_TO_EXP_ELEM ((nargs
+ HOST_CHAR_BIT
- 1) / HOST_CHAR_BIT
);
215 fprintf_unfiltered (stream
, "B'<unimplemented>'");
218 case OP_OBJC_NSSTRING
: /* Objective-C Foundation Class
219 NSString constant. */
221 struct value_print_options opts
;
223 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
224 (*pos
) += 3 + BYTES_TO_EXP_ELEM (nargs
+ 1);
225 fputs_filtered ("@\"", stream
);
226 get_user_print_options (&opts
);
227 LA_PRINT_STRING (stream
, builtin_type (exp
->gdbarch
)->builtin_char
,
228 &exp
->elts
[pc
+ 2].string
, nargs
, NULL
, 0, &opts
);
229 fputs_filtered ("\"", stream
);
233 case OP_OBJC_MSGCALL
:
234 { /* Objective C message (method) call. */
238 nargs
= longest_to_int (exp
->elts
[pc
+ 2].longconst
);
239 fprintf_unfiltered (stream
, "[");
240 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
241 if (0 == target_read_string (exp
->elts
[pc
+ 1].longconst
,
242 &selector
, 1024, NULL
))
244 error (_("bad selector"));
251 s
= alloca (strlen (selector
) + 1);
252 strcpy (s
, selector
);
253 for (tem
= 0; tem
< nargs
; tem
++)
255 nextS
= strchr (s
, ':');
256 gdb_assert (nextS
); /* Make sure we found ':'. */
258 fprintf_unfiltered (stream
, " %s: ", s
);
260 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
265 fprintf_unfiltered (stream
, " %s", selector
);
267 fprintf_unfiltered (stream
, "]");
268 /* "selector" was malloc'd by target_read_string. Free it. */
275 nargs
= longest_to_int (exp
->elts
[pc
+ 2].longconst
);
276 nargs
-= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
279 if (exp
->elts
[pc
+ 4].opcode
== OP_LONG
280 && exp
->elts
[pc
+ 5].type
281 == builtin_type (exp
->gdbarch
)->builtin_char
282 && exp
->language_defn
->la_language
== language_c
)
284 /* Attempt to print C character arrays using string syntax.
285 Walk through the args, picking up one character from each
286 of the OP_LONG expression elements. If any array element
287 does not match our expection of what we should find for
288 a simple string, revert back to array printing. Note that
289 the last expression element is an explicit null terminator
290 byte, which doesn't get printed. */
291 tempstr
= alloca (nargs
);
295 if (exp
->elts
[pc
].opcode
!= OP_LONG
296 || exp
->elts
[pc
+ 1].type
297 != builtin_type (exp
->gdbarch
)->builtin_char
)
299 /* Not a simple array of char, use regular array
307 longest_to_int (exp
->elts
[pc
+ 2].longconst
);
314 struct value_print_options opts
;
316 get_user_print_options (&opts
);
317 LA_PRINT_STRING (stream
, builtin_type (exp
->gdbarch
)->builtin_char
,
318 tempstr
, nargs
- 1, NULL
, 0, &opts
);
323 fputs_filtered (" {", stream
);
324 for (tem
= 0; tem
< nargs
; tem
++)
328 fputs_filtered (", ", stream
);
330 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
332 fputs_filtered ("}", stream
);
337 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
338 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
339 /* Gcc support both these syntaxes. Unsure which is preferred. */
341 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
342 fputs_filtered (": ", stream
);
344 fputs_filtered (".", stream
);
345 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
346 fputs_filtered ("=", stream
);
348 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
352 if ((int) prec
> (int) PREC_COMMA
)
353 fputs_filtered ("(", stream
);
354 /* Print the subexpressions, forcing parentheses
355 around any binary operations within them.
356 This is more parentheses than are strictly necessary,
357 but it looks clearer. */
358 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
359 fputs_filtered (" ? ", stream
);
360 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
361 fputs_filtered (" : ", stream
);
362 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
363 if ((int) prec
> (int) PREC_COMMA
)
364 fputs_filtered (")", stream
);
368 case TERNOP_SLICE_COUNT
:
369 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
370 fputs_filtered ("(", stream
);
371 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
372 fputs_filtered (opcode
== TERNOP_SLICE
? " : " : " UP ", stream
);
373 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
374 fputs_filtered (")", stream
);
377 case STRUCTOP_STRUCT
:
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 /* Will not occur for Modula-2. */
387 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
388 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
389 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
390 fputs_filtered ("->", stream
);
391 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
394 case STRUCTOP_MEMBER
:
395 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
396 fputs_filtered (".*", stream
);
397 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
401 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
402 fputs_filtered ("->*", stream
);
403 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
406 case BINOP_SUBSCRIPT
:
407 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
408 fputs_filtered ("[", stream
);
409 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
410 fputs_filtered ("]", stream
);
413 case UNOP_POSTINCREMENT
:
414 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
415 fputs_filtered ("++", stream
);
418 case UNOP_POSTDECREMENT
:
419 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
420 fputs_filtered ("--", stream
);
425 if ((int) prec
> (int) PREC_PREFIX
)
426 fputs_filtered ("(", stream
);
427 fputs_filtered ("(", stream
);
428 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
429 fputs_filtered (") ", stream
);
430 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
431 if ((int) prec
> (int) PREC_PREFIX
)
432 fputs_filtered (")", stream
);
435 case UNOP_DYNAMIC_CAST
:
436 case UNOP_REINTERPRET_CAST
:
437 fputs_filtered (opcode
== UNOP_DYNAMIC_CAST
? "dynamic_cast"
438 : "reinterpret_cast", stream
);
439 fputs_filtered ("<", stream
);
441 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
442 fputs_filtered ("> (", stream
);
443 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
444 fputs_filtered (")", stream
);
449 if ((int) prec
> (int) PREC_PREFIX
)
450 fputs_filtered ("(", stream
);
451 if (TYPE_CODE (exp
->elts
[pc
+ 1].type
) == TYPE_CODE_FUNC
452 && exp
->elts
[pc
+ 3].opcode
== OP_LONG
)
454 struct value_print_options opts
;
456 /* We have a minimal symbol fn, probably. It's encoded
457 as a UNOP_MEMVAL (function-type) of an OP_LONG (int, address).
458 Swallow the OP_LONG (including both its opcodes); ignore
459 its type; print the value in the type of the MEMVAL. */
461 val
= value_at_lazy (exp
->elts
[pc
+ 1].type
,
462 (CORE_ADDR
) exp
->elts
[pc
+ 5].longconst
);
463 get_raw_print_options (&opts
);
464 value_print (val
, stream
, &opts
);
468 fputs_filtered ("{", stream
);
469 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
470 fputs_filtered ("} ", stream
);
471 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 char *op_name (struct expression
*, enum exp_opcode
);
652 static int dump_subexp_body (struct expression
*exp
, struct ui_file
*, int);
654 /* Name for OPCODE, when it appears in expression EXP. */
657 op_name (struct expression
*exp
, enum exp_opcode opcode
)
659 return exp
->language_defn
->la_exp_desc
->op_name (opcode
);
662 /* Default name for the standard operator OPCODE (i.e., one defined in
663 the definition of enum exp_opcode). */
666 op_name_standard (enum exp_opcode opcode
)
674 sprintf (buf
, "<unknown %d>", opcode
);
680 #include "std-operator.def"
685 /* Print a raw dump of expression EXP to STREAM.
686 NOTE, if non-NULL, is printed as extra explanatory text. */
689 dump_raw_expression (struct expression
*exp
, struct ui_file
*stream
,
697 fprintf_filtered (stream
, "Dump of expression @ ");
698 gdb_print_host_address (exp
, stream
);
700 fprintf_filtered (stream
, ", %s:", note
);
701 fprintf_filtered (stream
, "\n\tLanguage %s, %d elements, %ld bytes each.\n",
702 exp
->language_defn
->la_name
, exp
->nelts
,
703 (long) sizeof (union exp_element
));
704 fprintf_filtered (stream
, "\t%5s %20s %16s %s\n", "Index", "Opcode",
705 "Hex Value", "String Value");
706 for (elt
= 0; elt
< exp
->nelts
; elt
++)
708 fprintf_filtered (stream
, "\t%5d ", elt
);
709 opcode_name
= op_name (exp
, exp
->elts
[elt
].opcode
);
711 fprintf_filtered (stream
, "%20s ", opcode_name
);
712 print_longest (stream
, 'd', 0, exp
->elts
[elt
].longconst
);
713 fprintf_filtered (stream
, " ");
715 for (eltscan
= (char *) &exp
->elts
[elt
],
716 eltsize
= sizeof (union exp_element
);
720 fprintf_filtered (stream
, "%c",
721 isprint (*eltscan
) ? (*eltscan
& 0xFF) : '.');
723 fprintf_filtered (stream
, "\n");
727 /* Dump the subexpression of prefix expression EXP whose operator is at
728 position ELT onto STREAM. Returns the position of the next
729 subexpression in EXP. */
732 dump_subexp (struct expression
*exp
, struct ui_file
*stream
, int elt
)
734 static int indent
= 0;
737 fprintf_filtered (stream
, "\n");
738 fprintf_filtered (stream
, "\t%5d ", elt
);
740 for (i
= 1; i
<= indent
; i
++)
741 fprintf_filtered (stream
, " ");
744 fprintf_filtered (stream
, "%-20s ", op_name (exp
, exp
->elts
[elt
].opcode
));
746 elt
= dump_subexp_body (exp
, stream
, elt
);
753 /* Dump the operands of prefix expression EXP whose opcode is at
754 position ELT onto STREAM. Returns the position of the next
755 subexpression in EXP. */
758 dump_subexp_body (struct expression
*exp
, struct ui_file
*stream
, int elt
)
760 return exp
->language_defn
->la_exp_desc
->dump_subexp_body (exp
, stream
, elt
);
763 /* Default value for subexp_body in exp_descriptor vector. */
766 dump_subexp_body_standard (struct expression
*exp
,
767 struct ui_file
*stream
, int elt
)
769 int opcode
= exp
->elts
[elt
++].opcode
;
775 case TERNOP_SLICE_COUNT
:
776 elt
= dump_subexp (exp
, stream
, elt
);
786 case BINOP_LOGICAL_AND
:
787 case BINOP_LOGICAL_OR
:
788 case BINOP_BITWISE_AND
:
789 case BINOP_BITWISE_IOR
:
790 case BINOP_BITWISE_XOR
:
800 case BINOP_SUBSCRIPT
:
805 case BINOP_ASSIGN_MODIFY
:
811 case STRUCTOP_MEMBER
:
813 elt
= dump_subexp (exp
, stream
, elt
);
816 case UNOP_LOGICAL_NOT
:
817 case UNOP_COMPLEMENT
:
820 case UNOP_PREINCREMENT
:
821 case UNOP_POSTINCREMENT
:
822 case UNOP_PREDECREMENT
:
823 case UNOP_POSTDECREMENT
:
836 elt
= dump_subexp (exp
, stream
, elt
);
839 fprintf_filtered (stream
, "Type @");
840 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
841 fprintf_filtered (stream
, " (");
842 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
843 fprintf_filtered (stream
, "), value %ld (0x%lx)",
844 (long) exp
->elts
[elt
+ 1].longconst
,
845 (long) exp
->elts
[elt
+ 1].longconst
);
849 fprintf_filtered (stream
, "Type @");
850 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
851 fprintf_filtered (stream
, " (");
852 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
853 fprintf_filtered (stream
, "), value %g",
854 (double) exp
->elts
[elt
+ 1].doubleconst
);
858 fprintf_filtered (stream
, "Block @");
859 gdb_print_host_address (exp
->elts
[elt
].block
, stream
);
860 fprintf_filtered (stream
, ", symbol @");
861 gdb_print_host_address (exp
->elts
[elt
+ 1].symbol
, stream
);
862 fprintf_filtered (stream
, " (%s)",
863 SYMBOL_PRINT_NAME (exp
->elts
[elt
+ 1].symbol
));
866 case OP_VAR_ENTRY_VALUE
:
867 fprintf_filtered (stream
, "Entry value of symbol @");
868 gdb_print_host_address (exp
->elts
[elt
].symbol
, stream
);
869 fprintf_filtered (stream
, " (%s)",
870 SYMBOL_PRINT_NAME (exp
->elts
[elt
].symbol
));
874 fprintf_filtered (stream
, "History element %ld",
875 (long) exp
->elts
[elt
].longconst
);
879 fprintf_filtered (stream
, "Register $%s", &exp
->elts
[elt
+ 1].string
);
880 elt
+= 3 + BYTES_TO_EXP_ELEM (exp
->elts
[elt
].longconst
+ 1);
883 fprintf_filtered (stream
, "Internal var @");
884 gdb_print_host_address (exp
->elts
[elt
].internalvar
, stream
);
885 fprintf_filtered (stream
, " (%s)",
886 internalvar_name (exp
->elts
[elt
].internalvar
));
893 nargs
= longest_to_int (exp
->elts
[elt
].longconst
);
895 fprintf_filtered (stream
, "Number of args: %d", nargs
);
898 for (i
= 1; i
<= nargs
+ 1; i
++)
899 elt
= dump_subexp (exp
, stream
, elt
);
907 lower
= longest_to_int (exp
->elts
[elt
].longconst
);
908 upper
= longest_to_int (exp
->elts
[elt
+ 1].longconst
);
910 fprintf_filtered (stream
, "Bounds [%d:%d]", lower
, upper
);
913 for (i
= 1; i
<= upper
- lower
+ 1; i
++)
914 elt
= dump_subexp (exp
, stream
, elt
);
919 case UNOP_DYNAMIC_CAST
:
920 case UNOP_REINTERPRET_CAST
:
921 fprintf_filtered (stream
, "Type @");
922 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
923 fprintf_filtered (stream
, " (");
924 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
925 fprintf_filtered (stream
, ")");
926 elt
= dump_subexp (exp
, stream
, elt
+ 2);
928 case UNOP_MEMVAL_TLS
:
929 fprintf_filtered (stream
, "TLS type @");
930 gdb_print_host_address (exp
->elts
[elt
+ 1].type
, stream
);
931 fprintf_filtered (stream
, " (__thread /* \"%s\" */ ",
932 (exp
->elts
[elt
].objfile
== NULL
? "(null)"
933 : exp
->elts
[elt
].objfile
->name
));
934 type_print (exp
->elts
[elt
+ 1].type
, NULL
, stream
, 0);
935 fprintf_filtered (stream
, ")");
936 elt
= dump_subexp (exp
, stream
, elt
+ 3);
939 fprintf_filtered (stream
, "Type @");
940 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
941 fprintf_filtered (stream
, " (");
942 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
943 fprintf_filtered (stream
, ")");
946 case STRUCTOP_STRUCT
:
952 len
= longest_to_int (exp
->elts
[elt
].longconst
);
953 elem_name
= &exp
->elts
[elt
+ 1].string
;
955 fprintf_filtered (stream
, "Element name: `%.*s'", len
, elem_name
);
956 elt
= dump_subexp (exp
, stream
, elt
+ 3 + BYTES_TO_EXP_ELEM (len
+ 1));
964 fprintf_filtered (stream
, "Type @");
965 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
966 fprintf_filtered (stream
, " (");
967 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
968 fprintf_filtered (stream
, ") ");
970 len
= longest_to_int (exp
->elts
[elt
+ 1].longconst
);
971 elem_name
= &exp
->elts
[elt
+ 2].string
;
973 fprintf_filtered (stream
, "Field name: `%.*s'", len
, elem_name
);
974 elt
+= 4 + BYTES_TO_EXP_ELEM (len
+ 1);
982 len
= exp
->elts
[elt
++].longconst
;
983 fprintf_filtered (stream
, "%s TypeInstance: ", plongest (len
));
986 fprintf_filtered (stream
, "Type @");
987 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
988 fprintf_filtered (stream
, " (");
989 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
990 fprintf_filtered (stream
, ")");
993 fputs_filtered (", ", stream
);
995 /* Ending LEN and ending TYPE_INSTANCE. */
997 elt
= dump_subexp (exp
, stream
, elt
);
1002 case MULTI_SUBSCRIPT
:
1003 case OP_F77_UNDETERMINED_ARGLIST
:
1012 fprintf_filtered (stream
, "Unknown format");
1019 dump_prefix_expression (struct expression
*exp
, struct ui_file
*stream
)
1023 fprintf_filtered (stream
, "Dump of expression @ ");
1024 gdb_print_host_address (exp
, stream
);
1025 fputs_filtered (", after conversion to prefix form:\nExpression: `", stream
);
1026 if (exp
->elts
[0].opcode
!= OP_TYPE
)
1027 print_expression (exp
, stream
);
1029 fputs_filtered ("Type printing not yet supported....", stream
);
1030 fprintf_filtered (stream
, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",
1031 exp
->language_defn
->la_name
, exp
->nelts
,
1032 (long) sizeof (union exp_element
));
1033 fputs_filtered ("\n", stream
);
1035 for (elt
= 0; elt
< exp
->nelts
;)
1036 elt
= dump_subexp (exp
, stream
, elt
);
1037 fputs_filtered ("\n", stream
);