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
);
214 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
216 += 3 + BYTES_TO_EXP_ELEM ((nargs
+ HOST_CHAR_BIT
- 1) / HOST_CHAR_BIT
);
217 fprintf_unfiltered (stream
, "B'<unimplemented>'");
220 case OP_OBJC_NSSTRING
: /* Objective-C Foundation Class
221 NSString constant. */
223 struct value_print_options opts
;
225 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
226 (*pos
) += 3 + BYTES_TO_EXP_ELEM (nargs
+ 1);
227 fputs_filtered ("@\"", stream
);
228 get_user_print_options (&opts
);
229 LA_PRINT_STRING (stream
, builtin_type (exp
->gdbarch
)->builtin_char
,
230 &exp
->elts
[pc
+ 2].string
, nargs
, NULL
, 0, &opts
);
231 fputs_filtered ("\"", stream
);
235 case OP_OBJC_MSGCALL
:
236 { /* Objective C message (method) call. */
240 nargs
= longest_to_int (exp
->elts
[pc
+ 2].longconst
);
241 fprintf_unfiltered (stream
, "[");
242 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
243 if (0 == target_read_string (exp
->elts
[pc
+ 1].longconst
,
244 &selector
, 1024, NULL
))
246 error (_("bad selector"));
253 s
= alloca (strlen (selector
) + 1);
254 strcpy (s
, selector
);
255 for (tem
= 0; tem
< nargs
; tem
++)
257 nextS
= strchr (s
, ':');
258 gdb_assert (nextS
); /* Make sure we found ':'. */
260 fprintf_unfiltered (stream
, " %s: ", s
);
262 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
267 fprintf_unfiltered (stream
, " %s", selector
);
269 fprintf_unfiltered (stream
, "]");
270 /* "selector" was malloc'd by target_read_string. Free it. */
277 nargs
= longest_to_int (exp
->elts
[pc
+ 2].longconst
);
278 nargs
-= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
281 if (exp
->elts
[pc
+ 4].opcode
== OP_LONG
282 && exp
->elts
[pc
+ 5].type
283 == builtin_type (exp
->gdbarch
)->builtin_char
284 && exp
->language_defn
->la_language
== language_c
)
286 /* Attempt to print C character arrays using string syntax.
287 Walk through the args, picking up one character from each
288 of the OP_LONG expression elements. If any array element
289 does not match our expection of what we should find for
290 a simple string, revert back to array printing. Note that
291 the last expression element is an explicit null terminator
292 byte, which doesn't get printed. */
293 tempstr
= alloca (nargs
);
297 if (exp
->elts
[pc
].opcode
!= OP_LONG
298 || exp
->elts
[pc
+ 1].type
299 != builtin_type (exp
->gdbarch
)->builtin_char
)
301 /* Not a simple array of char, use regular array
309 longest_to_int (exp
->elts
[pc
+ 2].longconst
);
316 struct value_print_options opts
;
318 get_user_print_options (&opts
);
319 LA_PRINT_STRING (stream
, builtin_type (exp
->gdbarch
)->builtin_char
,
320 tempstr
, nargs
- 1, NULL
, 0, &opts
);
325 fputs_filtered (" {", stream
);
326 for (tem
= 0; tem
< nargs
; tem
++)
330 fputs_filtered (", ", stream
);
332 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
334 fputs_filtered ("}", stream
);
339 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
340 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
341 /* Gcc support both these syntaxes. Unsure which is preferred. */
343 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
344 fputs_filtered (": ", stream
);
346 fputs_filtered (".", stream
);
347 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
348 fputs_filtered ("=", stream
);
350 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
354 if ((int) prec
> (int) PREC_COMMA
)
355 fputs_filtered ("(", stream
);
356 /* Print the subexpressions, forcing parentheses
357 around any binary operations within them.
358 This is more parentheses than are strictly necessary,
359 but it looks clearer. */
360 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
361 fputs_filtered (" ? ", stream
);
362 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
363 fputs_filtered (" : ", stream
);
364 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
365 if ((int) prec
> (int) PREC_COMMA
)
366 fputs_filtered (")", stream
);
370 case TERNOP_SLICE_COUNT
:
371 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
372 fputs_filtered ("(", stream
);
373 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
374 fputs_filtered (opcode
== TERNOP_SLICE
? " : " : " UP ", stream
);
375 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
376 fputs_filtered (")", stream
);
379 case STRUCTOP_STRUCT
:
380 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
381 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
382 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
383 fputs_filtered (".", stream
);
384 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
387 /* Will not occur for Modula-2. */
389 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
390 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
391 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
392 fputs_filtered ("->", stream
);
393 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
396 case STRUCTOP_MEMBER
:
397 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
398 fputs_filtered (".*", stream
);
399 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
403 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
404 fputs_filtered ("->*", stream
);
405 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
408 case BINOP_SUBSCRIPT
:
409 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
410 fputs_filtered ("[", stream
);
411 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
412 fputs_filtered ("]", stream
);
415 case UNOP_POSTINCREMENT
:
416 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
417 fputs_filtered ("++", stream
);
420 case UNOP_POSTDECREMENT
:
421 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
422 fputs_filtered ("--", stream
);
427 if ((int) prec
> (int) PREC_PREFIX
)
428 fputs_filtered ("(", stream
);
429 fputs_filtered ("(", stream
);
430 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
431 fputs_filtered (") ", stream
);
432 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
433 if ((int) prec
> (int) PREC_PREFIX
)
434 fputs_filtered (")", stream
);
438 if ((int) prec
> (int) PREC_PREFIX
)
439 fputs_filtered ("(", stream
);
440 fputs_filtered ("(", stream
);
441 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
442 fputs_filtered (") ", stream
);
443 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
444 if ((int) prec
> (int) PREC_PREFIX
)
445 fputs_filtered (")", stream
);
448 case UNOP_DYNAMIC_CAST
:
449 case UNOP_REINTERPRET_CAST
:
450 fputs_filtered (opcode
== UNOP_DYNAMIC_CAST
? "dynamic_cast"
451 : "reinterpret_cast", stream
);
452 fputs_filtered ("<", stream
);
453 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
454 fputs_filtered ("> (", stream
);
455 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
456 fputs_filtered (")", stream
);
461 if ((int) prec
> (int) PREC_PREFIX
)
462 fputs_filtered ("(", stream
);
463 if (TYPE_CODE (exp
->elts
[pc
+ 1].type
) == TYPE_CODE_FUNC
464 && exp
->elts
[pc
+ 3].opcode
== OP_LONG
)
466 struct value_print_options opts
;
468 /* We have a minimal symbol fn, probably. It's encoded
469 as a UNOP_MEMVAL (function-type) of an OP_LONG (int, address).
470 Swallow the OP_LONG (including both its opcodes); ignore
471 its type; print the value in the type of the MEMVAL. */
473 val
= value_at_lazy (exp
->elts
[pc
+ 1].type
,
474 (CORE_ADDR
) exp
->elts
[pc
+ 5].longconst
);
475 get_raw_print_options (&opts
);
476 value_print (val
, stream
, &opts
);
480 fputs_filtered ("{", stream
);
481 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
482 fputs_filtered ("} ", stream
);
483 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
485 if ((int) prec
> (int) PREC_PREFIX
)
486 fputs_filtered (")", stream
);
489 case UNOP_MEMVAL_TYPE
:
490 if ((int) prec
> (int) PREC_PREFIX
)
491 fputs_filtered ("(", stream
);
492 fputs_filtered ("{", stream
);
493 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
494 fputs_filtered ("} ", stream
);
495 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
496 if ((int) prec
> (int) PREC_PREFIX
)
497 fputs_filtered (")", stream
);
500 case UNOP_MEMVAL_TLS
:
502 if ((int) prec
> (int) PREC_PREFIX
)
503 fputs_filtered ("(", stream
);
504 fputs_filtered ("{", stream
);
505 type_print (exp
->elts
[pc
+ 2].type
, "", stream
, 0);
506 fputs_filtered ("} ", stream
);
507 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
508 if ((int) prec
> (int) PREC_PREFIX
)
509 fputs_filtered (")", stream
);
512 case BINOP_ASSIGN_MODIFY
:
513 opcode
= exp
->elts
[pc
+ 1].opcode
;
515 myprec
= PREC_ASSIGN
;
519 for (tem
= 0; op_print_tab
[tem
].opcode
!= OP_NULL
; tem
++)
520 if (op_print_tab
[tem
].opcode
== opcode
)
522 op_str
= op_print_tab
[tem
].string
;
525 if (op_print_tab
[tem
].opcode
!= opcode
)
526 /* Not found; don't try to keep going because we don't know how
527 to interpret further elements. */
528 error (_("Invalid expression"));
535 if (exp
->language_defn
->la_name_of_this
)
536 fputs_filtered (exp
->language_defn
->la_name_of_this
, stream
);
538 fprintf_filtered (stream
, _("<language %s has no 'this'>"),
539 exp
->language_defn
->la_name
);
544 case MULTI_SUBSCRIPT
:
546 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
547 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
548 fprintf_unfiltered (stream
, " [");
549 for (tem
= 0; tem
< nargs
; tem
++)
552 fprintf_unfiltered (stream
, ", ");
553 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
555 fprintf_unfiltered (stream
, "]");
560 fprintf_unfiltered (stream
, "VAL(");
561 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
562 fprintf_unfiltered (stream
, ",");
563 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
564 fprintf_unfiltered (stream
, ")");
569 LONGEST count
= exp
->elts
[pc
+ 1].longconst
;
573 fputs_unfiltered ("TypesInstance(", stream
);
576 type_print (exp
->elts
[(*pos
)++].type
, "", stream
, 0);
578 fputs_unfiltered (",", stream
);
580 fputs_unfiltered (",", stream
);
581 /* Ending COUNT and ending TYPE_INSTANCE. */
583 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
584 fputs_unfiltered (")", stream
);
592 for (tem
= 0; op_print_tab
[tem
].opcode
!= OP_NULL
; tem
++)
593 if (op_print_tab
[tem
].opcode
== opcode
)
595 op_str
= op_print_tab
[tem
].string
;
596 myprec
= op_print_tab
[tem
].precedence
;
597 assoc
= op_print_tab
[tem
].right_assoc
;
600 if (op_print_tab
[tem
].opcode
!= opcode
)
601 /* Not found; don't try to keep going because we don't know how
602 to interpret further elements. For example, this happens
603 if opcode is OP_TYPE. */
604 error (_("Invalid expression"));
607 /* Note that PREC_BUILTIN will always emit parentheses. */
608 if ((int) myprec
< (int) prec
)
609 fputs_filtered ("(", stream
);
610 if ((int) opcode
> (int) BINOP_END
)
614 /* Unary postfix operator. */
615 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
616 fputs_filtered (op_str
, stream
);
620 /* Unary prefix operator. */
621 fputs_filtered (op_str
, stream
);
622 if (myprec
== PREC_BUILTIN_FUNCTION
)
623 fputs_filtered ("(", stream
);
624 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
625 if (myprec
== PREC_BUILTIN_FUNCTION
)
626 fputs_filtered (")", stream
);
631 /* Binary operator. */
632 /* Print left operand.
633 If operator is right-associative,
634 increment precedence for this operand. */
635 print_subexp (exp
, pos
, stream
,
636 (enum precedence
) ((int) myprec
+ assoc
));
637 /* Print the operator itself. */
639 fprintf_filtered (stream
, " %s= ", op_str
);
640 else if (op_str
[0] == ',')
641 fprintf_filtered (stream
, "%s ", op_str
);
643 fprintf_filtered (stream
, " %s ", op_str
);
644 /* Print right operand.
645 If operator is left-associative,
646 increment precedence for this operand. */
647 print_subexp (exp
, pos
, stream
,
648 (enum precedence
) ((int) myprec
+ !assoc
));
651 if ((int) myprec
< (int) prec
)
652 fputs_filtered (")", stream
);
655 /* Return the operator corresponding to opcode OP as
656 a string. NULL indicates that the opcode was not found in the
657 current language table. */
659 op_string (enum exp_opcode op
)
662 const struct op_print
*op_print_tab
;
664 op_print_tab
= current_language
->la_op_print_tab
;
665 for (tem
= 0; op_print_tab
[tem
].opcode
!= OP_NULL
; tem
++)
666 if (op_print_tab
[tem
].opcode
== op
)
667 return op_print_tab
[tem
].string
;
671 /* Support for dumping the raw data from expressions in a human readable
674 static int dump_subexp_body (struct expression
*exp
, struct ui_file
*, int);
676 /* Name for OPCODE, when it appears in expression EXP. */
679 op_name (struct expression
*exp
, enum exp_opcode opcode
)
681 return exp
->language_defn
->la_exp_desc
->op_name (opcode
);
684 /* Default name for the standard operator OPCODE (i.e., one defined in
685 the definition of enum exp_opcode). */
688 op_name_standard (enum exp_opcode opcode
)
696 sprintf (buf
, "<unknown %d>", opcode
);
702 #include "std-operator.def"
707 /* Print a raw dump of expression EXP to STREAM.
708 NOTE, if non-NULL, is printed as extra explanatory text. */
711 dump_raw_expression (struct expression
*exp
, struct ui_file
*stream
,
719 fprintf_filtered (stream
, "Dump of expression @ ");
720 gdb_print_host_address (exp
, stream
);
722 fprintf_filtered (stream
, ", %s:", note
);
723 fprintf_filtered (stream
, "\n\tLanguage %s, %d elements, %ld bytes each.\n",
724 exp
->language_defn
->la_name
, exp
->nelts
,
725 (long) sizeof (union exp_element
));
726 fprintf_filtered (stream
, "\t%5s %20s %16s %s\n", "Index", "Opcode",
727 "Hex Value", "String Value");
728 for (elt
= 0; elt
< exp
->nelts
; elt
++)
730 fprintf_filtered (stream
, "\t%5d ", elt
);
731 opcode_name
= op_name (exp
, exp
->elts
[elt
].opcode
);
733 fprintf_filtered (stream
, "%20s ", opcode_name
);
734 print_longest (stream
, 'd', 0, exp
->elts
[elt
].longconst
);
735 fprintf_filtered (stream
, " ");
737 for (eltscan
= (char *) &exp
->elts
[elt
],
738 eltsize
= sizeof (union exp_element
);
742 fprintf_filtered (stream
, "%c",
743 isprint (*eltscan
) ? (*eltscan
& 0xFF) : '.');
745 fprintf_filtered (stream
, "\n");
749 /* Dump the subexpression of prefix expression EXP whose operator is at
750 position ELT onto STREAM. Returns the position of the next
751 subexpression in EXP. */
754 dump_subexp (struct expression
*exp
, struct ui_file
*stream
, int elt
)
756 static int indent
= 0;
759 fprintf_filtered (stream
, "\n");
760 fprintf_filtered (stream
, "\t%5d ", elt
);
762 for (i
= 1; i
<= indent
; i
++)
763 fprintf_filtered (stream
, " ");
766 fprintf_filtered (stream
, "%-20s ", op_name (exp
, exp
->elts
[elt
].opcode
));
768 elt
= dump_subexp_body (exp
, stream
, elt
);
775 /* Dump the operands of prefix expression EXP whose opcode is at
776 position ELT onto STREAM. Returns the position of the next
777 subexpression in EXP. */
780 dump_subexp_body (struct expression
*exp
, struct ui_file
*stream
, int elt
)
782 return exp
->language_defn
->la_exp_desc
->dump_subexp_body (exp
, stream
, elt
);
785 /* Default value for subexp_body in exp_descriptor vector. */
788 dump_subexp_body_standard (struct expression
*exp
,
789 struct ui_file
*stream
, int elt
)
791 int opcode
= exp
->elts
[elt
++].opcode
;
797 case TERNOP_SLICE_COUNT
:
798 elt
= dump_subexp (exp
, stream
, elt
);
808 case BINOP_LOGICAL_AND
:
809 case BINOP_LOGICAL_OR
:
810 case BINOP_BITWISE_AND
:
811 case BINOP_BITWISE_IOR
:
812 case BINOP_BITWISE_XOR
:
822 case BINOP_SUBSCRIPT
:
827 case BINOP_ASSIGN_MODIFY
:
833 case STRUCTOP_MEMBER
:
835 elt
= dump_subexp (exp
, stream
, elt
);
838 case UNOP_LOGICAL_NOT
:
839 case UNOP_COMPLEMENT
:
842 case UNOP_PREINCREMENT
:
843 case UNOP_POSTINCREMENT
:
844 case UNOP_PREDECREMENT
:
845 case UNOP_POSTDECREMENT
:
858 elt
= dump_subexp (exp
, stream
, elt
);
861 fprintf_filtered (stream
, "Type @");
862 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
863 fprintf_filtered (stream
, " (");
864 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
865 fprintf_filtered (stream
, "), value %ld (0x%lx)",
866 (long) exp
->elts
[elt
+ 1].longconst
,
867 (long) exp
->elts
[elt
+ 1].longconst
);
871 fprintf_filtered (stream
, "Type @");
872 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
873 fprintf_filtered (stream
, " (");
874 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
875 fprintf_filtered (stream
, "), value %g",
876 (double) exp
->elts
[elt
+ 1].doubleconst
);
880 fprintf_filtered (stream
, "Block @");
881 gdb_print_host_address (exp
->elts
[elt
].block
, stream
);
882 fprintf_filtered (stream
, ", symbol @");
883 gdb_print_host_address (exp
->elts
[elt
+ 1].symbol
, stream
);
884 fprintf_filtered (stream
, " (%s)",
885 SYMBOL_PRINT_NAME (exp
->elts
[elt
+ 1].symbol
));
888 case OP_VAR_ENTRY_VALUE
:
889 fprintf_filtered (stream
, "Entry value of symbol @");
890 gdb_print_host_address (exp
->elts
[elt
].symbol
, stream
);
891 fprintf_filtered (stream
, " (%s)",
892 SYMBOL_PRINT_NAME (exp
->elts
[elt
].symbol
));
896 fprintf_filtered (stream
, "History element %ld",
897 (long) exp
->elts
[elt
].longconst
);
901 fprintf_filtered (stream
, "Register $%s", &exp
->elts
[elt
+ 1].string
);
902 elt
+= 3 + BYTES_TO_EXP_ELEM (exp
->elts
[elt
].longconst
+ 1);
905 fprintf_filtered (stream
, "Internal var @");
906 gdb_print_host_address (exp
->elts
[elt
].internalvar
, stream
);
907 fprintf_filtered (stream
, " (%s)",
908 internalvar_name (exp
->elts
[elt
].internalvar
));
915 nargs
= longest_to_int (exp
->elts
[elt
].longconst
);
917 fprintf_filtered (stream
, "Number of args: %d", nargs
);
920 for (i
= 1; i
<= nargs
+ 1; i
++)
921 elt
= dump_subexp (exp
, stream
, elt
);
929 lower
= longest_to_int (exp
->elts
[elt
].longconst
);
930 upper
= longest_to_int (exp
->elts
[elt
+ 1].longconst
);
932 fprintf_filtered (stream
, "Bounds [%d:%d]", lower
, upper
);
935 for (i
= 1; i
<= upper
- lower
+ 1; i
++)
936 elt
= dump_subexp (exp
, stream
, elt
);
939 case UNOP_DYNAMIC_CAST
:
940 case UNOP_REINTERPRET_CAST
:
942 case UNOP_MEMVAL_TYPE
:
943 fprintf_filtered (stream
, " (");
944 elt
= dump_subexp (exp
, stream
, elt
);
945 fprintf_filtered (stream
, ")");
946 elt
= dump_subexp (exp
, stream
, elt
);
950 fprintf_filtered (stream
, "Type @");
951 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
952 fprintf_filtered (stream
, " (");
953 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
954 fprintf_filtered (stream
, ")");
955 elt
= dump_subexp (exp
, stream
, elt
+ 2);
957 case UNOP_MEMVAL_TLS
:
958 fprintf_filtered (stream
, "TLS type @");
959 gdb_print_host_address (exp
->elts
[elt
+ 1].type
, stream
);
960 fprintf_filtered (stream
, " (__thread /* \"%s\" */ ",
961 (exp
->elts
[elt
].objfile
== NULL
? "(null)"
962 : exp
->elts
[elt
].objfile
->name
));
963 type_print (exp
->elts
[elt
+ 1].type
, NULL
, stream
, 0);
964 fprintf_filtered (stream
, ")");
965 elt
= dump_subexp (exp
, stream
, elt
+ 3);
968 fprintf_filtered (stream
, "Type @");
969 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
970 fprintf_filtered (stream
, " (");
971 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
972 fprintf_filtered (stream
, ")");
977 fprintf_filtered (stream
, "Typeof (");
978 elt
= dump_subexp (exp
, stream
, elt
);
979 fprintf_filtered (stream
, ")");
981 case STRUCTOP_STRUCT
:
987 len
= longest_to_int (exp
->elts
[elt
].longconst
);
988 elem_name
= &exp
->elts
[elt
+ 1].string
;
990 fprintf_filtered (stream
, "Element name: `%.*s'", len
, elem_name
);
991 elt
= dump_subexp (exp
, stream
, elt
+ 3 + BYTES_TO_EXP_ELEM (len
+ 1));
999 fprintf_filtered (stream
, "Type @");
1000 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
1001 fprintf_filtered (stream
, " (");
1002 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
1003 fprintf_filtered (stream
, ") ");
1005 len
= longest_to_int (exp
->elts
[elt
+ 1].longconst
);
1006 elem_name
= &exp
->elts
[elt
+ 2].string
;
1008 fprintf_filtered (stream
, "Field name: `%.*s'", len
, elem_name
);
1009 elt
+= 4 + BYTES_TO_EXP_ELEM (len
+ 1);
1016 len
= exp
->elts
[elt
++].longconst
;
1017 fprintf_filtered (stream
, "%s TypeInstance: ", plongest (len
));
1020 fprintf_filtered (stream
, "Type @");
1021 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
1022 fprintf_filtered (stream
, " (");
1023 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
1024 fprintf_filtered (stream
, ")");
1027 fputs_filtered (", ", stream
);
1029 /* Ending LEN and ending TYPE_INSTANCE. */
1031 elt
= dump_subexp (exp
, stream
, elt
);
1036 case MULTI_SUBSCRIPT
:
1037 case OP_F77_UNDETERMINED_ARGLIST
:
1046 fprintf_filtered (stream
, "Unknown format");
1053 dump_prefix_expression (struct expression
*exp
, struct ui_file
*stream
)
1057 fprintf_filtered (stream
, "Dump of expression @ ");
1058 gdb_print_host_address (exp
, stream
);
1059 fputs_filtered (", after conversion to prefix form:\nExpression: `", stream
);
1060 print_expression (exp
, stream
);
1061 fprintf_filtered (stream
, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",
1062 exp
->language_defn
->la_name
, exp
->nelts
,
1063 (long) sizeof (union exp_element
));
1064 fputs_filtered ("\n", stream
);
1066 for (elt
= 0; elt
< exp
->nelts
;)
1067 elt
= dump_subexp (exp
, stream
, elt
);
1068 fputs_filtered ("\n", stream
);