1 /* Print in infix form a struct expression.
3 Copyright (C) 1986, 1988-1989, 1991-2000, 2003, 2007-2012 Free
4 Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
24 #include "expression.h"
27 #include "parser-defs.h"
28 #include "user-regs.h" /* For user_reg_map_regnum_to_name. */
30 #include "gdb_string.h"
33 #include "gdb_assert.h"
41 print_expression (struct expression
*exp
, struct ui_file
*stream
)
45 print_subexp (exp
, &pc
, stream
, PREC_NULL
);
48 /* Print the subexpression of EXP that starts in position POS, on STREAM.
49 PREC is the precedence of the surrounding operator;
50 if the precedence of the main operator of this subexpression is less,
51 parentheses are needed here. */
54 print_subexp (struct expression
*exp
, int *pos
,
55 struct ui_file
*stream
, enum precedence prec
)
57 exp
->language_defn
->la_exp_desc
->print_subexp (exp
, pos
, stream
, prec
);
60 /* Standard implementation of print_subexp for use in language_defn
63 print_subexp_standard (struct expression
*exp
, int *pos
,
64 struct ui_file
*stream
, enum precedence prec
)
67 const struct op_print
*op_print_tab
;
71 int assign_modify
= 0;
72 enum exp_opcode opcode
;
73 enum precedence myprec
= PREC_NULL
;
74 /* Set to 1 for a right-associative operator. */
79 op_print_tab
= exp
->language_defn
->la_op_print_tab
;
81 opcode
= exp
->elts
[pc
].opcode
;
88 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
94 fputs_filtered (type_name_no_tag (exp
->elts
[pc
+ 1].type
), stream
);
95 fputs_filtered ("::", stream
);
96 nargs
= longest_to_int (exp
->elts
[pc
+ 2].longconst
);
97 (*pos
) += 4 + BYTES_TO_EXP_ELEM (nargs
+ 1);
98 fputs_filtered (&exp
->elts
[pc
+ 3].string
, stream
);
103 struct value_print_options opts
;
105 get_raw_print_options (&opts
);
107 value_print (value_from_longest (exp
->elts
[pc
+ 1].type
,
108 exp
->elts
[pc
+ 2].longconst
),
115 struct value_print_options opts
;
117 get_raw_print_options (&opts
);
119 value_print (value_from_double (exp
->elts
[pc
+ 1].type
,
120 exp
->elts
[pc
+ 2].doubleconst
),
130 b
= exp
->elts
[pc
+ 1].block
;
132 && BLOCK_FUNCTION (b
) != NULL
133 && SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b
)) != NULL
)
135 fputs_filtered (SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b
)), stream
);
136 fputs_filtered ("::", stream
);
138 fputs_filtered (SYMBOL_PRINT_NAME (exp
->elts
[pc
+ 2].symbol
), stream
);
142 case OP_VAR_ENTRY_VALUE
:
145 fprintf_filtered (stream
, "%s@entry",
146 SYMBOL_PRINT_NAME (exp
->elts
[pc
+ 1].symbol
));
152 fprintf_filtered (stream
, "$%d",
153 longest_to_int (exp
->elts
[pc
+ 1].longconst
));
158 const char *name
= &exp
->elts
[pc
+ 2].string
;
160 (*pos
) += 3 + BYTES_TO_EXP_ELEM (exp
->elts
[pc
+ 1].longconst
+ 1);
161 fprintf_filtered (stream
, "$%s", name
);
167 fprintf_filtered (stream
, "%s",
168 longest_to_int (exp
->elts
[pc
+ 1].longconst
)
174 fprintf_filtered (stream
, "$%s",
175 internalvar_name (exp
->elts
[pc
+ 1].internalvar
));
180 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
181 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
182 fputs_filtered (" (", stream
);
183 for (tem
= 0; tem
< nargs
; tem
++)
186 fputs_filtered (", ", stream
);
187 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
189 fputs_filtered (")", stream
);
193 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
194 (*pos
) += 3 + BYTES_TO_EXP_ELEM (nargs
+ 1);
195 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
200 struct value_print_options opts
;
202 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
203 (*pos
) += 3 + BYTES_TO_EXP_ELEM (nargs
+ 1);
204 /* LA_PRINT_STRING will print using the current repeat count threshold.
205 If necessary, we can temporarily set it to zero, or pass it as an
206 additional parameter to LA_PRINT_STRING. -fnf */
207 get_user_print_options (&opts
);
208 LA_PRINT_STRING (stream
, builtin_type (exp
->gdbarch
)->builtin_char
,
209 &exp
->elts
[pc
+ 2].string
, nargs
, NULL
, 0, &opts
);
213 case OP_OBJC_NSSTRING
: /* Objective-C Foundation Class
214 NSString constant. */
216 struct value_print_options opts
;
218 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
219 (*pos
) += 3 + BYTES_TO_EXP_ELEM (nargs
+ 1);
220 fputs_filtered ("@\"", stream
);
221 get_user_print_options (&opts
);
222 LA_PRINT_STRING (stream
, builtin_type (exp
->gdbarch
)->builtin_char
,
223 &exp
->elts
[pc
+ 2].string
, nargs
, NULL
, 0, &opts
);
224 fputs_filtered ("\"", stream
);
228 case OP_OBJC_MSGCALL
:
229 { /* Objective C message (method) call. */
233 nargs
= longest_to_int (exp
->elts
[pc
+ 2].longconst
);
234 fprintf_unfiltered (stream
, "[");
235 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
236 if (0 == target_read_string (exp
->elts
[pc
+ 1].longconst
,
237 &selector
, 1024, NULL
))
239 error (_("bad selector"));
246 s
= alloca (strlen (selector
) + 1);
247 strcpy (s
, selector
);
248 for (tem
= 0; tem
< nargs
; tem
++)
250 nextS
= strchr (s
, ':');
251 gdb_assert (nextS
); /* Make sure we found ':'. */
253 fprintf_unfiltered (stream
, " %s: ", s
);
255 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
260 fprintf_unfiltered (stream
, " %s", selector
);
262 fprintf_unfiltered (stream
, "]");
263 /* "selector" was malloc'd by target_read_string. Free it. */
270 nargs
= longest_to_int (exp
->elts
[pc
+ 2].longconst
);
271 nargs
-= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
274 if (exp
->elts
[pc
+ 4].opcode
== OP_LONG
275 && exp
->elts
[pc
+ 5].type
276 == builtin_type (exp
->gdbarch
)->builtin_char
277 && exp
->language_defn
->la_language
== language_c
)
279 /* Attempt to print C character arrays using string syntax.
280 Walk through the args, picking up one character from each
281 of the OP_LONG expression elements. If any array element
282 does not match our expection of what we should find for
283 a simple string, revert back to array printing. Note that
284 the last expression element is an explicit null terminator
285 byte, which doesn't get printed. */
286 tempstr
= alloca (nargs
);
290 if (exp
->elts
[pc
].opcode
!= OP_LONG
291 || exp
->elts
[pc
+ 1].type
292 != builtin_type (exp
->gdbarch
)->builtin_char
)
294 /* Not a simple array of char, use regular array
302 longest_to_int (exp
->elts
[pc
+ 2].longconst
);
309 struct value_print_options opts
;
311 get_user_print_options (&opts
);
312 LA_PRINT_STRING (stream
, builtin_type (exp
->gdbarch
)->builtin_char
,
313 tempstr
, nargs
- 1, NULL
, 0, &opts
);
318 fputs_filtered (" {", stream
);
319 for (tem
= 0; tem
< nargs
; tem
++)
323 fputs_filtered (", ", stream
);
325 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
327 fputs_filtered ("}", stream
);
332 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
333 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
334 /* Gcc support both these syntaxes. Unsure which is preferred. */
336 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
337 fputs_filtered (": ", stream
);
339 fputs_filtered (".", stream
);
340 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
341 fputs_filtered ("=", stream
);
343 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
347 if ((int) prec
> (int) PREC_COMMA
)
348 fputs_filtered ("(", stream
);
349 /* Print the subexpressions, forcing parentheses
350 around any binary operations within them.
351 This is more parentheses than are strictly necessary,
352 but it looks clearer. */
353 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
354 fputs_filtered (" ? ", stream
);
355 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
356 fputs_filtered (" : ", stream
);
357 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
358 if ((int) prec
> (int) PREC_COMMA
)
359 fputs_filtered (")", stream
);
363 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
364 fputs_filtered ("(", stream
);
365 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
366 fputs_filtered (opcode
== TERNOP_SLICE
? " : " : " UP ", stream
);
367 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
368 fputs_filtered (")", stream
);
371 case STRUCTOP_STRUCT
:
372 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
373 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
374 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
375 fputs_filtered (".", stream
);
376 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
379 /* Will not occur for Modula-2. */
381 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
382 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
383 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
384 fputs_filtered ("->", stream
);
385 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
388 case STRUCTOP_MEMBER
:
389 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
390 fputs_filtered (".*", stream
);
391 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
395 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
396 fputs_filtered ("->*", stream
);
397 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
400 case BINOP_SUBSCRIPT
:
401 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
402 fputs_filtered ("[", stream
);
403 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
404 fputs_filtered ("]", stream
);
407 case UNOP_POSTINCREMENT
:
408 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
409 fputs_filtered ("++", stream
);
412 case UNOP_POSTDECREMENT
:
413 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
414 fputs_filtered ("--", stream
);
419 if ((int) prec
> (int) PREC_PREFIX
)
420 fputs_filtered ("(", stream
);
421 fputs_filtered ("(", stream
);
422 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
423 fputs_filtered (") ", stream
);
424 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
425 if ((int) prec
> (int) PREC_PREFIX
)
426 fputs_filtered (")", stream
);
430 if ((int) prec
> (int) PREC_PREFIX
)
431 fputs_filtered ("(", stream
);
432 fputs_filtered ("(", stream
);
433 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
434 fputs_filtered (") ", stream
);
435 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
436 if ((int) prec
> (int) PREC_PREFIX
)
437 fputs_filtered (")", stream
);
440 case UNOP_DYNAMIC_CAST
:
441 case UNOP_REINTERPRET_CAST
:
442 fputs_filtered (opcode
== UNOP_DYNAMIC_CAST
? "dynamic_cast"
443 : "reinterpret_cast", stream
);
444 fputs_filtered ("<", stream
);
445 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
446 fputs_filtered ("> (", stream
);
447 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
448 fputs_filtered (")", stream
);
453 if ((int) prec
> (int) PREC_PREFIX
)
454 fputs_filtered ("(", stream
);
455 if (TYPE_CODE (exp
->elts
[pc
+ 1].type
) == TYPE_CODE_FUNC
456 && exp
->elts
[pc
+ 3].opcode
== OP_LONG
)
458 struct value_print_options opts
;
460 /* We have a minimal symbol fn, probably. It's encoded
461 as a UNOP_MEMVAL (function-type) of an OP_LONG (int, address).
462 Swallow the OP_LONG (including both its opcodes); ignore
463 its type; print the value in the type of the MEMVAL. */
465 val
= value_at_lazy (exp
->elts
[pc
+ 1].type
,
466 (CORE_ADDR
) exp
->elts
[pc
+ 5].longconst
);
467 get_raw_print_options (&opts
);
468 value_print (val
, stream
, &opts
);
472 fputs_filtered ("{", stream
);
473 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
474 fputs_filtered ("} ", stream
);
475 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
477 if ((int) prec
> (int) PREC_PREFIX
)
478 fputs_filtered (")", stream
);
481 case UNOP_MEMVAL_TYPE
:
482 if ((int) prec
> (int) PREC_PREFIX
)
483 fputs_filtered ("(", stream
);
484 fputs_filtered ("{", stream
);
485 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
486 fputs_filtered ("} ", stream
);
487 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
488 if ((int) prec
> (int) PREC_PREFIX
)
489 fputs_filtered (")", stream
);
492 case UNOP_MEMVAL_TLS
:
494 if ((int) prec
> (int) PREC_PREFIX
)
495 fputs_filtered ("(", stream
);
496 fputs_filtered ("{", stream
);
497 type_print (exp
->elts
[pc
+ 2].type
, "", stream
, 0);
498 fputs_filtered ("} ", stream
);
499 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
500 if ((int) prec
> (int) PREC_PREFIX
)
501 fputs_filtered (")", stream
);
504 case BINOP_ASSIGN_MODIFY
:
505 opcode
= exp
->elts
[pc
+ 1].opcode
;
507 myprec
= PREC_ASSIGN
;
511 for (tem
= 0; op_print_tab
[tem
].opcode
!= OP_NULL
; tem
++)
512 if (op_print_tab
[tem
].opcode
== opcode
)
514 op_str
= op_print_tab
[tem
].string
;
517 if (op_print_tab
[tem
].opcode
!= opcode
)
518 /* Not found; don't try to keep going because we don't know how
519 to interpret further elements. */
520 error (_("Invalid expression"));
527 if (exp
->language_defn
->la_name_of_this
)
528 fputs_filtered (exp
->language_defn
->la_name_of_this
, stream
);
530 fprintf_filtered (stream
, _("<language %s has no 'this'>"),
531 exp
->language_defn
->la_name
);
536 case MULTI_SUBSCRIPT
:
538 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
539 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
540 fprintf_unfiltered (stream
, " [");
541 for (tem
= 0; tem
< nargs
; tem
++)
544 fprintf_unfiltered (stream
, ", ");
545 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
547 fprintf_unfiltered (stream
, "]");
552 fprintf_unfiltered (stream
, "VAL(");
553 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
554 fprintf_unfiltered (stream
, ",");
555 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
556 fprintf_unfiltered (stream
, ")");
561 LONGEST count
= exp
->elts
[pc
+ 1].longconst
;
565 fputs_unfiltered ("TypesInstance(", stream
);
568 type_print (exp
->elts
[(*pos
)++].type
, "", stream
, 0);
570 fputs_unfiltered (",", stream
);
572 fputs_unfiltered (",", stream
);
573 /* Ending COUNT and ending TYPE_INSTANCE. */
575 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
576 fputs_unfiltered (")", stream
);
584 for (tem
= 0; op_print_tab
[tem
].opcode
!= OP_NULL
; tem
++)
585 if (op_print_tab
[tem
].opcode
== opcode
)
587 op_str
= op_print_tab
[tem
].string
;
588 myprec
= op_print_tab
[tem
].precedence
;
589 assoc
= op_print_tab
[tem
].right_assoc
;
592 if (op_print_tab
[tem
].opcode
!= opcode
)
593 /* Not found; don't try to keep going because we don't know how
594 to interpret further elements. For example, this happens
595 if opcode is OP_TYPE. */
596 error (_("Invalid expression"));
599 /* Note that PREC_BUILTIN will always emit parentheses. */
600 if ((int) myprec
< (int) prec
)
601 fputs_filtered ("(", stream
);
602 if ((int) opcode
> (int) BINOP_END
)
606 /* Unary postfix operator. */
607 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
608 fputs_filtered (op_str
, stream
);
612 /* Unary prefix operator. */
613 fputs_filtered (op_str
, stream
);
614 if (myprec
== PREC_BUILTIN_FUNCTION
)
615 fputs_filtered ("(", stream
);
616 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
617 if (myprec
== PREC_BUILTIN_FUNCTION
)
618 fputs_filtered (")", stream
);
623 /* Binary operator. */
624 /* Print left operand.
625 If operator is right-associative,
626 increment precedence for this operand. */
627 print_subexp (exp
, pos
, stream
,
628 (enum precedence
) ((int) myprec
+ assoc
));
629 /* Print the operator itself. */
631 fprintf_filtered (stream
, " %s= ", op_str
);
632 else if (op_str
[0] == ',')
633 fprintf_filtered (stream
, "%s ", op_str
);
635 fprintf_filtered (stream
, " %s ", op_str
);
636 /* Print right operand.
637 If operator is left-associative,
638 increment precedence for this operand. */
639 print_subexp (exp
, pos
, stream
,
640 (enum precedence
) ((int) myprec
+ !assoc
));
643 if ((int) myprec
< (int) prec
)
644 fputs_filtered (")", stream
);
647 /* Return the operator corresponding to opcode OP as
648 a string. NULL indicates that the opcode was not found in the
649 current language table. */
651 op_string (enum exp_opcode op
)
654 const struct op_print
*op_print_tab
;
656 op_print_tab
= current_language
->la_op_print_tab
;
657 for (tem
= 0; op_print_tab
[tem
].opcode
!= OP_NULL
; tem
++)
658 if (op_print_tab
[tem
].opcode
== op
)
659 return op_print_tab
[tem
].string
;
663 /* Support for dumping the raw data from expressions in a human readable
666 static int dump_subexp_body (struct expression
*exp
, struct ui_file
*, int);
668 /* Name for OPCODE, when it appears in expression EXP. */
671 op_name (struct expression
*exp
, enum exp_opcode opcode
)
673 return exp
->language_defn
->la_exp_desc
->op_name (opcode
);
676 /* Default name for the standard operator OPCODE (i.e., one defined in
677 the definition of enum exp_opcode). */
680 op_name_standard (enum exp_opcode opcode
)
688 sprintf (buf
, "<unknown %d>", opcode
);
694 #include "std-operator.def"
699 /* Print a raw dump of expression EXP to STREAM.
700 NOTE, if non-NULL, is printed as extra explanatory text. */
703 dump_raw_expression (struct expression
*exp
, struct ui_file
*stream
,
711 fprintf_filtered (stream
, "Dump of expression @ ");
712 gdb_print_host_address (exp
, stream
);
714 fprintf_filtered (stream
, ", %s:", note
);
715 fprintf_filtered (stream
, "\n\tLanguage %s, %d elements, %ld bytes each.\n",
716 exp
->language_defn
->la_name
, exp
->nelts
,
717 (long) sizeof (union exp_element
));
718 fprintf_filtered (stream
, "\t%5s %20s %16s %s\n", "Index", "Opcode",
719 "Hex Value", "String Value");
720 for (elt
= 0; elt
< exp
->nelts
; elt
++)
722 fprintf_filtered (stream
, "\t%5d ", elt
);
723 opcode_name
= op_name (exp
, exp
->elts
[elt
].opcode
);
725 fprintf_filtered (stream
, "%20s ", opcode_name
);
726 print_longest (stream
, 'd', 0, exp
->elts
[elt
].longconst
);
727 fprintf_filtered (stream
, " ");
729 for (eltscan
= (char *) &exp
->elts
[elt
],
730 eltsize
= sizeof (union exp_element
);
734 fprintf_filtered (stream
, "%c",
735 isprint (*eltscan
) ? (*eltscan
& 0xFF) : '.');
737 fprintf_filtered (stream
, "\n");
741 /* Dump the subexpression of prefix expression EXP whose operator is at
742 position ELT onto STREAM. Returns the position of the next
743 subexpression in EXP. */
746 dump_subexp (struct expression
*exp
, struct ui_file
*stream
, int elt
)
748 static int indent
= 0;
751 fprintf_filtered (stream
, "\n");
752 fprintf_filtered (stream
, "\t%5d ", elt
);
754 for (i
= 1; i
<= indent
; i
++)
755 fprintf_filtered (stream
, " ");
758 fprintf_filtered (stream
, "%-20s ", op_name (exp
, exp
->elts
[elt
].opcode
));
760 elt
= dump_subexp_body (exp
, stream
, elt
);
767 /* Dump the operands of prefix expression EXP whose opcode is at
768 position ELT onto STREAM. Returns the position of the next
769 subexpression in EXP. */
772 dump_subexp_body (struct expression
*exp
, struct ui_file
*stream
, int elt
)
774 return exp
->language_defn
->la_exp_desc
->dump_subexp_body (exp
, stream
, elt
);
777 /* Default value for subexp_body in exp_descriptor vector. */
780 dump_subexp_body_standard (struct expression
*exp
,
781 struct ui_file
*stream
, int elt
)
783 int opcode
= exp
->elts
[elt
++].opcode
;
789 elt
= dump_subexp (exp
, stream
, elt
);
799 case BINOP_LOGICAL_AND
:
800 case BINOP_LOGICAL_OR
:
801 case BINOP_BITWISE_AND
:
802 case BINOP_BITWISE_IOR
:
803 case BINOP_BITWISE_XOR
:
813 case BINOP_SUBSCRIPT
:
818 case BINOP_ASSIGN_MODIFY
:
824 case STRUCTOP_MEMBER
:
826 elt
= dump_subexp (exp
, stream
, elt
);
829 case UNOP_LOGICAL_NOT
:
830 case UNOP_COMPLEMENT
:
833 case UNOP_PREINCREMENT
:
834 case UNOP_POSTINCREMENT
:
835 case UNOP_PREDECREMENT
:
836 case UNOP_POSTDECREMENT
:
849 elt
= dump_subexp (exp
, stream
, elt
);
852 fprintf_filtered (stream
, "Type @");
853 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
854 fprintf_filtered (stream
, " (");
855 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
856 fprintf_filtered (stream
, "), value %ld (0x%lx)",
857 (long) exp
->elts
[elt
+ 1].longconst
,
858 (long) exp
->elts
[elt
+ 1].longconst
);
862 fprintf_filtered (stream
, "Type @");
863 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
864 fprintf_filtered (stream
, " (");
865 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
866 fprintf_filtered (stream
, "), value %g",
867 (double) exp
->elts
[elt
+ 1].doubleconst
);
871 fprintf_filtered (stream
, "Block @");
872 gdb_print_host_address (exp
->elts
[elt
].block
, stream
);
873 fprintf_filtered (stream
, ", symbol @");
874 gdb_print_host_address (exp
->elts
[elt
+ 1].symbol
, stream
);
875 fprintf_filtered (stream
, " (%s)",
876 SYMBOL_PRINT_NAME (exp
->elts
[elt
+ 1].symbol
));
879 case OP_VAR_ENTRY_VALUE
:
880 fprintf_filtered (stream
, "Entry value of symbol @");
881 gdb_print_host_address (exp
->elts
[elt
].symbol
, stream
);
882 fprintf_filtered (stream
, " (%s)",
883 SYMBOL_PRINT_NAME (exp
->elts
[elt
].symbol
));
887 fprintf_filtered (stream
, "History element %ld",
888 (long) exp
->elts
[elt
].longconst
);
892 fprintf_filtered (stream
, "Register $%s", &exp
->elts
[elt
+ 1].string
);
893 elt
+= 3 + BYTES_TO_EXP_ELEM (exp
->elts
[elt
].longconst
+ 1);
896 fprintf_filtered (stream
, "Internal var @");
897 gdb_print_host_address (exp
->elts
[elt
].internalvar
, stream
);
898 fprintf_filtered (stream
, " (%s)",
899 internalvar_name (exp
->elts
[elt
].internalvar
));
906 nargs
= longest_to_int (exp
->elts
[elt
].longconst
);
908 fprintf_filtered (stream
, "Number of args: %d", nargs
);
911 for (i
= 1; i
<= nargs
+ 1; i
++)
912 elt
= dump_subexp (exp
, stream
, elt
);
920 lower
= longest_to_int (exp
->elts
[elt
].longconst
);
921 upper
= longest_to_int (exp
->elts
[elt
+ 1].longconst
);
923 fprintf_filtered (stream
, "Bounds [%d:%d]", lower
, upper
);
926 for (i
= 1; i
<= upper
- lower
+ 1; i
++)
927 elt
= dump_subexp (exp
, stream
, elt
);
930 case UNOP_DYNAMIC_CAST
:
931 case UNOP_REINTERPRET_CAST
:
933 case UNOP_MEMVAL_TYPE
:
934 fprintf_filtered (stream
, " (");
935 elt
= dump_subexp (exp
, stream
, elt
);
936 fprintf_filtered (stream
, ")");
937 elt
= dump_subexp (exp
, stream
, elt
);
941 fprintf_filtered (stream
, "Type @");
942 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
943 fprintf_filtered (stream
, " (");
944 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
945 fprintf_filtered (stream
, ")");
946 elt
= dump_subexp (exp
, stream
, elt
+ 2);
948 case UNOP_MEMVAL_TLS
:
949 fprintf_filtered (stream
, "TLS type @");
950 gdb_print_host_address (exp
->elts
[elt
+ 1].type
, stream
);
951 fprintf_filtered (stream
, " (__thread /* \"%s\" */ ",
952 (exp
->elts
[elt
].objfile
== NULL
? "(null)"
953 : exp
->elts
[elt
].objfile
->name
));
954 type_print (exp
->elts
[elt
+ 1].type
, NULL
, stream
, 0);
955 fprintf_filtered (stream
, ")");
956 elt
= dump_subexp (exp
, stream
, elt
+ 3);
959 fprintf_filtered (stream
, "Type @");
960 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
961 fprintf_filtered (stream
, " (");
962 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
963 fprintf_filtered (stream
, ")");
968 fprintf_filtered (stream
, "Typeof (");
969 elt
= dump_subexp (exp
, stream
, elt
);
970 fprintf_filtered (stream
, ")");
972 case STRUCTOP_STRUCT
:
978 len
= longest_to_int (exp
->elts
[elt
].longconst
);
979 elem_name
= &exp
->elts
[elt
+ 1].string
;
981 fprintf_filtered (stream
, "Element name: `%.*s'", len
, elem_name
);
982 elt
= dump_subexp (exp
, stream
, elt
+ 3 + BYTES_TO_EXP_ELEM (len
+ 1));
990 fprintf_filtered (stream
, "Type @");
991 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
992 fprintf_filtered (stream
, " (");
993 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
994 fprintf_filtered (stream
, ") ");
996 len
= longest_to_int (exp
->elts
[elt
+ 1].longconst
);
997 elem_name
= &exp
->elts
[elt
+ 2].string
;
999 fprintf_filtered (stream
, "Field name: `%.*s'", len
, elem_name
);
1000 elt
+= 4 + BYTES_TO_EXP_ELEM (len
+ 1);
1007 len
= exp
->elts
[elt
++].longconst
;
1008 fprintf_filtered (stream
, "%s TypeInstance: ", plongest (len
));
1011 fprintf_filtered (stream
, "Type @");
1012 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
1013 fprintf_filtered (stream
, " (");
1014 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
1015 fprintf_filtered (stream
, ")");
1018 fputs_filtered (", ", stream
);
1020 /* Ending LEN and ending TYPE_INSTANCE. */
1022 elt
= dump_subexp (exp
, stream
, elt
);
1027 case MULTI_SUBSCRIPT
:
1028 case OP_F77_UNDETERMINED_ARGLIST
:
1036 fprintf_filtered (stream
, "Unknown format");
1043 dump_prefix_expression (struct expression
*exp
, struct ui_file
*stream
)
1047 fprintf_filtered (stream
, "Dump of expression @ ");
1048 gdb_print_host_address (exp
, stream
);
1049 fputs_filtered (", after conversion to prefix form:\nExpression: `", stream
);
1050 print_expression (exp
, stream
);
1051 fprintf_filtered (stream
, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",
1052 exp
->language_defn
->la_name
, exp
->nelts
,
1053 (long) sizeof (union exp_element
));
1054 fputs_filtered ("\n", stream
);
1056 for (elt
= 0; elt
< exp
->nelts
;)
1057 elt
= dump_subexp (exp
, stream
, elt
);
1058 fputs_filtered ("\n", stream
);