8c80bc48612aeb97c893101e48851821a28404a5
[deliverable/binutils-gdb.git] / gdb / ch-valprint.c
1 /* Support for printing Chill values for GDB, the GNU debugger.
2 Copyright 1986, 1988, 1989, 1991 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
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.
10
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.
15
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. */
19
20 #include "defs.h"
21 #include "obstack.h"
22 #include "symtab.h"
23 #include "gdbtypes.h"
24 #include "valprint.h"
25 #include "expression.h"
26 #include "language.h"
27
28 \f
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
32 target byte order.
33
34 If the data are a string pointer, returns the number of string characters
35 printed.
36
37 If DEREF_REF is nonzero, then dereference references, otherwise just print
38 them like pointers.
39
40 The PRETTY parameter controls prettyprinting. */
41
42 int
43 chill_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
44 pretty)
45 struct type *type;
46 char *valaddr;
47 CORE_ADDR address;
48 FILE *stream;
49 int format;
50 int deref_ref;
51 int recurse;
52 enum val_prettyprint pretty;
53 {
54 LONGEST val;
55
56 switch (TYPE_CODE (type))
57 {
58 case TYPE_CODE_ARRAY:
59 if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)
60 {
61 if (prettyprint_arrays)
62 {
63 print_spaces_filtered (2 + 2 * recurse, stream);
64 }
65 fprintf_filtered (stream, "[");
66 val_print_array_elements (type, valaddr, address, stream, format,
67 deref_ref, recurse, pretty, 0);
68 fprintf_filtered (stream, "]");
69 }
70 else
71 {
72 error ("unimplemented in chill_val_print; unspecified array length");
73 }
74 break;
75
76 case TYPE_CODE_INT:
77 format = format ? format : output_format;
78 if (format)
79 {
80 print_scalar_formatted (valaddr, type, format, 0, stream);
81 }
82 else
83 {
84 val_print_type_code_int (type, valaddr, stream);
85 }
86 break;
87
88 case TYPE_CODE_CHAR:
89 format = format ? format : output_format;
90 if (format)
91 {
92 print_scalar_formatted (valaddr, type, format, 0, stream);
93 }
94 else
95 {
96 LA_PRINT_CHAR ((unsigned char) unpack_long (type, valaddr),
97 stream);
98 }
99 break;
100
101 case TYPE_CODE_FLT:
102 if (format)
103 {
104 print_scalar_formatted (valaddr, type, format, 0, stream);
105 }
106 else
107 {
108 print_floating (valaddr, type, stream);
109 }
110 break;
111
112 case TYPE_CODE_BOOL:
113 format = format ? format : output_format;
114 if (format)
115 {
116 print_scalar_formatted (valaddr, type, format, 0, stream);
117 }
118 else
119 {
120 val = unpack_long (builtin_type_chill_bool, valaddr);
121 fprintf_filtered (stream, val ? "TRUE" : "FALSE");
122 }
123 break;
124
125 case TYPE_CODE_UNDEF:
126 /* This happens (without TYPE_FLAG_STUB set) on systems which don't use
127 dbx xrefs (NO_DBX_XREFS in gcc) if a file has a "struct foo *bar"
128 and no complete type for struct foo in that file. */
129 fprintf_filtered (stream, "<incomplete type>");
130 break;
131
132 case TYPE_CODE_PTR:
133 case TYPE_CODE_MEMBER:
134 case TYPE_CODE_REF:
135 case TYPE_CODE_UNION:
136 case TYPE_CODE_STRUCT:
137 case TYPE_CODE_ENUM:
138 case TYPE_CODE_FUNC:
139 case TYPE_CODE_VOID:
140 case TYPE_CODE_ERROR:
141 case TYPE_CODE_RANGE:
142 error ("Unimplemented chill_val_print support for type %d",
143 TYPE_CODE (type));
144 break;
145
146 default:
147 error ("Invalid Chill type code %d in symbol table.", TYPE_CODE (type));
148 }
149 fflush (stream);
150 return (0);
151 }
This page took 0.03185 seconds and 4 git commands to generate.