| 1 | // OBSOLETE /* Support for printing Chill types for GDB, the GNU debugger. |
| 2 | // OBSOLETE Copyright 1986, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 2000 |
| 3 | // OBSOLETE Free Software Foundation, Inc. |
| 4 | // OBSOLETE |
| 5 | // OBSOLETE This file is part of GDB. |
| 6 | // OBSOLETE |
| 7 | // OBSOLETE This program is free software; you can redistribute it and/or modify |
| 8 | // OBSOLETE it under the terms of the GNU General Public License as published by |
| 9 | // OBSOLETE the Free Software Foundation; either version 2 of the License, or |
| 10 | // OBSOLETE (at your option) any later version. |
| 11 | // OBSOLETE |
| 12 | // OBSOLETE This program is distributed in the hope that it will be useful, |
| 13 | // OBSOLETE but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | // OBSOLETE MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | // OBSOLETE GNU General Public License for more details. |
| 16 | // OBSOLETE |
| 17 | // OBSOLETE You should have received a copy of the GNU General Public License |
| 18 | // OBSOLETE along with this program; if not, write to the Free Software |
| 19 | // OBSOLETE Foundation, Inc., 59 Temple Place - Suite 330, |
| 20 | // OBSOLETE Boston, MA 02111-1307, USA. */ |
| 21 | // OBSOLETE |
| 22 | // OBSOLETE #include "defs.h" |
| 23 | // OBSOLETE #include "gdb_obstack.h" |
| 24 | // OBSOLETE #include "bfd.h" /* Binary File Description */ |
| 25 | // OBSOLETE #include "symtab.h" |
| 26 | // OBSOLETE #include "gdbtypes.h" |
| 27 | // OBSOLETE #include "expression.h" |
| 28 | // OBSOLETE #include "value.h" |
| 29 | // OBSOLETE #include "gdbcore.h" |
| 30 | // OBSOLETE #include "target.h" |
| 31 | // OBSOLETE #include "language.h" |
| 32 | // OBSOLETE #include "ch-lang.h" |
| 33 | // OBSOLETE #include "typeprint.h" |
| 34 | // OBSOLETE |
| 35 | // OBSOLETE #include "gdb_string.h" |
| 36 | // OBSOLETE #include <errno.h> |
| 37 | // OBSOLETE |
| 38 | // OBSOLETE static void chill_type_print_base (struct type *, struct ui_file *, int, int); |
| 39 | // OBSOLETE |
| 40 | // OBSOLETE void |
| 41 | // OBSOLETE chill_print_type (struct type *type, char *varstring, struct ui_file *stream, |
| 42 | // OBSOLETE int show, int level) |
| 43 | // OBSOLETE { |
| 44 | // OBSOLETE if (varstring != NULL && *varstring != '\0') |
| 45 | // OBSOLETE { |
| 46 | // OBSOLETE fputs_filtered (varstring, stream); |
| 47 | // OBSOLETE fputs_filtered (" ", stream); |
| 48 | // OBSOLETE } |
| 49 | // OBSOLETE chill_type_print_base (type, stream, show, level); |
| 50 | // OBSOLETE } |
| 51 | // OBSOLETE |
| 52 | // OBSOLETE /* Print the name of the type (or the ultimate pointer target, |
| 53 | // OBSOLETE function value or array element). |
| 54 | // OBSOLETE |
| 55 | // OBSOLETE SHOW nonzero means don't print this type as just its name; |
| 56 | // OBSOLETE show its real definition even if it has a name. |
| 57 | // OBSOLETE SHOW zero means print just typename or tag if there is one |
| 58 | // OBSOLETE SHOW negative means abbreviate structure elements. |
| 59 | // OBSOLETE SHOW is decremented for printing of structure elements. |
| 60 | // OBSOLETE |
| 61 | // OBSOLETE LEVEL is the depth to indent by. |
| 62 | // OBSOLETE We increase it for some recursive calls. */ |
| 63 | // OBSOLETE |
| 64 | // OBSOLETE static void |
| 65 | // OBSOLETE chill_type_print_base (struct type *type, struct ui_file *stream, int show, |
| 66 | // OBSOLETE int level) |
| 67 | // OBSOLETE { |
| 68 | // OBSOLETE register int len; |
| 69 | // OBSOLETE register int i; |
| 70 | // OBSOLETE struct type *index_type; |
| 71 | // OBSOLETE struct type *range_type; |
| 72 | // OBSOLETE LONGEST low_bound; |
| 73 | // OBSOLETE LONGEST high_bound; |
| 74 | // OBSOLETE |
| 75 | // OBSOLETE QUIT; |
| 76 | // OBSOLETE |
| 77 | // OBSOLETE wrap_here (" "); |
| 78 | // OBSOLETE if (type == NULL) |
| 79 | // OBSOLETE { |
| 80 | // OBSOLETE fputs_filtered ("<type unknown>", stream); |
| 81 | // OBSOLETE return; |
| 82 | // OBSOLETE } |
| 83 | // OBSOLETE |
| 84 | // OBSOLETE /* When SHOW is zero or less, and there is a valid type name, then always |
| 85 | // OBSOLETE just print the type name directly from the type. */ |
| 86 | // OBSOLETE |
| 87 | // OBSOLETE if ((show <= 0) && (TYPE_NAME (type) != NULL)) |
| 88 | // OBSOLETE { |
| 89 | // OBSOLETE fputs_filtered (TYPE_NAME (type), stream); |
| 90 | // OBSOLETE return; |
| 91 | // OBSOLETE } |
| 92 | // OBSOLETE |
| 93 | // OBSOLETE if (TYPE_CODE (type) != TYPE_CODE_TYPEDEF) |
| 94 | // OBSOLETE CHECK_TYPEDEF (type); |
| 95 | // OBSOLETE |
| 96 | // OBSOLETE switch (TYPE_CODE (type)) |
| 97 | // OBSOLETE { |
| 98 | // OBSOLETE case TYPE_CODE_TYPEDEF: |
| 99 | // OBSOLETE chill_type_print_base (TYPE_TARGET_TYPE (type), stream, 0, level); |
| 100 | // OBSOLETE break; |
| 101 | // OBSOLETE case TYPE_CODE_PTR: |
| 102 | // OBSOLETE if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_VOID) |
| 103 | // OBSOLETE { |
| 104 | // OBSOLETE fprintf_filtered (stream, |
| 105 | // OBSOLETE TYPE_NAME (type) ? TYPE_NAME (type) : "PTR"); |
| 106 | // OBSOLETE break; |
| 107 | // OBSOLETE } |
| 108 | // OBSOLETE fprintf_filtered (stream, "REF "); |
| 109 | // OBSOLETE chill_type_print_base (TYPE_TARGET_TYPE (type), stream, 0, level); |
| 110 | // OBSOLETE break; |
| 111 | // OBSOLETE |
| 112 | // OBSOLETE case TYPE_CODE_BOOL: |
| 113 | // OBSOLETE /* FIXME: we should probably just print the TYPE_NAME, in case |
| 114 | // OBSOLETE anyone ever fixes the compiler to give us the real names |
| 115 | // OBSOLETE in the presence of the chill equivalent of typedef (assuming |
| 116 | // OBSOLETE there is one). */ |
| 117 | // OBSOLETE fprintf_filtered (stream, |
| 118 | // OBSOLETE TYPE_NAME (type) ? TYPE_NAME (type) : "BOOL"); |
| 119 | // OBSOLETE break; |
| 120 | // OBSOLETE |
| 121 | // OBSOLETE case TYPE_CODE_ARRAY: |
| 122 | // OBSOLETE fputs_filtered ("ARRAY (", stream); |
| 123 | // OBSOLETE range_type = TYPE_FIELD_TYPE (type, 0); |
| 124 | // OBSOLETE if (TYPE_CODE (range_type) != TYPE_CODE_RANGE) |
| 125 | // OBSOLETE chill_print_type (range_type, "", stream, 0, level); |
| 126 | // OBSOLETE else |
| 127 | // OBSOLETE { |
| 128 | // OBSOLETE index_type = TYPE_TARGET_TYPE (range_type); |
| 129 | // OBSOLETE low_bound = TYPE_FIELD_BITPOS (range_type, 0); |
| 130 | // OBSOLETE high_bound = TYPE_FIELD_BITPOS (range_type, 1); |
| 131 | // OBSOLETE print_type_scalar (index_type, low_bound, stream); |
| 132 | // OBSOLETE fputs_filtered (":", stream); |
| 133 | // OBSOLETE print_type_scalar (index_type, high_bound, stream); |
| 134 | // OBSOLETE } |
| 135 | // OBSOLETE fputs_filtered (") ", stream); |
| 136 | // OBSOLETE chill_print_type (TYPE_TARGET_TYPE (type), "", stream, 0, level); |
| 137 | // OBSOLETE break; |
| 138 | // OBSOLETE |
| 139 | // OBSOLETE case TYPE_CODE_BITSTRING: |
| 140 | // OBSOLETE fprintf_filtered (stream, "BOOLS (%d)", |
| 141 | // OBSOLETE TYPE_FIELD_BITPOS (TYPE_FIELD_TYPE (type, 0), 1) + 1); |
| 142 | // OBSOLETE break; |
| 143 | // OBSOLETE |
| 144 | // OBSOLETE case TYPE_CODE_SET: |
| 145 | // OBSOLETE fputs_filtered ("POWERSET ", stream); |
| 146 | // OBSOLETE chill_print_type (TYPE_INDEX_TYPE (type), "", stream, |
| 147 | // OBSOLETE show - 1, level); |
| 148 | // OBSOLETE break; |
| 149 | // OBSOLETE |
| 150 | // OBSOLETE case TYPE_CODE_STRING: |
| 151 | // OBSOLETE range_type = TYPE_FIELD_TYPE (type, 0); |
| 152 | // OBSOLETE index_type = TYPE_TARGET_TYPE (range_type); |
| 153 | // OBSOLETE high_bound = TYPE_FIELD_BITPOS (range_type, 1); |
| 154 | // OBSOLETE fputs_filtered ("CHARS (", stream); |
| 155 | // OBSOLETE print_type_scalar (index_type, high_bound + 1, stream); |
| 156 | // OBSOLETE fputs_filtered (")", stream); |
| 157 | // OBSOLETE break; |
| 158 | // OBSOLETE |
| 159 | // OBSOLETE case TYPE_CODE_MEMBER: |
| 160 | // OBSOLETE fprintf_filtered (stream, "MEMBER "); |
| 161 | // OBSOLETE chill_type_print_base (TYPE_TARGET_TYPE (type), stream, 0, level); |
| 162 | // OBSOLETE break; |
| 163 | // OBSOLETE case TYPE_CODE_REF: |
| 164 | // OBSOLETE fprintf_filtered (stream, "/*LOC*/ "); |
| 165 | // OBSOLETE chill_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level); |
| 166 | // OBSOLETE break; |
| 167 | // OBSOLETE case TYPE_CODE_FUNC: |
| 168 | // OBSOLETE fprintf_filtered (stream, "PROC ("); |
| 169 | // OBSOLETE len = TYPE_NFIELDS (type); |
| 170 | // OBSOLETE for (i = 0; i < len; i++) |
| 171 | // OBSOLETE { |
| 172 | // OBSOLETE struct type *param_type = TYPE_FIELD_TYPE (type, i); |
| 173 | // OBSOLETE if (i > 0) |
| 174 | // OBSOLETE { |
| 175 | // OBSOLETE fputs_filtered (", ", stream); |
| 176 | // OBSOLETE wrap_here (" "); |
| 177 | // OBSOLETE } |
| 178 | // OBSOLETE if (TYPE_CODE (param_type) == TYPE_CODE_REF) |
| 179 | // OBSOLETE { |
| 180 | // OBSOLETE chill_type_print_base (TYPE_TARGET_TYPE (param_type), |
| 181 | // OBSOLETE stream, 0, level); |
| 182 | // OBSOLETE fputs_filtered (" LOC", stream); |
| 183 | // OBSOLETE } |
| 184 | // OBSOLETE else |
| 185 | // OBSOLETE chill_type_print_base (param_type, stream, show, level); |
| 186 | // OBSOLETE } |
| 187 | // OBSOLETE fprintf_filtered (stream, ")"); |
| 188 | // OBSOLETE if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID) |
| 189 | // OBSOLETE { |
| 190 | // OBSOLETE fputs_filtered (" RETURNS (", stream); |
| 191 | // OBSOLETE chill_type_print_base (TYPE_TARGET_TYPE (type), stream, 0, level); |
| 192 | // OBSOLETE fputs_filtered (")", stream); |
| 193 | // OBSOLETE } |
| 194 | // OBSOLETE break; |
| 195 | // OBSOLETE |
| 196 | // OBSOLETE case TYPE_CODE_STRUCT: |
| 197 | // OBSOLETE if (chill_varying_type (type)) |
| 198 | // OBSOLETE { |
| 199 | // OBSOLETE chill_type_print_base (TYPE_FIELD_TYPE (type, 1), |
| 200 | // OBSOLETE stream, 0, level); |
| 201 | // OBSOLETE fputs_filtered (" VARYING", stream); |
| 202 | // OBSOLETE } |
| 203 | // OBSOLETE else |
| 204 | // OBSOLETE { |
| 205 | // OBSOLETE fprintf_filtered (stream, "STRUCT "); |
| 206 | // OBSOLETE |
| 207 | // OBSOLETE fprintf_filtered (stream, "(\n"); |
| 208 | // OBSOLETE if ((TYPE_NFIELDS (type) == 0) && (TYPE_NFN_FIELDS (type) == 0)) |
| 209 | // OBSOLETE { |
| 210 | // OBSOLETE if (TYPE_STUB (type)) |
| 211 | // OBSOLETE { |
| 212 | // OBSOLETE fprintfi_filtered (level + 4, stream, "<incomplete type>\n"); |
| 213 | // OBSOLETE } |
| 214 | // OBSOLETE else |
| 215 | // OBSOLETE { |
| 216 | // OBSOLETE fprintfi_filtered (level + 4, stream, "<no data fields>\n"); |
| 217 | // OBSOLETE } |
| 218 | // OBSOLETE } |
| 219 | // OBSOLETE else |
| 220 | // OBSOLETE { |
| 221 | // OBSOLETE len = TYPE_NFIELDS (type); |
| 222 | // OBSOLETE for (i = TYPE_N_BASECLASSES (type); i < len; i++) |
| 223 | // OBSOLETE { |
| 224 | // OBSOLETE struct type *field_type = TYPE_FIELD_TYPE (type, i); |
| 225 | // OBSOLETE QUIT; |
| 226 | // OBSOLETE print_spaces_filtered (level + 4, stream); |
| 227 | // OBSOLETE if (TYPE_CODE (field_type) == TYPE_CODE_UNION) |
| 228 | // OBSOLETE { |
| 229 | // OBSOLETE int j; /* variant number */ |
| 230 | // OBSOLETE fputs_filtered ("CASE OF\n", stream); |
| 231 | // OBSOLETE for (j = 0; j < TYPE_NFIELDS (field_type); j++) |
| 232 | // OBSOLETE { |
| 233 | // OBSOLETE int k; /* variant field index */ |
| 234 | // OBSOLETE struct type *variant_type |
| 235 | // OBSOLETE = TYPE_FIELD_TYPE (field_type, j); |
| 236 | // OBSOLETE int var_len = TYPE_NFIELDS (variant_type); |
| 237 | // OBSOLETE print_spaces_filtered (level + 4, stream); |
| 238 | // OBSOLETE if (strcmp (TYPE_FIELD_NAME (field_type, j), |
| 239 | // OBSOLETE "else") == 0) |
| 240 | // OBSOLETE fputs_filtered ("ELSE\n", stream); |
| 241 | // OBSOLETE else |
| 242 | // OBSOLETE fputs_filtered (":\n", stream); |
| 243 | // OBSOLETE if (TYPE_CODE (variant_type) != TYPE_CODE_STRUCT) |
| 244 | // OBSOLETE error ("variant record confusion"); |
| 245 | // OBSOLETE for (k = 0; k < var_len; k++) |
| 246 | // OBSOLETE { |
| 247 | // OBSOLETE print_spaces_filtered (level + 8, stream); |
| 248 | // OBSOLETE chill_print_type (TYPE_FIELD_TYPE (variant_type, k), |
| 249 | // OBSOLETE TYPE_FIELD_NAME (variant_type, k), |
| 250 | // OBSOLETE stream, show - 1, level + 8); |
| 251 | // OBSOLETE if (k < (var_len - 1)) |
| 252 | // OBSOLETE fputs_filtered (",", stream); |
| 253 | // OBSOLETE fputs_filtered ("\n", stream); |
| 254 | // OBSOLETE } |
| 255 | // OBSOLETE } |
| 256 | // OBSOLETE print_spaces_filtered (level + 4, stream); |
| 257 | // OBSOLETE fputs_filtered ("ESAC", stream); |
| 258 | // OBSOLETE } |
| 259 | // OBSOLETE else |
| 260 | // OBSOLETE chill_print_type (field_type, |
| 261 | // OBSOLETE TYPE_FIELD_NAME (type, i), |
| 262 | // OBSOLETE stream, show - 1, level + 4); |
| 263 | // OBSOLETE if (i < (len - 1)) |
| 264 | // OBSOLETE { |
| 265 | // OBSOLETE fputs_filtered (",", stream); |
| 266 | // OBSOLETE } |
| 267 | // OBSOLETE fputs_filtered ("\n", stream); |
| 268 | // OBSOLETE } |
| 269 | // OBSOLETE } |
| 270 | // OBSOLETE fprintfi_filtered (level, stream, ")"); |
| 271 | // OBSOLETE } |
| 272 | // OBSOLETE break; |
| 273 | // OBSOLETE |
| 274 | // OBSOLETE case TYPE_CODE_RANGE: |
| 275 | // OBSOLETE { |
| 276 | // OBSOLETE struct type *target = TYPE_TARGET_TYPE (type); |
| 277 | // OBSOLETE if (target && TYPE_NAME (target)) |
| 278 | // OBSOLETE fputs_filtered (TYPE_NAME (target), stream); |
| 279 | // OBSOLETE else |
| 280 | // OBSOLETE fputs_filtered ("RANGE", stream); |
| 281 | // OBSOLETE if (target == NULL) |
| 282 | // OBSOLETE target = builtin_type_long; |
| 283 | // OBSOLETE fputs_filtered (" (", stream); |
| 284 | // OBSOLETE print_type_scalar (target, TYPE_LOW_BOUND (type), stream); |
| 285 | // OBSOLETE fputs_filtered (":", stream); |
| 286 | // OBSOLETE print_type_scalar (target, TYPE_HIGH_BOUND (type), stream); |
| 287 | // OBSOLETE fputs_filtered (")", stream); |
| 288 | // OBSOLETE } |
| 289 | // OBSOLETE break; |
| 290 | // OBSOLETE |
| 291 | // OBSOLETE case TYPE_CODE_ENUM: |
| 292 | // OBSOLETE { |
| 293 | // OBSOLETE register int lastval = 0; |
| 294 | // OBSOLETE fprintf_filtered (stream, "SET ("); |
| 295 | // OBSOLETE len = TYPE_NFIELDS (type); |
| 296 | // OBSOLETE for (i = 0; i < len; i++) |
| 297 | // OBSOLETE { |
| 298 | // OBSOLETE QUIT; |
| 299 | // OBSOLETE if (i) |
| 300 | // OBSOLETE fprintf_filtered (stream, ", "); |
| 301 | // OBSOLETE wrap_here (" "); |
| 302 | // OBSOLETE fputs_filtered (TYPE_FIELD_NAME (type, i), stream); |
| 303 | // OBSOLETE if (lastval != TYPE_FIELD_BITPOS (type, i)) |
| 304 | // OBSOLETE { |
| 305 | // OBSOLETE fprintf_filtered (stream, " = %d", TYPE_FIELD_BITPOS (type, i)); |
| 306 | // OBSOLETE lastval = TYPE_FIELD_BITPOS (type, i); |
| 307 | // OBSOLETE } |
| 308 | // OBSOLETE lastval++; |
| 309 | // OBSOLETE } |
| 310 | // OBSOLETE fprintf_filtered (stream, ")"); |
| 311 | // OBSOLETE } |
| 312 | // OBSOLETE break; |
| 313 | // OBSOLETE |
| 314 | // OBSOLETE case TYPE_CODE_VOID: |
| 315 | // OBSOLETE case TYPE_CODE_UNDEF: |
| 316 | // OBSOLETE case TYPE_CODE_ERROR: |
| 317 | // OBSOLETE case TYPE_CODE_UNION: |
| 318 | // OBSOLETE case TYPE_CODE_METHOD: |
| 319 | // OBSOLETE error ("missing language support in chill_type_print_base"); |
| 320 | // OBSOLETE break; |
| 321 | // OBSOLETE |
| 322 | // OBSOLETE default: |
| 323 | // OBSOLETE |
| 324 | // OBSOLETE /* Handle types not explicitly handled by the other cases, |
| 325 | // OBSOLETE such as fundamental types. For these, just print whatever |
| 326 | // OBSOLETE the type name is, as recorded in the type itself. If there |
| 327 | // OBSOLETE is no type name, then complain. */ |
| 328 | // OBSOLETE |
| 329 | // OBSOLETE if (TYPE_NAME (type) != NULL) |
| 330 | // OBSOLETE { |
| 331 | // OBSOLETE fputs_filtered (TYPE_NAME (type), stream); |
| 332 | // OBSOLETE } |
| 333 | // OBSOLETE else |
| 334 | // OBSOLETE { |
| 335 | // OBSOLETE error ("Unrecognized type code (%d) in symbol table.", |
| 336 | // OBSOLETE TYPE_CODE (type)); |
| 337 | // OBSOLETE } |
| 338 | // OBSOLETE break; |
| 339 | // OBSOLETE } |
| 340 | // OBSOLETE } |