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 Free 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"
39 print_expression (struct expression
*exp
, struct ui_file
*stream
)
42 print_subexp (exp
, &pc
, stream
, PREC_NULL
);
45 /* Print the subexpression of EXP that starts in position POS, on STREAM.
46 PREC is the precedence of the surrounding operator;
47 if the precedence of the main operator of this subexpression is less,
48 parentheses are needed here. */
51 print_subexp (struct expression
*exp
, int *pos
,
52 struct ui_file
*stream
, enum precedence prec
)
54 exp
->language_defn
->la_exp_desc
->print_subexp (exp
, pos
, stream
, prec
);
57 /* Standard implementation of print_subexp for use in language_defn
60 print_subexp_standard (struct expression
*exp
, int *pos
,
61 struct ui_file
*stream
, enum precedence prec
)
64 const struct op_print
*op_print_tab
;
68 int assign_modify
= 0;
69 enum exp_opcode opcode
;
70 enum precedence myprec
= PREC_NULL
;
71 /* Set to 1 for a right-associative operator. */
76 op_print_tab
= exp
->language_defn
->la_op_print_tab
;
78 opcode
= exp
->elts
[pc
].opcode
;
86 fputs_filtered (type_name_no_tag (exp
->elts
[pc
+ 1].type
), stream
);
87 fputs_filtered ("::", stream
);
88 nargs
= longest_to_int (exp
->elts
[pc
+ 2].longconst
);
89 (*pos
) += 4 + BYTES_TO_EXP_ELEM (nargs
+ 1);
90 fputs_filtered (&exp
->elts
[pc
+ 3].string
, stream
);
95 value_print (value_from_longest (exp
->elts
[pc
+ 1].type
,
96 exp
->elts
[pc
+ 2].longconst
),
97 stream
, 0, Val_no_prettyprint
);
102 value_print (value_from_double (exp
->elts
[pc
+ 1].type
,
103 exp
->elts
[pc
+ 2].doubleconst
),
104 stream
, 0, Val_no_prettyprint
);
111 b
= exp
->elts
[pc
+ 1].block
;
113 && BLOCK_FUNCTION (b
) != NULL
114 && SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b
)) != NULL
)
116 fputs_filtered (SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b
)), stream
);
117 fputs_filtered ("::", stream
);
119 fputs_filtered (SYMBOL_PRINT_NAME (exp
->elts
[pc
+ 2].symbol
), stream
);
125 fprintf_filtered (stream
, "$%d",
126 longest_to_int (exp
->elts
[pc
+ 1].longconst
));
131 const char *name
= &exp
->elts
[pc
+ 2].string
;
132 (*pos
) += 3 + BYTES_TO_EXP_ELEM (exp
->elts
[pc
+ 1].longconst
+ 1);
133 fprintf_filtered (stream
, "$%s", name
);
139 fprintf_filtered (stream
, "%s",
140 longest_to_int (exp
->elts
[pc
+ 1].longconst
)
146 fprintf_filtered (stream
, "$%s",
147 internalvar_name (exp
->elts
[pc
+ 1].internalvar
));
152 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
153 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
154 fputs_filtered (" (", stream
);
155 for (tem
= 0; tem
< nargs
; tem
++)
158 fputs_filtered (", ", stream
);
159 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
161 fputs_filtered (")", stream
);
165 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
166 (*pos
) += 3 + BYTES_TO_EXP_ELEM (nargs
+ 1);
167 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
171 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
172 (*pos
) += 3 + BYTES_TO_EXP_ELEM (nargs
+ 1);
173 /* LA_PRINT_STRING will print using the current repeat count threshold.
174 If necessary, we can temporarily set it to zero, or pass it as an
175 additional parameter to LA_PRINT_STRING. -fnf */
176 LA_PRINT_STRING (stream
, &exp
->elts
[pc
+ 2].string
, nargs
, 1, 0);
180 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
182 += 3 + BYTES_TO_EXP_ELEM ((nargs
+ HOST_CHAR_BIT
- 1) / HOST_CHAR_BIT
);
183 fprintf_unfiltered (stream
, "B'<unimplemented>'");
186 case OP_OBJC_NSSTRING
: /* Objective-C Foundation Class NSString constant. */
187 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
188 (*pos
) += 3 + BYTES_TO_EXP_ELEM (nargs
+ 1);
189 fputs_filtered ("@\"", stream
);
190 LA_PRINT_STRING (stream
, &exp
->elts
[pc
+ 2].string
, nargs
, 1, 0);
191 fputs_filtered ("\"", stream
);
194 case OP_OBJC_MSGCALL
:
195 { /* Objective C message (method) call. */
198 nargs
= longest_to_int (exp
->elts
[pc
+ 2].longconst
);
199 fprintf_unfiltered (stream
, "[");
200 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
201 if (0 == target_read_string (exp
->elts
[pc
+ 1].longconst
,
202 &selector
, 1024, NULL
))
204 error (_("bad selector"));
210 s
= alloca (strlen (selector
) + 1);
211 strcpy (s
, selector
);
212 for (tem
= 0; tem
< nargs
; tem
++)
214 nextS
= strchr (s
, ':');
216 fprintf_unfiltered (stream
, " %s: ", s
);
218 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
223 fprintf_unfiltered (stream
, " %s", selector
);
225 fprintf_unfiltered (stream
, "]");
226 /* "selector" was malloc'd by target_read_string. Free it. */
233 nargs
= longest_to_int (exp
->elts
[pc
+ 2].longconst
);
234 nargs
-= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
237 if (exp
->elts
[pc
+ 4].opcode
== OP_LONG
238 && exp
->elts
[pc
+ 5].type
== builtin_type_char
239 && exp
->language_defn
->la_language
== language_c
)
241 /* Attempt to print C character arrays using string syntax.
242 Walk through the args, picking up one character from each
243 of the OP_LONG expression elements. If any array element
244 does not match our expection of what we should find for
245 a simple string, revert back to array printing. Note that
246 the last expression element is an explicit null terminator
247 byte, which doesn't get printed. */
248 tempstr
= alloca (nargs
);
252 if (exp
->elts
[pc
].opcode
!= OP_LONG
253 || exp
->elts
[pc
+ 1].type
!= builtin_type_char
)
255 /* Not a simple array of char, use regular array printing. */
262 longest_to_int (exp
->elts
[pc
+ 2].longconst
);
269 LA_PRINT_STRING (stream
, tempstr
, nargs
- 1, 1, 0);
274 fputs_filtered (" {", stream
);
275 for (tem
= 0; tem
< nargs
; tem
++)
279 fputs_filtered (", ", stream
);
281 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
283 fputs_filtered ("}", stream
);
288 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
289 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
290 /* Gcc support both these syntaxes. Unsure which is preferred. */
292 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
293 fputs_filtered (": ", stream
);
295 fputs_filtered (".", stream
);
296 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
297 fputs_filtered ("=", stream
);
299 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
303 if ((int) prec
> (int) PREC_COMMA
)
304 fputs_filtered ("(", stream
);
305 /* Print the subexpressions, forcing parentheses
306 around any binary operations within them.
307 This is more parentheses than are strictly necessary,
308 but it looks clearer. */
309 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
310 fputs_filtered (" ? ", stream
);
311 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
312 fputs_filtered (" : ", stream
);
313 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
314 if ((int) prec
> (int) PREC_COMMA
)
315 fputs_filtered (")", stream
);
319 case TERNOP_SLICE_COUNT
:
320 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
321 fputs_filtered ("(", stream
);
322 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
323 fputs_filtered (opcode
== TERNOP_SLICE
? " : " : " UP ", stream
);
324 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
325 fputs_filtered (")", stream
);
328 case STRUCTOP_STRUCT
:
329 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
330 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
331 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
332 fputs_filtered (".", stream
);
333 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
336 /* Will not occur for Modula-2 */
338 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
339 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
340 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
341 fputs_filtered ("->", stream
);
342 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
345 case STRUCTOP_MEMBER
:
346 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
347 fputs_filtered (".*", stream
);
348 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
352 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
353 fputs_filtered ("->*", stream
);
354 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
357 case BINOP_SUBSCRIPT
:
358 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
359 fputs_filtered ("[", stream
);
360 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
361 fputs_filtered ("]", stream
);
364 case UNOP_POSTINCREMENT
:
365 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
366 fputs_filtered ("++", stream
);
369 case UNOP_POSTDECREMENT
:
370 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
371 fputs_filtered ("--", stream
);
376 if ((int) prec
> (int) PREC_PREFIX
)
377 fputs_filtered ("(", stream
);
378 fputs_filtered ("(", stream
);
379 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
380 fputs_filtered (") ", stream
);
381 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
382 if ((int) prec
> (int) PREC_PREFIX
)
383 fputs_filtered (")", stream
);
388 if ((int) prec
> (int) PREC_PREFIX
)
389 fputs_filtered ("(", stream
);
390 if (TYPE_CODE (exp
->elts
[pc
+ 1].type
) == TYPE_CODE_FUNC
&&
391 exp
->elts
[pc
+ 3].opcode
== OP_LONG
)
393 /* We have a minimal symbol fn, probably. It's encoded
394 as a UNOP_MEMVAL (function-type) of an OP_LONG (int, address).
395 Swallow the OP_LONG (including both its opcodes); ignore
396 its type; print the value in the type of the MEMVAL. */
398 val
= value_at_lazy (exp
->elts
[pc
+ 1].type
,
399 (CORE_ADDR
) exp
->elts
[pc
+ 5].longconst
);
400 value_print (val
, stream
, 0, Val_no_prettyprint
);
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
);
409 if ((int) prec
> (int) PREC_PREFIX
)
410 fputs_filtered (")", stream
);
413 case UNOP_MEMVAL_TLS
:
415 if ((int) prec
> (int) PREC_PREFIX
)
416 fputs_filtered ("(", stream
);
417 fputs_filtered ("{", stream
);
418 type_print (exp
->elts
[pc
+ 2].type
, "", stream
, 0);
419 fputs_filtered ("} ", stream
);
420 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
421 if ((int) prec
> (int) PREC_PREFIX
)
422 fputs_filtered (")", stream
);
425 case BINOP_ASSIGN_MODIFY
:
426 opcode
= exp
->elts
[pc
+ 1].opcode
;
428 myprec
= PREC_ASSIGN
;
432 for (tem
= 0; op_print_tab
[tem
].opcode
!= OP_NULL
; tem
++)
433 if (op_print_tab
[tem
].opcode
== opcode
)
435 op_str
= op_print_tab
[tem
].string
;
438 if (op_print_tab
[tem
].opcode
!= opcode
)
439 /* Not found; don't try to keep going because we don't know how
440 to interpret further elements. */
441 error (_("Invalid expression"));
448 fputs_filtered ("this", stream
);
451 /* Objective-C ops */
455 fputs_filtered ("self", stream
); /* The ObjC equivalent of "this". */
460 case MULTI_SUBSCRIPT
:
462 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
463 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
464 fprintf_unfiltered (stream
, " [");
465 for (tem
= 0; tem
< nargs
; tem
++)
468 fprintf_unfiltered (stream
, ", ");
469 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
471 fprintf_unfiltered (stream
, "]");
476 fprintf_unfiltered (stream
, "VAL(");
477 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
478 fprintf_unfiltered (stream
, ",");
479 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
480 fprintf_unfiltered (stream
, ")");
485 error (_("print_subexp: Not implemented."));
491 for (tem
= 0; op_print_tab
[tem
].opcode
!= OP_NULL
; tem
++)
492 if (op_print_tab
[tem
].opcode
== opcode
)
494 op_str
= op_print_tab
[tem
].string
;
495 myprec
= op_print_tab
[tem
].precedence
;
496 assoc
= op_print_tab
[tem
].right_assoc
;
499 if (op_print_tab
[tem
].opcode
!= opcode
)
500 /* Not found; don't try to keep going because we don't know how
501 to interpret further elements. For example, this happens
502 if opcode is OP_TYPE. */
503 error (_("Invalid expression"));
506 /* Note that PREC_BUILTIN will always emit parentheses. */
507 if ((int) myprec
< (int) prec
)
508 fputs_filtered ("(", stream
);
509 if ((int) opcode
> (int) BINOP_END
)
513 /* Unary postfix operator. */
514 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
515 fputs_filtered (op_str
, stream
);
519 /* Unary prefix operator. */
520 fputs_filtered (op_str
, stream
);
521 if (myprec
== PREC_BUILTIN_FUNCTION
)
522 fputs_filtered ("(", stream
);
523 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
524 if (myprec
== PREC_BUILTIN_FUNCTION
)
525 fputs_filtered (")", stream
);
530 /* Binary operator. */
531 /* Print left operand.
532 If operator is right-associative,
533 increment precedence for this operand. */
534 print_subexp (exp
, pos
, stream
,
535 (enum precedence
) ((int) myprec
+ assoc
));
536 /* Print the operator itself. */
538 fprintf_filtered (stream
, " %s= ", op_str
);
539 else if (op_str
[0] == ',')
540 fprintf_filtered (stream
, "%s ", op_str
);
542 fprintf_filtered (stream
, " %s ", op_str
);
543 /* Print right operand.
544 If operator is left-associative,
545 increment precedence for this operand. */
546 print_subexp (exp
, pos
, stream
,
547 (enum precedence
) ((int) myprec
+ !assoc
));
550 if ((int) myprec
< (int) prec
)
551 fputs_filtered (")", stream
);
554 /* Return the operator corresponding to opcode OP as
555 a string. NULL indicates that the opcode was not found in the
556 current language table. */
558 op_string (enum exp_opcode op
)
561 const struct op_print
*op_print_tab
;
563 op_print_tab
= current_language
->la_op_print_tab
;
564 for (tem
= 0; op_print_tab
[tem
].opcode
!= OP_NULL
; tem
++)
565 if (op_print_tab
[tem
].opcode
== op
)
566 return op_print_tab
[tem
].string
;
570 /* Support for dumping the raw data from expressions in a human readable
573 static char *op_name (struct expression
*, enum exp_opcode
);
574 static int dump_subexp_body (struct expression
*exp
, struct ui_file
*, int);
576 /* Name for OPCODE, when it appears in expression EXP. */
579 op_name (struct expression
*exp
, enum exp_opcode opcode
)
581 return exp
->language_defn
->la_exp_desc
->op_name (opcode
);
584 /* Default name for the standard operator OPCODE (i.e., one defined in
585 the definition of enum exp_opcode). */
588 op_name_standard (enum exp_opcode opcode
)
596 sprintf (buf
, "<unknown %d>", opcode
);
617 case BINOP_LOGICAL_AND
:
618 return "BINOP_LOGICAL_AND";
619 case BINOP_LOGICAL_OR
:
620 return "BINOP_LOGICAL_OR";
621 case BINOP_BITWISE_AND
:
622 return "BINOP_BITWISE_AND";
623 case BINOP_BITWISE_IOR
:
624 return "BINOP_BITWISE_IOR";
625 case BINOP_BITWISE_XOR
:
626 return "BINOP_BITWISE_XOR";
628 return "BINOP_EQUAL";
630 return "BINOP_NOTEQUAL";
640 return "BINOP_REPEAT";
642 return "BINOP_ASSIGN";
644 return "BINOP_COMMA";
645 case BINOP_SUBSCRIPT
:
646 return "BINOP_SUBSCRIPT";
647 case MULTI_SUBSCRIPT
:
648 return "MULTI_SUBSCRIPT";
655 case STRUCTOP_MEMBER
:
656 return "STRUCTOP_MEMBER";
658 return "STRUCTOP_MPTR";
660 return "BINOP_INTDIV";
661 case BINOP_ASSIGN_MODIFY
:
662 return "BINOP_ASSIGN_MODIFY";
670 return "BINOP_CONCAT";
672 return "BINOP_RANGE";
676 return "TERNOP_COND";
678 return "TERNOP_SLICE";
679 case TERNOP_SLICE_COUNT
:
680 return "TERNOP_SLICE_COUNT";
686 return "OP_VAR_VALUE";
690 return "OP_REGISTER";
692 return "OP_INTERNALVAR";
698 return "OP_BITSTRING";
704 return "UNOP_MEMVAL";
705 case UNOP_MEMVAL_TLS
:
706 return "UNOP_MEMVAL_TLS";
709 case UNOP_LOGICAL_NOT
:
710 return "UNOP_LOGICAL_NOT";
711 case UNOP_COMPLEMENT
:
712 return "UNOP_COMPLEMENT";
717 case UNOP_PREINCREMENT
:
718 return "UNOP_PREINCREMENT";
719 case UNOP_POSTINCREMENT
:
720 return "UNOP_POSTINCREMENT";
721 case UNOP_PREDECREMENT
:
722 return "UNOP_PREDECREMENT";
723 case UNOP_POSTDECREMENT
:
724 return "UNOP_POSTDECREMENT";
726 return "UNOP_SIZEOF";
732 return "UNOP_LENGTH";
758 return "OP_M2_STRING";
759 case STRUCTOP_STRUCT
:
760 return "STRUCTOP_STRUCT";
762 return "STRUCTOP_PTR";
766 return "OP_OBJC_SELF";
777 dump_raw_expression (struct expression
*exp
, struct ui_file
*stream
,
785 fprintf_filtered (stream
, "Dump of expression @ ");
786 gdb_print_host_address (exp
, stream
);
787 fprintf_filtered (stream
, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",
788 exp
->language_defn
->la_name
, exp
->nelts
,
789 (long) sizeof (union exp_element
));
790 fprintf_filtered (stream
, "\t%5s %20s %16s %s\n", "Index", "Opcode",
791 "Hex Value", "String Value");
792 for (elt
= 0; elt
< exp
->nelts
; elt
++)
794 fprintf_filtered (stream
, "\t%5d ", elt
);
795 opcode_name
= op_name (exp
, exp
->elts
[elt
].opcode
);
797 fprintf_filtered (stream
, "%20s ", opcode_name
);
798 print_longest (stream
, 'd', 0, exp
->elts
[elt
].longconst
);
799 fprintf_filtered (stream
, " ");
801 for (eltscan
= (char *) &exp
->elts
[elt
],
802 eltsize
= sizeof (union exp_element
);
806 fprintf_filtered (stream
, "%c",
807 isprint (*eltscan
) ? (*eltscan
& 0xFF) : '.');
809 fprintf_filtered (stream
, "\n");
813 /* Dump the subexpression of prefix expression EXP whose operator is at
814 position ELT onto STREAM. Returns the position of the next
815 subexpression in EXP. */
818 dump_subexp (struct expression
*exp
, struct ui_file
*stream
, int elt
)
820 static int indent
= 0;
823 fprintf_filtered (stream
, "\n");
824 fprintf_filtered (stream
, "\t%5d ", elt
);
826 for (i
= 1; i
<= indent
; i
++)
827 fprintf_filtered (stream
, " ");
830 fprintf_filtered (stream
, "%-20s ", op_name (exp
, exp
->elts
[elt
].opcode
));
832 elt
= dump_subexp_body (exp
, stream
, elt
);
839 /* Dump the operands of prefix expression EXP whose opcode is at
840 position ELT onto STREAM. Returns the position of the next
841 subexpression in EXP. */
844 dump_subexp_body (struct expression
*exp
, struct ui_file
*stream
, int elt
)
846 return exp
->language_defn
->la_exp_desc
->dump_subexp_body (exp
, stream
, elt
);
849 /* Default value for subexp_body in exp_descriptor vector. */
852 dump_subexp_body_standard (struct expression
*exp
,
853 struct ui_file
*stream
, int elt
)
855 int opcode
= exp
->elts
[elt
++].opcode
;
861 case TERNOP_SLICE_COUNT
:
862 elt
= dump_subexp (exp
, stream
, elt
);
871 case BINOP_LOGICAL_AND
:
872 case BINOP_LOGICAL_OR
:
873 case BINOP_BITWISE_AND
:
874 case BINOP_BITWISE_IOR
:
875 case BINOP_BITWISE_XOR
:
885 case BINOP_SUBSCRIPT
:
890 case BINOP_ASSIGN_MODIFY
:
898 case STRUCTOP_MEMBER
:
900 elt
= dump_subexp (exp
, stream
, elt
);
902 case UNOP_LOGICAL_NOT
:
903 case UNOP_COMPLEMENT
:
906 case UNOP_PREINCREMENT
:
907 case UNOP_POSTINCREMENT
:
908 case UNOP_PREDECREMENT
:
909 case UNOP_POSTDECREMENT
:
928 elt
= dump_subexp (exp
, stream
, elt
);
931 fprintf_filtered (stream
, "Type @");
932 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
933 fprintf_filtered (stream
, " (");
934 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
935 fprintf_filtered (stream
, "), value %ld (0x%lx)",
936 (long) exp
->elts
[elt
+ 1].longconst
,
937 (long) exp
->elts
[elt
+ 1].longconst
);
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
, "), value %g",
946 (double) exp
->elts
[elt
+ 1].doubleconst
);
950 fprintf_filtered (stream
, "Block @");
951 gdb_print_host_address (exp
->elts
[elt
].block
, stream
);
952 fprintf_filtered (stream
, ", symbol @");
953 gdb_print_host_address (exp
->elts
[elt
+ 1].symbol
, stream
);
954 fprintf_filtered (stream
, " (%s)",
955 DEPRECATED_SYMBOL_NAME (exp
->elts
[elt
+ 1].symbol
));
959 fprintf_filtered (stream
, "History element %ld",
960 (long) exp
->elts
[elt
].longconst
);
964 fprintf_filtered (stream
, "Register $%s", &exp
->elts
[elt
+ 1].string
);
965 elt
+= 3 + BYTES_TO_EXP_ELEM (exp
->elts
[elt
].longconst
+ 1);
968 fprintf_filtered (stream
, "Internal var @");
969 gdb_print_host_address (exp
->elts
[elt
].internalvar
, stream
);
970 fprintf_filtered (stream
, " (%s)",
971 exp
->elts
[elt
].internalvar
->name
);
978 nargs
= longest_to_int (exp
->elts
[elt
].longconst
);
980 fprintf_filtered (stream
, "Number of args: %d", nargs
);
983 for (i
= 1; i
<= nargs
+ 1; i
++)
984 elt
= dump_subexp (exp
, stream
, elt
);
992 lower
= longest_to_int (exp
->elts
[elt
].longconst
);
993 upper
= longest_to_int (exp
->elts
[elt
+ 1].longconst
);
995 fprintf_filtered (stream
, "Bounds [%d:%d]", lower
, upper
);
998 for (i
= 1; i
<= upper
- lower
+ 1; i
++)
999 elt
= dump_subexp (exp
, stream
, elt
);
1004 fprintf_filtered (stream
, "Type @");
1005 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
1006 fprintf_filtered (stream
, " (");
1007 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
1008 fprintf_filtered (stream
, ")");
1009 elt
= dump_subexp (exp
, stream
, elt
+ 2);
1011 case UNOP_MEMVAL_TLS
:
1012 fprintf_filtered (stream
, "TLS type @");
1013 gdb_print_host_address (exp
->elts
[elt
+ 1].type
, stream
);
1014 fprintf_filtered (stream
, " (__thread /* \"%s\" */ ",
1015 (exp
->elts
[elt
].objfile
== NULL
? "(null)"
1016 : exp
->elts
[elt
].objfile
->name
));
1017 type_print (exp
->elts
[elt
+ 1].type
, NULL
, stream
, 0);
1018 fprintf_filtered (stream
, ")");
1019 elt
= dump_subexp (exp
, stream
, elt
+ 3);
1022 fprintf_filtered (stream
, "Type @");
1023 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
1024 fprintf_filtered (stream
, " (");
1025 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
1026 fprintf_filtered (stream
, ")");
1029 case STRUCTOP_STRUCT
:
1035 len
= longest_to_int (exp
->elts
[elt
].longconst
);
1036 elem_name
= &exp
->elts
[elt
+ 1].string
;
1038 fprintf_filtered (stream
, "Element name: `%.*s'", len
, elem_name
);
1039 elt
= dump_subexp (exp
, stream
, elt
+ 3 + BYTES_TO_EXP_ELEM (len
+ 1));
1047 fprintf_filtered (stream
, "Type @");
1048 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
1049 fprintf_filtered (stream
, " (");
1050 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
1051 fprintf_filtered (stream
, ") ");
1053 len
= longest_to_int (exp
->elts
[elt
+ 1].longconst
);
1054 elem_name
= &exp
->elts
[elt
+ 2].string
;
1056 fprintf_filtered (stream
, "Field name: `%.*s'", len
, elem_name
);
1057 elt
+= 4 + BYTES_TO_EXP_ELEM (len
+ 1);
1062 case MULTI_SUBSCRIPT
:
1063 case OP_F77_UNDETERMINED_ARGLIST
:
1072 fprintf_filtered (stream
, "Unknown format");
1079 dump_prefix_expression (struct expression
*exp
, struct ui_file
*stream
)
1083 fprintf_filtered (stream
, "Dump of expression @ ");
1084 gdb_print_host_address (exp
, stream
);
1085 fputs_filtered (", after conversion to prefix form:\nExpression: `", stream
);
1086 if (exp
->elts
[0].opcode
!= OP_TYPE
)
1087 print_expression (exp
, stream
);
1089 fputs_filtered ("Type printing not yet supported....", stream
);
1090 fprintf_filtered (stream
, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",
1091 exp
->language_defn
->la_name
, exp
->nelts
,
1092 (long) sizeof (union exp_element
));
1093 fputs_filtered ("\n", stream
);
1095 for (elt
= 0; elt
< exp
->nelts
;)
1096 elt
= dump_subexp (exp
, stream
, elt
);
1097 fputs_filtered ("\n", stream
);