Commit | Line | Data |
---|---|---|
a8a69e63 | 1 | /* Support for printing Chill values for GDB, the GNU debugger. |
67e9b3b3 PS |
2 | Copyright 1986, 1988, 1989, 1991, 1992, 1993, 1994 |
3 | Free Software Foundation, Inc. | |
a8a69e63 FF |
4 | |
5 | This file is part of GDB. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program; if not, write to the Free Software | |
6c9638b4 | 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
a8a69e63 FF |
20 | |
21 | #include "defs.h" | |
22 | #include "obstack.h" | |
23 | #include "symtab.h" | |
24 | #include "gdbtypes.h" | |
25 | #include "valprint.h" | |
26 | #include "expression.h" | |
8fbdca53 | 27 | #include "value.h" |
a8a69e63 | 28 | #include "language.h" |
5e81259d | 29 | #include "demangle.h" |
100f92e2 | 30 | #include "c-lang.h" /* For c_val_print */ |
1c95d7ab JK |
31 | #include "typeprint.h" |
32 | #include "ch-lang.h" | |
477b2425 | 33 | #include "annotate.h" |
a8a69e63 | 34 | |
8fbdca53 | 35 | static void |
199b2450 | 36 | chill_print_value_fields PARAMS ((struct type *, char *, GDB_FILE *, int, int, |
8fbdca53 FF |
37 | enum val_prettyprint, struct type **)); |
38 | ||
3bcf4181 PB |
39 | \f |
40 | /* Print integral scalar data VAL, of type TYPE, onto stdio stream STREAM. | |
41 | Used to print data from type structures in a specified type. For example, | |
42 | array bounds may be characters or booleans in some languages, and this | |
43 | allows the ranges to be printed in their "natural" form rather than as | |
44 | decimal integer values. */ | |
45 | ||
46 | void | |
47 | chill_print_type_scalar (type, val, stream) | |
48 | struct type *type; | |
49 | LONGEST val; | |
50 | GDB_FILE *stream; | |
51 | { | |
52 | switch (TYPE_CODE (type)) | |
53 | { | |
54 | case TYPE_CODE_RANGE: | |
55 | if (TYPE_TARGET_TYPE (type)) | |
56 | { | |
57 | chill_print_type_scalar (TYPE_TARGET_TYPE (type), val, stream); | |
58 | return; | |
59 | } | |
6b14af2b FF |
60 | break; |
61 | case TYPE_CODE_UNDEF: | |
62 | case TYPE_CODE_PTR: | |
63 | case TYPE_CODE_ARRAY: | |
64 | case TYPE_CODE_STRUCT: | |
65 | case TYPE_CODE_UNION: | |
66 | case TYPE_CODE_ENUM: | |
67 | case TYPE_CODE_FUNC: | |
68 | case TYPE_CODE_INT: | |
69 | case TYPE_CODE_FLT: | |
70 | case TYPE_CODE_VOID: | |
71 | case TYPE_CODE_SET: | |
72 | case TYPE_CODE_STRING: | |
73 | case TYPE_CODE_BITSTRING: | |
74 | case TYPE_CODE_ERROR: | |
75 | case TYPE_CODE_MEMBER: | |
76 | case TYPE_CODE_METHOD: | |
77 | case TYPE_CODE_REF: | |
78 | case TYPE_CODE_CHAR: | |
79 | case TYPE_CODE_BOOL: | |
80 | case TYPE_CODE_COMPLEX: | |
5e548861 | 81 | case TYPE_CODE_TYPEDEF: |
6b14af2b FF |
82 | default: |
83 | break; | |
3bcf4181 PB |
84 | } |
85 | print_type_scalar (type, val, stream); | |
86 | } | |
a8a69e63 | 87 | \f |
35f8a588 PB |
88 | /* Print the elements of an array. |
89 | Similar to val_print_array_elements, but prints | |
90 | element indexes (in Chill syntax). */ | |
91 | ||
92 | static void | |
93 | chill_val_print_array_elements (type, valaddr, address, stream, | |
94 | format, deref_ref, recurse, pretty) | |
95 | struct type *type; | |
96 | char *valaddr; | |
97 | CORE_ADDR address; | |
98 | GDB_FILE *stream; | |
99 | int format; | |
100 | int deref_ref; | |
101 | int recurse; | |
102 | enum val_prettyprint pretty; | |
103 | { | |
104 | unsigned int i = 0; | |
105 | unsigned int things_printed = 0; | |
106 | unsigned len; | |
107 | struct type *elttype; | |
108 | struct type *range_type = TYPE_FIELD_TYPE (type, 0); | |
109 | struct type *index_type = TYPE_TARGET_TYPE (range_type); | |
110 | unsigned eltlen; | |
111 | /* Position of the array element we are examining to see | |
112 | whether it is repeated. */ | |
113 | unsigned int rep1; | |
114 | /* Number of repetitions we have detected so far. */ | |
115 | unsigned int reps; | |
116 | LONGEST low_bound = TYPE_FIELD_BITPOS (range_type, 0); | |
35f8a588 | 117 | |
5e548861 | 118 | elttype = check_typedef (TYPE_TARGET_TYPE (type)); |
35f8a588 PB |
119 | eltlen = TYPE_LENGTH (elttype); |
120 | len = TYPE_LENGTH (type) / eltlen; | |
121 | ||
122 | annotate_array_section_begin (i, elttype); | |
123 | ||
124 | for (; i < len && things_printed < print_max; i++) | |
125 | { | |
126 | if (i != 0) | |
127 | { | |
128 | if (prettyprint_arrays) | |
129 | { | |
130 | fprintf_filtered (stream, ",\n"); | |
131 | print_spaces_filtered (2 + 2 * recurse, stream); | |
132 | } | |
133 | else | |
134 | { | |
135 | fprintf_filtered (stream, ", "); | |
136 | } | |
137 | } | |
138 | wrap_here (n_spaces (2 + 2 * recurse)); | |
139 | ||
140 | rep1 = i + 1; | |
141 | reps = 1; | |
142 | while ((rep1 < len) && | |
143 | !memcmp (valaddr + i * eltlen, valaddr + rep1 * eltlen, eltlen)) | |
144 | { | |
145 | ++reps; | |
146 | ++rep1; | |
147 | } | |
148 | ||
149 | fputs_filtered ("(", stream); | |
3bcf4181 | 150 | chill_print_type_scalar (index_type, low_bound + i, stream); |
35f8a588 PB |
151 | if (reps > 1) |
152 | { | |
153 | fputs_filtered (":", stream); | |
3bcf4181 PB |
154 | chill_print_type_scalar (index_type, low_bound + i + reps - 1, |
155 | stream); | |
35f8a588 PB |
156 | fputs_filtered ("): ", stream); |
157 | val_print (elttype, valaddr + i * eltlen, 0, stream, format, | |
158 | deref_ref, recurse + 1, pretty); | |
159 | ||
160 | i = rep1 - 1; | |
161 | things_printed += 1; | |
162 | } | |
163 | else | |
164 | { | |
165 | fputs_filtered ("): ", stream); | |
166 | val_print (elttype, valaddr + i * eltlen, 0, stream, format, | |
167 | deref_ref, recurse + 1, pretty); | |
168 | annotate_elt (); | |
169 | things_printed++; | |
170 | } | |
171 | } | |
172 | annotate_array_section_end (); | |
173 | if (i < len) | |
174 | { | |
175 | fprintf_filtered (stream, "..."); | |
176 | } | |
177 | } | |
178 | ||
a8a69e63 FF |
179 | /* Print data of type TYPE located at VALADDR (within GDB), which came from |
180 | the inferior at address ADDRESS, onto stdio stream STREAM according to | |
181 | FORMAT (a letter or 0 for natural format). The data at VALADDR is in | |
182 | target byte order. | |
183 | ||
184 | If the data are a string pointer, returns the number of string characters | |
185 | printed. | |
186 | ||
187 | If DEREF_REF is nonzero, then dereference references, otherwise just print | |
188 | them like pointers. | |
189 | ||
190 | The PRETTY parameter controls prettyprinting. */ | |
191 | ||
192 | int | |
193 | chill_val_print (type, valaddr, address, stream, format, deref_ref, recurse, | |
194 | pretty) | |
195 | struct type *type; | |
196 | char *valaddr; | |
197 | CORE_ADDR address; | |
199b2450 | 198 | GDB_FILE *stream; |
a8a69e63 FF |
199 | int format; |
200 | int deref_ref; | |
201 | int recurse; | |
202 | enum val_prettyprint pretty; | |
203 | { | |
a8a69e63 | 204 | LONGEST val; |
ec16f701 | 205 | unsigned int i = 0; /* Number of characters printed. */ |
c7da3ed3 | 206 | struct type *elttype; |
c7da3ed3 | 207 | CORE_ADDR addr; |
a8a69e63 | 208 | |
5e548861 PB |
209 | CHECK_TYPEDEF (type); |
210 | ||
a8a69e63 FF |
211 | switch (TYPE_CODE (type)) |
212 | { | |
213 | case TYPE_CODE_ARRAY: | |
214 | if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0) | |
215 | { | |
a8a69e63 FF |
216 | if (prettyprint_arrays) |
217 | { | |
218 | print_spaces_filtered (2 + 2 * recurse, stream); | |
219 | } | |
220 | fprintf_filtered (stream, "["); | |
35f8a588 PB |
221 | chill_val_print_array_elements (type, valaddr, address, stream, |
222 | format, deref_ref, recurse, pretty); | |
a8a69e63 FF |
223 | fprintf_filtered (stream, "]"); |
224 | } | |
225 | else | |
226 | { | |
227 | error ("unimplemented in chill_val_print; unspecified array length"); | |
228 | } | |
229 | break; | |
230 | ||
231 | case TYPE_CODE_INT: | |
232 | format = format ? format : output_format; | |
233 | if (format) | |
234 | { | |
235 | print_scalar_formatted (valaddr, type, format, 0, stream); | |
236 | } | |
237 | else | |
238 | { | |
239 | val_print_type_code_int (type, valaddr, stream); | |
240 | } | |
241 | break; | |
242 | ||
243 | case TYPE_CODE_CHAR: | |
244 | format = format ? format : output_format; | |
245 | if (format) | |
246 | { | |
247 | print_scalar_formatted (valaddr, type, format, 0, stream); | |
248 | } | |
249 | else | |
250 | { | |
251 | LA_PRINT_CHAR ((unsigned char) unpack_long (type, valaddr), | |
252 | stream); | |
253 | } | |
254 | break; | |
255 | ||
256 | case TYPE_CODE_FLT: | |
257 | if (format) | |
258 | { | |
259 | print_scalar_formatted (valaddr, type, format, 0, stream); | |
260 | } | |
261 | else | |
262 | { | |
263 | print_floating (valaddr, type, stream); | |
264 | } | |
265 | break; | |
266 | ||
267 | case TYPE_CODE_BOOL: | |
268 | format = format ? format : output_format; | |
269 | if (format) | |
270 | { | |
271 | print_scalar_formatted (valaddr, type, format, 0, stream); | |
272 | } | |
273 | else | |
274 | { | |
61932a8e | 275 | /* FIXME: Why is this using builtin_type_chill_bool not type? */ |
a8a69e63 FF |
276 | val = unpack_long (builtin_type_chill_bool, valaddr); |
277 | fprintf_filtered (stream, val ? "TRUE" : "FALSE"); | |
278 | } | |
279 | break; | |
280 | ||
281 | case TYPE_CODE_UNDEF: | |
282 | /* This happens (without TYPE_FLAG_STUB set) on systems which don't use | |
283 | dbx xrefs (NO_DBX_XREFS in gcc) if a file has a "struct foo *bar" | |
284 | and no complete type for struct foo in that file. */ | |
285 | fprintf_filtered (stream, "<incomplete type>"); | |
286 | break; | |
287 | ||
288 | case TYPE_CODE_PTR: | |
c7da3ed3 FF |
289 | if (format && format != 's') |
290 | { | |
291 | print_scalar_formatted (valaddr, type, format, 0, stream); | |
292 | break; | |
293 | } | |
294 | addr = unpack_pointer (type, valaddr); | |
5e548861 | 295 | elttype = check_typedef (TYPE_TARGET_TYPE (type)); |
e10cfcaa PB |
296 | |
297 | /* We assume a NULL pointer is all zeros ... */ | |
298 | if (addr == 0) | |
299 | { | |
300 | fputs_filtered ("NULL", stream); | |
301 | return 0; | |
302 | } | |
c7da3ed3 FF |
303 | |
304 | if (TYPE_CODE (elttype) == TYPE_CODE_FUNC) | |
305 | { | |
306 | /* Try to print what function it points to. */ | |
307 | print_address_demangle (addr, stream, demangle); | |
308 | /* Return value is irrelevant except for string pointers. */ | |
309 | return (0); | |
310 | } | |
311 | if (addressprint && format != 's') | |
312 | { | |
d24c0599 | 313 | print_address_numeric (addr, 1, stream); |
c7da3ed3 FF |
314 | } |
315 | ||
316 | /* For a pointer to char or unsigned char, also print the string | |
317 | pointed to, unless pointer is null. */ | |
c7da3ed3 FF |
318 | if (TYPE_LENGTH (elttype) == 1 |
319 | && TYPE_CODE (elttype) == TYPE_CODE_CHAR | |
320 | && (format == 0 || format == 's') | |
321 | && addr != 0 | |
322 | && /* If print_max is UINT_MAX, the alloca below will fail. | |
323 | In that case don't try to print the string. */ | |
324 | print_max < UINT_MAX) | |
325 | { | |
8fbdca53 | 326 | i = val_print_string (addr, 0, stream); |
c7da3ed3 FF |
327 | } |
328 | /* Return number of characters printed, plus one for the | |
329 | terminating null if we have "reached the end". */ | |
330 | return (i + (print_max && i != print_max)); | |
331 | break; | |
332 | ||
c4413e2c | 333 | case TYPE_CODE_STRING: |
ec16f701 FF |
334 | i = TYPE_LENGTH (type); |
335 | LA_PRINT_STRING (stream, valaddr, i, 0); | |
c4413e2c FF |
336 | /* Return number of characters printed, plus one for the terminating |
337 | null if we have "reached the end". */ | |
338 | return (i + (print_max && i != print_max)); | |
339 | break; | |
340 | ||
cba00921 | 341 | case TYPE_CODE_BITSTRING: |
e909f287 | 342 | case TYPE_CODE_SET: |
6f52d064 | 343 | elttype = TYPE_INDEX_TYPE (type); |
5e548861 | 344 | CHECK_TYPEDEF (elttype); |
e10cfcaa PB |
345 | if (TYPE_FLAGS (elttype) & TYPE_FLAG_STUB) |
346 | { | |
347 | fprintf_filtered (stream, "<incomplete type>"); | |
348 | gdb_flush (stream); | |
349 | break; | |
350 | } | |
e909f287 | 351 | { |
e10cfcaa | 352 | struct type *range = elttype; |
706bfe5a | 353 | LONGEST low_bound, high_bound; |
e909f287 | 354 | int i; |
cba00921 | 355 | int is_bitstring = TYPE_CODE (type) == TYPE_CODE_BITSTRING; |
e909f287 | 356 | int need_comma = 0; |
e909f287 PB |
357 | |
358 | if (is_bitstring) | |
359 | fputs_filtered ("B'", stream); | |
360 | else | |
361 | fputs_filtered ("[", stream); | |
706bfe5a PB |
362 | |
363 | i = get_discrete_bounds (range, &low_bound, &high_bound); | |
364 | maybe_bad_bstring: | |
365 | if (i < 0) | |
366 | { | |
367 | fputs_filtered ("<error value>", stream); | |
368 | goto done; | |
369 | } | |
370 | ||
e909f287 PB |
371 | for (i = low_bound; i <= high_bound; i++) |
372 | { | |
373 | int element = value_bit_index (type, valaddr, i); | |
706bfe5a PB |
374 | if (element < 0) |
375 | { | |
376 | i = element; | |
377 | goto maybe_bad_bstring; | |
378 | } | |
e909f287 PB |
379 | if (is_bitstring) |
380 | fprintf_filtered (stream, "%d", element); | |
381 | else if (element) | |
382 | { | |
383 | if (need_comma) | |
384 | fputs_filtered (", ", stream); | |
3bcf4181 | 385 | chill_print_type_scalar (range, i, stream); |
e909f287 PB |
386 | need_comma = 1; |
387 | ||
388 | /* Look for a continuous range of true elements. */ | |
389 | if (i+1 <= high_bound && value_bit_index (type, valaddr, ++i)) | |
390 | { | |
391 | int j = i; /* j is the upper bound so far of the range */ | |
392 | fputs_filtered (":", stream); | |
393 | while (i+1 <= high_bound | |
394 | && value_bit_index (type, valaddr, ++i)) | |
395 | j = i; | |
3bcf4181 | 396 | chill_print_type_scalar (range, j, stream); |
e909f287 PB |
397 | } |
398 | } | |
399 | } | |
706bfe5a | 400 | done: |
e909f287 PB |
401 | if (is_bitstring) |
402 | fputs_filtered ("'", stream); | |
403 | else | |
404 | fputs_filtered ("]", stream); | |
405 | } | |
406 | break; | |
407 | ||
8fbdca53 | 408 | case TYPE_CODE_STRUCT: |
6073b8de | 409 | if (chill_varying_type (type)) |
cba00921 | 410 | { |
5e548861 | 411 | struct type *inner = check_typedef (TYPE_FIELD_TYPE (type, 1)); |
cba00921 PB |
412 | long length = unpack_long (TYPE_FIELD_TYPE (type, 0), valaddr); |
413 | char *data_addr = valaddr + TYPE_FIELD_BITPOS (type, 1) / 8; | |
414 | ||
415 | switch (TYPE_CODE (inner)) | |
416 | { | |
417 | case TYPE_CODE_STRING: | |
418 | if (length > TYPE_LENGTH (type)) | |
419 | { | |
420 | fprintf_filtered (stream, | |
6b14af2b | 421 | "<dynamic length %ld > static length %d>", |
cba00921 | 422 | length, TYPE_LENGTH (type)); |
cba00921 PB |
423 | } |
424 | LA_PRINT_STRING (stream, data_addr, length, 0); | |
425 | return length; | |
1c95d7ab JK |
426 | default: |
427 | break; | |
cba00921 PB |
428 | } |
429 | } | |
8fbdca53 FF |
430 | chill_print_value_fields (type, valaddr, stream, format, recurse, pretty, |
431 | 0); | |
432 | break; | |
433 | ||
a8a69e63 | 434 | case TYPE_CODE_REF: |
8a177da6 PB |
435 | if (addressprint) |
436 | { | |
833e0d94 JK |
437 | fprintf_filtered (stream, "LOC("); |
438 | print_address_numeric | |
439 | (extract_address (valaddr, TARGET_PTR_BIT / HOST_CHAR_BIT), | |
d24c0599 | 440 | 1, |
833e0d94 JK |
441 | stream); |
442 | fprintf_filtered (stream, ")"); | |
8a177da6 PB |
443 | if (deref_ref) |
444 | fputs_filtered (": ", stream); | |
445 | } | |
446 | /* De-reference the reference. */ | |
447 | if (deref_ref) | |
448 | { | |
449 | if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_UNDEF) | |
450 | { | |
82a2edfb | 451 | value_ptr deref_val = |
8a177da6 PB |
452 | value_at |
453 | (TYPE_TARGET_TYPE (type), | |
454 | unpack_pointer (lookup_pointer_type (builtin_type_void), | |
455 | valaddr)); | |
456 | val_print (VALUE_TYPE (deref_val), | |
457 | VALUE_CONTENTS (deref_val), | |
458 | VALUE_ADDRESS (deref_val), stream, format, | |
459 | deref_ref, recurse + 1, pretty); | |
460 | } | |
461 | else | |
462 | fputs_filtered ("???", stream); | |
463 | } | |
464 | break; | |
465 | ||
a8a69e63 | 466 | case TYPE_CODE_ENUM: |
8a177da6 PB |
467 | c_val_print (type, valaddr, address, stream, format, |
468 | deref_ref, recurse, pretty); | |
469 | break; | |
470 | ||
11b959da FF |
471 | case TYPE_CODE_RANGE: |
472 | if (TYPE_TARGET_TYPE (type)) | |
473 | chill_val_print (TYPE_TARGET_TYPE (type), valaddr, address, stream, | |
474 | format, deref_ref, recurse, pretty); | |
475 | break; | |
476 | ||
8a177da6 PB |
477 | case TYPE_CODE_MEMBER: |
478 | case TYPE_CODE_UNION: | |
a8a69e63 FF |
479 | case TYPE_CODE_FUNC: |
480 | case TYPE_CODE_VOID: | |
481 | case TYPE_CODE_ERROR: | |
a8a69e63 | 482 | default: |
11b959da | 483 | /* Let's defer printing to the C printer, rather than |
8a177da6 PB |
484 | print an error message. FIXME! */ |
485 | c_val_print (type, valaddr, address, stream, format, | |
486 | deref_ref, recurse, pretty); | |
a8a69e63 | 487 | } |
199b2450 | 488 | gdb_flush (stream); |
a8a69e63 FF |
489 | return (0); |
490 | } | |
8fbdca53 FF |
491 | |
492 | /* Mutually recursive subroutines of cplus_print_value and c_val_print to | |
493 | print out a structure's fields: cp_print_value_fields and cplus_print_value. | |
494 | ||
495 | TYPE, VALADDR, STREAM, RECURSE, and PRETTY have the | |
496 | same meanings as in cplus_print_value and c_val_print. | |
497 | ||
498 | DONT_PRINT is an array of baseclass types that we | |
499 | should not print, or zero if called from top level. */ | |
500 | ||
501 | static void | |
502 | chill_print_value_fields (type, valaddr, stream, format, recurse, pretty, | |
503 | dont_print) | |
504 | struct type *type; | |
505 | char *valaddr; | |
199b2450 | 506 | GDB_FILE *stream; |
8fbdca53 FF |
507 | int format; |
508 | int recurse; | |
509 | enum val_prettyprint pretty; | |
510 | struct type **dont_print; | |
511 | { | |
512 | int i, len; | |
513 | int fields_seen = 0; | |
514 | ||
5e548861 | 515 | CHECK_TYPEDEF (type); |
8fbdca53 | 516 | |
8a177da6 | 517 | fprintf_filtered (stream, "["); |
8fbdca53 FF |
518 | len = TYPE_NFIELDS (type); |
519 | if (len == 0) | |
520 | { | |
521 | fprintf_filtered (stream, "<No data fields>"); | |
522 | } | |
523 | else | |
524 | { | |
525 | for (i = 0; i < len; i++) | |
526 | { | |
527 | if (fields_seen) | |
528 | { | |
529 | fprintf_filtered (stream, ", "); | |
530 | } | |
531 | fields_seen = 1; | |
532 | if (pretty) | |
533 | { | |
534 | fprintf_filtered (stream, "\n"); | |
535 | print_spaces_filtered (2 + 2 * recurse, stream); | |
536 | } | |
537 | else | |
538 | { | |
539 | wrap_here (n_spaces (2 + 2 * recurse)); | |
540 | } | |
8a177da6 | 541 | fputs_filtered (".", stream); |
5e81259d FF |
542 | fprintf_symbol_filtered (stream, TYPE_FIELD_NAME (type, i), |
543 | language_chill, DMGL_NO_OPTS); | |
8a177da6 | 544 | fputs_filtered (": ", stream); |
8fbdca53 FF |
545 | if (TYPE_FIELD_PACKED (type, i)) |
546 | { | |
82a2edfb | 547 | value_ptr v; |
8fbdca53 FF |
548 | |
549 | /* Bitfields require special handling, especially due to byte | |
550 | order problems. */ | |
551 | v = value_from_longest (TYPE_FIELD_TYPE (type, i), | |
552 | unpack_field_as_long (type, valaddr, i)); | |
553 | ||
554 | chill_val_print (TYPE_FIELD_TYPE (type, i), VALUE_CONTENTS (v), 0, | |
555 | stream, format, 0, recurse + 1, pretty); | |
556 | } | |
557 | else | |
558 | { | |
559 | chill_val_print (TYPE_FIELD_TYPE (type, i), | |
560 | valaddr + TYPE_FIELD_BITPOS (type, i) / 8, | |
561 | 0, stream, format, 0, recurse + 1, pretty); | |
562 | } | |
563 | } | |
564 | if (pretty) | |
565 | { | |
566 | fprintf_filtered (stream, "\n"); | |
567 | print_spaces_filtered (2 * recurse, stream); | |
568 | } | |
569 | } | |
8a177da6 | 570 | fprintf_filtered (stream, "]"); |
8fbdca53 | 571 | } |
e10cfcaa PB |
572 | \f |
573 | int | |
574 | chill_value_print (val, stream, format, pretty) | |
575 | value_ptr val; | |
576 | GDB_FILE *stream; | |
577 | int format; | |
578 | enum val_prettyprint pretty; | |
579 | { | |
398f584f | 580 | struct type *type = VALUE_TYPE (val); |
5e548861 | 581 | struct type *real_type = check_typedef (type); |
e10cfcaa | 582 | |
398f584f | 583 | /* If it is a pointer, indicate what it points to. |
e10cfcaa | 584 | |
5e548861 | 585 | Print type also if it is a reference. */ |
e10cfcaa | 586 | |
5e548861 PB |
587 | if (TYPE_CODE (real_type) == TYPE_CODE_PTR || |
588 | TYPE_CODE (real_type) == TYPE_CODE_REF) | |
398f584f PB |
589 | { |
590 | char *valaddr = VALUE_CONTENTS (val); | |
591 | CORE_ADDR addr = unpack_pointer (type, valaddr); | |
592 | if (TYPE_CODE (type) != TYPE_CODE_PTR || addr != 0) | |
e10cfcaa | 593 | { |
398f584f PB |
594 | int i; |
595 | char *name = TYPE_NAME (type); | |
596 | if (name) | |
597 | fputs_filtered (name, stream); | |
598 | else if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_VOID) | |
599 | fputs_filtered ("PTR", stream); | |
600 | else | |
e10cfcaa | 601 | { |
e10cfcaa | 602 | fprintf_filtered (stream, "("); |
398f584f | 603 | type_print (type, "", stream, -1); |
e10cfcaa | 604 | fprintf_filtered (stream, ")"); |
e10cfcaa | 605 | } |
398f584f PB |
606 | fprintf_filtered (stream, "("); |
607 | i = val_print (type, valaddr, VALUE_ADDRESS (val), | |
608 | stream, format, 1, 0, pretty); | |
609 | fprintf_filtered (stream, ")"); | |
610 | return i; | |
e10cfcaa | 611 | } |
e10cfcaa | 612 | } |
398f584f PB |
613 | return (val_print (type, VALUE_CONTENTS (val), |
614 | VALUE_ADDRESS (val), stream, format, 1, 0, pretty)); | |
e10cfcaa PB |
615 | } |
616 | ||
617 |