1 /* Target description support for GDB.
3 Copyright (C) 2006, 2007, 2008, 2009, 2010 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"
40 typedef struct property
45 DEF_VEC_O(property_s);
47 /* An individual register from a target description. */
49 typedef struct tdesc_reg
51 /* The name of this register. In standard features, it may be
52 recognized by the architecture support code, or it may be purely
56 /* The register number used by this target to refer to this
57 register. This is used for remote p/P packets and to determine
58 the ordering of registers in the remote g/G packets. */
61 /* If this flag is set, GDB should save and restore this register
62 around calls to an inferior function. */
65 /* The name of the register group containing this register, or NULL
66 if the group should be automatically determined from the
67 register's type. If this is "general", "float", or "vector", the
68 corresponding "info" command should display this register's
69 value. It can be an arbitrary string, but should be limited to
70 alphanumeric characters and internal hyphens. Currently other
71 strings are ignored (treated as NULL). */
74 /* The size of the register, in bits. */
77 /* The type of the register. This string corresponds to either
78 a named type from the target description or a predefined
82 /* The target-described type corresponding to TYPE, if found. */
83 struct tdesc_type *tdesc_type;
85 DEF_VEC_P(tdesc_reg_p);
87 /* A named type from a target description. */
89 typedef struct tdesc_type_field
92 struct tdesc_type *type;
95 DEF_VEC_O(tdesc_type_field);
97 typedef struct tdesc_type_flag
102 DEF_VEC_O(tdesc_type_flag);
104 typedef struct tdesc_type
106 /* The name of this type. */
109 /* Identify the kind of this type. */
112 /* Predefined types. */
125 TDESC_TYPE_IEEE_SINGLE,
126 TDESC_TYPE_IEEE_DOUBLE,
127 TDESC_TYPE_ARM_FPA_EXT,
129 TDESC_TYPE_I386_EFLAGS,
130 TDESC_TYPE_I386_MXCSR,
132 /* Types defined by a target feature. */
139 /* Kind-specific data. */
145 struct tdesc_type *type;
149 /* Struct or union type. */
152 VEC(tdesc_type_field) *fields;
159 VEC(tdesc_type_flag) *flags;
164 DEF_VEC_P(tdesc_type_p);
166 /* A feature from a target description. Each feature is a collection
167 of other elements, e.g. registers and types. */
169 typedef struct tdesc_feature
171 /* The name of this feature. It may be recognized by the architecture
175 /* The registers associated with this feature. */
176 VEC(tdesc_reg_p) *registers;
178 /* The types associated with this feature. */
179 VEC(tdesc_type_p) *types;
181 DEF_VEC_P(tdesc_feature_p);
183 /* A compatible architecture from a target description. */
184 typedef const struct bfd_arch_info *arch_p;
187 /* A target description. */
191 /* The architecture reported by the target, if any. */
192 const struct bfd_arch_info *arch;
194 /* The osabi reported by the target, if any; GDB_OSABI_UNKNOWN
196 enum gdb_osabi osabi;
198 /* The list of compatible architectures reported by the target. */
199 VEC(arch_p) *compatible;
201 /* Any architecture-specific properties specified by the target. */
202 VEC(property_s) *properties;
204 /* The features associated with this target. */
205 VEC(tdesc_feature_p) *features;
208 /* Per-architecture data associated with a target description. The
209 target description may be shared by multiple architectures, but
210 this data is private to one gdbarch. */
212 typedef struct tdesc_arch_reg
214 struct tdesc_reg *reg;
217 DEF_VEC_O(tdesc_arch_reg);
219 struct tdesc_arch_data
221 /* A list of register/type pairs, indexed by GDB's internal register number.
222 During initialization of the gdbarch this list is used to store
223 registers which the architecture assigns a fixed register number.
224 Registers which are NULL in this array, or off the end, are
225 treated as zero-sized and nameless (i.e. placeholders in the
227 VEC(tdesc_arch_reg) *arch_regs;
229 /* Functions which report the register name, type, and reggroups for
231 gdbarch_register_name_ftype *pseudo_register_name;
232 gdbarch_register_type_ftype *pseudo_register_type;
233 gdbarch_register_reggroup_p_ftype *pseudo_register_reggroup_p;
236 /* Global state. These variables are associated with the current
237 target; if GDB adds support for multiple simultaneous targets, then
238 these variables should become target-specific data. */
240 /* A flag indicating that a description has already been fetched from
241 the current target, so it should not be queried again. */
243 static int target_desc_fetched;
245 /* The description fetched from the current target, or NULL if the
246 current target 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 static const struct target_desc *current_target_desc;
253 /* Other global variables. */
255 /* The filename to read a target description from. */
257 static char *target_description_filename;
259 /* A handle for architecture-specific data associated with the
260 target description (see struct tdesc_arch_data). */
262 static struct gdbarch_data *tdesc_data;
264 /* Fetch the current target's description, and switch the current
265 architecture to one which incorporates that description. */
268 target_find_description (void)
270 /* If we've already fetched a description from the target, don't do
271 it again. This allows a target to fetch the description early,
272 during its to_open or to_create_inferior, if it needs extra
273 information about the target to initialize. */
274 if (target_desc_fetched)
277 /* The current architecture should not have any target description
278 specified. It should have been cleared, e.g. when we
279 disconnected from the previous target. */
280 gdb_assert (gdbarch_target_desc (target_gdbarch) == NULL);
282 /* First try to fetch an XML description from the user-specified
284 current_target_desc = NULL;
285 if (target_description_filename != NULL
286 && *target_description_filename != '\0')
288 = file_read_description_xml (target_description_filename);
290 /* Next try to read the description from the current target using
292 if (current_target_desc == NULL)
293 current_target_desc = target_read_description_xml (¤t_target);
295 /* If that failed try a target-specific hook. */
296 if (current_target_desc == NULL)
297 current_target_desc = target_read_description (¤t_target);
299 /* If a non-NULL description was returned, then update the current
301 if (current_target_desc)
303 struct gdbarch_info info;
305 gdbarch_info_init (&info);
306 info.target_desc = current_target_desc;
307 if (!gdbarch_update_p (info))
308 warning (_("Architecture rejected target-supplied description"));
311 struct tdesc_arch_data *data;
313 data = gdbarch_data (target_gdbarch, tdesc_data);
314 if (tdesc_has_registers (current_target_desc)
315 && data->arch_regs == NULL)
316 warning (_("Target-supplied registers are not supported "
317 "by the current architecture"));
321 /* Now that we know this description is usable, record that we
323 target_desc_fetched = 1;
326 /* Discard any description fetched from the current target, and switch
327 the current architecture to one with no target description. */
330 target_clear_description (void)
332 struct gdbarch_info info;
334 if (!target_desc_fetched)
337 target_desc_fetched = 0;
338 current_target_desc = NULL;
340 gdbarch_info_init (&info);
341 if (!gdbarch_update_p (info))
342 internal_error (__FILE__, __LINE__,
343 _("Could not remove target-supplied description"));
346 /* Return the global current target description. This should only be
347 used by gdbarch initialization code; most access should be through
348 an existing gdbarch. */
350 const struct target_desc *
351 target_current_description (void)
353 if (target_desc_fetched)
354 return current_target_desc;
359 /* Return non-zero if this target description is compatible
360 with the given BFD architecture. */
363 tdesc_compatible_p (const struct target_desc *target_desc,
364 const struct bfd_arch_info *arch)
366 const struct bfd_arch_info *compat;
369 for (ix = 0; VEC_iterate (arch_p, target_desc->compatible, ix, compat);
373 || arch->compatible (arch, compat)
374 || compat->compatible (compat, arch))
382 /* Direct accessors for target descriptions. */
384 /* Return the string value of a property named KEY, or NULL if the
385 property was not specified. */
388 tdesc_property (const struct target_desc *target_desc, const char *key)
390 struct property *prop;
393 for (ix = 0; VEC_iterate (property_s, target_desc->properties, ix, prop);
395 if (strcmp (prop->key, key) == 0)
401 /* Return the BFD architecture associated with this target
402 description, or NULL if no architecture was specified. */
404 const struct bfd_arch_info *
405 tdesc_architecture (const struct target_desc *target_desc)
407 return target_desc->arch;
410 /* Return the OSABI associated with this target description, or
411 GDB_OSABI_UNKNOWN if no osabi was specified. */
414 tdesc_osabi (const struct target_desc *target_desc)
416 return target_desc->osabi;
421 /* Return 1 if this target description includes any registers. */
424 tdesc_has_registers (const struct target_desc *target_desc)
427 struct tdesc_feature *feature;
429 if (target_desc == NULL)
433 VEC_iterate (tdesc_feature_p, target_desc->features, ix, feature);
435 if (! VEC_empty (tdesc_reg_p, feature->registers))
441 /* Return the feature with the given name, if present, or NULL if
442 the named feature is not found. */
444 const struct tdesc_feature *
445 tdesc_find_feature (const struct target_desc *target_desc,
449 struct tdesc_feature *feature;
452 VEC_iterate (tdesc_feature_p, target_desc->features, ix, feature);
454 if (strcmp (feature->name, name) == 0)
460 /* Return the name of FEATURE. */
463 tdesc_feature_name (const struct tdesc_feature *feature)
465 return feature->name;
468 /* Predefined types. */
469 static struct tdesc_type tdesc_predefined_types[] =
471 { "int8", TDESC_TYPE_INT8 },
472 { "int16", TDESC_TYPE_INT16 },
473 { "int32", TDESC_TYPE_INT32 },
474 { "int64", TDESC_TYPE_INT64 },
475 { "int128", TDESC_TYPE_INT128 },
476 { "uint8", TDESC_TYPE_UINT8 },
477 { "uint16", TDESC_TYPE_UINT16 },
478 { "uint32", TDESC_TYPE_UINT32 },
479 { "uint64", TDESC_TYPE_UINT64 },
480 { "uint128", TDESC_TYPE_UINT128 },
481 { "code_ptr", TDESC_TYPE_CODE_PTR },
482 { "data_ptr", TDESC_TYPE_DATA_PTR },
483 { "ieee_single", TDESC_TYPE_IEEE_SINGLE },
484 { "ieee_double", TDESC_TYPE_IEEE_DOUBLE },
485 { "arm_fpa_ext", TDESC_TYPE_ARM_FPA_EXT },
486 { "i387_ext", TDESC_TYPE_I387_EXT },
487 { "i386_eflags", TDESC_TYPE_I386_EFLAGS },
488 { "i386_mxcsr", TDESC_TYPE_I386_MXCSR }
491 /* Return the type associated with ID in the context of FEATURE, or
495 tdesc_named_type (const struct tdesc_feature *feature, const char *id)
498 struct tdesc_type *type;
500 /* First try target-defined types. */
501 for (ix = 0; VEC_iterate (tdesc_type_p, feature->types, ix, type); ix++)
502 if (strcmp (type->name, id) == 0)
505 /* Next try the predefined types. */
506 for (ix = 0; ix < ARRAY_SIZE (tdesc_predefined_types); ix++)
507 if (strcmp (tdesc_predefined_types[ix].name, id) == 0)
508 return &tdesc_predefined_types[ix];
513 /* Lookup type associated with ID. */
516 tdesc_find_type (struct gdbarch *gdbarch, const char *id)
518 struct tdesc_arch_reg *reg;
519 struct tdesc_arch_data *data;
522 data = gdbarch_data (gdbarch, tdesc_data);
523 num_regs = VEC_length (tdesc_arch_reg, data->arch_regs);
524 for (i = 0; i < num_regs; i++)
526 reg = VEC_index (tdesc_arch_reg, data->arch_regs, i);
528 && reg->reg->tdesc_type
530 && strcmp (id, reg->reg->tdesc_type->name) == 0)
537 /* Construct, if necessary, and return the GDB type implementing target
538 type TDESC_TYPE for architecture GDBARCH. */
541 tdesc_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *tdesc_type)
545 switch (tdesc_type->kind)
547 /* Predefined types. */
548 case TDESC_TYPE_INT8:
549 return builtin_type (gdbarch)->builtin_int8;
551 case TDESC_TYPE_INT16:
552 return builtin_type (gdbarch)->builtin_int16;
554 case TDESC_TYPE_INT32:
555 return builtin_type (gdbarch)->builtin_int32;
557 case TDESC_TYPE_INT64:
558 return builtin_type (gdbarch)->builtin_int64;
560 case TDESC_TYPE_INT128:
561 return builtin_type (gdbarch)->builtin_int128;
563 case TDESC_TYPE_UINT8:
564 return builtin_type (gdbarch)->builtin_uint8;
566 case TDESC_TYPE_UINT16:
567 return builtin_type (gdbarch)->builtin_uint16;
569 case TDESC_TYPE_UINT32:
570 return builtin_type (gdbarch)->builtin_uint32;
572 case TDESC_TYPE_UINT64:
573 return builtin_type (gdbarch)->builtin_uint64;
575 case TDESC_TYPE_UINT128:
576 return builtin_type (gdbarch)->builtin_uint128;
578 case TDESC_TYPE_CODE_PTR:
579 return builtin_type (gdbarch)->builtin_func_ptr;
581 case TDESC_TYPE_DATA_PTR:
582 return builtin_type (gdbarch)->builtin_data_ptr;
588 type = tdesc_find_type (gdbarch, tdesc_type->name);
592 switch (tdesc_type->kind)
594 case TDESC_TYPE_IEEE_SINGLE:
595 return arch_float_type (gdbarch, -1, "builtin_type_ieee_single",
596 floatformats_ieee_single);
598 case TDESC_TYPE_IEEE_DOUBLE:
599 return arch_float_type (gdbarch, -1, "builtin_type_ieee_double",
600 floatformats_ieee_double);
602 case TDESC_TYPE_ARM_FPA_EXT:
603 return arch_float_type (gdbarch, -1, "builtin_type_arm_ext",
604 floatformats_arm_ext);
606 case TDESC_TYPE_I387_EXT:
607 return arch_float_type (gdbarch, -1, "builtin_type_i387_ext",
608 floatformats_i387_ext);
610 case TDESC_TYPE_I386_EFLAGS:
614 type = arch_flags_type (gdbarch, "builtin_type_i386_eflags", 4);
615 append_flags_type_flag (type, 0, "CF");
616 append_flags_type_flag (type, 1, NULL);
617 append_flags_type_flag (type, 2, "PF");
618 append_flags_type_flag (type, 4, "AF");
619 append_flags_type_flag (type, 6, "ZF");
620 append_flags_type_flag (type, 7, "SF");
621 append_flags_type_flag (type, 8, "TF");
622 append_flags_type_flag (type, 9, "IF");
623 append_flags_type_flag (type, 10, "DF");
624 append_flags_type_flag (type, 11, "OF");
625 append_flags_type_flag (type, 14, "NT");
626 append_flags_type_flag (type, 16, "RF");
627 append_flags_type_flag (type, 17, "VM");
628 append_flags_type_flag (type, 18, "AC");
629 append_flags_type_flag (type, 19, "VIF");
630 append_flags_type_flag (type, 20, "VIP");
631 append_flags_type_flag (type, 21, "ID");
637 case TDESC_TYPE_I386_MXCSR:
641 type = arch_flags_type (gdbarch, "builtin_type_i386_mxcsr", 4);
642 append_flags_type_flag (type, 0, "IE");
643 append_flags_type_flag (type, 1, "DE");
644 append_flags_type_flag (type, 2, "ZE");
645 append_flags_type_flag (type, 3, "OE");
646 append_flags_type_flag (type, 4, "UE");
647 append_flags_type_flag (type, 5, "PE");
648 append_flags_type_flag (type, 6, "DAZ");
649 append_flags_type_flag (type, 7, "IM");
650 append_flags_type_flag (type, 8, "DM");
651 append_flags_type_flag (type, 9, "ZM");
652 append_flags_type_flag (type, 10, "OM");
653 append_flags_type_flag (type, 11, "UM");
654 append_flags_type_flag (type, 12, "PM");
655 append_flags_type_flag (type, 15, "FZ");
661 /* Types defined by a target feature. */
662 case TDESC_TYPE_VECTOR:
664 struct type *type, *field_type;
666 field_type = tdesc_gdb_type (gdbarch, tdesc_type->u.v.type);
667 type = init_vector_type (field_type, tdesc_type->u.v.count);
668 TYPE_NAME (type) = xstrdup (tdesc_type->name);
673 case TDESC_TYPE_STRUCT:
675 struct type *type, *field_type;
676 struct tdesc_type_field *f;
679 type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
680 TYPE_NAME (type) = xstrdup (tdesc_type->name);
681 TYPE_TAG_NAME (type) = TYPE_NAME (type);
684 VEC_iterate (tdesc_type_field, tdesc_type->u.u.fields, ix, f);
691 struct type *field_type;
692 int bitsize, total_size;
694 /* This invariant should be preserved while creating
696 gdb_assert (tdesc_type->u.u.size != 0);
697 if (tdesc_type->u.u.size > 4)
698 field_type = builtin_type (gdbarch)->builtin_uint64;
700 field_type = builtin_type (gdbarch)->builtin_uint32;
702 fld = append_composite_type_field_raw (type, xstrdup (f->name),
705 /* For little-endian, BITPOS counts from the LSB of
706 the structure and marks the LSB of the field. For
707 big-endian, BITPOS counts from the MSB of the
708 structure and marks the MSB of the field. Either
709 way, it is the number of bits to the "left" of the
710 field. To calculate this in big-endian, we need
711 the total size of the structure. */
712 bitsize = f->end - f->start + 1;
713 total_size = tdesc_type->u.u.size * TARGET_CHAR_BIT;
714 if (gdbarch_bits_big_endian (gdbarch))
715 FIELD_BITPOS (fld[0]) = total_size - f->start - bitsize;
717 FIELD_BITPOS (fld[0]) = f->start;
718 FIELD_BITSIZE (fld[0]) = bitsize;
722 field_type = tdesc_gdb_type (gdbarch, f->type);
723 append_composite_type_field (type, xstrdup (f->name),
728 if (tdesc_type->u.u.size != 0)
729 TYPE_LENGTH (type) = tdesc_type->u.u.size;
733 case TDESC_TYPE_UNION:
735 struct type *type, *field_type;
736 struct tdesc_type_field *f;
739 type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION);
740 TYPE_NAME (type) = xstrdup (tdesc_type->name);
743 VEC_iterate (tdesc_type_field, tdesc_type->u.u.fields, ix, f);
746 field_type = tdesc_gdb_type (gdbarch, f->type);
747 append_composite_type_field (type, xstrdup (f->name), field_type);
749 /* If any of the children of a union are vectors, flag the
750 union as a vector also. This allows e.g. a union of two
751 vector types to show up automatically in "info vector". */
752 if (TYPE_VECTOR (field_type))
753 TYPE_VECTOR (type) = 1;
758 case TDESC_TYPE_FLAGS:
760 struct type *type, *field_type;
761 struct tdesc_type_flag *f;
764 type = arch_flags_type (gdbarch, xstrdup (tdesc_type->name),
765 tdesc_type->u.f.size);
767 VEC_iterate (tdesc_type_flag, tdesc_type->u.f.flags, ix, f);
769 /* Note that contrary to the function name, this call will
770 just set the properties of an already-allocated
772 append_flags_type_flag (type, f->start, f->name);
778 internal_error (__FILE__, __LINE__,
779 "Type \"%s\" has an unknown kind %d",
780 tdesc_type->name, tdesc_type->kind);
784 /* Support for registers from target descriptions. */
786 /* Construct the per-gdbarch data. */
789 tdesc_data_init (struct obstack *obstack)
791 struct tdesc_arch_data *data;
793 data = OBSTACK_ZALLOC (obstack, struct tdesc_arch_data);
797 /* Similar, but for the temporary copy used during architecture
800 struct tdesc_arch_data *
801 tdesc_data_alloc (void)
803 return XZALLOC (struct tdesc_arch_data);
806 /* Free something allocated by tdesc_data_alloc, if it is not going
807 to be used (for instance if it was unsuitable for the
811 tdesc_data_cleanup (void *data_untyped)
813 struct tdesc_arch_data *data = data_untyped;
815 VEC_free (tdesc_arch_reg, data->arch_regs);
819 /* Search FEATURE for a register named NAME. */
821 static struct tdesc_reg *
822 tdesc_find_register_early (const struct tdesc_feature *feature,
826 struct tdesc_reg *reg;
829 VEC_iterate (tdesc_reg_p, feature->registers, ixr, reg);
831 if (strcasecmp (reg->name, name) == 0)
837 /* Search FEATURE for a register named NAME. Assign REGNO to it. */
840 tdesc_numbered_register (const struct tdesc_feature *feature,
841 struct tdesc_arch_data *data,
842 int regno, const char *name)
844 struct tdesc_arch_reg arch_reg = { 0 };
845 struct tdesc_reg *reg = tdesc_find_register_early (feature, name);
850 /* Make sure the vector includes a REGNO'th element. */
851 while (regno >= VEC_length (tdesc_arch_reg, data->arch_regs))
852 VEC_safe_push (tdesc_arch_reg, data->arch_regs, &arch_reg);
855 VEC_replace (tdesc_arch_reg, data->arch_regs, regno, &arch_reg);
859 /* Search FEATURE for a register named NAME, but do not assign a fixed
860 register number to it. */
863 tdesc_unnumbered_register (const struct tdesc_feature *feature,
866 struct tdesc_reg *reg = tdesc_find_register_early (feature, name);
874 /* Search FEATURE for a register whose name is in NAMES and assign
878 tdesc_numbered_register_choices (const struct tdesc_feature *feature,
879 struct tdesc_arch_data *data,
880 int regno, const char *const names[])
884 for (i = 0; names[i] != NULL; i++)
885 if (tdesc_numbered_register (feature, data, regno, names[i]))
891 /* Search FEATURE for a register named NAME, and return its size in
892 bits. The register must exist. */
895 tdesc_register_size (const struct tdesc_feature *feature,
898 struct tdesc_reg *reg = tdesc_find_register_early (feature, name);
900 gdb_assert (reg != NULL);
904 /* Look up a register by its GDB internal register number. */
906 static struct tdesc_arch_reg *
907 tdesc_find_arch_register (struct gdbarch *gdbarch, int regno)
909 struct tdesc_arch_reg *reg;
910 struct tdesc_arch_data *data;
912 data = gdbarch_data (gdbarch, tdesc_data);
913 if (regno < VEC_length (tdesc_arch_reg, data->arch_regs))
914 return VEC_index (tdesc_arch_reg, data->arch_regs, regno);
919 static struct tdesc_reg *
920 tdesc_find_register (struct gdbarch *gdbarch, int regno)
922 struct tdesc_arch_reg *reg = tdesc_find_arch_register (gdbarch, regno);
923 return reg? reg->reg : NULL;
926 /* Return the name of register REGNO, from the target description or
927 from an architecture-provided pseudo_register_name method. */
930 tdesc_register_name (struct gdbarch *gdbarch, int regno)
932 struct tdesc_reg *reg = tdesc_find_register (gdbarch, regno);
933 int num_regs = gdbarch_num_regs (gdbarch);
934 int num_pseudo_regs = gdbarch_num_pseudo_regs (gdbarch);
939 if (regno >= num_regs && regno < num_regs + num_pseudo_regs)
941 struct tdesc_arch_data *data = gdbarch_data (gdbarch, tdesc_data);
942 gdb_assert (data->pseudo_register_name != NULL);
943 return data->pseudo_register_name (gdbarch, regno);
950 tdesc_register_type (struct gdbarch *gdbarch, int regno)
952 struct tdesc_arch_reg *arch_reg = tdesc_find_arch_register (gdbarch, regno);
953 struct tdesc_reg *reg = arch_reg? arch_reg->reg : NULL;
954 int num_regs = gdbarch_num_regs (gdbarch);
955 int num_pseudo_regs = gdbarch_num_pseudo_regs (gdbarch);
957 if (reg == NULL && regno >= num_regs && regno < num_regs + num_pseudo_regs)
959 struct tdesc_arch_data *data = gdbarch_data (gdbarch, tdesc_data);
960 gdb_assert (data->pseudo_register_type != NULL);
961 return data->pseudo_register_type (gdbarch, regno);
965 /* Return "int0_t", since "void" has a misleading size of one. */
966 return builtin_type (gdbarch)->builtin_int0;
968 if (arch_reg->type == NULL)
970 /* First check for a predefined or target defined type. */
972 arch_reg->type = tdesc_gdb_type (gdbarch, reg->tdesc_type);
974 /* Next try size-sensitive type shortcuts. */
975 else if (strcmp (reg->type, "float") == 0)
977 if (reg->bitsize == gdbarch_float_bit (gdbarch))
978 arch_reg->type = builtin_type (gdbarch)->builtin_float;
979 else if (reg->bitsize == gdbarch_double_bit (gdbarch))
980 arch_reg->type = builtin_type (gdbarch)->builtin_double;
981 else if (reg->bitsize == gdbarch_long_double_bit (gdbarch))
982 arch_reg->type = builtin_type (gdbarch)->builtin_long_double;
985 warning (_("Register \"%s\" has an unsupported size (%d bits)"),
986 reg->name, reg->bitsize);
987 arch_reg->type = builtin_type (gdbarch)->builtin_double;
990 else if (strcmp (reg->type, "int") == 0)
992 if (reg->bitsize == gdbarch_long_bit (gdbarch))
993 arch_reg->type = builtin_type (gdbarch)->builtin_long;
994 else if (reg->bitsize == TARGET_CHAR_BIT)
995 arch_reg->type = builtin_type (gdbarch)->builtin_char;
996 else if (reg->bitsize == gdbarch_short_bit (gdbarch))
997 arch_reg->type = builtin_type (gdbarch)->builtin_short;
998 else if (reg->bitsize == gdbarch_int_bit (gdbarch))
999 arch_reg->type = builtin_type (gdbarch)->builtin_int;
1000 else if (reg->bitsize == gdbarch_long_long_bit (gdbarch))
1001 arch_reg->type = builtin_type (gdbarch)->builtin_long_long;
1002 else if (reg->bitsize == gdbarch_ptr_bit (gdbarch))
1003 /* A bit desperate by this point... */
1004 arch_reg->type = builtin_type (gdbarch)->builtin_data_ptr;
1007 warning (_("Register \"%s\" has an unsupported size (%d bits)"),
1008 reg->name, reg->bitsize);
1009 arch_reg->type = builtin_type (gdbarch)->builtin_long;
1013 if (arch_reg->type == NULL)
1014 internal_error (__FILE__, __LINE__,
1015 "Register \"%s\" has an unknown type \"%s\"",
1016 reg->name, reg->type);
1019 return arch_reg->type;
1023 tdesc_remote_register_number (struct gdbarch *gdbarch, int regno)
1025 struct tdesc_reg *reg = tdesc_find_register (gdbarch, regno);
1028 return reg->target_regnum;
1033 /* Check whether REGNUM is a member of REGGROUP. Registers from the
1034 target description may be classified as general, float, or vector.
1035 Unlike a gdbarch register_reggroup_p method, this function will
1036 return -1 if it does not know; the caller should handle registers
1037 with no specified group.
1039 Arbitrary strings (other than "general", "float", and "vector")
1040 from the description are not used; they cause the register to be
1041 displayed in "info all-registers" but excluded from "info
1042 registers" et al. The names of containing features are also not
1043 used. This might be extended to display registers in some more
1046 The save-restore flag is also implemented here. */
1049 tdesc_register_in_reggroup_p (struct gdbarch *gdbarch, int regno,
1050 struct reggroup *reggroup)
1052 struct tdesc_reg *reg = tdesc_find_register (gdbarch, regno);
1054 if (reg != NULL && reg->group != NULL)
1056 int general_p = 0, float_p = 0, vector_p = 0;
1058 if (strcmp (reg->group, "general") == 0)
1060 else if (strcmp (reg->group, "float") == 0)
1062 else if (strcmp (reg->group, "vector") == 0)
1065 if (reggroup == float_reggroup)
1068 if (reggroup == vector_reggroup)
1071 if (reggroup == general_reggroup)
1076 && (reggroup == save_reggroup || reggroup == restore_reggroup))
1077 return reg->save_restore;
1082 /* Check whether REGNUM is a member of REGGROUP. Registers with no
1083 group specified go to the default reggroup function and are handled
1087 tdesc_register_reggroup_p (struct gdbarch *gdbarch, int regno,
1088 struct reggroup *reggroup)
1090 int num_regs = gdbarch_num_regs (gdbarch);
1091 int num_pseudo_regs = gdbarch_num_pseudo_regs (gdbarch);
1094 if (regno >= num_regs && regno < num_regs + num_pseudo_regs)
1096 struct tdesc_arch_data *data = gdbarch_data (gdbarch, tdesc_data);
1097 if (data->pseudo_register_reggroup_p != NULL)
1098 return data->pseudo_register_reggroup_p (gdbarch, regno, reggroup);
1099 /* Otherwise fall through to the default reggroup_p. */
1102 ret = tdesc_register_in_reggroup_p (gdbarch, regno, reggroup);
1106 return default_register_reggroup_p (gdbarch, regno, reggroup);
1109 /* Record architecture-specific functions to call for pseudo-register
1113 set_tdesc_pseudo_register_name (struct gdbarch *gdbarch,
1114 gdbarch_register_name_ftype *pseudo_name)
1116 struct tdesc_arch_data *data = gdbarch_data (gdbarch, tdesc_data);
1118 data->pseudo_register_name = pseudo_name;
1122 set_tdesc_pseudo_register_type (struct gdbarch *gdbarch,
1123 gdbarch_register_type_ftype *pseudo_type)
1125 struct tdesc_arch_data *data = gdbarch_data (gdbarch, tdesc_data);
1127 data->pseudo_register_type = pseudo_type;
1131 set_tdesc_pseudo_register_reggroup_p
1132 (struct gdbarch *gdbarch,
1133 gdbarch_register_reggroup_p_ftype *pseudo_reggroup_p)
1135 struct tdesc_arch_data *data = gdbarch_data (gdbarch, tdesc_data);
1137 data->pseudo_register_reggroup_p = pseudo_reggroup_p;
1140 /* Update GDBARCH to use the target description for registers. */
1143 tdesc_use_registers (struct gdbarch *gdbarch,
1144 const struct target_desc *target_desc,
1145 struct tdesc_arch_data *early_data)
1147 int num_regs = gdbarch_num_regs (gdbarch);
1149 struct tdesc_feature *feature;
1150 struct tdesc_reg *reg;
1151 struct tdesc_arch_data *data;
1152 struct tdesc_arch_reg *arch_reg, new_arch_reg = { 0 };
1155 /* We can't use the description for registers if it doesn't describe
1156 any. This function should only be called after validating
1157 registers, so the caller should know that registers are
1159 gdb_assert (tdesc_has_registers (target_desc));
1161 data = gdbarch_data (gdbarch, tdesc_data);
1162 data->arch_regs = early_data->arch_regs;
1165 /* Build up a set of all registers, so that we can assign register
1166 numbers where needed. The hash table expands as necessary, so
1167 the initial size is arbitrary. */
1168 reg_hash = htab_create (37, htab_hash_pointer, htab_eq_pointer, NULL);
1170 VEC_iterate (tdesc_feature_p, target_desc->features, ixf, feature);
1173 VEC_iterate (tdesc_reg_p, feature->registers, ixr, reg);
1176 void **slot = htab_find_slot (reg_hash, reg, INSERT);
1181 /* Remove any registers which were assigned numbers by the
1184 VEC_iterate (tdesc_arch_reg, data->arch_regs, ixr, arch_reg);
1187 htab_remove_elt (reg_hash, arch_reg->reg);
1189 /* Assign numbers to the remaining registers and add them to the
1190 list of registers. The new numbers are always above gdbarch_num_regs.
1191 Iterate over the features, not the hash table, so that the order
1192 matches that in the target description. */
1194 gdb_assert (VEC_length (tdesc_arch_reg, data->arch_regs) <= num_regs);
1195 while (VEC_length (tdesc_arch_reg, data->arch_regs) < num_regs)
1196 VEC_safe_push (tdesc_arch_reg, data->arch_regs, &new_arch_reg);
1198 VEC_iterate (tdesc_feature_p, target_desc->features, ixf, feature);
1201 VEC_iterate (tdesc_reg_p, feature->registers, ixr, reg);
1203 if (htab_find (reg_hash, reg) != NULL)
1205 new_arch_reg.reg = reg;
1206 VEC_safe_push (tdesc_arch_reg, data->arch_regs, &new_arch_reg);
1210 htab_delete (reg_hash);
1212 /* Update the architecture. */
1213 set_gdbarch_num_regs (gdbarch, num_regs);
1214 set_gdbarch_register_name (gdbarch, tdesc_register_name);
1215 set_gdbarch_register_type (gdbarch, tdesc_register_type);
1216 set_gdbarch_remote_register_number (gdbarch,
1217 tdesc_remote_register_number);
1218 set_gdbarch_register_reggroup_p (gdbarch, tdesc_register_reggroup_p);
1222 /* Methods for constructing a target description. */
1225 tdesc_free_reg (struct tdesc_reg *reg)
1234 tdesc_create_reg (struct tdesc_feature *feature, const char *name,
1235 int regnum, int save_restore, const char *group,
1236 int bitsize, const char *type)
1238 struct tdesc_reg *reg = XZALLOC (struct tdesc_reg);
1240 reg->name = xstrdup (name);
1241 reg->target_regnum = regnum;
1242 reg->save_restore = save_restore;
1243 reg->group = group ? xstrdup (group) : NULL;
1244 reg->bitsize = bitsize;
1245 reg->type = type ? xstrdup (type) : xstrdup ("<unknown>");
1247 /* If the register's type is target-defined, look it up now. We may not
1248 have easy access to the containing feature when we want it later. */
1249 reg->tdesc_type = tdesc_named_type (feature, reg->type);
1251 VEC_safe_push (tdesc_reg_p, feature->registers, reg);
1255 tdesc_free_type (struct tdesc_type *type)
1260 case TDESC_TYPE_STRUCT:
1261 case TDESC_TYPE_UNION:
1263 struct tdesc_type_field *f;
1267 VEC_iterate (tdesc_type_field, type->u.u.fields, ix, f);
1271 VEC_free (tdesc_type_field, type->u.u.fields);
1275 case TDESC_TYPE_FLAGS:
1277 struct tdesc_type_flag *f;
1281 VEC_iterate (tdesc_type_flag, type->u.f.flags, ix, f);
1285 VEC_free (tdesc_type_flag, type->u.f.flags);
1298 tdesc_create_vector (struct tdesc_feature *feature, const char *name,
1299 struct tdesc_type *field_type, int count)
1301 struct tdesc_type *type = XZALLOC (struct tdesc_type);
1303 type->name = xstrdup (name);
1304 type->kind = TDESC_TYPE_VECTOR;
1305 type->u.v.type = field_type;
1306 type->u.v.count = count;
1308 VEC_safe_push (tdesc_type_p, feature->types, type);
1313 tdesc_create_struct (struct tdesc_feature *feature, const char *name)
1315 struct tdesc_type *type = XZALLOC (struct tdesc_type);
1317 type->name = xstrdup (name);
1318 type->kind = TDESC_TYPE_STRUCT;
1320 VEC_safe_push (tdesc_type_p, feature->types, type);
1324 /* Set the total length of TYPE. Structs which contain bitfields may
1325 omit the reserved bits, so the end of the last field may not
1329 tdesc_set_struct_size (struct tdesc_type *type, LONGEST size)
1331 gdb_assert (type->kind == TDESC_TYPE_STRUCT);
1332 type->u.u.size = size;
1336 tdesc_create_union (struct tdesc_feature *feature, const char *name)
1338 struct tdesc_type *type = XZALLOC (struct tdesc_type);
1340 type->name = xstrdup (name);
1341 type->kind = TDESC_TYPE_UNION;
1343 VEC_safe_push (tdesc_type_p, feature->types, type);
1348 tdesc_create_flags (struct tdesc_feature *feature, const char *name,
1351 struct tdesc_type *type = XZALLOC (struct tdesc_type);
1353 type->name = xstrdup (name);
1354 type->kind = TDESC_TYPE_FLAGS;
1355 type->u.f.size = size;
1357 VEC_safe_push (tdesc_type_p, feature->types, type);
1361 /* Add a new field. Return a temporary pointer to the field, which
1362 is only valid until the next call to tdesc_add_field (the vector
1363 might be reallocated). */
1366 tdesc_add_field (struct tdesc_type *type, const char *field_name,
1367 struct tdesc_type *field_type)
1369 struct tdesc_type_field f = { 0 };
1371 gdb_assert (type->kind == TDESC_TYPE_UNION
1372 || type->kind == TDESC_TYPE_STRUCT);
1374 f.name = xstrdup (field_name);
1375 f.type = field_type;
1377 VEC_safe_push (tdesc_type_field, type->u.u.fields, &f);
1380 /* Add a new bitfield. */
1383 tdesc_add_bitfield (struct tdesc_type *type, const char *field_name,
1386 struct tdesc_type_field f = { 0 };
1388 gdb_assert (type->kind == TDESC_TYPE_STRUCT);
1390 f.name = xstrdup (field_name);
1394 VEC_safe_push (tdesc_type_field, type->u.u.fields, &f);
1398 tdesc_add_flag (struct tdesc_type *type, int start,
1399 const char *flag_name)
1401 struct tdesc_type_flag f = { 0 };
1403 gdb_assert (type->kind == TDESC_TYPE_FLAGS);
1405 f.name = xstrdup (flag_name);
1408 VEC_safe_push (tdesc_type_flag, type->u.f.flags, &f);
1412 tdesc_free_feature (struct tdesc_feature *feature)
1414 struct tdesc_reg *reg;
1415 struct tdesc_type *type;
1418 for (ix = 0; VEC_iterate (tdesc_reg_p, feature->registers, ix, reg); ix++)
1419 tdesc_free_reg (reg);
1420 VEC_free (tdesc_reg_p, feature->registers);
1422 for (ix = 0; VEC_iterate (tdesc_type_p, feature->types, ix, type); ix++)
1423 tdesc_free_type (type);
1424 VEC_free (tdesc_type_p, feature->types);
1426 xfree (feature->name);
1430 struct tdesc_feature *
1431 tdesc_create_feature (struct target_desc *tdesc, const char *name)
1433 struct tdesc_feature *new_feature = XZALLOC (struct tdesc_feature);
1435 new_feature->name = xstrdup (name);
1437 VEC_safe_push (tdesc_feature_p, tdesc->features, new_feature);
1441 struct target_desc *
1442 allocate_target_description (void)
1444 return XZALLOC (struct target_desc);
1448 free_target_description (void *arg)
1450 struct target_desc *target_desc = arg;
1451 struct tdesc_feature *feature;
1452 struct property *prop;
1456 VEC_iterate (tdesc_feature_p, target_desc->features, ix, feature);
1458 tdesc_free_feature (feature);
1459 VEC_free (tdesc_feature_p, target_desc->features);
1462 VEC_iterate (property_s, target_desc->properties, ix, prop);
1466 xfree (prop->value);
1468 VEC_free (property_s, target_desc->properties);
1470 VEC_free (arch_p, target_desc->compatible);
1472 xfree (target_desc);
1476 make_cleanup_free_target_description (struct target_desc *target_desc)
1478 return make_cleanup (free_target_description, target_desc);
1482 tdesc_add_compatible (struct target_desc *target_desc,
1483 const struct bfd_arch_info *compatible)
1485 const struct bfd_arch_info *compat;
1488 /* If this instance of GDB is compiled without BFD support for the
1489 compatible architecture, simply ignore it -- we would not be able
1490 to handle it anyway. */
1491 if (compatible == NULL)
1494 for (ix = 0; VEC_iterate (arch_p, target_desc->compatible, ix, compat);
1496 if (compat == compatible)
1497 internal_error (__FILE__, __LINE__,
1498 _("Attempted to add duplicate "
1499 "compatible architecture \"%s\""),
1500 compatible->printable_name);
1502 VEC_safe_push (arch_p, target_desc->compatible, compatible);
1506 set_tdesc_property (struct target_desc *target_desc,
1507 const char *key, const char *value)
1509 struct property *prop, new_prop;
1512 gdb_assert (key != NULL && value != NULL);
1514 for (ix = 0; VEC_iterate (property_s, target_desc->properties, ix, prop);
1516 if (strcmp (prop->key, key) == 0)
1517 internal_error (__FILE__, __LINE__,
1518 _("Attempted to add duplicate property \"%s\""), key);
1520 new_prop.key = xstrdup (key);
1521 new_prop.value = xstrdup (value);
1522 VEC_safe_push (property_s, target_desc->properties, &new_prop);
1526 set_tdesc_architecture (struct target_desc *target_desc,
1527 const struct bfd_arch_info *arch)
1529 target_desc->arch = arch;
1533 set_tdesc_osabi (struct target_desc *target_desc, enum gdb_osabi osabi)
1535 target_desc->osabi = osabi;
1539 static struct cmd_list_element *tdesc_set_cmdlist, *tdesc_show_cmdlist;
1540 static struct cmd_list_element *tdesc_unset_cmdlist;
1542 /* Helper functions for the CLI commands. */
1545 set_tdesc_cmd (char *args, int from_tty)
1547 help_list (tdesc_set_cmdlist, "set tdesc ", -1, gdb_stdout);
1551 show_tdesc_cmd (char *args, int from_tty)
1553 cmd_show_list (tdesc_show_cmdlist, from_tty, "");
1557 unset_tdesc_cmd (char *args, int from_tty)
1559 help_list (tdesc_unset_cmdlist, "unset tdesc ", -1, gdb_stdout);
1563 set_tdesc_filename_cmd (char *args, int from_tty,
1564 struct cmd_list_element *c)
1566 target_clear_description ();
1567 target_find_description ();
1571 show_tdesc_filename_cmd (struct ui_file *file, int from_tty,
1572 struct cmd_list_element *c,
1575 if (value != NULL && *value != '\0')
1576 printf_filtered (_("\
1577 The target description will be read from \"%s\".\n"),
1580 printf_filtered (_("\
1581 The target description will be read from the target.\n"));
1585 unset_tdesc_filename_cmd (char *args, int from_tty)
1587 xfree (target_description_filename);
1588 target_description_filename = NULL;
1589 target_clear_description ();
1590 target_find_description ();
1594 maint_print_c_tdesc_cmd (char *args, int from_tty)
1596 const struct target_desc *tdesc;
1597 const struct bfd_arch_info *compatible;
1598 const char *filename, *inp;
1599 char *function, *outp;
1600 struct property *prop;
1601 struct tdesc_feature *feature;
1602 struct tdesc_reg *reg;
1603 struct tdesc_type *type;
1604 struct tdesc_type_field *f;
1607 /* Use the global target-supplied description, not the current
1608 architecture's. This lets a GDB for one architecture generate C
1609 for another architecture's description, even though the gdbarch
1610 initialization code will reject the new description. */
1611 tdesc = current_target_desc;
1613 error (_("There is no target description to print."));
1615 if (target_description_filename == NULL)
1616 error (_("The current target description did not come from an XML file."));
1618 filename = lbasename (target_description_filename);
1619 function = alloca (strlen (filename) + 1);
1620 for (inp = filename, outp = function; *inp != '\0'; inp++)
1623 else if (*inp == '-')
1629 /* Standard boilerplate. */
1630 printf_unfiltered ("/* THIS FILE IS GENERATED. Original: %s */\n\n",
1632 printf_unfiltered ("#include \"defs.h\"\n");
1633 printf_unfiltered ("#include \"osabi.h\"\n");
1634 printf_unfiltered ("#include \"target-descriptions.h\"\n");
1635 printf_unfiltered ("\n");
1637 printf_unfiltered ("struct target_desc *tdesc_%s;\n", function);
1638 printf_unfiltered ("static void\n");
1639 printf_unfiltered ("initialize_tdesc_%s (void)\n", function);
1640 printf_unfiltered ("{\n");
1642 (" struct target_desc *result = allocate_target_description ();\n");
1643 printf_unfiltered (" struct tdesc_feature *feature;\n");
1644 printf_unfiltered (" struct tdesc_type *field_type, *type;\n");
1645 printf_unfiltered ("\n");
1647 if (tdesc_architecture (tdesc) != NULL)
1650 (" set_tdesc_architecture (result, bfd_scan_arch (\"%s\"));\n",
1651 tdesc_architecture (tdesc)->printable_name);
1652 printf_unfiltered ("\n");
1655 if (tdesc_osabi (tdesc) > GDB_OSABI_UNKNOWN
1656 && tdesc_osabi (tdesc) < GDB_OSABI_INVALID)
1659 (" set_tdesc_osabi (result, osabi_from_tdesc_string (\"%s\"));\n",
1660 gdbarch_osabi_name (tdesc_osabi (tdesc)));
1661 printf_unfiltered ("\n");
1664 for (ix = 0; VEC_iterate (arch_p, tdesc->compatible, ix, compatible);
1668 (" tdesc_add_compatible (result, bfd_scan_arch (\"%s\"));\n",
1669 compatible->printable_name);
1672 printf_unfiltered ("\n");
1674 for (ix = 0; VEC_iterate (property_s, tdesc->properties, ix, prop);
1677 printf_unfiltered (" set_tdesc_property (result, \"%s\", \"%s\");\n",
1678 prop->key, prop->value);
1682 VEC_iterate (tdesc_feature_p, tdesc->features, ix, feature);
1685 printf_unfiltered (" feature = tdesc_create_feature (result, \"%s\");\n",
1689 VEC_iterate (tdesc_type_p, feature->types, ix2, type);
1694 case TDESC_TYPE_VECTOR:
1696 (" field_type = tdesc_named_type (feature, \"%s\");\n",
1697 type->u.v.type->name);
1699 (" tdesc_create_vector (feature, \"%s\", field_type, %d);\n",
1700 type->name, type->u.v.count);
1702 case TDESC_TYPE_UNION:
1704 (" type = tdesc_create_union (feature, \"%s\");\n",
1707 VEC_iterate (tdesc_type_field, type->u.u.fields, ix3, f);
1711 (" field_type = tdesc_named_type (feature, \"%s\");\n",
1714 (" tdesc_add_field (type, \"%s\", field_type);\n",
1719 error (_("C output is not supported type \"%s\"."), type->name);
1721 printf_unfiltered ("\n");
1725 VEC_iterate (tdesc_reg_p, feature->registers, ix2, reg);
1728 printf_unfiltered (" tdesc_create_reg (feature, \"%s\", %ld, %d, ",
1729 reg->name, reg->target_regnum, reg->save_restore);
1731 printf_unfiltered ("\"%s\", ", reg->group);
1733 printf_unfiltered ("NULL, ");
1734 printf_unfiltered ("%d, \"%s\");\n", reg->bitsize, reg->type);
1737 printf_unfiltered ("\n");
1740 printf_unfiltered (" tdesc_%s = result;\n", function);
1741 printf_unfiltered ("}\n");
1744 /* Provide a prototype to silence -Wmissing-prototypes. */
1745 extern initialize_file_ftype _initialize_target_descriptions;
1748 _initialize_target_descriptions (void)
1750 tdesc_data = gdbarch_data_register_pre_init (tdesc_data_init);
1752 add_prefix_cmd ("tdesc", class_maintenance, set_tdesc_cmd, _("\
1753 Set target description specific variables."),
1754 &tdesc_set_cmdlist, "set tdesc ",
1755 0 /* allow-unknown */, &setlist);
1756 add_prefix_cmd ("tdesc", class_maintenance, show_tdesc_cmd, _("\
1757 Show target description specific variables."),
1758 &tdesc_show_cmdlist, "show tdesc ",
1759 0 /* allow-unknown */, &showlist);
1760 add_prefix_cmd ("tdesc", class_maintenance, unset_tdesc_cmd, _("\
1761 Unset target description specific variables."),
1762 &tdesc_unset_cmdlist, "unset tdesc ",
1763 0 /* allow-unknown */, &unsetlist);
1765 add_setshow_filename_cmd ("filename", class_obscure,
1766 &target_description_filename,
1768 Set the file to read for an XML target description"), _("\
1769 Show the file to read for an XML target description"), _("\
1770 When set, GDB will read the target description from a local\n\
1771 file instead of querying the remote target."),
1772 set_tdesc_filename_cmd,
1773 show_tdesc_filename_cmd,
1774 &tdesc_set_cmdlist, &tdesc_show_cmdlist);
1776 add_cmd ("filename", class_obscure, unset_tdesc_filename_cmd, _("\
1777 Unset the file to read for an XML target description. When unset,\n\
1778 GDB will read the description from the target."),
1779 &tdesc_unset_cmdlist);
1781 add_cmd ("c-tdesc", class_maintenance, maint_print_c_tdesc_cmd, _("\
1782 Print the current target description as a C source file."),
1783 &maintenanceprintlist);