1 /* Target description support for GDB.
3 Copyright (C) 2006-2013 Free Software Foundation, Inc.
5 Contributed by CodeSourcery.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
23 #include "arch-utils.h"
26 #include "reggroups.h"
28 #include "target-descriptions.h"
30 #include "xml-support.h"
31 #include "xml-tdesc.h"
34 #include "gdb_assert.h"
35 #include "gdb_obstack.h"
41 typedef struct property
46 DEF_VEC_O(property_s);
48 /* An individual register from a target description. */
50 typedef struct tdesc_reg
52 /* The name of this register. In standard features, it may be
53 recognized by the architecture support code, or it may be purely
57 /* The register number used by this target to refer to this
58 register. This is used for remote p/P packets and to determine
59 the ordering of registers in the remote g/G packets. */
62 /* If this flag is set, GDB should save and restore this register
63 around calls to an inferior function. */
66 /* The name of the register group containing this register, or NULL
67 if the group should be automatically determined from the
68 register's type. If this is "general", "float", or "vector", the
69 corresponding "info" command should display this register's
70 value. It can be an arbitrary string, but should be limited to
71 alphanumeric characters and internal hyphens. Currently other
72 strings are ignored (treated as NULL). */
75 /* The size of the register, in bits. */
78 /* The type of the register. This string corresponds to either
79 a named type from the target description or a predefined
83 /* The target-described type corresponding to TYPE, if found. */
84 struct tdesc_type *tdesc_type;
86 DEF_VEC_P(tdesc_reg_p);
88 /* A named type from a target description. */
90 typedef struct tdesc_type_field
93 struct tdesc_type *type;
96 DEF_VEC_O(tdesc_type_field);
98 typedef struct tdesc_type_flag
103 DEF_VEC_O(tdesc_type_flag);
105 typedef struct tdesc_type
107 /* The name of this type. */
110 /* Identify the kind of this type. */
113 /* Predefined types. */
126 TDESC_TYPE_IEEE_SINGLE,
127 TDESC_TYPE_IEEE_DOUBLE,
128 TDESC_TYPE_ARM_FPA_EXT,
131 /* Types defined by a target feature. */
138 /* Kind-specific data. */
144 struct tdesc_type *type;
148 /* Struct or union type. */
151 VEC(tdesc_type_field) *fields;
158 VEC(tdesc_type_flag) *flags;
163 DEF_VEC_P(tdesc_type_p);
165 /* A feature from a target description. Each feature is a collection
166 of other elements, e.g. registers and types. */
168 typedef struct tdesc_feature
170 /* The name of this feature. It may be recognized by the architecture
174 /* The registers associated with this feature. */
175 VEC(tdesc_reg_p) *registers;
177 /* The types associated with this feature. */
178 VEC(tdesc_type_p) *types;
180 DEF_VEC_P(tdesc_feature_p);
182 /* A compatible architecture from a target description. */
183 typedef const struct bfd_arch_info *arch_p;
186 /* A target description. */
190 /* The architecture reported by the target, if any. */
191 const struct bfd_arch_info *arch;
193 /* The osabi reported by the target, if any; GDB_OSABI_UNKNOWN
195 enum gdb_osabi osabi;
197 /* The list of compatible architectures reported by the target. */
198 VEC(arch_p) *compatible;
200 /* Any architecture-specific properties specified by the target. */
201 VEC(property_s) *properties;
203 /* The features associated with this target. */
204 VEC(tdesc_feature_p) *features;
207 /* Per-architecture data associated with a target description. The
208 target description may be shared by multiple architectures, but
209 this data is private to one gdbarch. */
211 typedef struct tdesc_arch_reg
213 struct tdesc_reg *reg;
216 DEF_VEC_O(tdesc_arch_reg);
218 struct tdesc_arch_data
220 /* A list of register/type pairs, indexed by GDB's internal register number.
221 During initialization of the gdbarch this list is used to store
222 registers which the architecture assigns a fixed register number.
223 Registers which are NULL in this array, or off the end, are
224 treated as zero-sized and nameless (i.e. placeholders in the
226 VEC(tdesc_arch_reg) *arch_regs;
228 /* Functions which report the register name, type, and reggroups for
230 gdbarch_register_name_ftype *pseudo_register_name;
231 gdbarch_register_type_ftype *pseudo_register_type;
232 gdbarch_register_reggroup_p_ftype *pseudo_register_reggroup_p;
235 /* Info about an inferior's target description. There's one of these
236 for each inferior. */
238 struct target_desc_info
240 /* A flag indicating that a description has already been fetched
241 from the target, so it should not be queried again. */
245 /* The description fetched from the target, or NULL if the target
246 did not supply any description. Only valid when
247 target_desc_fetched is set. Only the description initialization
248 code should access this; normally, the description should be
249 accessed through the gdbarch object. */
251 const struct target_desc *tdesc;
253 /* The filename to read a target description from, as set by "set
254 tdesc filename ..." */
259 /* Get the inferior INF's target description info, allocating one on
260 the stop if necessary. */
262 static struct target_desc_info *
263 get_tdesc_info (struct inferior *inf)
265 if (inf->tdesc_info == NULL)
266 inf->tdesc_info = XCNEW (struct target_desc_info);
267 return inf->tdesc_info;
270 /* A handle for architecture-specific data associated with the
271 target description (see struct tdesc_arch_data). */
273 static struct gdbarch_data *tdesc_data;
275 /* See target-descriptions.h. */
278 target_desc_info_from_user_p (struct target_desc_info *info)
280 return info != NULL && info->filename != NULL;
283 /* See target-descriptions.h. */
286 copy_inferior_target_desc_info (struct inferior *destinf, struct inferior *srcinf)
288 struct target_desc_info *src = get_tdesc_info (srcinf);
289 struct target_desc_info *dest = get_tdesc_info (destinf);
291 dest->fetched = src->fetched;
292 dest->tdesc = src->tdesc;
293 dest->filename = src->filename != NULL ? xstrdup (src->filename) : NULL;
296 /* See target-descriptions.h. */
299 target_desc_info_free (struct target_desc_info *tdesc_info)
301 if (tdesc_info != NULL)
303 xfree (tdesc_info->filename);
308 /* Convenience helper macros. */
310 #define target_desc_fetched \
311 get_tdesc_info (current_inferior ())->fetched
312 #define current_target_desc \
313 get_tdesc_info (current_inferior ())->tdesc
314 #define target_description_filename \
315 get_tdesc_info (current_inferior ())->filename
317 /* The string manipulated by the "set tdesc filename ..." command. */
319 static char *tdesc_filename_cmd_string;
321 /* Fetch the current target's description, and switch the current
322 architecture to one which incorporates that description. */
325 target_find_description (void)
327 /* If we've already fetched a description from the target, don't do
328 it again. This allows a target to fetch the description early,
329 during its to_open or to_create_inferior, if it needs extra
330 information about the target to initialize. */
331 if (target_desc_fetched)
334 /* The current architecture should not have any target description
335 specified. It should have been cleared, e.g. when we
336 disconnected from the previous target. */
337 gdb_assert (gdbarch_target_desc (target_gdbarch ()) == NULL);
339 /* First try to fetch an XML description from the user-specified
341 current_target_desc = NULL;
342 if (target_description_filename != NULL
343 && *target_description_filename != '\0')
345 = file_read_description_xml (target_description_filename);
347 /* Next try to read the description from the current target using
349 if (current_target_desc == NULL)
350 current_target_desc = target_read_description_xml (¤t_target);
352 /* If that failed try a target-specific hook. */
353 if (current_target_desc == NULL)
354 current_target_desc = target_read_description (¤t_target);
356 /* If a non-NULL description was returned, then update the current
358 if (current_target_desc)
360 struct gdbarch_info info;
362 gdbarch_info_init (&info);
363 info.target_desc = current_target_desc;
364 if (!gdbarch_update_p (info))
365 warning (_("Architecture rejected target-supplied description"));
368 struct tdesc_arch_data *data;
370 data = gdbarch_data (target_gdbarch (), tdesc_data);
371 if (tdesc_has_registers (current_target_desc)
372 && data->arch_regs == NULL)
373 warning (_("Target-supplied registers are not supported "
374 "by the current architecture"));
378 /* Now that we know this description is usable, record that we
380 target_desc_fetched = 1;
383 /* Discard any description fetched from the current target, and switch
384 the current architecture to one with no target description. */
387 target_clear_description (void)
389 struct gdbarch_info info;
391 if (!target_desc_fetched)
394 target_desc_fetched = 0;
395 current_target_desc = NULL;
397 gdbarch_info_init (&info);
398 if (!gdbarch_update_p (info))
399 internal_error (__FILE__, __LINE__,
400 _("Could not remove target-supplied description"));
403 /* Return the global current target description. This should only be
404 used by gdbarch initialization code; most access should be through
405 an existing gdbarch. */
407 const struct target_desc *
408 target_current_description (void)
410 if (target_desc_fetched)
411 return current_target_desc;
416 /* Return non-zero if this target description is compatible
417 with the given BFD architecture. */
420 tdesc_compatible_p (const struct target_desc *target_desc,
421 const struct bfd_arch_info *arch)
423 const struct bfd_arch_info *compat;
426 for (ix = 0; VEC_iterate (arch_p, target_desc->compatible, ix, compat);
430 || arch->compatible (arch, compat)
431 || compat->compatible (compat, arch))
439 /* Direct accessors for target descriptions. */
441 /* Return the string value of a property named KEY, or NULL if the
442 property was not specified. */
445 tdesc_property (const struct target_desc *target_desc, const char *key)
447 struct property *prop;
450 for (ix = 0; VEC_iterate (property_s, target_desc->properties, ix, prop);
452 if (strcmp (prop->key, key) == 0)
458 /* Return the BFD architecture associated with this target
459 description, or NULL if no architecture was specified. */
461 const struct bfd_arch_info *
462 tdesc_architecture (const struct target_desc *target_desc)
464 return target_desc->arch;
467 /* Return the OSABI associated with this target description, or
468 GDB_OSABI_UNKNOWN if no osabi was specified. */
471 tdesc_osabi (const struct target_desc *target_desc)
473 return target_desc->osabi;
478 /* Return 1 if this target description includes any registers. */
481 tdesc_has_registers (const struct target_desc *target_desc)
484 struct tdesc_feature *feature;
486 if (target_desc == NULL)
490 VEC_iterate (tdesc_feature_p, target_desc->features, ix, feature);
492 if (! VEC_empty (tdesc_reg_p, feature->registers))
498 /* Return the feature with the given name, if present, or NULL if
499 the named feature is not found. */
501 const struct tdesc_feature *
502 tdesc_find_feature (const struct target_desc *target_desc,
506 struct tdesc_feature *feature;
509 VEC_iterate (tdesc_feature_p, target_desc->features, ix, feature);
511 if (strcmp (feature->name, name) == 0)
517 /* Return the name of FEATURE. */
520 tdesc_feature_name (const struct tdesc_feature *feature)
522 return feature->name;
525 /* Predefined types. */
526 static struct tdesc_type tdesc_predefined_types[] =
528 { "int8", TDESC_TYPE_INT8 },
529 { "int16", TDESC_TYPE_INT16 },
530 { "int32", TDESC_TYPE_INT32 },
531 { "int64", TDESC_TYPE_INT64 },
532 { "int128", TDESC_TYPE_INT128 },
533 { "uint8", TDESC_TYPE_UINT8 },
534 { "uint16", TDESC_TYPE_UINT16 },
535 { "uint32", TDESC_TYPE_UINT32 },
536 { "uint64", TDESC_TYPE_UINT64 },
537 { "uint128", TDESC_TYPE_UINT128 },
538 { "code_ptr", TDESC_TYPE_CODE_PTR },
539 { "data_ptr", TDESC_TYPE_DATA_PTR },
540 { "ieee_single", TDESC_TYPE_IEEE_SINGLE },
541 { "ieee_double", TDESC_TYPE_IEEE_DOUBLE },
542 { "arm_fpa_ext", TDESC_TYPE_ARM_FPA_EXT },
543 { "i387_ext", TDESC_TYPE_I387_EXT }
546 /* Return the type associated with ID in the context of FEATURE, or
550 tdesc_named_type (const struct tdesc_feature *feature, const char *id)
553 struct tdesc_type *type;
555 /* First try target-defined types. */
556 for (ix = 0; VEC_iterate (tdesc_type_p, feature->types, ix, type); ix++)
557 if (strcmp (type->name, id) == 0)
560 /* Next try the predefined types. */
561 for (ix = 0; ix < ARRAY_SIZE (tdesc_predefined_types); ix++)
562 if (strcmp (tdesc_predefined_types[ix].name, id) == 0)
563 return &tdesc_predefined_types[ix];
568 /* Lookup type associated with ID. */
571 tdesc_find_type (struct gdbarch *gdbarch, const char *id)
573 struct tdesc_arch_reg *reg;
574 struct tdesc_arch_data *data;
577 data = gdbarch_data (gdbarch, tdesc_data);
578 num_regs = VEC_length (tdesc_arch_reg, data->arch_regs);
579 for (i = 0; i < num_regs; i++)
581 reg = VEC_index (tdesc_arch_reg, data->arch_regs, i);
583 && reg->reg->tdesc_type
585 && strcmp (id, reg->reg->tdesc_type->name) == 0)
592 /* Construct, if necessary, and return the GDB type implementing target
593 type TDESC_TYPE for architecture GDBARCH. */
596 tdesc_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *tdesc_type)
600 switch (tdesc_type->kind)
602 /* Predefined types. */
603 case TDESC_TYPE_INT8:
604 return builtin_type (gdbarch)->builtin_int8;
606 case TDESC_TYPE_INT16:
607 return builtin_type (gdbarch)->builtin_int16;
609 case TDESC_TYPE_INT32:
610 return builtin_type (gdbarch)->builtin_int32;
612 case TDESC_TYPE_INT64:
613 return builtin_type (gdbarch)->builtin_int64;
615 case TDESC_TYPE_INT128:
616 return builtin_type (gdbarch)->builtin_int128;
618 case TDESC_TYPE_UINT8:
619 return builtin_type (gdbarch)->builtin_uint8;
621 case TDESC_TYPE_UINT16:
622 return builtin_type (gdbarch)->builtin_uint16;
624 case TDESC_TYPE_UINT32:
625 return builtin_type (gdbarch)->builtin_uint32;
627 case TDESC_TYPE_UINT64:
628 return builtin_type (gdbarch)->builtin_uint64;
630 case TDESC_TYPE_UINT128:
631 return builtin_type (gdbarch)->builtin_uint128;
633 case TDESC_TYPE_CODE_PTR:
634 return builtin_type (gdbarch)->builtin_func_ptr;
636 case TDESC_TYPE_DATA_PTR:
637 return builtin_type (gdbarch)->builtin_data_ptr;
643 type = tdesc_find_type (gdbarch, tdesc_type->name);
647 switch (tdesc_type->kind)
649 case TDESC_TYPE_IEEE_SINGLE:
650 return arch_float_type (gdbarch, -1, "builtin_type_ieee_single",
651 floatformats_ieee_single);
653 case TDESC_TYPE_IEEE_DOUBLE:
654 return arch_float_type (gdbarch, -1, "builtin_type_ieee_double",
655 floatformats_ieee_double);
657 case TDESC_TYPE_ARM_FPA_EXT:
658 return arch_float_type (gdbarch, -1, "builtin_type_arm_ext",
659 floatformats_arm_ext);
661 case TDESC_TYPE_I387_EXT:
662 return arch_float_type (gdbarch, -1, "builtin_type_i387_ext",
663 floatformats_i387_ext);
665 /* Types defined by a target feature. */
666 case TDESC_TYPE_VECTOR:
668 struct type *type, *field_type;
670 field_type = tdesc_gdb_type (gdbarch, tdesc_type->u.v.type);
671 type = init_vector_type (field_type, tdesc_type->u.v.count);
672 TYPE_NAME (type) = xstrdup (tdesc_type->name);
677 case TDESC_TYPE_STRUCT:
679 struct type *type, *field_type;
680 struct tdesc_type_field *f;
683 type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
684 TYPE_NAME (type) = xstrdup (tdesc_type->name);
685 TYPE_TAG_NAME (type) = TYPE_NAME (type);
688 VEC_iterate (tdesc_type_field, tdesc_type->u.u.fields, ix, f);
695 struct type *field_type;
696 int bitsize, total_size;
698 /* This invariant should be preserved while creating
700 gdb_assert (tdesc_type->u.u.size != 0);
701 if (tdesc_type->u.u.size > 4)
702 field_type = builtin_type (gdbarch)->builtin_uint64;
704 field_type = builtin_type (gdbarch)->builtin_uint32;
706 fld = append_composite_type_field_raw (type, xstrdup (f->name),
709 /* For little-endian, BITPOS counts from the LSB of
710 the structure and marks the LSB of the field. For
711 big-endian, BITPOS counts from the MSB of the
712 structure and marks the MSB of the field. Either
713 way, it is the number of bits to the "left" of the
714 field. To calculate this in big-endian, we need
715 the total size of the structure. */
716 bitsize = f->end - f->start + 1;
717 total_size = tdesc_type->u.u.size * TARGET_CHAR_BIT;
718 if (gdbarch_bits_big_endian (gdbarch))
719 SET_FIELD_BITPOS (fld[0], total_size - f->start - bitsize);
721 SET_FIELD_BITPOS (fld[0], f->start);
722 FIELD_BITSIZE (fld[0]) = bitsize;
726 field_type = tdesc_gdb_type (gdbarch, f->type);
727 append_composite_type_field (type, xstrdup (f->name),
732 if (tdesc_type->u.u.size != 0)
733 TYPE_LENGTH (type) = tdesc_type->u.u.size;
737 case TDESC_TYPE_UNION:
739 struct type *type, *field_type;
740 struct tdesc_type_field *f;
743 type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION);
744 TYPE_NAME (type) = xstrdup (tdesc_type->name);
747 VEC_iterate (tdesc_type_field, tdesc_type->u.u.fields, ix, f);
750 field_type = tdesc_gdb_type (gdbarch, f->type);
751 append_composite_type_field (type, xstrdup (f->name), field_type);
753 /* If any of the children of a union are vectors, flag the
754 union as a vector also. This allows e.g. a union of two
755 vector types to show up automatically in "info vector". */
756 if (TYPE_VECTOR (field_type))
757 TYPE_VECTOR (type) = 1;
762 case TDESC_TYPE_FLAGS:
764 struct tdesc_type_flag *f;
767 type = arch_flags_type (gdbarch, tdesc_type->name,
768 tdesc_type->u.f.size);
770 VEC_iterate (tdesc_type_flag, tdesc_type->u.f.flags, ix, f);
772 /* Note that contrary to the function name, this call will
773 just set the properties of an already-allocated
775 append_flags_type_flag (type, f->start,
776 *f->name ? f->name : NULL);
782 internal_error (__FILE__, __LINE__,
783 "Type \"%s\" has an unknown kind %d",
784 tdesc_type->name, tdesc_type->kind);
788 /* Support for registers from target descriptions. */
790 /* Construct the per-gdbarch data. */
793 tdesc_data_init (struct obstack *obstack)
795 struct tdesc_arch_data *data;
797 data = OBSTACK_ZALLOC (obstack, struct tdesc_arch_data);
801 /* Similar, but for the temporary copy used during architecture
804 struct tdesc_arch_data *
805 tdesc_data_alloc (void)
807 return XZALLOC (struct tdesc_arch_data);
810 /* Free something allocated by tdesc_data_alloc, if it is not going
811 to be used (for instance if it was unsuitable for the
815 tdesc_data_cleanup (void *data_untyped)
817 struct tdesc_arch_data *data = data_untyped;
819 VEC_free (tdesc_arch_reg, data->arch_regs);
823 /* Search FEATURE for a register named NAME. */
825 static struct tdesc_reg *
826 tdesc_find_register_early (const struct tdesc_feature *feature,
830 struct tdesc_reg *reg;
833 VEC_iterate (tdesc_reg_p, feature->registers, ixr, reg);
835 if (strcasecmp (reg->name, name) == 0)
841 /* Search FEATURE for a register named NAME. Assign REGNO to it. */
844 tdesc_numbered_register (const struct tdesc_feature *feature,
845 struct tdesc_arch_data *data,
846 int regno, const char *name)
848 struct tdesc_arch_reg arch_reg = { 0 };
849 struct tdesc_reg *reg = tdesc_find_register_early (feature, name);
854 /* Make sure the vector includes a REGNO'th element. */
855 while (regno >= VEC_length (tdesc_arch_reg, data->arch_regs))
856 VEC_safe_push (tdesc_arch_reg, data->arch_regs, &arch_reg);
859 VEC_replace (tdesc_arch_reg, data->arch_regs, regno, &arch_reg);
863 /* Search FEATURE for a register named NAME, but do not assign a fixed
864 register number to it. */
867 tdesc_unnumbered_register (const struct tdesc_feature *feature,
870 struct tdesc_reg *reg = tdesc_find_register_early (feature, name);
878 /* Search FEATURE for a register whose name is in NAMES and assign
882 tdesc_numbered_register_choices (const struct tdesc_feature *feature,
883 struct tdesc_arch_data *data,
884 int regno, const char *const names[])
888 for (i = 0; names[i] != NULL; i++)
889 if (tdesc_numbered_register (feature, data, regno, names[i]))
895 /* Search FEATURE for a register named NAME, and return its size in
896 bits. The register must exist. */
899 tdesc_register_size (const struct tdesc_feature *feature,
902 struct tdesc_reg *reg = tdesc_find_register_early (feature, name);
904 gdb_assert (reg != NULL);
908 /* Look up a register by its GDB internal register number. */
910 static struct tdesc_arch_reg *
911 tdesc_find_arch_register (struct gdbarch *gdbarch, int regno)
913 struct tdesc_arch_data *data;
915 data = gdbarch_data (gdbarch, tdesc_data);
916 if (regno < VEC_length (tdesc_arch_reg, data->arch_regs))
917 return VEC_index (tdesc_arch_reg, data->arch_regs, regno);
922 static struct tdesc_reg *
923 tdesc_find_register (struct gdbarch *gdbarch, int regno)
925 struct tdesc_arch_reg *reg = tdesc_find_arch_register (gdbarch, regno);
927 return reg? reg->reg : NULL;
930 /* Return the name of register REGNO, from the target description or
931 from an architecture-provided pseudo_register_name method. */
934 tdesc_register_name (struct gdbarch *gdbarch, int regno)
936 struct tdesc_reg *reg = tdesc_find_register (gdbarch, regno);
937 int num_regs = gdbarch_num_regs (gdbarch);
938 int num_pseudo_regs = gdbarch_num_pseudo_regs (gdbarch);
943 if (regno >= num_regs && regno < num_regs + num_pseudo_regs)
945 struct tdesc_arch_data *data = gdbarch_data (gdbarch, tdesc_data);
947 gdb_assert (data->pseudo_register_name != NULL);
948 return data->pseudo_register_name (gdbarch, regno);
955 tdesc_register_type (struct gdbarch *gdbarch, int regno)
957 struct tdesc_arch_reg *arch_reg = tdesc_find_arch_register (gdbarch, regno);
958 struct tdesc_reg *reg = arch_reg? arch_reg->reg : NULL;
959 int num_regs = gdbarch_num_regs (gdbarch);
960 int num_pseudo_regs = gdbarch_num_pseudo_regs (gdbarch);
962 if (reg == NULL && regno >= num_regs && regno < num_regs + num_pseudo_regs)
964 struct tdesc_arch_data *data = gdbarch_data (gdbarch, tdesc_data);
966 gdb_assert (data->pseudo_register_type != NULL);
967 return data->pseudo_register_type (gdbarch, regno);
971 /* Return "int0_t", since "void" has a misleading size of one. */
972 return builtin_type (gdbarch)->builtin_int0;
974 if (arch_reg->type == NULL)
976 /* First check for a predefined or target defined type. */
978 arch_reg->type = tdesc_gdb_type (gdbarch, reg->tdesc_type);
980 /* Next try size-sensitive type shortcuts. */
981 else if (strcmp (reg->type, "float") == 0)
983 if (reg->bitsize == gdbarch_float_bit (gdbarch))
984 arch_reg->type = builtin_type (gdbarch)->builtin_float;
985 else if (reg->bitsize == gdbarch_double_bit (gdbarch))
986 arch_reg->type = builtin_type (gdbarch)->builtin_double;
987 else if (reg->bitsize == gdbarch_long_double_bit (gdbarch))
988 arch_reg->type = builtin_type (gdbarch)->builtin_long_double;
991 warning (_("Register \"%s\" has an unsupported size (%d bits)"),
992 reg->name, reg->bitsize);
993 arch_reg->type = builtin_type (gdbarch)->builtin_double;
996 else if (strcmp (reg->type, "int") == 0)
998 if (reg->bitsize == gdbarch_long_bit (gdbarch))
999 arch_reg->type = builtin_type (gdbarch)->builtin_long;
1000 else if (reg->bitsize == TARGET_CHAR_BIT)
1001 arch_reg->type = builtin_type (gdbarch)->builtin_char;
1002 else if (reg->bitsize == gdbarch_short_bit (gdbarch))
1003 arch_reg->type = builtin_type (gdbarch)->builtin_short;
1004 else if (reg->bitsize == gdbarch_int_bit (gdbarch))
1005 arch_reg->type = builtin_type (gdbarch)->builtin_int;
1006 else if (reg->bitsize == gdbarch_long_long_bit (gdbarch))
1007 arch_reg->type = builtin_type (gdbarch)->builtin_long_long;
1008 else if (reg->bitsize == gdbarch_ptr_bit (gdbarch))
1009 /* A bit desperate by this point... */
1010 arch_reg->type = builtin_type (gdbarch)->builtin_data_ptr;
1013 warning (_("Register \"%s\" has an unsupported size (%d bits)"),
1014 reg->name, reg->bitsize);
1015 arch_reg->type = builtin_type (gdbarch)->builtin_long;
1019 if (arch_reg->type == NULL)
1020 internal_error (__FILE__, __LINE__,
1021 "Register \"%s\" has an unknown type \"%s\"",
1022 reg->name, reg->type);
1025 return arch_reg->type;
1029 tdesc_remote_register_number (struct gdbarch *gdbarch, int regno)
1031 struct tdesc_reg *reg = tdesc_find_register (gdbarch, regno);
1034 return reg->target_regnum;
1039 /* Check whether REGNUM is a member of REGGROUP. Registers from the
1040 target description may be classified as general, float, or vector.
1041 Unlike a gdbarch register_reggroup_p method, this function will
1042 return -1 if it does not know; the caller should handle registers
1043 with no specified group.
1045 Arbitrary strings (other than "general", "float", and "vector")
1046 from the description are not used; they cause the register to be
1047 displayed in "info all-registers" but excluded from "info
1048 registers" et al. The names of containing features are also not
1049 used. This might be extended to display registers in some more
1052 The save-restore flag is also implemented here. */
1055 tdesc_register_in_reggroup_p (struct gdbarch *gdbarch, int regno,
1056 struct reggroup *reggroup)
1058 struct tdesc_reg *reg = tdesc_find_register (gdbarch, regno);
1060 if (reg != NULL && reg->group != NULL)
1062 int general_p = 0, float_p = 0, vector_p = 0;
1064 if (strcmp (reg->group, "general") == 0)
1066 else if (strcmp (reg->group, "float") == 0)
1068 else if (strcmp (reg->group, "vector") == 0)
1071 if (reggroup == float_reggroup)
1074 if (reggroup == vector_reggroup)
1077 if (reggroup == general_reggroup)
1082 && (reggroup == save_reggroup || reggroup == restore_reggroup))
1083 return reg->save_restore;
1088 /* Check whether REGNUM is a member of REGGROUP. Registers with no
1089 group specified go to the default reggroup function and are handled
1093 tdesc_register_reggroup_p (struct gdbarch *gdbarch, int regno,
1094 struct reggroup *reggroup)
1096 int num_regs = gdbarch_num_regs (gdbarch);
1097 int num_pseudo_regs = gdbarch_num_pseudo_regs (gdbarch);
1100 if (regno >= num_regs && regno < num_regs + num_pseudo_regs)
1102 struct tdesc_arch_data *data = gdbarch_data (gdbarch, tdesc_data);
1104 if (data->pseudo_register_reggroup_p != NULL)
1105 return data->pseudo_register_reggroup_p (gdbarch, regno, reggroup);
1106 /* Otherwise fall through to the default reggroup_p. */
1109 ret = tdesc_register_in_reggroup_p (gdbarch, regno, reggroup);
1113 return default_register_reggroup_p (gdbarch, regno, reggroup);
1116 /* Record architecture-specific functions to call for pseudo-register
1120 set_tdesc_pseudo_register_name (struct gdbarch *gdbarch,
1121 gdbarch_register_name_ftype *pseudo_name)
1123 struct tdesc_arch_data *data = gdbarch_data (gdbarch, tdesc_data);
1125 data->pseudo_register_name = pseudo_name;
1129 set_tdesc_pseudo_register_type (struct gdbarch *gdbarch,
1130 gdbarch_register_type_ftype *pseudo_type)
1132 struct tdesc_arch_data *data = gdbarch_data (gdbarch, tdesc_data);
1134 data->pseudo_register_type = pseudo_type;
1138 set_tdesc_pseudo_register_reggroup_p
1139 (struct gdbarch *gdbarch,
1140 gdbarch_register_reggroup_p_ftype *pseudo_reggroup_p)
1142 struct tdesc_arch_data *data = gdbarch_data (gdbarch, tdesc_data);
1144 data->pseudo_register_reggroup_p = pseudo_reggroup_p;
1147 /* Update GDBARCH to use the target description for registers. */
1150 tdesc_use_registers (struct gdbarch *gdbarch,
1151 const struct target_desc *target_desc,
1152 struct tdesc_arch_data *early_data)
1154 int num_regs = gdbarch_num_regs (gdbarch);
1156 struct tdesc_feature *feature;
1157 struct tdesc_reg *reg;
1158 struct tdesc_arch_data *data;
1159 struct tdesc_arch_reg *arch_reg, new_arch_reg = { 0 };
1162 /* We can't use the description for registers if it doesn't describe
1163 any. This function should only be called after validating
1164 registers, so the caller should know that registers are
1166 gdb_assert (tdesc_has_registers (target_desc));
1168 data = gdbarch_data (gdbarch, tdesc_data);
1169 data->arch_regs = early_data->arch_regs;
1172 /* Build up a set of all registers, so that we can assign register
1173 numbers where needed. The hash table expands as necessary, so
1174 the initial size is arbitrary. */
1175 reg_hash = htab_create (37, htab_hash_pointer, htab_eq_pointer, NULL);
1177 VEC_iterate (tdesc_feature_p, target_desc->features, ixf, feature);
1180 VEC_iterate (tdesc_reg_p, feature->registers, ixr, reg);
1183 void **slot = htab_find_slot (reg_hash, reg, INSERT);
1188 /* Remove any registers which were assigned numbers by the
1191 VEC_iterate (tdesc_arch_reg, data->arch_regs, ixr, arch_reg);
1194 htab_remove_elt (reg_hash, arch_reg->reg);
1196 /* Assign numbers to the remaining registers and add them to the
1197 list of registers. The new numbers are always above gdbarch_num_regs.
1198 Iterate over the features, not the hash table, so that the order
1199 matches that in the target description. */
1201 gdb_assert (VEC_length (tdesc_arch_reg, data->arch_regs) <= num_regs);
1202 while (VEC_length (tdesc_arch_reg, data->arch_regs) < num_regs)
1203 VEC_safe_push (tdesc_arch_reg, data->arch_regs, &new_arch_reg);
1205 VEC_iterate (tdesc_feature_p, target_desc->features, ixf, feature);
1208 VEC_iterate (tdesc_reg_p, feature->registers, ixr, reg);
1210 if (htab_find (reg_hash, reg) != NULL)
1212 new_arch_reg.reg = reg;
1213 VEC_safe_push (tdesc_arch_reg, data->arch_regs, &new_arch_reg);
1217 htab_delete (reg_hash);
1219 /* Update the architecture. */
1220 set_gdbarch_num_regs (gdbarch, num_regs);
1221 set_gdbarch_register_name (gdbarch, tdesc_register_name);
1222 set_gdbarch_register_type (gdbarch, tdesc_register_type);
1223 set_gdbarch_remote_register_number (gdbarch,
1224 tdesc_remote_register_number);
1225 set_gdbarch_register_reggroup_p (gdbarch, tdesc_register_reggroup_p);
1229 /* Methods for constructing a target description. */
1232 tdesc_free_reg (struct tdesc_reg *reg)
1241 tdesc_create_reg (struct tdesc_feature *feature, const char *name,
1242 int regnum, int save_restore, const char *group,
1243 int bitsize, const char *type)
1245 struct tdesc_reg *reg = XZALLOC (struct tdesc_reg);
1247 reg->name = xstrdup (name);
1248 reg->target_regnum = regnum;
1249 reg->save_restore = save_restore;
1250 reg->group = group ? xstrdup (group) : NULL;
1251 reg->bitsize = bitsize;
1252 reg->type = type ? xstrdup (type) : xstrdup ("<unknown>");
1254 /* If the register's type is target-defined, look it up now. We may not
1255 have easy access to the containing feature when we want it later. */
1256 reg->tdesc_type = tdesc_named_type (feature, reg->type);
1258 VEC_safe_push (tdesc_reg_p, feature->registers, reg);
1262 tdesc_free_type (struct tdesc_type *type)
1266 case TDESC_TYPE_STRUCT:
1267 case TDESC_TYPE_UNION:
1269 struct tdesc_type_field *f;
1273 VEC_iterate (tdesc_type_field, type->u.u.fields, ix, f);
1277 VEC_free (tdesc_type_field, type->u.u.fields);
1281 case TDESC_TYPE_FLAGS:
1283 struct tdesc_type_flag *f;
1287 VEC_iterate (tdesc_type_flag, type->u.f.flags, ix, f);
1291 VEC_free (tdesc_type_flag, type->u.f.flags);
1304 tdesc_create_vector (struct tdesc_feature *feature, const char *name,
1305 struct tdesc_type *field_type, int count)
1307 struct tdesc_type *type = XZALLOC (struct tdesc_type);
1309 type->name = xstrdup (name);
1310 type->kind = TDESC_TYPE_VECTOR;
1311 type->u.v.type = field_type;
1312 type->u.v.count = count;
1314 VEC_safe_push (tdesc_type_p, feature->types, type);
1319 tdesc_create_struct (struct tdesc_feature *feature, const char *name)
1321 struct tdesc_type *type = XZALLOC (struct tdesc_type);
1323 type->name = xstrdup (name);
1324 type->kind = TDESC_TYPE_STRUCT;
1326 VEC_safe_push (tdesc_type_p, feature->types, type);
1330 /* Set the total length of TYPE. Structs which contain bitfields may
1331 omit the reserved bits, so the end of the last field may not
1335 tdesc_set_struct_size (struct tdesc_type *type, LONGEST size)
1337 gdb_assert (type->kind == TDESC_TYPE_STRUCT);
1338 type->u.u.size = size;
1342 tdesc_create_union (struct tdesc_feature *feature, const char *name)
1344 struct tdesc_type *type = XZALLOC (struct tdesc_type);
1346 type->name = xstrdup (name);
1347 type->kind = TDESC_TYPE_UNION;
1349 VEC_safe_push (tdesc_type_p, feature->types, type);
1354 tdesc_create_flags (struct tdesc_feature *feature, const char *name,
1357 struct tdesc_type *type = XZALLOC (struct tdesc_type);
1359 type->name = xstrdup (name);
1360 type->kind = TDESC_TYPE_FLAGS;
1361 type->u.f.size = size;
1363 VEC_safe_push (tdesc_type_p, feature->types, type);
1367 /* Add a new field. Return a temporary pointer to the field, which
1368 is only valid until the next call to tdesc_add_field (the vector
1369 might be reallocated). */
1372 tdesc_add_field (struct tdesc_type *type, const char *field_name,
1373 struct tdesc_type *field_type)
1375 struct tdesc_type_field f = { 0 };
1377 gdb_assert (type->kind == TDESC_TYPE_UNION
1378 || type->kind == TDESC_TYPE_STRUCT);
1380 f.name = xstrdup (field_name);
1381 f.type = field_type;
1383 VEC_safe_push (tdesc_type_field, type->u.u.fields, &f);
1386 /* Add a new bitfield. */
1389 tdesc_add_bitfield (struct tdesc_type *type, const char *field_name,
1392 struct tdesc_type_field f = { 0 };
1394 gdb_assert (type->kind == TDESC_TYPE_STRUCT);
1396 f.name = xstrdup (field_name);
1400 VEC_safe_push (tdesc_type_field, type->u.u.fields, &f);
1404 tdesc_add_flag (struct tdesc_type *type, int start,
1405 const char *flag_name)
1407 struct tdesc_type_flag f = { 0 };
1409 gdb_assert (type->kind == TDESC_TYPE_FLAGS);
1411 f.name = xstrdup (flag_name);
1414 VEC_safe_push (tdesc_type_flag, type->u.f.flags, &f);
1418 tdesc_free_feature (struct tdesc_feature *feature)
1420 struct tdesc_reg *reg;
1421 struct tdesc_type *type;
1424 for (ix = 0; VEC_iterate (tdesc_reg_p, feature->registers, ix, reg); ix++)
1425 tdesc_free_reg (reg);
1426 VEC_free (tdesc_reg_p, feature->registers);
1428 for (ix = 0; VEC_iterate (tdesc_type_p, feature->types, ix, type); ix++)
1429 tdesc_free_type (type);
1430 VEC_free (tdesc_type_p, feature->types);
1432 xfree (feature->name);
1436 struct tdesc_feature *
1437 tdesc_create_feature (struct target_desc *tdesc, const char *name)
1439 struct tdesc_feature *new_feature = XZALLOC (struct tdesc_feature);
1441 new_feature->name = xstrdup (name);
1443 VEC_safe_push (tdesc_feature_p, tdesc->features, new_feature);
1447 struct target_desc *
1448 allocate_target_description (void)
1450 return XZALLOC (struct target_desc);
1454 free_target_description (void *arg)
1456 struct target_desc *target_desc = arg;
1457 struct tdesc_feature *feature;
1458 struct property *prop;
1462 VEC_iterate (tdesc_feature_p, target_desc->features, ix, feature);
1464 tdesc_free_feature (feature);
1465 VEC_free (tdesc_feature_p, target_desc->features);
1468 VEC_iterate (property_s, target_desc->properties, ix, prop);
1472 xfree (prop->value);
1474 VEC_free (property_s, target_desc->properties);
1476 VEC_free (arch_p, target_desc->compatible);
1478 xfree (target_desc);
1482 make_cleanup_free_target_description (struct target_desc *target_desc)
1484 return make_cleanup (free_target_description, target_desc);
1488 tdesc_add_compatible (struct target_desc *target_desc,
1489 const struct bfd_arch_info *compatible)
1491 const struct bfd_arch_info *compat;
1494 /* If this instance of GDB is compiled without BFD support for the
1495 compatible architecture, simply ignore it -- we would not be able
1496 to handle it anyway. */
1497 if (compatible == NULL)
1500 for (ix = 0; VEC_iterate (arch_p, target_desc->compatible, ix, compat);
1502 if (compat == compatible)
1503 internal_error (__FILE__, __LINE__,
1504 _("Attempted to add duplicate "
1505 "compatible architecture \"%s\""),
1506 compatible->printable_name);
1508 VEC_safe_push (arch_p, target_desc->compatible, compatible);
1512 set_tdesc_property (struct target_desc *target_desc,
1513 const char *key, const char *value)
1515 struct property *prop, new_prop;
1518 gdb_assert (key != NULL && value != NULL);
1520 for (ix = 0; VEC_iterate (property_s, target_desc->properties, ix, prop);
1522 if (strcmp (prop->key, key) == 0)
1523 internal_error (__FILE__, __LINE__,
1524 _("Attempted to add duplicate property \"%s\""), key);
1526 new_prop.key = xstrdup (key);
1527 new_prop.value = xstrdup (value);
1528 VEC_safe_push (property_s, target_desc->properties, &new_prop);
1532 set_tdesc_architecture (struct target_desc *target_desc,
1533 const struct bfd_arch_info *arch)
1535 target_desc->arch = arch;
1539 set_tdesc_osabi (struct target_desc *target_desc, enum gdb_osabi osabi)
1541 target_desc->osabi = osabi;
1545 static struct cmd_list_element *tdesc_set_cmdlist, *tdesc_show_cmdlist;
1546 static struct cmd_list_element *tdesc_unset_cmdlist;
1548 /* Helper functions for the CLI commands. */
1551 set_tdesc_cmd (char *args, int from_tty)
1553 help_list (tdesc_set_cmdlist, "set tdesc ", -1, gdb_stdout);
1557 show_tdesc_cmd (char *args, int from_tty)
1559 cmd_show_list (tdesc_show_cmdlist, from_tty, "");
1563 unset_tdesc_cmd (char *args, int from_tty)
1565 help_list (tdesc_unset_cmdlist, "unset tdesc ", -1, gdb_stdout);
1569 set_tdesc_filename_cmd (char *args, int from_tty,
1570 struct cmd_list_element *c)
1572 xfree (target_description_filename);
1573 target_description_filename = xstrdup (tdesc_filename_cmd_string);
1575 target_clear_description ();
1576 target_find_description ();
1580 show_tdesc_filename_cmd (struct ui_file *file, int from_tty,
1581 struct cmd_list_element *c,
1584 value = target_description_filename;
1586 if (value != NULL && *value != '\0')
1587 printf_filtered (_("The target description will be read from \"%s\".\n"),
1590 printf_filtered (_("The target description will be "
1591 "read from the target.\n"));
1595 unset_tdesc_filename_cmd (char *args, int from_tty)
1597 xfree (target_description_filename);
1598 target_description_filename = NULL;
1599 target_clear_description ();
1600 target_find_description ();
1604 maint_print_c_tdesc_cmd (char *args, int from_tty)
1606 const struct target_desc *tdesc;
1607 const struct bfd_arch_info *compatible;
1608 const char *filename, *inp;
1609 char *function, *outp;
1610 struct property *prop;
1611 struct tdesc_feature *feature;
1612 struct tdesc_reg *reg;
1613 struct tdesc_type *type;
1614 struct tdesc_type_field *f;
1615 struct tdesc_type_flag *flag;
1617 int printed_field_type = 0;
1619 /* Use the global target-supplied description, not the current
1620 architecture's. This lets a GDB for one architecture generate C
1621 for another architecture's description, even though the gdbarch
1622 initialization code will reject the new description. */
1623 tdesc = current_target_desc;
1625 error (_("There is no target description to print."));
1627 if (target_description_filename == NULL)
1628 error (_("The current target description did not come from an XML file."));
1630 filename = lbasename (target_description_filename);
1631 function = alloca (strlen (filename) + 1);
1632 for (inp = filename, outp = function; *inp != '\0'; inp++)
1635 else if (*inp == '-')
1641 /* Standard boilerplate. */
1642 printf_unfiltered ("/* THIS FILE IS GENERATED. "
1643 "-*- buffer-read-only: t -*- vi"
1645 printf_unfiltered (" Original: %s */\n\n", filename);
1646 printf_unfiltered ("#include \"defs.h\"\n");
1647 printf_unfiltered ("#include \"osabi.h\"\n");
1648 printf_unfiltered ("#include \"target-descriptions.h\"\n");
1649 printf_unfiltered ("\n");
1651 printf_unfiltered ("struct target_desc *tdesc_%s;\n", function);
1652 printf_unfiltered ("static void\n");
1653 printf_unfiltered ("initialize_tdesc_%s (void)\n", function);
1654 printf_unfiltered ("{\n");
1656 (" struct target_desc *result = allocate_target_description ();\n");
1657 printf_unfiltered (" struct tdesc_feature *feature;\n");
1659 /* Now we do some "filtering" in order to know which variables to
1660 declare. This is needed because otherwise we would declare unused
1661 variables `field_type' and `type'. */
1663 VEC_iterate (tdesc_feature_p, tdesc->features, ix, feature);
1666 int printed_desc_type = 0;
1669 VEC_iterate (tdesc_type_p, feature->types, ix2, type);
1672 if (!printed_field_type)
1674 printf_unfiltered (" struct tdesc_type *field_type;\n");
1675 printed_field_type = 1;
1678 if ((type->kind == TDESC_TYPE_UNION
1679 || type->kind == TDESC_TYPE_STRUCT)
1680 && VEC_length (tdesc_type_field, type->u.u.fields) > 0)
1682 printf_unfiltered (" struct tdesc_type *type;\n");
1683 printed_desc_type = 1;
1688 if (printed_desc_type)
1692 printf_unfiltered ("\n");
1694 if (tdesc_architecture (tdesc) != NULL)
1697 (" set_tdesc_architecture (result, bfd_scan_arch (\"%s\"));\n",
1698 tdesc_architecture (tdesc)->printable_name);
1699 printf_unfiltered ("\n");
1702 if (tdesc_osabi (tdesc) > GDB_OSABI_UNKNOWN
1703 && tdesc_osabi (tdesc) < GDB_OSABI_INVALID)
1706 (" set_tdesc_osabi (result, osabi_from_tdesc_string (\"%s\"));\n",
1707 gdbarch_osabi_name (tdesc_osabi (tdesc)));
1708 printf_unfiltered ("\n");
1711 for (ix = 0; VEC_iterate (arch_p, tdesc->compatible, ix, compatible);
1715 (" tdesc_add_compatible (result, bfd_scan_arch (\"%s\"));\n",
1716 compatible->printable_name);
1719 printf_unfiltered ("\n");
1721 for (ix = 0; VEC_iterate (property_s, tdesc->properties, ix, prop);
1724 printf_unfiltered (" set_tdesc_property (result, \"%s\", \"%s\");\n",
1725 prop->key, prop->value);
1729 VEC_iterate (tdesc_feature_p, tdesc->features, ix, feature);
1732 printf_unfiltered (" \
1733 feature = tdesc_create_feature (result, \"%s\");\n",
1737 VEC_iterate (tdesc_type_p, feature->types, ix2, type);
1742 case TDESC_TYPE_VECTOR:
1744 (" field_type = tdesc_named_type (feature, \"%s\");\n",
1745 type->u.v.type->name);
1747 (" tdesc_create_vector (feature, \"%s\", field_type, %d);\n",
1748 type->name, type->u.v.count);
1750 case TDESC_TYPE_STRUCT:
1752 (" type = tdesc_create_struct (feature, \"%s\");\n",
1754 if (type->u.u.size != 0)
1756 (" tdesc_set_struct_size (type, %s);\n",
1757 plongest (type->u.u.size));
1759 VEC_iterate (tdesc_type_field, type->u.u.fields, ix3, f);
1762 /* Going first for implicitly sized types, else part handles
1763 bitfields. As reported on xml-tdesc.c implicitly sized types
1764 cannot contain a bitfield. */
1765 if (f->start == 0 && f->end == 0)
1768 (" field_type = tdesc_named_type (feature, \"%s\");\n",
1771 (" tdesc_add_field (type, \"%s\", field_type);\n",
1776 (" tdesc_add_bitfield (type, \"%s\", %d, %d);\n",
1777 f->name, f->start, f->end);
1780 case TDESC_TYPE_UNION:
1782 (" type = tdesc_create_union (feature, \"%s\");\n",
1785 VEC_iterate (tdesc_type_field, type->u.u.fields, ix3, f);
1789 (" field_type = tdesc_named_type (feature, \"%s\");\n",
1792 (" tdesc_add_field (type, \"%s\", field_type);\n",
1796 case TDESC_TYPE_FLAGS:
1798 (" field_type = tdesc_create_flags (feature, \"%s\", %d);\n",
1799 type->name, (int) type->u.f.size);
1801 VEC_iterate (tdesc_type_flag, type->u.f.flags, ix3,
1805 (" tdesc_add_flag (field_type, %d, \"%s\");\n",
1806 flag->start, flag->name);
1809 error (_("C output is not supported type \"%s\"."), type->name);
1811 printf_unfiltered ("\n");
1815 VEC_iterate (tdesc_reg_p, feature->registers, ix2, reg);
1818 printf_unfiltered (" tdesc_create_reg (feature, \"%s\", %ld, %d, ",
1819 reg->name, reg->target_regnum, reg->save_restore);
1821 printf_unfiltered ("\"%s\", ", reg->group);
1823 printf_unfiltered ("NULL, ");
1824 printf_unfiltered ("%d, \"%s\");\n", reg->bitsize, reg->type);
1827 printf_unfiltered ("\n");
1830 printf_unfiltered (" tdesc_%s = result;\n", function);
1831 printf_unfiltered ("}\n");
1834 /* Provide a prototype to silence -Wmissing-prototypes. */
1835 extern initialize_file_ftype _initialize_target_descriptions;
1838 _initialize_target_descriptions (void)
1840 tdesc_data = gdbarch_data_register_pre_init (tdesc_data_init);
1842 add_prefix_cmd ("tdesc", class_maintenance, set_tdesc_cmd, _("\
1843 Set target description specific variables."),
1844 &tdesc_set_cmdlist, "set tdesc ",
1845 0 /* allow-unknown */, &setlist);
1846 add_prefix_cmd ("tdesc", class_maintenance, show_tdesc_cmd, _("\
1847 Show target description specific variables."),
1848 &tdesc_show_cmdlist, "show tdesc ",
1849 0 /* allow-unknown */, &showlist);
1850 add_prefix_cmd ("tdesc", class_maintenance, unset_tdesc_cmd, _("\
1851 Unset target description specific variables."),
1852 &tdesc_unset_cmdlist, "unset tdesc ",
1853 0 /* allow-unknown */, &unsetlist);
1855 add_setshow_filename_cmd ("filename", class_obscure,
1856 &tdesc_filename_cmd_string,
1858 Set the file to read for an XML target description"), _("\
1859 Show the file to read for an XML target description"), _("\
1860 When set, GDB will read the target description from a local\n\
1861 file instead of querying the remote target."),
1862 set_tdesc_filename_cmd,
1863 show_tdesc_filename_cmd,
1864 &tdesc_set_cmdlist, &tdesc_show_cmdlist);
1866 add_cmd ("filename", class_obscure, unset_tdesc_filename_cmd, _("\
1867 Unset the file to read for an XML target description. When unset,\n\
1868 GDB will read the description from the target."),
1869 &tdesc_unset_cmdlist);
1871 add_cmd ("c-tdesc", class_maintenance, maint_print_c_tdesc_cmd, _("\
1872 Print the current target description as a C source file."),
1873 &maintenanceprintlist);