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
,
130 /* Types defined by a target feature. */
137 /* Kind-specific data. */
143 struct tdesc_type
*type
;
147 /* Struct or union type. */
150 VEC(tdesc_type_field
) *fields
;
157 VEC(tdesc_type_flag
) *flags
;
162 DEF_VEC_P(tdesc_type_p
);
164 /* A feature from a target description. Each feature is a collection
165 of other elements, e.g. registers and types. */
167 typedef struct tdesc_feature
169 /* The name of this feature. It may be recognized by the architecture
173 /* The registers associated with this feature. */
174 VEC(tdesc_reg_p
) *registers
;
176 /* The types associated with this feature. */
177 VEC(tdesc_type_p
) *types
;
179 DEF_VEC_P(tdesc_feature_p
);
181 /* A compatible architecture from a target description. */
182 typedef const struct bfd_arch_info
*arch_p
;
185 /* A target description. */
189 /* The architecture reported by the target, if any. */
190 const struct bfd_arch_info
*arch
;
192 /* The osabi reported by the target, if any; GDB_OSABI_UNKNOWN
194 enum gdb_osabi osabi
;
196 /* The list of compatible architectures reported by the target. */
197 VEC(arch_p
) *compatible
;
199 /* Any architecture-specific properties specified by the target. */
200 VEC(property_s
) *properties
;
202 /* The features associated with this target. */
203 VEC(tdesc_feature_p
) *features
;
206 /* Per-architecture data associated with a target description. The
207 target description may be shared by multiple architectures, but
208 this data is private to one gdbarch. */
210 typedef struct tdesc_arch_reg
212 struct tdesc_reg
*reg
;
215 DEF_VEC_O(tdesc_arch_reg
);
217 struct tdesc_arch_data
219 /* A list of register/type pairs, indexed by GDB's internal register number.
220 During initialization of the gdbarch this list is used to store
221 registers which the architecture assigns a fixed register number.
222 Registers which are NULL in this array, or off the end, are
223 treated as zero-sized and nameless (i.e. placeholders in the
225 VEC(tdesc_arch_reg
) *arch_regs
;
227 /* Functions which report the register name, type, and reggroups for
229 gdbarch_register_name_ftype
*pseudo_register_name
;
230 gdbarch_register_type_ftype
*pseudo_register_type
;
231 gdbarch_register_reggroup_p_ftype
*pseudo_register_reggroup_p
;
234 /* Global state. These variables are associated with the current
235 target; if GDB adds support for multiple simultaneous targets, then
236 these variables should become target-specific data. */
238 /* A flag indicating that a description has already been fetched from
239 the current target, so it should not be queried again. */
241 static int target_desc_fetched
;
243 /* The description fetched from the current target, or NULL if the
244 current target did not supply any description. Only valid when
245 target_desc_fetched is set. Only the description initialization
246 code should access this; normally, the description should be
247 accessed through the gdbarch object. */
249 static const struct target_desc
*current_target_desc
;
251 /* Other global variables. */
253 /* The filename to read a target description from. */
255 static char *target_description_filename
;
257 /* A handle for architecture-specific data associated with the
258 target description (see struct tdesc_arch_data). */
260 static struct gdbarch_data
*tdesc_data
;
262 /* Fetch the current target's description, and switch the current
263 architecture to one which incorporates that description. */
266 target_find_description (void)
268 /* If we've already fetched a description from the target, don't do
269 it again. This allows a target to fetch the description early,
270 during its to_open or to_create_inferior, if it needs extra
271 information about the target to initialize. */
272 if (target_desc_fetched
)
275 /* The current architecture should not have any target description
276 specified. It should have been cleared, e.g. when we
277 disconnected from the previous target. */
278 gdb_assert (gdbarch_target_desc (target_gdbarch
) == NULL
);
280 /* First try to fetch an XML description from the user-specified
282 current_target_desc
= NULL
;
283 if (target_description_filename
!= NULL
284 && *target_description_filename
!= '\0')
286 = file_read_description_xml (target_description_filename
);
288 /* Next try to read the description from the current target using
290 if (current_target_desc
== NULL
)
291 current_target_desc
= target_read_description_xml (¤t_target
);
293 /* If that failed try a target-specific hook. */
294 if (current_target_desc
== NULL
)
295 current_target_desc
= target_read_description (¤t_target
);
297 /* If a non-NULL description was returned, then update the current
299 if (current_target_desc
)
301 struct gdbarch_info info
;
303 gdbarch_info_init (&info
);
304 info
.target_desc
= current_target_desc
;
305 if (!gdbarch_update_p (info
))
306 warning (_("Architecture rejected target-supplied description"));
309 struct tdesc_arch_data
*data
;
311 data
= gdbarch_data (target_gdbarch
, tdesc_data
);
312 if (tdesc_has_registers (current_target_desc
)
313 && data
->arch_regs
== NULL
)
314 warning (_("Target-supplied registers are not supported "
315 "by the current architecture"));
319 /* Now that we know this description is usable, record that we
321 target_desc_fetched
= 1;
324 /* Discard any description fetched from the current target, and switch
325 the current architecture to one with no target description. */
328 target_clear_description (void)
330 struct gdbarch_info info
;
332 if (!target_desc_fetched
)
335 target_desc_fetched
= 0;
336 current_target_desc
= NULL
;
338 gdbarch_info_init (&info
);
339 if (!gdbarch_update_p (info
))
340 internal_error (__FILE__
, __LINE__
,
341 _("Could not remove target-supplied description"));
344 /* Return the global current target description. This should only be
345 used by gdbarch initialization code; most access should be through
346 an existing gdbarch. */
348 const struct target_desc
*
349 target_current_description (void)
351 if (target_desc_fetched
)
352 return current_target_desc
;
357 /* Return non-zero if this target description is compatible
358 with the given BFD architecture. */
361 tdesc_compatible_p (const struct target_desc
*target_desc
,
362 const struct bfd_arch_info
*arch
)
364 const struct bfd_arch_info
*compat
;
367 for (ix
= 0; VEC_iterate (arch_p
, target_desc
->compatible
, ix
, compat
);
371 || arch
->compatible (arch
, compat
)
372 || compat
->compatible (compat
, arch
))
380 /* Direct accessors for target descriptions. */
382 /* Return the string value of a property named KEY, or NULL if the
383 property was not specified. */
386 tdesc_property (const struct target_desc
*target_desc
, const char *key
)
388 struct property
*prop
;
391 for (ix
= 0; VEC_iterate (property_s
, target_desc
->properties
, ix
, prop
);
393 if (strcmp (prop
->key
, key
) == 0)
399 /* Return the BFD architecture associated with this target
400 description, or NULL if no architecture was specified. */
402 const struct bfd_arch_info
*
403 tdesc_architecture (const struct target_desc
*target_desc
)
405 return target_desc
->arch
;
408 /* Return the OSABI associated with this target description, or
409 GDB_OSABI_UNKNOWN if no osabi was specified. */
412 tdesc_osabi (const struct target_desc
*target_desc
)
414 return target_desc
->osabi
;
419 /* Return 1 if this target description includes any registers. */
422 tdesc_has_registers (const struct target_desc
*target_desc
)
425 struct tdesc_feature
*feature
;
427 if (target_desc
== NULL
)
431 VEC_iterate (tdesc_feature_p
, target_desc
->features
, ix
, feature
);
433 if (! VEC_empty (tdesc_reg_p
, feature
->registers
))
439 /* Return the feature with the given name, if present, or NULL if
440 the named feature is not found. */
442 const struct tdesc_feature
*
443 tdesc_find_feature (const struct target_desc
*target_desc
,
447 struct tdesc_feature
*feature
;
450 VEC_iterate (tdesc_feature_p
, target_desc
->features
, ix
, feature
);
452 if (strcmp (feature
->name
, name
) == 0)
458 /* Return the name of FEATURE. */
461 tdesc_feature_name (const struct tdesc_feature
*feature
)
463 return feature
->name
;
466 /* Predefined types. */
467 static struct tdesc_type tdesc_predefined_types
[] =
469 { "int8", TDESC_TYPE_INT8
},
470 { "int16", TDESC_TYPE_INT16
},
471 { "int32", TDESC_TYPE_INT32
},
472 { "int64", TDESC_TYPE_INT64
},
473 { "int128", TDESC_TYPE_INT128
},
474 { "uint8", TDESC_TYPE_UINT8
},
475 { "uint16", TDESC_TYPE_UINT16
},
476 { "uint32", TDESC_TYPE_UINT32
},
477 { "uint64", TDESC_TYPE_UINT64
},
478 { "uint128", TDESC_TYPE_UINT128
},
479 { "code_ptr", TDESC_TYPE_CODE_PTR
},
480 { "data_ptr", TDESC_TYPE_DATA_PTR
},
481 { "ieee_single", TDESC_TYPE_IEEE_SINGLE
},
482 { "ieee_double", TDESC_TYPE_IEEE_DOUBLE
},
483 { "arm_fpa_ext", TDESC_TYPE_ARM_FPA_EXT
},
484 { "i387_ext", TDESC_TYPE_I387_EXT
}
487 /* Return the type associated with ID in the context of FEATURE, or
491 tdesc_named_type (const struct tdesc_feature
*feature
, const char *id
)
494 struct tdesc_type
*type
;
496 /* First try target-defined types. */
497 for (ix
= 0; VEC_iterate (tdesc_type_p
, feature
->types
, ix
, type
); ix
++)
498 if (strcmp (type
->name
, id
) == 0)
501 /* Next try the predefined types. */
502 for (ix
= 0; ix
< ARRAY_SIZE (tdesc_predefined_types
); ix
++)
503 if (strcmp (tdesc_predefined_types
[ix
].name
, id
) == 0)
504 return &tdesc_predefined_types
[ix
];
509 /* Lookup type associated with ID. */
512 tdesc_find_type (struct gdbarch
*gdbarch
, const char *id
)
514 struct tdesc_arch_reg
*reg
;
515 struct tdesc_arch_data
*data
;
518 data
= gdbarch_data (gdbarch
, tdesc_data
);
519 num_regs
= VEC_length (tdesc_arch_reg
, data
->arch_regs
);
520 for (i
= 0; i
< num_regs
; i
++)
522 reg
= VEC_index (tdesc_arch_reg
, data
->arch_regs
, i
);
524 && reg
->reg
->tdesc_type
526 && strcmp (id
, reg
->reg
->tdesc_type
->name
) == 0)
533 /* Construct, if necessary, and return the GDB type implementing target
534 type TDESC_TYPE for architecture GDBARCH. */
537 tdesc_gdb_type (struct gdbarch
*gdbarch
, struct tdesc_type
*tdesc_type
)
541 switch (tdesc_type
->kind
)
543 /* Predefined types. */
544 case TDESC_TYPE_INT8
:
545 return builtin_type (gdbarch
)->builtin_int8
;
547 case TDESC_TYPE_INT16
:
548 return builtin_type (gdbarch
)->builtin_int16
;
550 case TDESC_TYPE_INT32
:
551 return builtin_type (gdbarch
)->builtin_int32
;
553 case TDESC_TYPE_INT64
:
554 return builtin_type (gdbarch
)->builtin_int64
;
556 case TDESC_TYPE_INT128
:
557 return builtin_type (gdbarch
)->builtin_int128
;
559 case TDESC_TYPE_UINT8
:
560 return builtin_type (gdbarch
)->builtin_uint8
;
562 case TDESC_TYPE_UINT16
:
563 return builtin_type (gdbarch
)->builtin_uint16
;
565 case TDESC_TYPE_UINT32
:
566 return builtin_type (gdbarch
)->builtin_uint32
;
568 case TDESC_TYPE_UINT64
:
569 return builtin_type (gdbarch
)->builtin_uint64
;
571 case TDESC_TYPE_UINT128
:
572 return builtin_type (gdbarch
)->builtin_uint128
;
574 case TDESC_TYPE_CODE_PTR
:
575 return builtin_type (gdbarch
)->builtin_func_ptr
;
577 case TDESC_TYPE_DATA_PTR
:
578 return builtin_type (gdbarch
)->builtin_data_ptr
;
584 type
= tdesc_find_type (gdbarch
, tdesc_type
->name
);
588 switch (tdesc_type
->kind
)
590 case TDESC_TYPE_IEEE_SINGLE
:
591 return arch_float_type (gdbarch
, -1, "builtin_type_ieee_single",
592 floatformats_ieee_single
);
594 case TDESC_TYPE_IEEE_DOUBLE
:
595 return arch_float_type (gdbarch
, -1, "builtin_type_ieee_double",
596 floatformats_ieee_double
);
598 case TDESC_TYPE_ARM_FPA_EXT
:
599 return arch_float_type (gdbarch
, -1, "builtin_type_arm_ext",
600 floatformats_arm_ext
);
602 case TDESC_TYPE_I387_EXT
:
603 return arch_float_type (gdbarch
, -1, "builtin_type_i387_ext",
604 floatformats_i387_ext
);
606 /* Types defined by a target feature. */
607 case TDESC_TYPE_VECTOR
:
609 struct type
*type
, *field_type
;
611 field_type
= tdesc_gdb_type (gdbarch
, tdesc_type
->u
.v
.type
);
612 type
= init_vector_type (field_type
, tdesc_type
->u
.v
.count
);
613 TYPE_NAME (type
) = xstrdup (tdesc_type
->name
);
618 case TDESC_TYPE_STRUCT
:
620 struct type
*type
, *field_type
;
621 struct tdesc_type_field
*f
;
624 type
= arch_composite_type (gdbarch
, NULL
, TYPE_CODE_STRUCT
);
625 TYPE_NAME (type
) = xstrdup (tdesc_type
->name
);
626 TYPE_TAG_NAME (type
) = TYPE_NAME (type
);
629 VEC_iterate (tdesc_type_field
, tdesc_type
->u
.u
.fields
, ix
, f
);
636 struct type
*field_type
;
637 int bitsize
, total_size
;
639 /* This invariant should be preserved while creating
641 gdb_assert (tdesc_type
->u
.u
.size
!= 0);
642 if (tdesc_type
->u
.u
.size
> 4)
643 field_type
= builtin_type (gdbarch
)->builtin_uint64
;
645 field_type
= builtin_type (gdbarch
)->builtin_uint32
;
647 fld
= append_composite_type_field_raw (type
, xstrdup (f
->name
),
650 /* For little-endian, BITPOS counts from the LSB of
651 the structure and marks the LSB of the field. For
652 big-endian, BITPOS counts from the MSB of the
653 structure and marks the MSB of the field. Either
654 way, it is the number of bits to the "left" of the
655 field. To calculate this in big-endian, we need
656 the total size of the structure. */
657 bitsize
= f
->end
- f
->start
+ 1;
658 total_size
= tdesc_type
->u
.u
.size
* TARGET_CHAR_BIT
;
659 if (gdbarch_bits_big_endian (gdbarch
))
660 FIELD_BITPOS (fld
[0]) = total_size
- f
->start
- bitsize
;
662 FIELD_BITPOS (fld
[0]) = f
->start
;
663 FIELD_BITSIZE (fld
[0]) = bitsize
;
667 field_type
= tdesc_gdb_type (gdbarch
, f
->type
);
668 append_composite_type_field (type
, xstrdup (f
->name
),
673 if (tdesc_type
->u
.u
.size
!= 0)
674 TYPE_LENGTH (type
) = tdesc_type
->u
.u
.size
;
678 case TDESC_TYPE_UNION
:
680 struct type
*type
, *field_type
;
681 struct tdesc_type_field
*f
;
684 type
= arch_composite_type (gdbarch
, NULL
, TYPE_CODE_UNION
);
685 TYPE_NAME (type
) = xstrdup (tdesc_type
->name
);
688 VEC_iterate (tdesc_type_field
, tdesc_type
->u
.u
.fields
, ix
, f
);
691 field_type
= tdesc_gdb_type (gdbarch
, f
->type
);
692 append_composite_type_field (type
, xstrdup (f
->name
), field_type
);
694 /* If any of the children of a union are vectors, flag the
695 union as a vector also. This allows e.g. a union of two
696 vector types to show up automatically in "info vector". */
697 if (TYPE_VECTOR (field_type
))
698 TYPE_VECTOR (type
) = 1;
703 case TDESC_TYPE_FLAGS
:
705 struct tdesc_type_flag
*f
;
708 type
= arch_flags_type (gdbarch
, xstrdup (tdesc_type
->name
),
709 tdesc_type
->u
.f
.size
);
711 VEC_iterate (tdesc_type_flag
, tdesc_type
->u
.f
.flags
, ix
, f
);
713 /* Note that contrary to the function name, this call will
714 just set the properties of an already-allocated
716 append_flags_type_flag (type
, f
->start
,
717 *f
->name
? f
->name
: NULL
);
723 internal_error (__FILE__
, __LINE__
,
724 "Type \"%s\" has an unknown kind %d",
725 tdesc_type
->name
, tdesc_type
->kind
);
729 /* Support for registers from target descriptions. */
731 /* Construct the per-gdbarch data. */
734 tdesc_data_init (struct obstack
*obstack
)
736 struct tdesc_arch_data
*data
;
738 data
= OBSTACK_ZALLOC (obstack
, struct tdesc_arch_data
);
742 /* Similar, but for the temporary copy used during architecture
745 struct tdesc_arch_data
*
746 tdesc_data_alloc (void)
748 return XZALLOC (struct tdesc_arch_data
);
751 /* Free something allocated by tdesc_data_alloc, if it is not going
752 to be used (for instance if it was unsuitable for the
756 tdesc_data_cleanup (void *data_untyped
)
758 struct tdesc_arch_data
*data
= data_untyped
;
760 VEC_free (tdesc_arch_reg
, data
->arch_regs
);
764 /* Search FEATURE for a register named NAME. */
766 static struct tdesc_reg
*
767 tdesc_find_register_early (const struct tdesc_feature
*feature
,
771 struct tdesc_reg
*reg
;
774 VEC_iterate (tdesc_reg_p
, feature
->registers
, ixr
, reg
);
776 if (strcasecmp (reg
->name
, name
) == 0)
782 /* Search FEATURE for a register named NAME. Assign REGNO to it. */
785 tdesc_numbered_register (const struct tdesc_feature
*feature
,
786 struct tdesc_arch_data
*data
,
787 int regno
, const char *name
)
789 struct tdesc_arch_reg arch_reg
= { 0 };
790 struct tdesc_reg
*reg
= tdesc_find_register_early (feature
, name
);
795 /* Make sure the vector includes a REGNO'th element. */
796 while (regno
>= VEC_length (tdesc_arch_reg
, data
->arch_regs
))
797 VEC_safe_push (tdesc_arch_reg
, data
->arch_regs
, &arch_reg
);
800 VEC_replace (tdesc_arch_reg
, data
->arch_regs
, regno
, &arch_reg
);
804 /* Search FEATURE for a register named NAME, but do not assign a fixed
805 register number to it. */
808 tdesc_unnumbered_register (const struct tdesc_feature
*feature
,
811 struct tdesc_reg
*reg
= tdesc_find_register_early (feature
, name
);
819 /* Search FEATURE for a register whose name is in NAMES and assign
823 tdesc_numbered_register_choices (const struct tdesc_feature
*feature
,
824 struct tdesc_arch_data
*data
,
825 int regno
, const char *const names
[])
829 for (i
= 0; names
[i
] != NULL
; i
++)
830 if (tdesc_numbered_register (feature
, data
, regno
, names
[i
]))
836 /* Search FEATURE for a register named NAME, and return its size in
837 bits. The register must exist. */
840 tdesc_register_size (const struct tdesc_feature
*feature
,
843 struct tdesc_reg
*reg
= tdesc_find_register_early (feature
, name
);
845 gdb_assert (reg
!= NULL
);
849 /* Look up a register by its GDB internal register number. */
851 static struct tdesc_arch_reg
*
852 tdesc_find_arch_register (struct gdbarch
*gdbarch
, int regno
)
854 struct tdesc_arch_data
*data
;
856 data
= gdbarch_data (gdbarch
, tdesc_data
);
857 if (regno
< VEC_length (tdesc_arch_reg
, data
->arch_regs
))
858 return VEC_index (tdesc_arch_reg
, data
->arch_regs
, regno
);
863 static struct tdesc_reg
*
864 tdesc_find_register (struct gdbarch
*gdbarch
, int regno
)
866 struct tdesc_arch_reg
*reg
= tdesc_find_arch_register (gdbarch
, regno
);
867 return reg
? reg
->reg
: NULL
;
870 /* Return the name of register REGNO, from the target description or
871 from an architecture-provided pseudo_register_name method. */
874 tdesc_register_name (struct gdbarch
*gdbarch
, int regno
)
876 struct tdesc_reg
*reg
= tdesc_find_register (gdbarch
, regno
);
877 int num_regs
= gdbarch_num_regs (gdbarch
);
878 int num_pseudo_regs
= gdbarch_num_pseudo_regs (gdbarch
);
883 if (regno
>= num_regs
&& regno
< num_regs
+ num_pseudo_regs
)
885 struct tdesc_arch_data
*data
= gdbarch_data (gdbarch
, tdesc_data
);
886 gdb_assert (data
->pseudo_register_name
!= NULL
);
887 return data
->pseudo_register_name (gdbarch
, regno
);
894 tdesc_register_type (struct gdbarch
*gdbarch
, int regno
)
896 struct tdesc_arch_reg
*arch_reg
= tdesc_find_arch_register (gdbarch
, regno
);
897 struct tdesc_reg
*reg
= arch_reg
? arch_reg
->reg
: NULL
;
898 int num_regs
= gdbarch_num_regs (gdbarch
);
899 int num_pseudo_regs
= gdbarch_num_pseudo_regs (gdbarch
);
901 if (reg
== NULL
&& regno
>= num_regs
&& regno
< num_regs
+ num_pseudo_regs
)
903 struct tdesc_arch_data
*data
= gdbarch_data (gdbarch
, tdesc_data
);
904 gdb_assert (data
->pseudo_register_type
!= NULL
);
905 return data
->pseudo_register_type (gdbarch
, regno
);
909 /* Return "int0_t", since "void" has a misleading size of one. */
910 return builtin_type (gdbarch
)->builtin_int0
;
912 if (arch_reg
->type
== NULL
)
914 /* First check for a predefined or target defined type. */
916 arch_reg
->type
= tdesc_gdb_type (gdbarch
, reg
->tdesc_type
);
918 /* Next try size-sensitive type shortcuts. */
919 else if (strcmp (reg
->type
, "float") == 0)
921 if (reg
->bitsize
== gdbarch_float_bit (gdbarch
))
922 arch_reg
->type
= builtin_type (gdbarch
)->builtin_float
;
923 else if (reg
->bitsize
== gdbarch_double_bit (gdbarch
))
924 arch_reg
->type
= builtin_type (gdbarch
)->builtin_double
;
925 else if (reg
->bitsize
== gdbarch_long_double_bit (gdbarch
))
926 arch_reg
->type
= builtin_type (gdbarch
)->builtin_long_double
;
929 warning (_("Register \"%s\" has an unsupported size (%d bits)"),
930 reg
->name
, reg
->bitsize
);
931 arch_reg
->type
= builtin_type (gdbarch
)->builtin_double
;
934 else if (strcmp (reg
->type
, "int") == 0)
936 if (reg
->bitsize
== gdbarch_long_bit (gdbarch
))
937 arch_reg
->type
= builtin_type (gdbarch
)->builtin_long
;
938 else if (reg
->bitsize
== TARGET_CHAR_BIT
)
939 arch_reg
->type
= builtin_type (gdbarch
)->builtin_char
;
940 else if (reg
->bitsize
== gdbarch_short_bit (gdbarch
))
941 arch_reg
->type
= builtin_type (gdbarch
)->builtin_short
;
942 else if (reg
->bitsize
== gdbarch_int_bit (gdbarch
))
943 arch_reg
->type
= builtin_type (gdbarch
)->builtin_int
;
944 else if (reg
->bitsize
== gdbarch_long_long_bit (gdbarch
))
945 arch_reg
->type
= builtin_type (gdbarch
)->builtin_long_long
;
946 else if (reg
->bitsize
== gdbarch_ptr_bit (gdbarch
))
947 /* A bit desperate by this point... */
948 arch_reg
->type
= builtin_type (gdbarch
)->builtin_data_ptr
;
951 warning (_("Register \"%s\" has an unsupported size (%d bits)"),
952 reg
->name
, reg
->bitsize
);
953 arch_reg
->type
= builtin_type (gdbarch
)->builtin_long
;
957 if (arch_reg
->type
== NULL
)
958 internal_error (__FILE__
, __LINE__
,
959 "Register \"%s\" has an unknown type \"%s\"",
960 reg
->name
, reg
->type
);
963 return arch_reg
->type
;
967 tdesc_remote_register_number (struct gdbarch
*gdbarch
, int regno
)
969 struct tdesc_reg
*reg
= tdesc_find_register (gdbarch
, regno
);
972 return reg
->target_regnum
;
977 /* Check whether REGNUM is a member of REGGROUP. Registers from the
978 target description may be classified as general, float, or vector.
979 Unlike a gdbarch register_reggroup_p method, this function will
980 return -1 if it does not know; the caller should handle registers
981 with no specified group.
983 Arbitrary strings (other than "general", "float", and "vector")
984 from the description are not used; they cause the register to be
985 displayed in "info all-registers" but excluded from "info
986 registers" et al. The names of containing features are also not
987 used. This might be extended to display registers in some more
990 The save-restore flag is also implemented here. */
993 tdesc_register_in_reggroup_p (struct gdbarch
*gdbarch
, int regno
,
994 struct reggroup
*reggroup
)
996 struct tdesc_reg
*reg
= tdesc_find_register (gdbarch
, regno
);
998 if (reg
!= NULL
&& reg
->group
!= NULL
)
1000 int general_p
= 0, float_p
= 0, vector_p
= 0;
1002 if (strcmp (reg
->group
, "general") == 0)
1004 else if (strcmp (reg
->group
, "float") == 0)
1006 else if (strcmp (reg
->group
, "vector") == 0)
1009 if (reggroup
== float_reggroup
)
1012 if (reggroup
== vector_reggroup
)
1015 if (reggroup
== general_reggroup
)
1020 && (reggroup
== save_reggroup
|| reggroup
== restore_reggroup
))
1021 return reg
->save_restore
;
1026 /* Check whether REGNUM is a member of REGGROUP. Registers with no
1027 group specified go to the default reggroup function and are handled
1031 tdesc_register_reggroup_p (struct gdbarch
*gdbarch
, int regno
,
1032 struct reggroup
*reggroup
)
1034 int num_regs
= gdbarch_num_regs (gdbarch
);
1035 int num_pseudo_regs
= gdbarch_num_pseudo_regs (gdbarch
);
1038 if (regno
>= num_regs
&& regno
< num_regs
+ num_pseudo_regs
)
1040 struct tdesc_arch_data
*data
= gdbarch_data (gdbarch
, tdesc_data
);
1041 if (data
->pseudo_register_reggroup_p
!= NULL
)
1042 return data
->pseudo_register_reggroup_p (gdbarch
, regno
, reggroup
);
1043 /* Otherwise fall through to the default reggroup_p. */
1046 ret
= tdesc_register_in_reggroup_p (gdbarch
, regno
, reggroup
);
1050 return default_register_reggroup_p (gdbarch
, regno
, reggroup
);
1053 /* Record architecture-specific functions to call for pseudo-register
1057 set_tdesc_pseudo_register_name (struct gdbarch
*gdbarch
,
1058 gdbarch_register_name_ftype
*pseudo_name
)
1060 struct tdesc_arch_data
*data
= gdbarch_data (gdbarch
, tdesc_data
);
1062 data
->pseudo_register_name
= pseudo_name
;
1066 set_tdesc_pseudo_register_type (struct gdbarch
*gdbarch
,
1067 gdbarch_register_type_ftype
*pseudo_type
)
1069 struct tdesc_arch_data
*data
= gdbarch_data (gdbarch
, tdesc_data
);
1071 data
->pseudo_register_type
= pseudo_type
;
1075 set_tdesc_pseudo_register_reggroup_p
1076 (struct gdbarch
*gdbarch
,
1077 gdbarch_register_reggroup_p_ftype
*pseudo_reggroup_p
)
1079 struct tdesc_arch_data
*data
= gdbarch_data (gdbarch
, tdesc_data
);
1081 data
->pseudo_register_reggroup_p
= pseudo_reggroup_p
;
1084 /* Update GDBARCH to use the target description for registers. */
1087 tdesc_use_registers (struct gdbarch
*gdbarch
,
1088 const struct target_desc
*target_desc
,
1089 struct tdesc_arch_data
*early_data
)
1091 int num_regs
= gdbarch_num_regs (gdbarch
);
1093 struct tdesc_feature
*feature
;
1094 struct tdesc_reg
*reg
;
1095 struct tdesc_arch_data
*data
;
1096 struct tdesc_arch_reg
*arch_reg
, new_arch_reg
= { 0 };
1099 /* We can't use the description for registers if it doesn't describe
1100 any. This function should only be called after validating
1101 registers, so the caller should know that registers are
1103 gdb_assert (tdesc_has_registers (target_desc
));
1105 data
= gdbarch_data (gdbarch
, tdesc_data
);
1106 data
->arch_regs
= early_data
->arch_regs
;
1109 /* Build up a set of all registers, so that we can assign register
1110 numbers where needed. The hash table expands as necessary, so
1111 the initial size is arbitrary. */
1112 reg_hash
= htab_create (37, htab_hash_pointer
, htab_eq_pointer
, NULL
);
1114 VEC_iterate (tdesc_feature_p
, target_desc
->features
, ixf
, feature
);
1117 VEC_iterate (tdesc_reg_p
, feature
->registers
, ixr
, reg
);
1120 void **slot
= htab_find_slot (reg_hash
, reg
, INSERT
);
1125 /* Remove any registers which were assigned numbers by the
1128 VEC_iterate (tdesc_arch_reg
, data
->arch_regs
, ixr
, arch_reg
);
1131 htab_remove_elt (reg_hash
, arch_reg
->reg
);
1133 /* Assign numbers to the remaining registers and add them to the
1134 list of registers. The new numbers are always above gdbarch_num_regs.
1135 Iterate over the features, not the hash table, so that the order
1136 matches that in the target description. */
1138 gdb_assert (VEC_length (tdesc_arch_reg
, data
->arch_regs
) <= num_regs
);
1139 while (VEC_length (tdesc_arch_reg
, data
->arch_regs
) < num_regs
)
1140 VEC_safe_push (tdesc_arch_reg
, data
->arch_regs
, &new_arch_reg
);
1142 VEC_iterate (tdesc_feature_p
, target_desc
->features
, ixf
, feature
);
1145 VEC_iterate (tdesc_reg_p
, feature
->registers
, ixr
, reg
);
1147 if (htab_find (reg_hash
, reg
) != NULL
)
1149 new_arch_reg
.reg
= reg
;
1150 VEC_safe_push (tdesc_arch_reg
, data
->arch_regs
, &new_arch_reg
);
1154 htab_delete (reg_hash
);
1156 /* Update the architecture. */
1157 set_gdbarch_num_regs (gdbarch
, num_regs
);
1158 set_gdbarch_register_name (gdbarch
, tdesc_register_name
);
1159 set_gdbarch_register_type (gdbarch
, tdesc_register_type
);
1160 set_gdbarch_remote_register_number (gdbarch
,
1161 tdesc_remote_register_number
);
1162 set_gdbarch_register_reggroup_p (gdbarch
, tdesc_register_reggroup_p
);
1166 /* Methods for constructing a target description. */
1169 tdesc_free_reg (struct tdesc_reg
*reg
)
1178 tdesc_create_reg (struct tdesc_feature
*feature
, const char *name
,
1179 int regnum
, int save_restore
, const char *group
,
1180 int bitsize
, const char *type
)
1182 struct tdesc_reg
*reg
= XZALLOC (struct tdesc_reg
);
1184 reg
->name
= xstrdup (name
);
1185 reg
->target_regnum
= regnum
;
1186 reg
->save_restore
= save_restore
;
1187 reg
->group
= group
? xstrdup (group
) : NULL
;
1188 reg
->bitsize
= bitsize
;
1189 reg
->type
= type
? xstrdup (type
) : xstrdup ("<unknown>");
1191 /* If the register's type is target-defined, look it up now. We may not
1192 have easy access to the containing feature when we want it later. */
1193 reg
->tdesc_type
= tdesc_named_type (feature
, reg
->type
);
1195 VEC_safe_push (tdesc_reg_p
, feature
->registers
, reg
);
1199 tdesc_free_type (struct tdesc_type
*type
)
1204 case TDESC_TYPE_STRUCT
:
1205 case TDESC_TYPE_UNION
:
1207 struct tdesc_type_field
*f
;
1211 VEC_iterate (tdesc_type_field
, type
->u
.u
.fields
, ix
, f
);
1215 VEC_free (tdesc_type_field
, type
->u
.u
.fields
);
1219 case TDESC_TYPE_FLAGS
:
1221 struct tdesc_type_flag
*f
;
1225 VEC_iterate (tdesc_type_flag
, type
->u
.f
.flags
, ix
, f
);
1229 VEC_free (tdesc_type_flag
, type
->u
.f
.flags
);
1242 tdesc_create_vector (struct tdesc_feature
*feature
, const char *name
,
1243 struct tdesc_type
*field_type
, int count
)
1245 struct tdesc_type
*type
= XZALLOC (struct tdesc_type
);
1247 type
->name
= xstrdup (name
);
1248 type
->kind
= TDESC_TYPE_VECTOR
;
1249 type
->u
.v
.type
= field_type
;
1250 type
->u
.v
.count
= count
;
1252 VEC_safe_push (tdesc_type_p
, feature
->types
, type
);
1257 tdesc_create_struct (struct tdesc_feature
*feature
, const char *name
)
1259 struct tdesc_type
*type
= XZALLOC (struct tdesc_type
);
1261 type
->name
= xstrdup (name
);
1262 type
->kind
= TDESC_TYPE_STRUCT
;
1264 VEC_safe_push (tdesc_type_p
, feature
->types
, type
);
1268 /* Set the total length of TYPE. Structs which contain bitfields may
1269 omit the reserved bits, so the end of the last field may not
1273 tdesc_set_struct_size (struct tdesc_type
*type
, LONGEST size
)
1275 gdb_assert (type
->kind
== TDESC_TYPE_STRUCT
);
1276 type
->u
.u
.size
= size
;
1280 tdesc_create_union (struct tdesc_feature
*feature
, const char *name
)
1282 struct tdesc_type
*type
= XZALLOC (struct tdesc_type
);
1284 type
->name
= xstrdup (name
);
1285 type
->kind
= TDESC_TYPE_UNION
;
1287 VEC_safe_push (tdesc_type_p
, feature
->types
, type
);
1292 tdesc_create_flags (struct tdesc_feature
*feature
, const char *name
,
1295 struct tdesc_type
*type
= XZALLOC (struct tdesc_type
);
1297 type
->name
= xstrdup (name
);
1298 type
->kind
= TDESC_TYPE_FLAGS
;
1299 type
->u
.f
.size
= size
;
1301 VEC_safe_push (tdesc_type_p
, feature
->types
, type
);
1305 /* Add a new field. Return a temporary pointer to the field, which
1306 is only valid until the next call to tdesc_add_field (the vector
1307 might be reallocated). */
1310 tdesc_add_field (struct tdesc_type
*type
, const char *field_name
,
1311 struct tdesc_type
*field_type
)
1313 struct tdesc_type_field f
= { 0 };
1315 gdb_assert (type
->kind
== TDESC_TYPE_UNION
1316 || type
->kind
== TDESC_TYPE_STRUCT
);
1318 f
.name
= xstrdup (field_name
);
1319 f
.type
= field_type
;
1321 VEC_safe_push (tdesc_type_field
, type
->u
.u
.fields
, &f
);
1324 /* Add a new bitfield. */
1327 tdesc_add_bitfield (struct tdesc_type
*type
, const char *field_name
,
1330 struct tdesc_type_field f
= { 0 };
1332 gdb_assert (type
->kind
== TDESC_TYPE_STRUCT
);
1334 f
.name
= xstrdup (field_name
);
1338 VEC_safe_push (tdesc_type_field
, type
->u
.u
.fields
, &f
);
1342 tdesc_add_flag (struct tdesc_type
*type
, int start
,
1343 const char *flag_name
)
1345 struct tdesc_type_flag f
= { 0 };
1347 gdb_assert (type
->kind
== TDESC_TYPE_FLAGS
);
1349 f
.name
= xstrdup (flag_name
);
1352 VEC_safe_push (tdesc_type_flag
, type
->u
.f
.flags
, &f
);
1356 tdesc_free_feature (struct tdesc_feature
*feature
)
1358 struct tdesc_reg
*reg
;
1359 struct tdesc_type
*type
;
1362 for (ix
= 0; VEC_iterate (tdesc_reg_p
, feature
->registers
, ix
, reg
); ix
++)
1363 tdesc_free_reg (reg
);
1364 VEC_free (tdesc_reg_p
, feature
->registers
);
1366 for (ix
= 0; VEC_iterate (tdesc_type_p
, feature
->types
, ix
, type
); ix
++)
1367 tdesc_free_type (type
);
1368 VEC_free (tdesc_type_p
, feature
->types
);
1370 xfree (feature
->name
);
1374 struct tdesc_feature
*
1375 tdesc_create_feature (struct target_desc
*tdesc
, const char *name
)
1377 struct tdesc_feature
*new_feature
= XZALLOC (struct tdesc_feature
);
1379 new_feature
->name
= xstrdup (name
);
1381 VEC_safe_push (tdesc_feature_p
, tdesc
->features
, new_feature
);
1385 struct target_desc
*
1386 allocate_target_description (void)
1388 return XZALLOC (struct target_desc
);
1392 free_target_description (void *arg
)
1394 struct target_desc
*target_desc
= arg
;
1395 struct tdesc_feature
*feature
;
1396 struct property
*prop
;
1400 VEC_iterate (tdesc_feature_p
, target_desc
->features
, ix
, feature
);
1402 tdesc_free_feature (feature
);
1403 VEC_free (tdesc_feature_p
, target_desc
->features
);
1406 VEC_iterate (property_s
, target_desc
->properties
, ix
, prop
);
1410 xfree (prop
->value
);
1412 VEC_free (property_s
, target_desc
->properties
);
1414 VEC_free (arch_p
, target_desc
->compatible
);
1416 xfree (target_desc
);
1420 make_cleanup_free_target_description (struct target_desc
*target_desc
)
1422 return make_cleanup (free_target_description
, target_desc
);
1426 tdesc_add_compatible (struct target_desc
*target_desc
,
1427 const struct bfd_arch_info
*compatible
)
1429 const struct bfd_arch_info
*compat
;
1432 /* If this instance of GDB is compiled without BFD support for the
1433 compatible architecture, simply ignore it -- we would not be able
1434 to handle it anyway. */
1435 if (compatible
== NULL
)
1438 for (ix
= 0; VEC_iterate (arch_p
, target_desc
->compatible
, ix
, compat
);
1440 if (compat
== compatible
)
1441 internal_error (__FILE__
, __LINE__
,
1442 _("Attempted to add duplicate "
1443 "compatible architecture \"%s\""),
1444 compatible
->printable_name
);
1446 VEC_safe_push (arch_p
, target_desc
->compatible
, compatible
);
1450 set_tdesc_property (struct target_desc
*target_desc
,
1451 const char *key
, const char *value
)
1453 struct property
*prop
, new_prop
;
1456 gdb_assert (key
!= NULL
&& value
!= NULL
);
1458 for (ix
= 0; VEC_iterate (property_s
, target_desc
->properties
, ix
, prop
);
1460 if (strcmp (prop
->key
, key
) == 0)
1461 internal_error (__FILE__
, __LINE__
,
1462 _("Attempted to add duplicate property \"%s\""), key
);
1464 new_prop
.key
= xstrdup (key
);
1465 new_prop
.value
= xstrdup (value
);
1466 VEC_safe_push (property_s
, target_desc
->properties
, &new_prop
);
1470 set_tdesc_architecture (struct target_desc
*target_desc
,
1471 const struct bfd_arch_info
*arch
)
1473 target_desc
->arch
= arch
;
1477 set_tdesc_osabi (struct target_desc
*target_desc
, enum gdb_osabi osabi
)
1479 target_desc
->osabi
= osabi
;
1483 static struct cmd_list_element
*tdesc_set_cmdlist
, *tdesc_show_cmdlist
;
1484 static struct cmd_list_element
*tdesc_unset_cmdlist
;
1486 /* Helper functions for the CLI commands. */
1489 set_tdesc_cmd (char *args
, int from_tty
)
1491 help_list (tdesc_set_cmdlist
, "set tdesc ", -1, gdb_stdout
);
1495 show_tdesc_cmd (char *args
, int from_tty
)
1497 cmd_show_list (tdesc_show_cmdlist
, from_tty
, "");
1501 unset_tdesc_cmd (char *args
, int from_tty
)
1503 help_list (tdesc_unset_cmdlist
, "unset tdesc ", -1, gdb_stdout
);
1507 set_tdesc_filename_cmd (char *args
, int from_tty
,
1508 struct cmd_list_element
*c
)
1510 target_clear_description ();
1511 target_find_description ();
1515 show_tdesc_filename_cmd (struct ui_file
*file
, int from_tty
,
1516 struct cmd_list_element
*c
,
1519 if (value
!= NULL
&& *value
!= '\0')
1520 printf_filtered (_("\
1521 The target description will be read from \"%s\".\n"),
1524 printf_filtered (_("\
1525 The target description will be read from the target.\n"));
1529 unset_tdesc_filename_cmd (char *args
, int from_tty
)
1531 xfree (target_description_filename
);
1532 target_description_filename
= NULL
;
1533 target_clear_description ();
1534 target_find_description ();
1538 maint_print_c_tdesc_cmd (char *args
, int from_tty
)
1540 const struct target_desc
*tdesc
;
1541 const struct bfd_arch_info
*compatible
;
1542 const char *filename
, *inp
;
1543 char *function
, *outp
;
1544 struct property
*prop
;
1545 struct tdesc_feature
*feature
;
1546 struct tdesc_reg
*reg
;
1547 struct tdesc_type
*type
;
1548 struct tdesc_type_field
*f
;
1549 struct tdesc_type_flag
*flag
;
1552 /* Use the global target-supplied description, not the current
1553 architecture's. This lets a GDB for one architecture generate C
1554 for another architecture's description, even though the gdbarch
1555 initialization code will reject the new description. */
1556 tdesc
= current_target_desc
;
1558 error (_("There is no target description to print."));
1560 if (target_description_filename
== NULL
)
1561 error (_("The current target description did not come from an XML file."));
1563 filename
= lbasename (target_description_filename
);
1564 function
= alloca (strlen (filename
) + 1);
1565 for (inp
= filename
, outp
= function
; *inp
!= '\0'; inp
++)
1568 else if (*inp
== '-')
1574 /* Standard boilerplate. */
1575 printf_unfiltered ("/* THIS FILE IS GENERATED. Original: %s */\n\n",
1577 printf_unfiltered ("#include \"defs.h\"\n");
1578 printf_unfiltered ("#include \"osabi.h\"\n");
1579 printf_unfiltered ("#include \"target-descriptions.h\"\n");
1580 printf_unfiltered ("\n");
1582 printf_unfiltered ("struct target_desc *tdesc_%s;\n", function
);
1583 printf_unfiltered ("static void\n");
1584 printf_unfiltered ("initialize_tdesc_%s (void)\n", function
);
1585 printf_unfiltered ("{\n");
1587 (" struct target_desc *result = allocate_target_description ();\n");
1588 printf_unfiltered (" struct tdesc_feature *feature;\n");
1589 printf_unfiltered (" struct tdesc_type *field_type, *type;\n");
1590 printf_unfiltered ("\n");
1592 if (tdesc_architecture (tdesc
) != NULL
)
1595 (" set_tdesc_architecture (result, bfd_scan_arch (\"%s\"));\n",
1596 tdesc_architecture (tdesc
)->printable_name
);
1597 printf_unfiltered ("\n");
1600 if (tdesc_osabi (tdesc
) > GDB_OSABI_UNKNOWN
1601 && tdesc_osabi (tdesc
) < GDB_OSABI_INVALID
)
1604 (" set_tdesc_osabi (result, osabi_from_tdesc_string (\"%s\"));\n",
1605 gdbarch_osabi_name (tdesc_osabi (tdesc
)));
1606 printf_unfiltered ("\n");
1609 for (ix
= 0; VEC_iterate (arch_p
, tdesc
->compatible
, ix
, compatible
);
1613 (" tdesc_add_compatible (result, bfd_scan_arch (\"%s\"));\n",
1614 compatible
->printable_name
);
1617 printf_unfiltered ("\n");
1619 for (ix
= 0; VEC_iterate (property_s
, tdesc
->properties
, ix
, prop
);
1622 printf_unfiltered (" set_tdesc_property (result, \"%s\", \"%s\");\n",
1623 prop
->key
, prop
->value
);
1627 VEC_iterate (tdesc_feature_p
, tdesc
->features
, ix
, feature
);
1630 printf_unfiltered (" feature = tdesc_create_feature (result, \"%s\");\n",
1634 VEC_iterate (tdesc_type_p
, feature
->types
, ix2
, type
);
1639 case TDESC_TYPE_VECTOR
:
1641 (" field_type = tdesc_named_type (feature, \"%s\");\n",
1642 type
->u
.v
.type
->name
);
1644 (" tdesc_create_vector (feature, \"%s\", field_type, %d);\n",
1645 type
->name
, type
->u
.v
.count
);
1647 case TDESC_TYPE_UNION
:
1649 (" type = tdesc_create_union (feature, \"%s\");\n",
1652 VEC_iterate (tdesc_type_field
, type
->u
.u
.fields
, ix3
, f
);
1656 (" field_type = tdesc_named_type (feature, \"%s\");\n",
1659 (" tdesc_add_field (type, \"%s\", field_type);\n",
1663 case TDESC_TYPE_FLAGS
:
1665 (" field_type = tdesc_create_flags (feature, \"%s\", %d);\n",
1666 type
->name
, (int) type
->u
.f
.size
);
1668 VEC_iterate (tdesc_type_flag
, type
->u
.f
.flags
, ix3
,
1672 (" tdesc_add_flag (field_type, %d, \"%s\");\n",
1673 flag
->start
, flag
->name
);
1676 error (_("C output is not supported type \"%s\"."), type
->name
);
1678 printf_unfiltered ("\n");
1682 VEC_iterate (tdesc_reg_p
, feature
->registers
, ix2
, reg
);
1685 printf_unfiltered (" tdesc_create_reg (feature, \"%s\", %ld, %d, ",
1686 reg
->name
, reg
->target_regnum
, reg
->save_restore
);
1688 printf_unfiltered ("\"%s\", ", reg
->group
);
1690 printf_unfiltered ("NULL, ");
1691 printf_unfiltered ("%d, \"%s\");\n", reg
->bitsize
, reg
->type
);
1694 printf_unfiltered ("\n");
1697 printf_unfiltered (" tdesc_%s = result;\n", function
);
1698 printf_unfiltered ("}\n");
1701 /* Provide a prototype to silence -Wmissing-prototypes. */
1702 extern initialize_file_ftype _initialize_target_descriptions
;
1705 _initialize_target_descriptions (void)
1707 tdesc_data
= gdbarch_data_register_pre_init (tdesc_data_init
);
1709 add_prefix_cmd ("tdesc", class_maintenance
, set_tdesc_cmd
, _("\
1710 Set target description specific variables."),
1711 &tdesc_set_cmdlist
, "set tdesc ",
1712 0 /* allow-unknown */, &setlist
);
1713 add_prefix_cmd ("tdesc", class_maintenance
, show_tdesc_cmd
, _("\
1714 Show target description specific variables."),
1715 &tdesc_show_cmdlist
, "show tdesc ",
1716 0 /* allow-unknown */, &showlist
);
1717 add_prefix_cmd ("tdesc", class_maintenance
, unset_tdesc_cmd
, _("\
1718 Unset target description specific variables."),
1719 &tdesc_unset_cmdlist
, "unset tdesc ",
1720 0 /* allow-unknown */, &unsetlist
);
1722 add_setshow_filename_cmd ("filename", class_obscure
,
1723 &target_description_filename
,
1725 Set the file to read for an XML target description"), _("\
1726 Show the file to read for an XML target description"), _("\
1727 When set, GDB will read the target description from a local\n\
1728 file instead of querying the remote target."),
1729 set_tdesc_filename_cmd
,
1730 show_tdesc_filename_cmd
,
1731 &tdesc_set_cmdlist
, &tdesc_show_cmdlist
);
1733 add_cmd ("filename", class_obscure
, unset_tdesc_filename_cmd
, _("\
1734 Unset the file to read for an XML target description. When unset,\n\
1735 GDB will read the description from the target."),
1736 &tdesc_unset_cmdlist
);
1738 add_cmd ("c-tdesc", class_maintenance
, maint_print_c_tdesc_cmd
, _("\
1739 Print the current target description as a C source file."),
1740 &maintenanceprintlist
);