Pass correct die_reader_specs in cutu_reader::init_tu_and_read_dwo_dies
[deliverable/binutils-gdb.git] / gdb / target-descriptions.c
CommitLineData
424163ea
DJ
1/* Target description support for GDB.
2
b811d2c2 3 Copyright (C) 2006-2020 Free Software Foundation, Inc.
424163ea
DJ
4
5 Contributed by CodeSourcery.
6
7 This file is part of GDB.
8
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
a9762ec7 11 the Free Software Foundation; either version 3 of the License, or
424163ea
DJ
12 (at your option) any later version.
13
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.
18
19 You should have received a copy of the GNU General Public License
a9762ec7 20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
424163ea
DJ
21
22#include "defs.h"
23#include "arch-utils.h"
23181151 24#include "gdbcmd.h"
123dc839
DJ
25#include "gdbtypes.h"
26#include "reggroups.h"
424163ea
DJ
27#include "target.h"
28#include "target-descriptions.h"
123dc839 29#include "xml-support.h"
23181151 30#include "xml-tdesc.h"
c3f08eb7 31#include "osabi.h"
424163ea 32
123dc839
DJ
33#include "gdb_obstack.h"
34#include "hashtab.h"
6ecd4729 35#include "inferior.h"
25aa13e5 36#include <algorithm>
27d41eac
YQ
37#include "completer.h"
38#include "readline/tilde.h" /* tilde_expand */
424163ea
DJ
39
40/* Types. */
41
129c10bc 42struct property
29709017 43{
129c10bc
SM
44 property (const std::string &key_, const std::string &value_)
45 : key (key_), value (value_)
46 {}
47
48 std::string key;
49 std::string value;
50};
29709017 51
b8df6ca7
AH
52/* Convert a tdesc_type to a gdb type. */
53
54static type *
55make_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *ttype)
56{
57 class gdb_type_creator : public tdesc_element_visitor
27d41eac 58 {
b8df6ca7
AH
59 public:
60 gdb_type_creator (struct gdbarch *gdbarch)
61 : m_gdbarch (gdbarch)
62 {}
d4a0e8b5 63
b8df6ca7
AH
64 type *get_type ()
65 {
66 return m_type;
67 }
d4a0e8b5 68
b8df6ca7
AH
69 void visit (const tdesc_type_builtin *e) override
70 {
71 switch (e->kind)
72 {
73 /* Predefined types. */
74 case TDESC_TYPE_BOOL:
75 m_type = builtin_type (m_gdbarch)->builtin_bool;
76 return;
77 case TDESC_TYPE_INT8:
78 m_type = builtin_type (m_gdbarch)->builtin_int8;
79 return;
80 case TDESC_TYPE_INT16:
81 m_type = builtin_type (m_gdbarch)->builtin_int16;
82 return;
83 case TDESC_TYPE_INT32:
84 m_type = builtin_type (m_gdbarch)->builtin_int32;
85 return;
86 case TDESC_TYPE_INT64:
87 m_type = builtin_type (m_gdbarch)->builtin_int64;
88 return;
89 case TDESC_TYPE_INT128:
90 m_type = builtin_type (m_gdbarch)->builtin_int128;
91 return;
92 case TDESC_TYPE_UINT8:
93 m_type = builtin_type (m_gdbarch)->builtin_uint8;
94 return;
95 case TDESC_TYPE_UINT16:
96 m_type = builtin_type (m_gdbarch)->builtin_uint16;
97 return;
98 case TDESC_TYPE_UINT32:
99 m_type = builtin_type (m_gdbarch)->builtin_uint32;
100 return;
101 case TDESC_TYPE_UINT64:
102 m_type = builtin_type (m_gdbarch)->builtin_uint64;
103 return;
104 case TDESC_TYPE_UINT128:
105 m_type = builtin_type (m_gdbarch)->builtin_uint128;
106 return;
107 case TDESC_TYPE_CODE_PTR:
108 m_type = builtin_type (m_gdbarch)->builtin_func_ptr;
109 return;
110 case TDESC_TYPE_DATA_PTR:
111 m_type = builtin_type (m_gdbarch)->builtin_data_ptr;
112 return;
113 }
d4a0e8b5 114
b8df6ca7
AH
115 m_type = tdesc_find_type (m_gdbarch, e->name.c_str ());
116 if (m_type != NULL)
117 return;
27d41eac 118
b8df6ca7
AH
119 switch (e->kind)
120 {
a6d0f249
AH
121 case TDESC_TYPE_IEEE_HALF:
122 m_type = arch_float_type (m_gdbarch, -1, "builtin_type_ieee_half",
123 floatformats_ieee_half);
124 return;
125
b8df6ca7
AH
126 case TDESC_TYPE_IEEE_SINGLE:
127 m_type = arch_float_type (m_gdbarch, -1, "builtin_type_ieee_single",
128 floatformats_ieee_single);
129 return;
130
131 case TDESC_TYPE_IEEE_DOUBLE:
132 m_type = arch_float_type (m_gdbarch, -1, "builtin_type_ieee_double",
133 floatformats_ieee_double);
134 return;
135 case TDESC_TYPE_ARM_FPA_EXT:
136 m_type = arch_float_type (m_gdbarch, -1, "builtin_type_arm_ext",
137 floatformats_arm_ext);
138 return;
139
140 case TDESC_TYPE_I387_EXT:
141 m_type = arch_float_type (m_gdbarch, -1, "builtin_type_i387_ext",
142 floatformats_i387_ext);
143 return;
144 }
d4a0e8b5 145
b8df6ca7
AH
146 internal_error (__FILE__, __LINE__,
147 "Type \"%s\" has an unknown kind %d",
148 e->name.c_str (), e->kind);
149 }
d4a0e8b5 150
b8df6ca7
AH
151 void visit (const tdesc_type_vector *e) override
152 {
153 m_type = tdesc_find_type (m_gdbarch, e->name.c_str ());
154 if (m_type != NULL)
155 return;
156
157 type *element_gdb_type = make_gdb_type (m_gdbarch, e->element_type);
158 m_type = init_vector_type (element_gdb_type, e->count);
159 TYPE_NAME (m_type) = xstrdup (e->name.c_str ());
160 return;
161 }
53c934e9 162
b8df6ca7
AH
163 void visit (const tdesc_type_with_fields *e) override
164 {
165 m_type = tdesc_find_type (m_gdbarch, e->name.c_str ());
166 if (m_type != NULL)
167 return;
d4a0e8b5 168
b8df6ca7
AH
169 switch (e->kind)
170 {
171 case TDESC_TYPE_STRUCT:
172 make_gdb_type_struct (e);
173 return;
174 case TDESC_TYPE_UNION:
175 make_gdb_type_union (e);
176 return;
177 case TDESC_TYPE_FLAGS:
178 make_gdb_type_flags (e);
179 return;
180 case TDESC_TYPE_ENUM:
181 make_gdb_type_enum (e);
182 return;
183 }
d4a0e8b5 184
b8df6ca7
AH
185 internal_error (__FILE__, __LINE__,
186 "Type \"%s\" has an unknown kind %d",
187 e->name.c_str (), e->kind);
188 }
d4a0e8b5 189
b8df6ca7 190 private:
d4a0e8b5 191
b8df6ca7
AH
192 void make_gdb_type_struct (const tdesc_type_with_fields *e)
193 {
194 m_type = arch_composite_type (m_gdbarch, NULL, TYPE_CODE_STRUCT);
195 TYPE_NAME (m_type) = xstrdup (e->name.c_str ());
d4a0e8b5 196
b8df6ca7
AH
197 for (const tdesc_type_field &f : e->fields)
198 {
199 if (f.start != -1 && f.end != -1)
200 {
201 /* Bitfield. */
202 struct field *fld;
203 struct type *field_gdb_type;
204 int bitsize, total_size;
205
206 /* This invariant should be preserved while creating types. */
207 gdb_assert (e->size != 0);
208 if (f.type != NULL)
209 field_gdb_type = make_gdb_type (m_gdbarch, f.type);
210 else if (e->size > 4)
211 field_gdb_type = builtin_type (m_gdbarch)->builtin_uint64;
212 else
213 field_gdb_type = builtin_type (m_gdbarch)->builtin_uint32;
214
215 fld = append_composite_type_field_raw
216 (m_type, xstrdup (f.name.c_str ()), field_gdb_type);
217
218 /* For little-endian, BITPOS counts from the LSB of
219 the structure and marks the LSB of the field. For
220 big-endian, BITPOS counts from the MSB of the
221 structure and marks the MSB of the field. Either
222 way, it is the number of bits to the "left" of the
223 field. To calculate this in big-endian, we need
224 the total size of the structure. */
225 bitsize = f.end - f.start + 1;
226 total_size = e->size * TARGET_CHAR_BIT;
d5a22e77 227 if (gdbarch_byte_order (m_gdbarch) == BFD_ENDIAN_BIG)
b8df6ca7
AH
228 SET_FIELD_BITPOS (fld[0], total_size - f.start - bitsize);
229 else
230 SET_FIELD_BITPOS (fld[0], f.start);
231 FIELD_BITSIZE (fld[0]) = bitsize;
232 }
233 else
234 {
235 gdb_assert (f.start == -1 && f.end == -1);
236 type *field_gdb_type = make_gdb_type (m_gdbarch, f.type);
237 append_composite_type_field (m_type,
d4a0e8b5 238 xstrdup (f.name.c_str ()),
b8df6ca7
AH
239 field_gdb_type);
240 }
241 }
d4a0e8b5 242
b8df6ca7
AH
243 if (e->size != 0)
244 TYPE_LENGTH (m_type) = e->size;
245 }
d4a0e8b5 246
b8df6ca7
AH
247 void make_gdb_type_union (const tdesc_type_with_fields *e)
248 {
249 m_type = arch_composite_type (m_gdbarch, NULL, TYPE_CODE_UNION);
250 TYPE_NAME (m_type) = xstrdup (e->name.c_str ());
d4a0e8b5 251
b8df6ca7
AH
252 for (const tdesc_type_field &f : e->fields)
253 {
254 type* field_gdb_type = make_gdb_type (m_gdbarch, f.type);
255 append_composite_type_field (m_type, xstrdup (f.name.c_str ()),
256 field_gdb_type);
257
258 /* If any of the children of a union are vectors, flag the
259 union as a vector also. This allows e.g. a union of two
260 vector types to show up automatically in "info vector". */
261 if (TYPE_VECTOR (field_gdb_type))
262 TYPE_VECTOR (m_type) = 1;
263 }
264 }
d4a0e8b5 265
b8df6ca7 266 void make_gdb_type_flags (const tdesc_type_with_fields *e)
d4a0e8b5 267 {
b8df6ca7
AH
268 m_type = arch_flags_type (m_gdbarch, e->name.c_str (),
269 e->size * TARGET_CHAR_BIT);
270
271 for (const tdesc_type_field &f : e->fields)
272 {
273 int bitsize = f.end - f.start + 1;
274
275 gdb_assert (f.type != NULL);
276 type *field_gdb_type = make_gdb_type (m_gdbarch, f.type);
277 append_flags_type_field (m_type, f.start, bitsize,
278 field_gdb_type, f.name.c_str ());
279 }
d4a0e8b5
SM
280 }
281
b8df6ca7
AH
282 void make_gdb_type_enum (const tdesc_type_with_fields *e)
283 {
284 m_type = arch_type (m_gdbarch, TYPE_CODE_ENUM, e->size * TARGET_CHAR_BIT,
285 e->name.c_str ());
d4a0e8b5 286
b8df6ca7
AH
287 TYPE_UNSIGNED (m_type) = 1;
288 for (const tdesc_type_field &f : e->fields)
289 {
290 struct field *fld
291 = append_composite_type_field_raw (m_type,
292 xstrdup (f.name.c_str ()),
293 NULL);
d4a0e8b5 294
b8df6ca7
AH
295 SET_FIELD_BITPOS (fld[0], f.start);
296 }
297 }
298
299 /* The gdbarch used. */
300 struct gdbarch *m_gdbarch;
301
302 /* The type created. */
303 type *m_type;
304 };
305
306 gdb_type_creator gdb_type (gdbarch);
307 ttype->accept (gdb_type);
308 return gdb_type.get_type ();
309}
123dc839 310
123dc839
DJ
311/* A target description. */
312
6eb1e6a8 313struct target_desc : tdesc_element
424163ea 314{
b468ff4c
YQ
315 target_desc ()
316 {}
317
3eea796c 318 virtual ~target_desc () = default;
b468ff4c
YQ
319
320 target_desc (const target_desc &) = delete;
321 void operator= (const target_desc &) = delete;
322
23181151 323 /* The architecture reported by the target, if any. */
b468ff4c 324 const struct bfd_arch_info *arch = NULL;
23181151 325
08d16641
PA
326 /* The osabi reported by the target, if any; GDB_OSABI_UNKNOWN
327 otherwise. */
b468ff4c 328 enum gdb_osabi osabi = GDB_OSABI_UNKNOWN;
08d16641 329
e35359c5 330 /* The list of compatible architectures reported by the target. */
40e2a983 331 std::vector<const bfd_arch_info *> compatible;
e35359c5 332
29709017 333 /* Any architecture-specific properties specified by the target. */
129c10bc 334 std::vector<property> properties;
123dc839
DJ
335
336 /* The features associated with this target. */
858c9d13 337 std::vector<tdesc_feature_up> features;
6eb1e6a8 338
e98577a9
AH
339 /* Used to cache the generated xml version of the target description. */
340 mutable char *xmltarget = nullptr;
341
6eb1e6a8
YQ
342 void accept (tdesc_element_visitor &v) const override
343 {
344 v.visit_pre (this);
345
3eea796c 346 for (const tdesc_feature_up &feature : features)
6eb1e6a8
YQ
347 feature->accept (v);
348
349 v.visit_post (this);
350 }
27d41eac
YQ
351
352 bool operator== (const target_desc &other) const
353 {
354 if (arch != other.arch)
355 return false;
356
357 if (osabi != other.osabi)
358 return false;
359
3eea796c 360 if (features.size () != other.features.size ())
27d41eac
YQ
361 return false;
362
3eea796c 363 for (int ix = 0; ix < features.size (); ix++)
27d41eac 364 {
3eea796c
SM
365 const tdesc_feature_up &feature1 = features[ix];
366 const tdesc_feature_up &feature2 = other.features[ix];
27d41eac 367
3eea796c 368 if (feature1 != feature2 && *feature1 != *feature2)
27d41eac
YQ
369 return false;
370 }
371
372 return true;
373 }
374
375 bool operator!= (const target_desc &other) const
376 {
377 return !(*this == other);
378 }
123dc839
DJ
379};
380
381/* Per-architecture data associated with a target description. The
382 target description may be shared by multiple architectures, but
383 this data is private to one gdbarch. */
384
f0cddbef 385struct tdesc_arch_reg
ad068eab 386{
f0cddbef
SM
387 tdesc_arch_reg (tdesc_reg *reg_, struct type *type_)
388 : reg (reg_), type (type_)
389 {}
390
ad068eab
UW
391 struct tdesc_reg *reg;
392 struct type *type;
f0cddbef 393};
ad068eab 394
123dc839
DJ
395struct tdesc_arch_data
396{
ad068eab 397 /* A list of register/type pairs, indexed by GDB's internal register number.
123dc839
DJ
398 During initialization of the gdbarch this list is used to store
399 registers which the architecture assigns a fixed register number.
400 Registers which are NULL in this array, or off the end, are
401 treated as zero-sized and nameless (i.e. placeholders in the
402 numbering). */
f0cddbef 403 std::vector<tdesc_arch_reg> arch_regs;
123dc839
DJ
404
405 /* Functions which report the register name, type, and reggroups for
406 pseudo-registers. */
f0cddbef
SM
407 gdbarch_register_name_ftype *pseudo_register_name = NULL;
408 gdbarch_register_type_ftype *pseudo_register_type = NULL;
409 gdbarch_register_reggroup_p_ftype *pseudo_register_reggroup_p = NULL;
424163ea
DJ
410};
411
6ecd4729
PA
412/* Info about an inferior's target description. There's one of these
413 for each inferior. */
424163ea 414
6ecd4729
PA
415struct target_desc_info
416{
417 /* A flag indicating that a description has already been fetched
418 from the target, so it should not be queried again. */
419
420 int fetched;
424163ea 421
6ecd4729
PA
422 /* The description fetched from the target, or NULL if the target
423 did not supply any description. Only valid when
424 target_desc_fetched is set. Only the description initialization
425 code should access this; normally, the description should be
426 accessed through the gdbarch object. */
424163ea 427
6ecd4729 428 const struct target_desc *tdesc;
424163ea 429
6ecd4729
PA
430 /* The filename to read a target description from, as set by "set
431 tdesc filename ..." */
424163ea 432
6ecd4729
PA
433 char *filename;
434};
23181151 435
6ecd4729
PA
436/* Get the inferior INF's target description info, allocating one on
437 the stop if necessary. */
23181151 438
6ecd4729
PA
439static struct target_desc_info *
440get_tdesc_info (struct inferior *inf)
441{
442 if (inf->tdesc_info == NULL)
443 inf->tdesc_info = XCNEW (struct target_desc_info);
444 return inf->tdesc_info;
445}
23181151 446
123dc839
DJ
447/* A handle for architecture-specific data associated with the
448 target description (see struct tdesc_arch_data). */
449
450static struct gdbarch_data *tdesc_data;
451
6ecd4729
PA
452/* See target-descriptions.h. */
453
454int
455target_desc_info_from_user_p (struct target_desc_info *info)
456{
457 return info != NULL && info->filename != NULL;
458}
459
460/* See target-descriptions.h. */
461
462void
463copy_inferior_target_desc_info (struct inferior *destinf, struct inferior *srcinf)
464{
465 struct target_desc_info *src = get_tdesc_info (srcinf);
466 struct target_desc_info *dest = get_tdesc_info (destinf);
467
468 dest->fetched = src->fetched;
469 dest->tdesc = src->tdesc;
470 dest->filename = src->filename != NULL ? xstrdup (src->filename) : NULL;
471}
472
473/* See target-descriptions.h. */
474
475void
476target_desc_info_free (struct target_desc_info *tdesc_info)
477{
478 if (tdesc_info != NULL)
479 {
480 xfree (tdesc_info->filename);
481 xfree (tdesc_info);
482 }
483}
484
485/* Convenience helper macros. */
486
487#define target_desc_fetched \
488 get_tdesc_info (current_inferior ())->fetched
489#define current_target_desc \
490 get_tdesc_info (current_inferior ())->tdesc
491#define target_description_filename \
492 get_tdesc_info (current_inferior ())->filename
493
494/* The string manipulated by the "set tdesc filename ..." command. */
495
496static char *tdesc_filename_cmd_string;
497
424163ea
DJ
498/* Fetch the current target's description, and switch the current
499 architecture to one which incorporates that description. */
500
501void
502target_find_description (void)
503{
504 /* If we've already fetched a description from the target, don't do
505 it again. This allows a target to fetch the description early,
506 during its to_open or to_create_inferior, if it needs extra
507 information about the target to initialize. */
508 if (target_desc_fetched)
509 return;
510
511 /* The current architecture should not have any target description
512 specified. It should have been cleared, e.g. when we
513 disconnected from the previous target. */
f5656ead 514 gdb_assert (gdbarch_target_desc (target_gdbarch ()) == NULL);
424163ea 515
23181151
DJ
516 /* First try to fetch an XML description from the user-specified
517 file. */
518 current_target_desc = NULL;
519 if (target_description_filename != NULL
520 && *target_description_filename != '\0')
521 current_target_desc
522 = file_read_description_xml (target_description_filename);
523
524 /* Next try to read the description from the current target using
525 target objects. */
526 if (current_target_desc == NULL)
8b88a78e 527 current_target_desc = target_read_description_xml (current_top_target ());
23181151
DJ
528
529 /* If that failed try a target-specific hook. */
530 if (current_target_desc == NULL)
8b88a78e 531 current_target_desc = target_read_description (current_top_target ());
424163ea
DJ
532
533 /* If a non-NULL description was returned, then update the current
534 architecture. */
535 if (current_target_desc)
536 {
537 struct gdbarch_info info;
538
539 gdbarch_info_init (&info);
540 info.target_desc = current_target_desc;
541 if (!gdbarch_update_p (info))
123dc839
DJ
542 warning (_("Architecture rejected target-supplied description"));
543 else
544 {
545 struct tdesc_arch_data *data;
546
19ba03f4
SM
547 data = ((struct tdesc_arch_data *)
548 gdbarch_data (target_gdbarch (), tdesc_data));
123dc839 549 if (tdesc_has_registers (current_target_desc)
f0cddbef 550 && data->arch_regs.empty ())
123dc839
DJ
551 warning (_("Target-supplied registers are not supported "
552 "by the current architecture"));
553 }
424163ea
DJ
554 }
555
556 /* Now that we know this description is usable, record that we
557 fetched it. */
558 target_desc_fetched = 1;
559}
560
561/* Discard any description fetched from the current target, and switch
562 the current architecture to one with no target description. */
563
564void
565target_clear_description (void)
566{
567 struct gdbarch_info info;
568
569 if (!target_desc_fetched)
570 return;
571
572 target_desc_fetched = 0;
573 current_target_desc = NULL;
574
575 gdbarch_info_init (&info);
576 if (!gdbarch_update_p (info))
577 internal_error (__FILE__, __LINE__,
578 _("Could not remove target-supplied description"));
579}
580
581/* Return the global current target description. This should only be
582 used by gdbarch initialization code; most access should be through
583 an existing gdbarch. */
584
585const struct target_desc *
586target_current_description (void)
587{
588 if (target_desc_fetched)
589 return current_target_desc;
590
591 return NULL;
592}
e35359c5
UW
593
594/* Return non-zero if this target description is compatible
595 with the given BFD architecture. */
596
597int
598tdesc_compatible_p (const struct target_desc *target_desc,
599 const struct bfd_arch_info *arch)
600{
40e2a983 601 for (const bfd_arch_info *compat : target_desc->compatible)
e35359c5
UW
602 {
603 if (compat == arch
604 || arch->compatible (arch, compat)
605 || compat->compatible (compat, arch))
606 return 1;
607 }
608
609 return 0;
610}
23181151
DJ
611\f
612
123dc839 613/* Direct accessors for target descriptions. */
424163ea 614
29709017
DJ
615/* Return the string value of a property named KEY, or NULL if the
616 property was not specified. */
617
618const char *
619tdesc_property (const struct target_desc *target_desc, const char *key)
620{
129c10bc
SM
621 for (const property &prop : target_desc->properties)
622 if (prop.key == key)
623 return prop.value.c_str ();
29709017
DJ
624
625 return NULL;
626}
627
23181151
DJ
628/* Return the BFD architecture associated with this target
629 description, or NULL if no architecture was specified. */
630
631const struct bfd_arch_info *
632tdesc_architecture (const struct target_desc *target_desc)
633{
634 return target_desc->arch;
635}
08d16641 636
268a13a5 637/* See gdbsupport/tdesc.h. */
d278f585
AH
638
639const char *
640tdesc_architecture_name (const struct target_desc *target_desc)
641{
642 return target_desc->arch->printable_name;
643}
644
08d16641
PA
645/* Return the OSABI associated with this target description, or
646 GDB_OSABI_UNKNOWN if no osabi was specified. */
647
648enum gdb_osabi
649tdesc_osabi (const struct target_desc *target_desc)
650{
651 return target_desc->osabi;
652}
653
268a13a5 654/* See gdbsupport/tdesc.h. */
d278f585
AH
655
656const char *
657tdesc_osabi_name (const struct target_desc *target_desc)
658{
659 enum gdb_osabi osabi = tdesc_osabi (target_desc);
660 if (osabi > GDB_OSABI_UNKNOWN && osabi < GDB_OSABI_INVALID)
661 return gdbarch_osabi_name (osabi);
662 return nullptr;
663}
23181151 664
123dc839
DJ
665/* Return 1 if this target description includes any registers. */
666
667int
668tdesc_has_registers (const struct target_desc *target_desc)
669{
123dc839
DJ
670 if (target_desc == NULL)
671 return 0;
672
3eea796c 673 for (const tdesc_feature_up &feature : target_desc->features)
c9c895b9 674 if (!feature->registers.empty ())
123dc839
DJ
675 return 1;
676
677 return 0;
678}
679
680/* Return the feature with the given name, if present, or NULL if
681 the named feature is not found. */
682
683const struct tdesc_feature *
684tdesc_find_feature (const struct target_desc *target_desc,
685 const char *name)
686{
3eea796c 687 for (const tdesc_feature_up &feature : target_desc->features)
f65ff9f9 688 if (feature->name == name)
3eea796c 689 return feature.get ();
123dc839
DJ
690
691 return NULL;
692}
693
694/* Return the name of FEATURE. */
695
696const char *
697tdesc_feature_name (const struct tdesc_feature *feature)
698{
f65ff9f9 699 return feature->name.c_str ();
123dc839
DJ
700}
701
9fd3625f
L
702/* Lookup type associated with ID. */
703
704struct type *
705tdesc_find_type (struct gdbarch *gdbarch, const char *id)
706{
f0cddbef
SM
707 tdesc_arch_data *data
708 = (struct tdesc_arch_data *) gdbarch_data (gdbarch, tdesc_data);
9fd3625f 709
f0cddbef 710 for (const tdesc_arch_reg &reg : data->arch_regs)
9fd3625f 711 {
f0cddbef
SM
712 if (reg.reg
713 && reg.reg->tdesc_type
714 && reg.type
715 && reg.reg->tdesc_type->name == id)
716 return reg.type;
9fd3625f
L
717 }
718
719 return NULL;
720}
721
123dc839
DJ
722/* Support for registers from target descriptions. */
723
724/* Construct the per-gdbarch data. */
725
726static void *
727tdesc_data_init (struct obstack *obstack)
728{
284a0e3c 729 return obstack_new<tdesc_arch_data> (obstack);
123dc839
DJ
730}
731
732/* Similar, but for the temporary copy used during architecture
733 initialization. */
734
735struct tdesc_arch_data *
736tdesc_data_alloc (void)
737{
f0cddbef 738 return new tdesc_arch_data ();
123dc839
DJ
739}
740
741/* Free something allocated by tdesc_data_alloc, if it is not going
742 to be used (for instance if it was unsuitable for the
743 architecture). */
744
745void
746tdesc_data_cleanup (void *data_untyped)
747{
19ba03f4 748 struct tdesc_arch_data *data = (struct tdesc_arch_data *) data_untyped;
123dc839 749
f0cddbef 750 delete data;
123dc839
DJ
751}
752
753/* Search FEATURE for a register named NAME. */
754
7cc46491
DJ
755static struct tdesc_reg *
756tdesc_find_register_early (const struct tdesc_feature *feature,
757 const char *name)
123dc839 758{
c9c895b9 759 for (const tdesc_reg_up &reg : feature->registers)
a8142ee1 760 if (strcasecmp (reg->name.c_str (), name) == 0)
c9c895b9 761 return reg.get ();
123dc839 762
7cc46491
DJ
763 return NULL;
764}
765
766/* Search FEATURE for a register named NAME. Assign REGNO to it. */
767
768int
769tdesc_numbered_register (const struct tdesc_feature *feature,
770 struct tdesc_arch_data *data,
771 int regno, const char *name)
772{
773 struct tdesc_reg *reg = tdesc_find_register_early (feature, name);
774
775 if (reg == NULL)
776 return 0;
777
778 /* Make sure the vector includes a REGNO'th element. */
f0cddbef
SM
779 while (regno >= data->arch_regs.size ())
780 data->arch_regs.emplace_back (nullptr, nullptr);
781
782 data->arch_regs[regno] = tdesc_arch_reg (reg, NULL);
ad068eab 783
7cc46491 784 return 1;
123dc839
DJ
785}
786
58d6951d
DJ
787/* Search FEATURE for a register named NAME, but do not assign a fixed
788 register number to it. */
789
790int
791tdesc_unnumbered_register (const struct tdesc_feature *feature,
792 const char *name)
793{
794 struct tdesc_reg *reg = tdesc_find_register_early (feature, name);
795
796 if (reg == NULL)
797 return 0;
798
799 return 1;
800}
801
7cc46491
DJ
802/* Search FEATURE for a register whose name is in NAMES and assign
803 REGNO to it. */
123dc839
DJ
804
805int
806tdesc_numbered_register_choices (const struct tdesc_feature *feature,
807 struct tdesc_arch_data *data,
808 int regno, const char *const names[])
809{
810 int i;
811
812 for (i = 0; names[i] != NULL; i++)
813 if (tdesc_numbered_register (feature, data, regno, names[i]))
814 return 1;
815
816 return 0;
817}
818
7cc46491
DJ
819/* Search FEATURE for a register named NAME, and return its size in
820 bits. The register must exist. */
821
822int
12863263 823tdesc_register_bitsize (const struct tdesc_feature *feature, const char *name)
7cc46491
DJ
824{
825 struct tdesc_reg *reg = tdesc_find_register_early (feature, name);
826
827 gdb_assert (reg != NULL);
828 return reg->bitsize;
829}
830
123dc839
DJ
831/* Look up a register by its GDB internal register number. */
832
ad068eab
UW
833static struct tdesc_arch_reg *
834tdesc_find_arch_register (struct gdbarch *gdbarch, int regno)
123dc839 835{
123dc839
DJ
836 struct tdesc_arch_data *data;
837
19ba03f4 838 data = (struct tdesc_arch_data *) gdbarch_data (gdbarch, tdesc_data);
f0cddbef
SM
839 if (regno < data->arch_regs.size ())
840 return &data->arch_regs[regno];
123dc839
DJ
841 else
842 return NULL;
843}
844
ad068eab
UW
845static struct tdesc_reg *
846tdesc_find_register (struct gdbarch *gdbarch, int regno)
847{
848 struct tdesc_arch_reg *reg = tdesc_find_arch_register (gdbarch, regno);
5d502164 849
ad068eab
UW
850 return reg? reg->reg : NULL;
851}
852
f8b73d13
DJ
853/* Return the name of register REGNO, from the target description or
854 from an architecture-provided pseudo_register_name method. */
855
856const char *
d93859e2 857tdesc_register_name (struct gdbarch *gdbarch, int regno)
123dc839 858{
d93859e2
UW
859 struct tdesc_reg *reg = tdesc_find_register (gdbarch, regno);
860 int num_regs = gdbarch_num_regs (gdbarch);
123dc839
DJ
861
862 if (reg != NULL)
a8142ee1 863 return reg->name.c_str ();
123dc839 864
f6efe3f8 865 if (regno >= num_regs && regno < gdbarch_num_cooked_regs (gdbarch))
123dc839 866 {
19ba03f4
SM
867 struct tdesc_arch_data *data
868 = (struct tdesc_arch_data *) gdbarch_data (gdbarch, tdesc_data);
5d502164 869
123dc839 870 gdb_assert (data->pseudo_register_name != NULL);
d93859e2 871 return data->pseudo_register_name (gdbarch, regno);
123dc839
DJ
872 }
873
874 return "";
875}
876
58d6951d 877struct type *
123dc839
DJ
878tdesc_register_type (struct gdbarch *gdbarch, int regno)
879{
ad068eab
UW
880 struct tdesc_arch_reg *arch_reg = tdesc_find_arch_register (gdbarch, regno);
881 struct tdesc_reg *reg = arch_reg? arch_reg->reg : NULL;
123dc839
DJ
882 int num_regs = gdbarch_num_regs (gdbarch);
883 int num_pseudo_regs = gdbarch_num_pseudo_regs (gdbarch);
884
885 if (reg == NULL && regno >= num_regs && regno < num_regs + num_pseudo_regs)
886 {
19ba03f4
SM
887 struct tdesc_arch_data *data
888 = (struct tdesc_arch_data *) gdbarch_data (gdbarch, tdesc_data);
5d502164 889
123dc839
DJ
890 gdb_assert (data->pseudo_register_type != NULL);
891 return data->pseudo_register_type (gdbarch, regno);
892 }
893
894 if (reg == NULL)
895 /* Return "int0_t", since "void" has a misleading size of one. */
df4df182 896 return builtin_type (gdbarch)->builtin_int0;
123dc839 897
ad068eab 898 if (arch_reg->type == NULL)
123dc839 899 {
ad068eab
UW
900 /* First check for a predefined or target defined type. */
901 if (reg->tdesc_type)
b8df6ca7 902 arch_reg->type = make_gdb_type (gdbarch, reg->tdesc_type);
ad068eab
UW
903
904 /* Next try size-sensitive type shortcuts. */
a8142ee1 905 else if (reg->type == "float")
ad068eab
UW
906 {
907 if (reg->bitsize == gdbarch_float_bit (gdbarch))
908 arch_reg->type = builtin_type (gdbarch)->builtin_float;
909 else if (reg->bitsize == gdbarch_double_bit (gdbarch))
910 arch_reg->type = builtin_type (gdbarch)->builtin_double;
911 else if (reg->bitsize == gdbarch_long_double_bit (gdbarch))
912 arch_reg->type = builtin_type (gdbarch)->builtin_long_double;
913 else
914 {
915 warning (_("Register \"%s\" has an unsupported size (%d bits)"),
a8142ee1 916 reg->name.c_str (), reg->bitsize);
ad068eab
UW
917 arch_reg->type = builtin_type (gdbarch)->builtin_double;
918 }
919 }
a8142ee1 920 else if (reg->type == "int")
ad068eab
UW
921 {
922 if (reg->bitsize == gdbarch_long_bit (gdbarch))
923 arch_reg->type = builtin_type (gdbarch)->builtin_long;
924 else if (reg->bitsize == TARGET_CHAR_BIT)
925 arch_reg->type = builtin_type (gdbarch)->builtin_char;
926 else if (reg->bitsize == gdbarch_short_bit (gdbarch))
927 arch_reg->type = builtin_type (gdbarch)->builtin_short;
928 else if (reg->bitsize == gdbarch_int_bit (gdbarch))
929 arch_reg->type = builtin_type (gdbarch)->builtin_int;
930 else if (reg->bitsize == gdbarch_long_long_bit (gdbarch))
931 arch_reg->type = builtin_type (gdbarch)->builtin_long_long;
932 else if (reg->bitsize == gdbarch_ptr_bit (gdbarch))
c378eb4e 933 /* A bit desperate by this point... */
ad068eab
UW
934 arch_reg->type = builtin_type (gdbarch)->builtin_data_ptr;
935 else
936 {
937 warning (_("Register \"%s\" has an unsupported size (%d bits)"),
a8142ee1 938 reg->name.c_str (), reg->bitsize);
ad068eab
UW
939 arch_reg->type = builtin_type (gdbarch)->builtin_long;
940 }
941 }
942
943 if (arch_reg->type == NULL)
944 internal_error (__FILE__, __LINE__,
945 "Register \"%s\" has an unknown type \"%s\"",
a8142ee1 946 reg->name.c_str (), reg->type.c_str ());
123dc839 947 }
123dc839 948
ad068eab 949 return arch_reg->type;
123dc839
DJ
950}
951
952static int
953tdesc_remote_register_number (struct gdbarch *gdbarch, int regno)
954{
955 struct tdesc_reg *reg = tdesc_find_register (gdbarch, regno);
956
957 if (reg != NULL)
958 return reg->target_regnum;
959 else
960 return -1;
961}
962
963/* Check whether REGNUM is a member of REGGROUP. Registers from the
cef0f868
SH
964 target description may be classified as general, float, vector or other
965 register groups registered with reggroup_add(). Unlike a gdbarch
966 register_reggroup_p method, this function will return -1 if it does not
967 know; the caller should handle registers with no specified group.
968
969 The names of containing features are not used. This might be extended
970 to display registers in some more useful groupings.
123dc839
DJ
971
972 The save-restore flag is also implemented here. */
973
f8b73d13
DJ
974int
975tdesc_register_in_reggroup_p (struct gdbarch *gdbarch, int regno,
976 struct reggroup *reggroup)
123dc839 977{
123dc839
DJ
978 struct tdesc_reg *reg = tdesc_find_register (gdbarch, regno);
979
aa66aac4
SV
980 if (reg != NULL)
981 {
982 if (reggroup == all_reggroup)
cef0f868 983 return 1;
123dc839 984
aa66aac4
SV
985 else if (reggroup == save_reggroup || reggroup == restore_reggroup)
986 return reg->save_restore;
987 else
988 return (int) (reg->group == reggroup_name (reggroup));
989 }
123dc839 990
f8b73d13
DJ
991 return -1;
992}
993
994/* Check whether REGNUM is a member of REGGROUP. Registers with no
995 group specified go to the default reggroup function and are handled
996 by type. */
997
998static int
999tdesc_register_reggroup_p (struct gdbarch *gdbarch, int regno,
1000 struct reggroup *reggroup)
1001{
1002 int num_regs = gdbarch_num_regs (gdbarch);
1003 int num_pseudo_regs = gdbarch_num_pseudo_regs (gdbarch);
1004 int ret;
1005
1006 if (regno >= num_regs && regno < num_regs + num_pseudo_regs)
1007 {
19ba03f4
SM
1008 struct tdesc_arch_data *data
1009 = (struct tdesc_arch_data *) gdbarch_data (gdbarch, tdesc_data);
5d502164 1010
58d6951d
DJ
1011 if (data->pseudo_register_reggroup_p != NULL)
1012 return data->pseudo_register_reggroup_p (gdbarch, regno, reggroup);
1013 /* Otherwise fall through to the default reggroup_p. */
f8b73d13
DJ
1014 }
1015
1016 ret = tdesc_register_in_reggroup_p (gdbarch, regno, reggroup);
1017 if (ret != -1)
1018 return ret;
1019
123dc839
DJ
1020 return default_register_reggroup_p (gdbarch, regno, reggroup);
1021}
1022
1023/* Record architecture-specific functions to call for pseudo-register
1024 support. */
1025
1026void
1027set_tdesc_pseudo_register_name (struct gdbarch *gdbarch,
1028 gdbarch_register_name_ftype *pseudo_name)
1029{
19ba03f4
SM
1030 struct tdesc_arch_data *data
1031 = (struct tdesc_arch_data *) gdbarch_data (gdbarch, tdesc_data);
123dc839
DJ
1032
1033 data->pseudo_register_name = pseudo_name;
1034}
1035
1036void
1037set_tdesc_pseudo_register_type (struct gdbarch *gdbarch,
1038 gdbarch_register_type_ftype *pseudo_type)
1039{
19ba03f4
SM
1040 struct tdesc_arch_data *data
1041 = (struct tdesc_arch_data *) gdbarch_data (gdbarch, tdesc_data);
123dc839
DJ
1042
1043 data->pseudo_register_type = pseudo_type;
1044}
1045
1046void
1047set_tdesc_pseudo_register_reggroup_p
1048 (struct gdbarch *gdbarch,
1049 gdbarch_register_reggroup_p_ftype *pseudo_reggroup_p)
1050{
19ba03f4
SM
1051 struct tdesc_arch_data *data
1052 = (struct tdesc_arch_data *) gdbarch_data (gdbarch, tdesc_data);
123dc839
DJ
1053
1054 data->pseudo_register_reggroup_p = pseudo_reggroup_p;
1055}
1056
1057/* Update GDBARCH to use the target description for registers. */
1058
1059void
1060tdesc_use_registers (struct gdbarch *gdbarch,
7cc46491 1061 const struct target_desc *target_desc,
123dc839
DJ
1062 struct tdesc_arch_data *early_data)
1063{
1064 int num_regs = gdbarch_num_regs (gdbarch);
123dc839
DJ
1065 struct tdesc_arch_data *data;
1066 htab_t reg_hash;
1067
123dc839
DJ
1068 /* We can't use the description for registers if it doesn't describe
1069 any. This function should only be called after validating
1070 registers, so the caller should know that registers are
1071 included. */
1072 gdb_assert (tdesc_has_registers (target_desc));
1073
19ba03f4 1074 data = (struct tdesc_arch_data *) gdbarch_data (gdbarch, tdesc_data);
ad068eab 1075 data->arch_regs = early_data->arch_regs;
f0cddbef 1076 delete early_data;
123dc839
DJ
1077
1078 /* Build up a set of all registers, so that we can assign register
1079 numbers where needed. The hash table expands as necessary, so
1080 the initial size is arbitrary. */
1081 reg_hash = htab_create (37, htab_hash_pointer, htab_eq_pointer, NULL);
3eea796c 1082 for (const tdesc_feature_up &feature : target_desc->features)
c9c895b9 1083 for (const tdesc_reg_up &reg : feature->registers)
123dc839 1084 {
c9c895b9 1085 void **slot = htab_find_slot (reg_hash, reg.get (), INSERT);
123dc839 1086
c9c895b9 1087 *slot = reg.get ();
cef0f868
SH
1088 /* Add reggroup if its new. */
1089 if (!reg->group.empty ())
1090 if (reggroup_find (gdbarch, reg->group.c_str ()) == NULL)
1091 reggroup_add (gdbarch, reggroup_gdbarch_new (gdbarch,
1092 reg->group.c_str (),
1093 USER_REGGROUP));
123dc839
DJ
1094 }
1095
1096 /* Remove any registers which were assigned numbers by the
1097 architecture. */
f0cddbef
SM
1098 for (const tdesc_arch_reg &arch_reg : data->arch_regs)
1099 if (arch_reg.reg != NULL)
1100 htab_remove_elt (reg_hash, arch_reg.reg);
123dc839
DJ
1101
1102 /* Assign numbers to the remaining registers and add them to the
f57d151a 1103 list of registers. The new numbers are always above gdbarch_num_regs.
123dc839
DJ
1104 Iterate over the features, not the hash table, so that the order
1105 matches that in the target description. */
1106
f0cddbef
SM
1107 gdb_assert (data->arch_regs.size () <= num_regs);
1108 while (data->arch_regs.size () < num_regs)
1109 data->arch_regs.emplace_back (nullptr, nullptr);
1110
3eea796c 1111 for (const tdesc_feature_up &feature : target_desc->features)
c9c895b9
SM
1112 for (const tdesc_reg_up &reg : feature->registers)
1113 if (htab_find (reg_hash, reg.get ()) != NULL)
123dc839 1114 {
f0cddbef 1115 data->arch_regs.emplace_back (reg.get (), nullptr);
123dc839
DJ
1116 num_regs++;
1117 }
1118
1119 htab_delete (reg_hash);
1120
1121 /* Update the architecture. */
1122 set_gdbarch_num_regs (gdbarch, num_regs);
1123 set_gdbarch_register_name (gdbarch, tdesc_register_name);
1124 set_gdbarch_register_type (gdbarch, tdesc_register_type);
1125 set_gdbarch_remote_register_number (gdbarch,
1126 tdesc_remote_register_number);
1127 set_gdbarch_register_reggroup_p (gdbarch, tdesc_register_reggroup_p);
1128}
123dc839 1129
268a13a5 1130/* See gdbsupport/tdesc.h. */
f49ff000 1131
123dc839 1132struct tdesc_feature *
3b74854b 1133tdesc_create_feature (struct target_desc *tdesc, const char *name)
123dc839 1134{
72ddacb7 1135 struct tdesc_feature *new_feature = new tdesc_feature (name);
123dc839 1136
3eea796c
SM
1137 tdesc->features.emplace_back (new_feature);
1138
123dc839
DJ
1139 return new_feature;
1140}
1141
424163ea
DJ
1142struct target_desc *
1143allocate_target_description (void)
1144{
b468ff4c 1145 return new target_desc ();
424163ea 1146}
29709017 1147
c55d06ec
TT
1148void
1149target_desc_deleter::operator() (struct target_desc *target_desc) const
23181151 1150{
b468ff4c 1151 delete target_desc;
23181151
DJ
1152}
1153
e35359c5
UW
1154void
1155tdesc_add_compatible (struct target_desc *target_desc,
1156 const struct bfd_arch_info *compatible)
1157{
e35359c5
UW
1158 /* If this instance of GDB is compiled without BFD support for the
1159 compatible architecture, simply ignore it -- we would not be able
1160 to handle it anyway. */
1161 if (compatible == NULL)
1162 return;
1163
40e2a983 1164 for (const bfd_arch_info *compat : target_desc->compatible)
e35359c5
UW
1165 if (compat == compatible)
1166 internal_error (__FILE__, __LINE__,
1167 _("Attempted to add duplicate "
1168 "compatible architecture \"%s\""),
1169 compatible->printable_name);
1170
40e2a983 1171 target_desc->compatible.push_back (compatible);
e35359c5
UW
1172}
1173
29709017
DJ
1174void
1175set_tdesc_property (struct target_desc *target_desc,
1176 const char *key, const char *value)
1177{
29709017
DJ
1178 gdb_assert (key != NULL && value != NULL);
1179
129c10bc
SM
1180 if (tdesc_property (target_desc, key) != NULL)
1181 internal_error (__FILE__, __LINE__,
1182 _("Attempted to add duplicate property \"%s\""), key);
29709017 1183
129c10bc 1184 target_desc->properties.emplace_back (key, value);
29709017 1185}
23181151 1186
268a13a5 1187/* See gdbsupport/tdesc.h. */
5f035c07
YQ
1188
1189void
1190set_tdesc_architecture (struct target_desc *target_desc,
1191 const char *name)
1192{
1193 set_tdesc_architecture (target_desc, bfd_scan_arch (name));
1194}
1195
23181151
DJ
1196void
1197set_tdesc_architecture (struct target_desc *target_desc,
1198 const struct bfd_arch_info *arch)
1199{
1200 target_desc->arch = arch;
1201}
08d16641 1202
268a13a5 1203/* See gdbsupport/tdesc.h. */
5f035c07
YQ
1204
1205void
1206set_tdesc_osabi (struct target_desc *target_desc, const char *name)
1207{
1208 set_tdesc_osabi (target_desc, osabi_from_tdesc_string (name));
1209}
1210
08d16641
PA
1211void
1212set_tdesc_osabi (struct target_desc *target_desc, enum gdb_osabi osabi)
1213{
1214 target_desc->osabi = osabi;
1215}
23181151
DJ
1216\f
1217
1218static struct cmd_list_element *tdesc_set_cmdlist, *tdesc_show_cmdlist;
1219static struct cmd_list_element *tdesc_unset_cmdlist;
1220
1221/* Helper functions for the CLI commands. */
1222
1223static void
981a3fb3 1224set_tdesc_cmd (const char *args, int from_tty)
23181151 1225{
635c7e8a 1226 help_list (tdesc_set_cmdlist, "set tdesc ", all_commands, gdb_stdout);
23181151
DJ
1227}
1228
1229static void
981a3fb3 1230show_tdesc_cmd (const char *args, int from_tty)
23181151
DJ
1231{
1232 cmd_show_list (tdesc_show_cmdlist, from_tty, "");
1233}
1234
1235static void
981a3fb3 1236unset_tdesc_cmd (const char *args, int from_tty)
23181151 1237{
635c7e8a 1238 help_list (tdesc_unset_cmdlist, "unset tdesc ", all_commands, gdb_stdout);
23181151
DJ
1239}
1240
1241static void
eb4c3f4a 1242set_tdesc_filename_cmd (const char *args, int from_tty,
23181151
DJ
1243 struct cmd_list_element *c)
1244{
6ecd4729
PA
1245 xfree (target_description_filename);
1246 target_description_filename = xstrdup (tdesc_filename_cmd_string);
1247
23181151
DJ
1248 target_clear_description ();
1249 target_find_description ();
1250}
1251
1252static void
1253show_tdesc_filename_cmd (struct ui_file *file, int from_tty,
1254 struct cmd_list_element *c,
1255 const char *value)
1256{
6ecd4729
PA
1257 value = target_description_filename;
1258
23181151 1259 if (value != NULL && *value != '\0')
3e43a32a 1260 printf_filtered (_("The target description will be read from \"%s\".\n"),
23181151
DJ
1261 value);
1262 else
3e43a32a
MS
1263 printf_filtered (_("The target description will be "
1264 "read from the target.\n"));
23181151
DJ
1265}
1266
1267static void
e100df1a 1268unset_tdesc_filename_cmd (const char *args, int from_tty)
23181151
DJ
1269{
1270 xfree (target_description_filename);
1271 target_description_filename = NULL;
1272 target_clear_description ();
1273 target_find_description ();
1274}
1275
6eb1e6a8
YQ
1276/* Print target description in C. */
1277
1278class print_c_tdesc : public tdesc_element_visitor
1279{
1280public:
1281 print_c_tdesc (std::string &filename_after_features)
1282 : m_filename_after_features (filename_after_features)
1283 {
1284 const char *inp;
1285 char *outp;
1286 const char *filename = lbasename (m_filename_after_features.c_str ());
1287
1288 m_function = (char *) xmalloc (strlen (filename) + 1);
1289 for (inp = filename, outp = m_function; *inp != '\0'; inp++)
1290 if (*inp == '.')
1291 break;
1292 else if (*inp == '-')
1293 *outp++ = '_';
1294 else
1295 *outp++ = *inp;
1296 *outp = '\0';
1297
1298 /* Standard boilerplate. */
1299 printf_unfiltered ("/* THIS FILE IS GENERATED. "
1300 "-*- buffer-read-only: t -*- vi"
1301 ":set ro:\n");
6eb1e6a8
YQ
1302 }
1303
1304 ~print_c_tdesc ()
1305 {
1306 xfree (m_function);
1307 }
1308
1309 void visit_pre (const target_desc *e) override
1310 {
25aa13e5
YQ
1311 printf_unfiltered (" Original: %s */\n\n",
1312 lbasename (m_filename_after_features.c_str ()));
1313
6eb1e6a8
YQ
1314 printf_unfiltered ("#include \"defs.h\"\n");
1315 printf_unfiltered ("#include \"osabi.h\"\n");
1316 printf_unfiltered ("#include \"target-descriptions.h\"\n");
1317 printf_unfiltered ("\n");
1318
1319 printf_unfiltered ("struct target_desc *tdesc_%s;\n", m_function);
1320 printf_unfiltered ("static void\n");
1321 printf_unfiltered ("initialize_tdesc_%s (void)\n", m_function);
1322 printf_unfiltered ("{\n");
1323 printf_unfiltered
1324 (" struct target_desc *result = allocate_target_description ();\n");
1325
1326 if (tdesc_architecture (e) != NULL)
1327 {
1328 printf_unfiltered
1329 (" set_tdesc_architecture (result, bfd_scan_arch (\"%s\"));\n",
1330 tdesc_architecture (e)->printable_name);
1331 printf_unfiltered ("\n");
1332 }
1333 if (tdesc_osabi (e) > GDB_OSABI_UNKNOWN
1334 && tdesc_osabi (e) < GDB_OSABI_INVALID)
1335 {
1336 printf_unfiltered
1337 (" set_tdesc_osabi (result, osabi_from_tdesc_string (\"%s\"));\n",
1338 gdbarch_osabi_name (tdesc_osabi (e)));
1339 printf_unfiltered ("\n");
1340 }
1341
23a8d186 1342 for (const bfd_arch_info_type *compatible : e->compatible)
40e2a983
SM
1343 printf_unfiltered
1344 (" tdesc_add_compatible (result, bfd_scan_arch (\"%s\"));\n",
1345 compatible->printable_name);
6eb1e6a8 1346
40e2a983 1347 if (!e->compatible.empty ())
6eb1e6a8
YQ
1348 printf_unfiltered ("\n");
1349
129c10bc
SM
1350 for (const property &prop : e->properties)
1351 printf_unfiltered (" set_tdesc_property (result, \"%s\", \"%s\");\n",
1352 prop.key.c_str (), prop.value.c_str ());
1353
6eb1e6a8
YQ
1354 printf_unfiltered (" struct tdesc_feature *feature;\n");
1355 }
1356
25aa13e5 1357 void visit_pre (const tdesc_feature *e) override
6eb1e6a8
YQ
1358 {
1359 printf_unfiltered ("\n feature = tdesc_create_feature (result, \"%s\");\n",
f65ff9f9 1360 e->name.c_str ());
6eb1e6a8
YQ
1361 }
1362
25aa13e5
YQ
1363 void visit_post (const tdesc_feature *e) override
1364 {}
1365
6eb1e6a8
YQ
1366 void visit_post (const target_desc *e) override
1367 {
1368 printf_unfiltered ("\n tdesc_%s = result;\n", m_function);
1369 printf_unfiltered ("}\n");
1370 }
1371
d4a0e8b5
SM
1372 void visit (const tdesc_type_builtin *type) override
1373 {
1374 error (_("C output is not supported type \"%s\"."), type->name.c_str ());
1375 }
1376
1377 void visit (const tdesc_type_vector *type) override
6eb1e6a8 1378 {
d4a0e8b5 1379 if (!m_printed_element_type)
6eb1e6a8 1380 {
d4a0e8b5
SM
1381 printf_unfiltered (" tdesc_type *element_type;\n");
1382 m_printed_element_type = true;
6eb1e6a8
YQ
1383 }
1384
d4a0e8b5
SM
1385 printf_unfiltered
1386 (" element_type = tdesc_named_type (feature, \"%s\");\n",
1387 type->element_type->name.c_str ());
1388 printf_unfiltered
1389 (" tdesc_create_vector (feature, \"%s\", element_type, %d);\n",
1390 type->name.c_str (), type->count);
1391
1392 printf_unfiltered ("\n");
1393 }
1394
1395 void visit (const tdesc_type_with_fields *type) override
1396 {
1397 if (!m_printed_type_with_fields)
6eb1e6a8 1398 {
d4a0e8b5
SM
1399 printf_unfiltered (" tdesc_type_with_fields *type_with_fields;\n");
1400 m_printed_type_with_fields = true;
1401 }
1402
6eb1e6a8
YQ
1403 switch (type->kind)
1404 {
6eb1e6a8
YQ
1405 case TDESC_TYPE_STRUCT:
1406 case TDESC_TYPE_FLAGS:
1407 if (type->kind == TDESC_TYPE_STRUCT)
1408 {
1409 printf_unfiltered
d4a0e8b5 1410 (" type_with_fields = tdesc_create_struct (feature, \"%s\");\n",
082b9140 1411 type->name.c_str ());
d4a0e8b5 1412 if (type->size != 0)
6eb1e6a8 1413 printf_unfiltered
d4a0e8b5 1414 (" tdesc_set_struct_size (type_with_fields, %d);\n", type->size);
6eb1e6a8
YQ
1415 }
1416 else
1417 {
1418 printf_unfiltered
d4a0e8b5
SM
1419 (" type_with_fields = tdesc_create_flags (feature, \"%s\", %d);\n",
1420 type->name.c_str (), type->size);
6eb1e6a8 1421 }
d4a0e8b5 1422 for (const tdesc_type_field &f : type->fields)
6eb1e6a8
YQ
1423 {
1424 const char *type_name;
1425
d05200d1
SM
1426 gdb_assert (f.type != NULL);
1427 type_name = f.type->name.c_str ();
6eb1e6a8
YQ
1428
1429 /* To minimize changes to generated files, don't emit type
1430 info for fields that have defaulted types. */
d05200d1 1431 if (f.start != -1)
6eb1e6a8 1432 {
d05200d1
SM
1433 gdb_assert (f.end != -1);
1434 if (f.type->kind == TDESC_TYPE_BOOL)
6eb1e6a8 1435 {
d05200d1 1436 gdb_assert (f.start == f.end);
6eb1e6a8 1437 printf_unfiltered
d4a0e8b5 1438 (" tdesc_add_flag (type_with_fields, %d, \"%s\");\n",
d05200d1 1439 f.start, f.name.c_str ());
6eb1e6a8 1440 }
d4a0e8b5
SM
1441 else if ((type->size == 4 && f.type->kind == TDESC_TYPE_UINT32)
1442 || (type->size == 8
d05200d1 1443 && f.type->kind == TDESC_TYPE_UINT64))
6eb1e6a8
YQ
1444 {
1445 printf_unfiltered
d4a0e8b5 1446 (" tdesc_add_bitfield (type_with_fields, \"%s\", %d, %d);\n",
d05200d1 1447 f.name.c_str (), f.start, f.end);
6eb1e6a8
YQ
1448 }
1449 else
1450 {
a8d2e585
SM
1451 printf_field_type_assignment
1452 ("tdesc_named_type (feature, \"%s\");\n",
6eb1e6a8
YQ
1453 type_name);
1454 printf_unfiltered
d4a0e8b5 1455 (" tdesc_add_typed_bitfield (type_with_fields, \"%s\","
6eb1e6a8 1456 " %d, %d, field_type);\n",
d05200d1 1457 f.name.c_str (), f.start, f.end);
6eb1e6a8
YQ
1458 }
1459 }
1460 else /* Not a bitfield. */
1461 {
d05200d1 1462 gdb_assert (f.end == -1);
6eb1e6a8 1463 gdb_assert (type->kind == TDESC_TYPE_STRUCT);
a8d2e585
SM
1464 printf_field_type_assignment
1465 ("tdesc_named_type (feature, \"%s\");\n", type_name);
6eb1e6a8 1466 printf_unfiltered
d4a0e8b5 1467 (" tdesc_add_field (type_with_fields, \"%s\", field_type);\n",
d05200d1 1468 f.name.c_str ());
6eb1e6a8
YQ
1469 }
1470 }
1471 break;
1472 case TDESC_TYPE_UNION:
1473 printf_unfiltered
d4a0e8b5 1474 (" type_with_fields = tdesc_create_union (feature, \"%s\");\n",
082b9140 1475 type->name.c_str ());
d4a0e8b5 1476 for (const tdesc_type_field &f : type->fields)
6eb1e6a8 1477 {
a8d2e585
SM
1478 printf_field_type_assignment
1479 ("tdesc_named_type (feature, \"%s\");\n", f.type->name.c_str ());
6eb1e6a8 1480 printf_unfiltered
d4a0e8b5 1481 (" tdesc_add_field (type_with_fields, \"%s\", field_type);\n",
d05200d1 1482 f.name.c_str ());
6eb1e6a8
YQ
1483 }
1484 break;
1485 case TDESC_TYPE_ENUM:
1486 printf_unfiltered
d4a0e8b5
SM
1487 (" type_with_fields = tdesc_create_enum (feature, \"%s\", %d);\n",
1488 type->name.c_str (), type->size);
1489 for (const tdesc_type_field &f : type->fields)
6eb1e6a8 1490 printf_unfiltered
d4a0e8b5 1491 (" tdesc_add_enum_value (type_with_fields, %d, \"%s\");\n",
d05200d1 1492 f.start, f.name.c_str ());
6eb1e6a8
YQ
1493 break;
1494 default:
082b9140 1495 error (_("C output is not supported type \"%s\"."), type->name.c_str ());
6eb1e6a8 1496 }
d4a0e8b5 1497
6eb1e6a8
YQ
1498 printf_unfiltered ("\n");
1499 }
1500
1501 void visit (const tdesc_reg *reg) override
1502 {
1503 printf_unfiltered (" tdesc_create_reg (feature, \"%s\", %ld, %d, ",
a8142ee1
SM
1504 reg->name.c_str (), reg->target_regnum,
1505 reg->save_restore);
1506 if (!reg->group.empty ())
1507 printf_unfiltered ("\"%s\", ", reg->group.c_str ());
6eb1e6a8
YQ
1508 else
1509 printf_unfiltered ("NULL, ");
a8142ee1 1510 printf_unfiltered ("%d, \"%s\");\n", reg->bitsize, reg->type.c_str ());
6eb1e6a8
YQ
1511 }
1512
25aa13e5
YQ
1513protected:
1514 std::string m_filename_after_features;
1515
6eb1e6a8 1516private:
a8d2e585
SM
1517
1518 /* Print an assignment to the field_type variable. Print the declaration
1519 of field_type if that has not been done yet. */
6e8c24fe 1520 ATTRIBUTE_PRINTF (2, 3)
a8d2e585
SM
1521 void printf_field_type_assignment (const char *fmt, ...)
1522 {
1523 if (!m_printed_field_type)
1524 {
1525 printf_unfiltered (" tdesc_type *field_type;\n");
1526 m_printed_field_type = true;
1527 }
1528
1529 printf_unfiltered (" field_type = ");
1530
1531 va_list args;
1532 va_start (args, fmt);
1533 vprintf_unfiltered (fmt, args);
1534 va_end (args);
1535 }
1536
6eb1e6a8 1537 char *m_function;
d4a0e8b5
SM
1538
1539 /* Did we print "struct tdesc_type *element_type;" yet? */
1540 bool m_printed_element_type = false;
1541
1542 /* Did we print "struct tdesc_type_with_fields *element_type;" yet? */
1543 bool m_printed_type_with_fields = false;
1544
1545 /* Did we print "struct tdesc_type *field_type;" yet? */
6eb1e6a8 1546 bool m_printed_field_type = false;
6eb1e6a8
YQ
1547};
1548
25aa13e5
YQ
1549/* Print target description feature in C. */
1550
1551class print_c_feature : public print_c_tdesc
1552{
1553public:
1554 print_c_feature (std::string &file)
1555 : print_c_tdesc (file)
1556 {
1557 /* Trim ".tmp". */
1558 auto const pos = m_filename_after_features.find_last_of ('.');
1559
1560 m_filename_after_features = m_filename_after_features.substr (0, pos);
1561 }
1562
1563 void visit_pre (const target_desc *e) override
1564 {
1565 printf_unfiltered (" Original: %s */\n\n",
1566 lbasename (m_filename_after_features.c_str ()));
1567
268a13a5 1568 printf_unfiltered ("#include \"gdbsupport/tdesc.h\"\n");
25aa13e5
YQ
1569 printf_unfiltered ("\n");
1570 }
1571
1572 void visit_post (const target_desc *e) override
1573 {}
1574
1575 void visit_pre (const tdesc_feature *e) override
1576 {
1577 std::string name (m_filename_after_features);
1578
1579 auto pos = name.find_first_of ('.');
1580
1581 name = name.substr (0, pos);
1582 std::replace (name.begin (), name.end (), '/', '_');
1583 std::replace (name.begin (), name.end (), '-', '_');
1584
1585 printf_unfiltered ("static int\n");
1586 printf_unfiltered ("create_feature_%s ", name.c_str ());
1587 printf_unfiltered ("(struct target_desc *result, long regnum)\n");
1588
1589 printf_unfiltered ("{\n");
1590 printf_unfiltered (" struct tdesc_feature *feature;\n");
0abe8a89
YQ
1591
1592 printf_unfiltered
3b74854b
AH
1593 ("\n feature = tdesc_create_feature (result, \"%s\");\n",
1594 e->name.c_str ());
25aa13e5
YQ
1595 }
1596
1597 void visit_post (const tdesc_feature *e) override
1598 {
1599 printf_unfiltered (" return regnum;\n");
1600 printf_unfiltered ("}\n");
1601 }
1602
1603 void visit (const tdesc_reg *reg) override
1604 {
ea03d0d3
YQ
1605 /* Most "reg" in XML target descriptions don't have "regnum"
1606 attribute, so the register number is allocated sequentially.
1607 In case that reg has "regnum" attribute, register number
1608 should be set by that explicitly. */
1609
1610 if (reg->target_regnum < m_next_regnum)
1611 {
1612 /* The integrity check, it can catch some errors on register
1613 number collision, like this,
1614
1615 <reg name="x0" bitsize="32"/>
1616 <reg name="x1" bitsize="32"/>
1617 <reg name="x2" bitsize="32"/>
1618 <reg name="x3" bitsize="32"/>
1619 <reg name="ps" bitsize="32" regnum="3"/>
1620
1621 but it also has false negatives. The target description
1622 below is correct,
1623
1624 <reg name="x1" bitsize="32" regnum="1"/>
1625 <reg name="x3" bitsize="32" regnum="3"/>
1626 <reg name="x2" bitsize="32" regnum="2"/>
1627 <reg name="x4" bitsize="32" regnum="4"/>
1628
1629 but it is not a good practice, so still error on this,
1630 and also print the message so that it can be saved in the
1631 generated c file. */
1632
1633 printf_unfiltered ("ERROR: \"regnum\" attribute %ld ",
1634 reg->target_regnum);
1635 printf_unfiltered ("is not the largest number (%d).\n",
1636 m_next_regnum);
1637 error (_("\"regnum\" attribute %ld is not the largest number (%d)."),
1638 reg->target_regnum, m_next_regnum);
1639 }
1640
1641 if (reg->target_regnum > m_next_regnum)
1642 {
1643 printf_unfiltered (" regnum = %ld;\n", reg->target_regnum);
1644 m_next_regnum = reg->target_regnum;
1645 }
1646
25aa13e5 1647 printf_unfiltered (" tdesc_create_reg (feature, \"%s\", regnum++, %d, ",
a8142ee1
SM
1648 reg->name.c_str (), reg->save_restore);
1649 if (!reg->group.empty ())
1650 printf_unfiltered ("\"%s\", ", reg->group.c_str ());
25aa13e5
YQ
1651 else
1652 printf_unfiltered ("NULL, ");
a8142ee1 1653 printf_unfiltered ("%d, \"%s\");\n", reg->bitsize, reg->type.c_str ());
ea03d0d3
YQ
1654
1655 m_next_regnum++;
25aa13e5
YQ
1656 }
1657
ea03d0d3
YQ
1658private:
1659 /* The register number to use for the next register we see. */
1660 int m_next_regnum = 0;
25aa13e5
YQ
1661};
1662
268a13a5 1663/* See gdbsupport/tdesc.h. */
e98577a9
AH
1664
1665const char *
1666tdesc_get_features_xml (const target_desc *tdesc)
1667{
1668 if (tdesc->xmltarget == nullptr)
1669 {
1670 std::string buffer ("@");
1671 print_xml_feature v (&buffer);
1672 tdesc->accept (v);
1673 tdesc->xmltarget = xstrdup (buffer.c_str ());
1674 }
1675 return tdesc->xmltarget;
1676}
1677
81adfced 1678static void
e100df1a 1679maint_print_c_tdesc_cmd (const char *args, int from_tty)
81adfced
DJ
1680{
1681 const struct target_desc *tdesc;
6eb1e6a8 1682 const char *filename;
81adfced 1683
8e2141c6
YQ
1684 if (args == NULL)
1685 {
1686 /* Use the global target-supplied description, not the current
1687 architecture's. This lets a GDB for one architecture generate C
1688 for another architecture's description, even though the gdbarch
1689 initialization code will reject the new description. */
1690 tdesc = current_target_desc;
1691 filename = target_description_filename;
1692 }
1693 else
1694 {
1695 /* Use the target description from the XML file. */
1696 filename = args;
1697 tdesc = file_read_description_xml (filename);
1698 }
1699
81adfced
DJ
1700 if (tdesc == NULL)
1701 error (_("There is no target description to print."));
1702
8e2141c6 1703 if (filename == NULL)
81adfced
DJ
1704 error (_("The current target description did not come from an XML file."));
1705
6eb1e6a8
YQ
1706 std::string filename_after_features (filename);
1707 auto loc = filename_after_features.rfind ("/features/");
4e2f8df6 1708
6eb1e6a8
YQ
1709 if (loc != std::string::npos)
1710 filename_after_features = filename_after_features.substr (loc + 10);
4e2f8df6 1711
25aa13e5
YQ
1712 /* Print c files for target features instead of target descriptions,
1713 because c files got from target features are more flexible than the
1714 counterparts. */
6c73f67f
YQ
1715 if (startswith (filename_after_features.c_str (), "i386/32bit-")
1716 || startswith (filename_after_features.c_str (), "i386/64bit-")
506fe5f4 1717 || startswith (filename_after_features.c_str (), "i386/x32-core.xml")
b5ffee31 1718 || startswith (filename_after_features.c_str (), "riscv/")
49bdb7ee 1719 || startswith (filename_after_features.c_str (), "tic6x-")
89abbcc2
AH
1720 || startswith (filename_after_features.c_str (), "aarch64")
1721 || startswith (filename_after_features.c_str (), "arm/"))
25aa13e5
YQ
1722 {
1723 print_c_feature v (filename_after_features);
81adfced 1724
25aa13e5
YQ
1725 tdesc->accept (v);
1726 }
1727 else
1728 {
1729 print_c_tdesc v (filename_after_features);
1730
1731 tdesc->accept (v);
1732 }
81adfced
DJ
1733}
1734
27d41eac
YQ
1735namespace selftests {
1736
1c28969e
SM
1737/* A reference target description, used for testing (see record_xml_tdesc). */
1738
1739struct xml_test_tdesc
1740{
1741 xml_test_tdesc (const char *name, std::unique_ptr<const target_desc> &&tdesc)
1742 : name (name), tdesc (std::move (tdesc))
1743 {}
1744
1745 const char *name;
1746 std::unique_ptr<const target_desc> tdesc;
1747};
1748
1749static std::vector<xml_test_tdesc> xml_tdesc;
27d41eac
YQ
1750
1751#if GDB_SELF_TEST
1752
405feb71 1753/* See target-descriptions.h. */
27d41eac
YQ
1754
1755void
1756record_xml_tdesc (const char *xml_file, const struct target_desc *tdesc)
1757{
1c28969e 1758 xml_tdesc.emplace_back (xml_file, std::unique_ptr<const target_desc> (tdesc));
27d41eac
YQ
1759}
1760#endif
1761
1762}
1763
85102364 1764/* Test the conversion process of a target description to/from xml: Take a target
e98577a9
AH
1765 description TDESC, convert to xml, back to a description, and confirm the new
1766 tdesc is identical to the original. */
1767static bool
1768maintenance_check_tdesc_xml_convert (const target_desc *tdesc, const char *name)
1769{
1770 const char *xml = tdesc_get_features_xml (tdesc);
1771
1772 if (xml == nullptr || *xml != '@')
1773 {
1774 printf_filtered (_("Could not convert description for %s to xml.\n"),
1775 name);
1776 return false;
1777 }
1778
1779 const target_desc *tdesc_trans = string_read_description_xml (xml + 1);
1780
1781 if (tdesc_trans == nullptr)
1782 {
1783 printf_filtered (_("Could not convert description for %s from xml.\n"),
1784 name);
1785 return false;
1786 }
1787 else if (*tdesc != *tdesc_trans)
1788 {
1789 printf_filtered (_("Converted description for %s does not match.\n"),
1790 name);
1791 return false;
1792 }
1793 return true;
1794}
1795
1796
27d41eac
YQ
1797/* Check that the target descriptions created dynamically by
1798 architecture-specific code equal the descriptions created from XML files
1799 found in the specified directory DIR. */
1800
1801static void
e100df1a 1802maintenance_check_xml_descriptions (const char *dir, int from_tty)
27d41eac
YQ
1803{
1804 if (dir == NULL)
1805 error (_("Missing dir name"));
1806
1807 gdb::unique_xmalloc_ptr<char> dir1 (tilde_expand (dir));
1808 std::string feature_dir (dir1.get ());
1809 unsigned int failed = 0;
1810
1811 for (auto const &e : selftests::xml_tdesc)
1812 {
1c28969e 1813 std::string tdesc_xml = (feature_dir + SLASH_STRING + e.name);
27d41eac
YQ
1814 const target_desc *tdesc
1815 = file_read_description_xml (tdesc_xml.data ());
1816
1c28969e 1817 if (tdesc == NULL || *tdesc != *e.tdesc)
e98577a9 1818 {
1c28969e 1819 printf_filtered ( _("Descriptions for %s do not match.\n"), e.name);
e98577a9
AH
1820 failed++;
1821 }
1c28969e
SM
1822 else if (!maintenance_check_tdesc_xml_convert (tdesc, e.name)
1823 || !maintenance_check_tdesc_xml_convert (e.tdesc.get (), e.name))
27d41eac
YQ
1824 failed++;
1825 }
1826 printf_filtered (_("Tested %lu XML files, %d failed\n"),
1827 (long) selftests::xml_tdesc.size (), failed);
1828}
1829
6c265988 1830void _initialize_target_descriptions ();
23181151 1831void
6c265988 1832_initialize_target_descriptions ()
23181151 1833{
123dc839
DJ
1834 tdesc_data = gdbarch_data_register_pre_init (tdesc_data_init);
1835
23181151
DJ
1836 add_prefix_cmd ("tdesc", class_maintenance, set_tdesc_cmd, _("\
1837Set target description specific variables."),
1838 &tdesc_set_cmdlist, "set tdesc ",
1839 0 /* allow-unknown */, &setlist);
1840 add_prefix_cmd ("tdesc", class_maintenance, show_tdesc_cmd, _("\
1841Show target description specific variables."),
1842 &tdesc_show_cmdlist, "show tdesc ",
1843 0 /* allow-unknown */, &showlist);
1844 add_prefix_cmd ("tdesc", class_maintenance, unset_tdesc_cmd, _("\
1845Unset target description specific variables."),
1846 &tdesc_unset_cmdlist, "unset tdesc ",
1847 0 /* allow-unknown */, &unsetlist);
1848
1849 add_setshow_filename_cmd ("filename", class_obscure,
6ecd4729 1850 &tdesc_filename_cmd_string,
23181151 1851 _("\
590042fc
PW
1852Set the file to read for an XML target description."), _("\
1853Show the file to read for an XML target description."), _("\
23181151
DJ
1854When set, GDB will read the target description from a local\n\
1855file instead of querying the remote target."),
1856 set_tdesc_filename_cmd,
1857 show_tdesc_filename_cmd,
1858 &tdesc_set_cmdlist, &tdesc_show_cmdlist);
1859
1860 add_cmd ("filename", class_obscure, unset_tdesc_filename_cmd, _("\
590042fc
PW
1861Unset the file to read for an XML target description.\n\
1862When unset, GDB will read the description from the target."),
23181151 1863 &tdesc_unset_cmdlist);
81adfced
DJ
1864
1865 add_cmd ("c-tdesc", class_maintenance, maint_print_c_tdesc_cmd, _("\
1866Print the current target description as a C source file."),
1867 &maintenanceprintlist);
27d41eac
YQ
1868
1869 cmd_list_element *cmd;
1870
1871 cmd = add_cmd ("xml-descriptions", class_maintenance,
1872 maintenance_check_xml_descriptions, _("\
590042fc 1873Check equality of GDB target descriptions and XML created descriptions.\n\
27d41eac
YQ
1874Check the target descriptions created in GDB equal the descriptions\n\
1875created from XML files in the directory.\n\
1876The parameter is the directory name."),
1877 &maintenancechecklist);
1878 set_cmd_completer (cmd, filename_completer);
23181151 1879}
This page took 1.969826 seconds and 4 git commands to generate.