1 /* Support for printing Chill values for GDB, the GNU debugger.
2 Copyright 1986, 1988, 1989, 1991 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
25 #include "expression.h"
29 /* Print data of type TYPE located at VALADDR (within GDB), which came from
30 the inferior at address ADDRESS, onto stdio stream STREAM according to
31 FORMAT (a letter or 0 for natural format). The data at VALADDR is in
34 If the data are a string pointer, returns the number of string characters
37 If DEREF_REF is nonzero, then dereference references, otherwise just print
40 The PRETTY parameter controls prettyprinting. */
43 chill_val_print (type
, valaddr
, address
, stream
, format
, deref_ref
, recurse
,
52 enum val_prettyprint pretty
;
55 unsigned int i
= 0; /* Number of characters printed. */
60 switch (TYPE_CODE (type
))
63 if (TYPE_LENGTH (type
) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type
)) > 0)
65 if (prettyprint_arrays
)
67 print_spaces_filtered (2 + 2 * recurse
, stream
);
69 fprintf_filtered (stream
, "[");
70 val_print_array_elements (type
, valaddr
, address
, stream
, format
,
71 deref_ref
, recurse
, pretty
, 0);
72 fprintf_filtered (stream
, "]");
76 error ("unimplemented in chill_val_print; unspecified array length");
81 format
= format
? format
: output_format
;
84 print_scalar_formatted (valaddr
, type
, format
, 0, stream
);
88 val_print_type_code_int (type
, valaddr
, stream
);
93 format
= format
? format
: output_format
;
96 print_scalar_formatted (valaddr
, type
, format
, 0, stream
);
100 LA_PRINT_CHAR ((unsigned char) unpack_long (type
, valaddr
),
108 print_scalar_formatted (valaddr
, type
, format
, 0, stream
);
112 print_floating (valaddr
, type
, stream
);
117 format
= format
? format
: output_format
;
120 print_scalar_formatted (valaddr
, type
, format
, 0, stream
);
124 val
= unpack_long (builtin_type_chill_bool
, valaddr
);
125 fprintf_filtered (stream
, val
? "TRUE" : "FALSE");
129 case TYPE_CODE_UNDEF
:
130 /* This happens (without TYPE_FLAG_STUB set) on systems which don't use
131 dbx xrefs (NO_DBX_XREFS in gcc) if a file has a "struct foo *bar"
132 and no complete type for struct foo in that file. */
133 fprintf_filtered (stream
, "<incomplete type>");
137 if (format
&& format
!= 's')
139 print_scalar_formatted (valaddr
, type
, format
, 0, stream
);
142 addr
= unpack_pointer (type
, valaddr
);
143 elttype
= TYPE_TARGET_TYPE (type
);
145 if (TYPE_CODE (elttype
) == TYPE_CODE_FUNC
)
147 /* Try to print what function it points to. */
148 print_address_demangle (addr
, stream
, demangle
);
149 /* Return value is irrelevant except for string pointers. */
152 if (addressprint
&& format
!= 's')
154 fprintf_filtered (stream
, "0x%x", addr
);
157 /* For a pointer to char or unsigned char, also print the string
158 pointed to, unless pointer is null. */
159 if (TYPE_LENGTH (elttype
) == 1
160 && TYPE_CODE (elttype
) == TYPE_CODE_CHAR
161 && (format
== 0 || format
== 's')
163 && /* If print_max is UINT_MAX, the alloca below will fail.
164 In that case don't try to print the string. */
165 print_max
< UINT_MAX
)
167 i
= val_print_string (addr
, stream
);
169 /* Return number of characters printed, plus one for the
170 terminating null if we have "reached the end". */
171 return (i
+ (print_max
&& i
!= print_max
));
174 case TYPE_CODE_STRING
:
175 if (format
&& format
!= 's')
177 print_scalar_formatted (valaddr
, type
, format
, 0, stream
);
180 if (addressprint
&& format
!= 's')
182 fprintf_filtered (stream
, "0x%x ", addr
);
184 i
= TYPE_LENGTH (type
);
185 LA_PRINT_STRING (stream
, valaddr
, i
, 0);
186 /* Return number of characters printed, plus one for the terminating
187 null if we have "reached the end". */
188 return (i
+ (print_max
&& i
!= print_max
));
191 case TYPE_CODE_MEMBER
:
193 case TYPE_CODE_UNION
:
194 case TYPE_CODE_STRUCT
:
198 case TYPE_CODE_ERROR
:
199 case TYPE_CODE_RANGE
:
200 error ("Unimplemented chill_val_print support for type %d",
205 error ("Invalid Chill type code %d in symbol table.", TYPE_CODE (type
));
This page took 0.034129 seconds and 4 git commands to generate.