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"
31 chill_print_value_fields
PARAMS ((struct type
*, char *, FILE *, int, int,
32 enum val_prettyprint
, struct type
**));
35 /* Print data of type TYPE located at VALADDR (within GDB), which came from
36 the inferior at address ADDRESS, onto stdio stream STREAM according to
37 FORMAT (a letter or 0 for natural format). The data at VALADDR is in
40 If the data are a string pointer, returns the number of string characters
43 If DEREF_REF is nonzero, then dereference references, otherwise just print
46 The PRETTY parameter controls prettyprinting. */
49 chill_val_print (type
, valaddr
, address
, stream
, format
, deref_ref
, recurse
,
58 enum val_prettyprint pretty
;
61 unsigned int i
= 0; /* Number of characters printed. */
65 switch (TYPE_CODE (type
))
68 if (TYPE_LENGTH (type
) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type
)) > 0)
70 if (prettyprint_arrays
)
72 print_spaces_filtered (2 + 2 * recurse
, stream
);
74 fprintf_filtered (stream
, "[");
75 val_print_array_elements (type
, valaddr
, address
, stream
, format
,
76 deref_ref
, recurse
, pretty
, 0);
77 fprintf_filtered (stream
, "]");
81 error ("unimplemented in chill_val_print; unspecified array length");
86 format
= format
? format
: output_format
;
89 print_scalar_formatted (valaddr
, type
, format
, 0, stream
);
93 val_print_type_code_int (type
, valaddr
, stream
);
98 format
= format
? format
: output_format
;
101 print_scalar_formatted (valaddr
, type
, format
, 0, stream
);
105 LA_PRINT_CHAR ((unsigned char) unpack_long (type
, valaddr
),
113 print_scalar_formatted (valaddr
, type
, format
, 0, stream
);
117 print_floating (valaddr
, type
, stream
);
122 format
= format
? format
: output_format
;
125 print_scalar_formatted (valaddr
, type
, format
, 0, stream
);
129 val
= unpack_long (builtin_type_chill_bool
, valaddr
);
130 fprintf_filtered (stream
, val
? "TRUE" : "FALSE");
134 case TYPE_CODE_UNDEF
:
135 /* This happens (without TYPE_FLAG_STUB set) on systems which don't use
136 dbx xrefs (NO_DBX_XREFS in gcc) if a file has a "struct foo *bar"
137 and no complete type for struct foo in that file. */
138 fprintf_filtered (stream
, "<incomplete type>");
142 if (format
&& format
!= 's')
144 print_scalar_formatted (valaddr
, type
, format
, 0, stream
);
147 addr
= unpack_pointer (type
, valaddr
);
148 elttype
= TYPE_TARGET_TYPE (type
);
150 if (TYPE_CODE (elttype
) == TYPE_CODE_FUNC
)
152 /* Try to print what function it points to. */
153 print_address_demangle (addr
, stream
, demangle
);
154 /* Return value is irrelevant except for string pointers. */
157 if (addressprint
&& format
!= 's')
159 fprintf_filtered (stream
, "H'%x", addr
);
162 /* For a pointer to char or unsigned char, also print the string
163 pointed to, unless pointer is null. */
164 if (TYPE_LENGTH (elttype
) == 1
165 && TYPE_CODE (elttype
) == TYPE_CODE_CHAR
166 && (format
== 0 || format
== 's')
168 && /* If print_max is UINT_MAX, the alloca below will fail.
169 In that case don't try to print the string. */
170 print_max
< UINT_MAX
)
172 i
= val_print_string (addr
, 0, stream
);
174 /* Return number of characters printed, plus one for the
175 terminating null if we have "reached the end". */
176 return (i
+ (print_max
&& i
!= print_max
));
179 case TYPE_CODE_STRING
:
180 if (format
&& format
!= 's')
182 print_scalar_formatted (valaddr
, type
, format
, 0, stream
);
185 if (addressprint
&& format
!= 's')
187 /* This used to say `addr', which is unset at this point.
188 Is `address' what is meant? */
189 fprintf_filtered (stream
, "H'%x ", address
);
191 i
= TYPE_LENGTH (type
);
192 LA_PRINT_STRING (stream
, valaddr
, i
, 0);
193 /* Return number of characters printed, plus one for the terminating
194 null if we have "reached the end". */
195 return (i
+ (print_max
&& i
!= print_max
));
198 case TYPE_CODE_STRUCT
:
199 chill_print_value_fields (type
, valaddr
, stream
, format
, recurse
, pretty
,
206 fprintf_filtered (stream
, "LOC(H'%lx)",
207 unpack_long (builtin_type_int
, valaddr
));
209 fputs_filtered (": ", stream
);
211 /* De-reference the reference. */
214 if (TYPE_CODE (TYPE_TARGET_TYPE (type
)) != TYPE_CODE_UNDEF
)
218 (TYPE_TARGET_TYPE (type
),
219 unpack_pointer (lookup_pointer_type (builtin_type_void
),
221 val_print (VALUE_TYPE (deref_val
),
222 VALUE_CONTENTS (deref_val
),
223 VALUE_ADDRESS (deref_val
), stream
, format
,
224 deref_ref
, recurse
+ 1, pretty
);
227 fputs_filtered ("???", stream
);
232 c_val_print (type
, valaddr
, address
, stream
, format
,
233 deref_ref
, recurse
, pretty
);
236 case TYPE_CODE_MEMBER
:
237 case TYPE_CODE_UNION
:
240 case TYPE_CODE_ERROR
:
241 case TYPE_CODE_RANGE
:
243 /* Let's derfer printing to the C printer, rather than
244 print an error message. FIXME! */
245 c_val_print (type
, valaddr
, address
, stream
, format
,
246 deref_ref
, recurse
, pretty
);
252 /* Mutually recursive subroutines of cplus_print_value and c_val_print to
253 print out a structure's fields: cp_print_value_fields and cplus_print_value.
255 TYPE, VALADDR, STREAM, RECURSE, and PRETTY have the
256 same meanings as in cplus_print_value and c_val_print.
258 DONT_PRINT is an array of baseclass types that we
259 should not print, or zero if called from top level. */
262 chill_print_value_fields (type
, valaddr
, stream
, format
, recurse
, pretty
,
269 enum val_prettyprint pretty
;
270 struct type
**dont_print
;
275 check_stub_type (type
);
277 fprintf_filtered (stream
, "[");
278 len
= TYPE_NFIELDS (type
);
281 fprintf_filtered (stream
, "<No data fields>");
285 for (i
= 0; i
< len
; i
++)
289 fprintf_filtered (stream
, ", ");
294 fprintf_filtered (stream
, "\n");
295 print_spaces_filtered (2 + 2 * recurse
, stream
);
299 wrap_here (n_spaces (2 + 2 * recurse
));
301 fputs_filtered (".", stream
);
302 fprintf_symbol_filtered (stream
, TYPE_FIELD_NAME (type
, i
),
303 language_chill
, DMGL_NO_OPTS
);
304 fputs_filtered (": ", stream
);
305 if (TYPE_FIELD_PACKED (type
, i
))
309 /* Bitfields require special handling, especially due to byte
311 v
= value_from_longest (TYPE_FIELD_TYPE (type
, i
),
312 unpack_field_as_long (type
, valaddr
, i
));
314 chill_val_print (TYPE_FIELD_TYPE (type
, i
), VALUE_CONTENTS (v
), 0,
315 stream
, format
, 0, recurse
+ 1, pretty
);
319 chill_val_print (TYPE_FIELD_TYPE (type
, i
),
320 valaddr
+ TYPE_FIELD_BITPOS (type
, i
) / 8,
321 0, stream
, format
, 0, recurse
+ 1, pretty
);
326 fprintf_filtered (stream
, "\n");
327 print_spaces_filtered (2 * recurse
, stream
);
330 fprintf_filtered (stream
, "]");
This page took 0.038813 seconds and 5 git commands to generate.