• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

修订版2c9a28c12dbad8ba9d8a085ff9b2439cf95fb22f (tree)
时间2019-09-26 05:03:15
作者Weimin Pan <weimin.pan@orac...>
CommiterWeimin Pan

Log Message

Sync up gdb with latest gcc and binutils

更改概述

差异

--- a/Makefile.def
+++ b/Makefile.def
@@ -404,6 +404,7 @@ dependencies = { module=all-gdb; on=all-build-bison; };
404404 dependencies = { module=all-gdb; on=all-sim; };
405405 dependencies = { module=all-gdb; on=all-libdecnumber; };
406406 dependencies = { module=all-gdb; on=all-libtermcap; };
407+dependencies = { module=all-gdb; on=all-libctf; };
407408
408409 dependencies = { module=configure-libgui; on=configure-tcl; };
409410 dependencies = { module=configure-libgui; on=configure-tk; };
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,23 @@
1+2019-09-24 Weimin Pan <weimin.pan@oracle.com>
2+
3+ * gdb/ctfread.c: New file.
4+ * gdb/ctfread.h: New file.
5+ * gdb/elfread.c: Include ctfread.h.
6+ (struct elfinfo text_p): New member ctfsect.
7+ (elf_locate_sections): Mark CTF section.
8+ (elf_symfile_read): Call elfctf_build_psymtabs.
9+ * gdb/Makefile.in (LIBCTF): Add.
10+ (CLIBS): Use it.
11+ (CDEPS): Likewise.
12+ (DIST): Add ctfread.c.
13+ * gdb/tracectf.h: Rename, was gdb/ctf.h
14+ * gdb/ctf.c: Replace ctf.h with tracectf.h
15+ * gdb/tracefile.c: Likewise
16+ * gdb/tracepoint.c: Remove unused include ctf.h
17+ * gdb/mi/mi-main.c: Likewise
18+ * Makefile.def (dependencies): Add all-libctf to all-gdb
19+ * Makefile.in: Add "all-gdb: maybe-all-libctf"
20+
121 2019-09-21 Simon Marchi <simon.marchi@polymtl.ca>
222
323 * solib-svr4.c (svr4_iterate_over_objfiles_in_search_order): Fix
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -153,6 +153,9 @@ INCLUDE_CFLAGS = -I$(INCLUDE_DIR)
153153 # Where is the "-liberty" library? Typically in ../libiberty.
154154 LIBIBERTY = ../libiberty/libiberty.a
155155
156+# Where is the CTF library? Typically in ../libctf.
157+LIBCTF = ../libctf/.libs/libctf.a
158+
156159 # Where is the BFD library? Typically in ../bfd.
157160 BFD_DIR = ../bfd
158161 BFD = $(BFD_DIR)/libbfd.a
@@ -588,13 +591,14 @@ INTERNAL_LDFLAGS = \
588591 # Libraries and corresponding dependencies for compiling gdb.
589592 # XM_CLIBS, defined in *config files, have host-dependent libs.
590593 # LIBIBERTY appears twice on purpose.
591-CLIBS = $(SIM) $(READLINE) $(OPCODES) $(BFD) $(ZLIB) $(INTL) $(LIBIBERTY) $(LIBDECNUMBER) \
594+CLIBS = $(SIM) $(READLINE) $(OPCODES) $(BFD) $(LIBCTF) $(ZLIB) \
595+ $(INTL) $(LIBIBERTY) $(LIBDECNUMBER) \
592596 $(XM_CLIBS) $(GDBTKLIBS) \
593597 @LIBS@ @GUILE_LIBS@ @PYTHON_LIBS@ \
594598 $(LIBEXPAT) $(LIBLZMA) $(LIBBABELTRACE) $(LIBIPT) \
595599 $(LIBIBERTY) $(WIN32LIBS) $(LIBGNU) $(LIBICONV) $(LIBMPFR) \
596600 $(SRCHIGH_LIBS)
597-CDEPS = $(NAT_CDEPS) $(SIM) $(BFD) $(READLINE_DEPS) \
601+CDEPS = $(NAT_CDEPS) $(SIM) $(BFD) $(READLINE_DEPS) $(LIBCTF) \
598602 $(OPCODES) $(INTL_DEPS) $(LIBIBERTY) $(CONFIG_DEPS) $(LIBGNU)
599603
600604 DIST = gdb
@@ -988,6 +992,7 @@ COMMON_SFILES = \
988992 cp-support.c \
989993 cp-valprint.c \
990994 ctf.c \
995+ ctfread.c \
991996 d-lang.c \
992997 d-namespace.c \
993998 d-valprint.c \
--- a/gdb/ctf.c
+++ b/gdb/ctf.c
@@ -20,7 +20,7 @@
2020 along with this program. If not, see <http://www.gnu.org/licenses/>. */
2121
2222 #include "defs.h"
23-#include "ctf.h"
23+#include "tracectf.h"
2424 #include "tracepoint.h"
2525 #include "regcache.h"
2626 #include <sys/stat.h>
--- /dev/null
+++ b/gdb/ctfread.c
@@ -0,0 +1,1522 @@
1+/* Compact ANSI-C Type Format (CTF) support in GDB.
2+
3+ Copyright (C) 2019 Free Software Foundation, Inc.
4+
5+ This file is part of GDB.
6+
7+ This program is free software; you can redistribute it and/or modify
8+ it under the terms of the GNU General Public License as published by
9+ the Free Software Foundation; either version 3 of the License, or
10+ (at your option) any later version.
11+
12+ This program is distributed in the hope that it will be useful,
13+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ GNU General Public License for more details.
16+
17+ You should have received a copy of the GNU General Public License
18+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
19+
20+/* This file format can be used to compactly represent the information needed
21+ by a debugger to interpret the ANSI-C types used by a given program.
22+ Traditionally, this kind of information is generated by the compiler when
23+ invoked with the -g flag and is stored in "stabs" strings or in the more
24+ modern DWARF format. A new -gtLEVEL option has been added in gcc to generate
25+ such information. CTF provides a representation of only the information
26+ that is relevant to debugging a complex, optimized C program such as the
27+ operating system kernel in a form that is significantly more compact than
28+ the equivalent stabs or DWARF representation. The format is data-model
29+ independent, so consumers do not need different code depending on whether
30+ they are 32-bit or 64-bit programs. CTF assumes that a standard ELF symbol
31+ table is available for use in the debugger, and uses the structure and data
32+ of the symbol table to avoid storing redundant information. The CTF data
33+ may be compressed on disk or in memory, indicated by a bit in the header.
34+ CTF may be interpreted in a raw disk file, or it may be stored in an ELF
35+ section, typically named .ctf. Data structures are aligned so that a raw
36+ CTF file or CTF ELF section may be manipulated using mmap(2).
37+
38+ The CTF file or section itself has the following structure:
39+
40+ +--------+--------+---------+----------+----------+-------+--------+
41+ | file | type | data | function | variable | data | string |
42+ | header | labels | objects | info | info | types | table |
43+ +--------+--------+---------+----------+----------+-------+--------+
44+
45+ The file header stores a magic number and version information, encoding
46+ flags, and the byte offset of each of the sections relative to the end of the
47+ header itself. If the CTF data has been uniquified against another set of
48+ CTF data, a reference to that data also appears in the the header. This
49+ reference is the name of the label corresponding to the types uniquified
50+ against.
51+
52+ Following the header is a list of labels, used to group the types included in
53+ the data types section. Each label is accompanied by a type ID i. A given
54+ label refers to the group of types whose IDs are in the range [0, i].
55+
56+ Data object and function records are stored in the same order as they appear
57+ in the corresponding symbol table, except that symbols marked SHN_UNDEF are
58+ not stored and symbols that have no type data are padded out with zeroes.
59+ For each data object, the type ID (a small integer) is recorded. For each
60+ function, the type ID of the return type and argument types is recorded.
61+
62+ Variable records (as distinct from data objects) provide a modicum of support
63+ for non-ELF systems, mapping a variable name to a CTF type ID. The variable
64+ names are sorted into ASCIIbetical order, permitting binary searching.
65+
66+ The data types section is a list of variable size records that represent each
67+ type, in order by their ID. The types themselves form a directed graph,
68+ where each node may contain one or more outgoing edges to other type nodes,
69+ denoted by their ID.
70+
71+ Strings are recorded as a string table ID (0 or 1) and a byte offset into the
72+ string table. String table 0 is the internal CTF string table. String table
73+ 1 is the external string table, which is the string table associated with the
74+ ELF symbol table for this object. CTF does not record any strings that are
75+ already in the symbol table, and the CTF string table does not contain any
76+ duplicated strings. */
77+
78+#include "defs.h"
79+#include "buildsym.h"
80+#include "complaints.h"
81+#include "block.h"
82+#include "ctfread.h"
83+#include "psympriv.h"
84+#include "ctf.h"
85+#include "ctf-api.h"
86+
87+static const struct objfile_key<htab, htab_deleter> ctf_tid_key;
88+static const struct objfile_data *ctf_file_key;
89+
90+/* A CTF context consists of a file pointer and an objfile pointer. */
91+
92+typedef struct ctf_context
93+{
94+ ctf_file_t *fp;
95+ struct objfile *of;
96+ struct buildsym_compunit *builder;
97+} ctf_context_t;
98+
99+/* The routines that read and process fields/members of a C struct, union,
100+ or enumeration, pass lists of data member fields in an instance of a
101+ field_info structure. It is derived from dwarf2read.c. */
102+
103+struct nextfield
104+{
105+ struct field field {};
106+};
107+
108+struct field_info
109+ {
110+ /* List of data member fields. */
111+ std::vector<struct nextfield> fields;
112+
113+ /* Number of fields. */
114+ int nfields = 0;
115+
116+ /* Context. */
117+ ctf_context_t cur_context;
118+
119+ /* Parent type. */
120+ struct type *ptype;
121+
122+ /* typedefs defined inside this class. TYPEDEF_FIELD_LIST contains head
123+ of a NULL terminated list of TYPEDEF_FIELD_LIST_COUNT elements. */
124+ std::vector<struct decl_field> typedef_field_list;
125+
126+ /* Nested types defined by this struct and the number of elements in
127+ this list. */
128+ std::vector<struct decl_field> nested_types_list;
129+ };
130+
131+
132+/* Local function prototypes */
133+
134+static void psymtab_to_symtab (struct partial_symtab *);
135+
136+static int ctf_add_type_cb (ctf_id_t tid, void *arg);
137+
138+static struct type *read_array_type (ctf_context_t *ccp, ctf_id_t tid);
139+
140+static struct type *read_pointer_type (ctf_context_t *ccp, ctf_id_t tid,
141+ ctf_id_t btid);
142+
143+static struct type *read_structure_type (ctf_context_t *ccp, ctf_id_t tid);
144+
145+static struct type *read_enum_type (ctf_context_t *ccp, ctf_id_t tid);
146+
147+static struct type *read_typedef_type (ctf_context_t *ccp, ctf_id_t tid,
148+ ctf_id_t btid, const char *name);
149+
150+static struct type *read_type_record (ctf_context_t *ccp, ctf_id_t tid);
151+
152+static void process_structure_type (ctf_context_t *ccp, ctf_id_t tid);
153+
154+static void process_struct_members (ctf_context_t *ccp, ctf_id_t tid,
155+ struct type *type);
156+
157+static struct symbol * new_symbol (ctf_context_t *ccp, struct type *type,
158+ ctf_id_t tid);
159+
160+struct ctf_tid_and_type
161+{
162+ ctf_id_t tid;
163+ struct type *type;
164+};
165+
166+/* Hash function for a ctf_tid_and_type. */
167+
168+static hashval_t
169+tid_and_type_hash (const void *item)
170+{
171+ const struct ctf_tid_and_type *ids
172+ = (const struct ctf_tid_and_type *) item;
173+
174+ return ids->tid;
175+}
176+
177+/* Equality function for a ctf_tid_and_type. */
178+
179+static int
180+tid_and_type_eq (const void *item_lhs, const void *item_rhs)
181+{
182+ const struct ctf_tid_and_type *ids_lhs
183+ = (const struct ctf_tid_and_type *) item_lhs;
184+ const struct ctf_tid_and_type *ids_rhs
185+ = (const struct ctf_tid_and_type *) item_rhs;
186+
187+ return ids_lhs->tid == ids_rhs->tid;
188+}
189+
190+/* Set the type associated with TID to TYP. */
191+
192+static struct type *
193+set_tid_type (struct objfile *of, ctf_id_t tid, struct type *typ)
194+{
195+ htab_t htab;
196+
197+ htab = (htab_t) ctf_tid_key.get (of);
198+ if (htab == NULL)
199+ {
200+ htab = htab_create_alloc (1, tid_and_type_hash,
201+ tid_and_type_eq,
202+ NULL, xcalloc, xfree);
203+ ctf_tid_key.set (of, htab);
204+ }
205+
206+ struct ctf_tid_and_type **slot, ids;
207+ ids.tid = tid;
208+ ids.type = typ;
209+ slot = (struct ctf_tid_and_type **) htab_find_slot (htab, &ids, INSERT);
210+ if (*slot)
211+ complaint (_("An internal GDB problem: ctf_ id_t %ld type already set"),
212+ (tid));
213+ *slot = XOBNEW (&of->objfile_obstack, struct ctf_tid_and_type);
214+ **slot = ids;
215+ return typ;
216+}
217+
218+/* Look up the type for TID in tid_and_type hash, return NULL if hash is
219+ empty or TID does not have a saved type. */
220+
221+static struct type *
222+get_tid_type (struct objfile *of, ctf_id_t tid)
223+{
224+ struct ctf_tid_and_type *slot, ids;
225+ htab_t htab;
226+
227+ htab = (htab_t) ctf_tid_key.get (of);
228+ if (htab == NULL)
229+ return NULL;
230+
231+ ids.tid = tid;
232+ ids.type = NULL;
233+ slot = (struct ctf_tid_and_type *) htab_find (htab, &ids);
234+ if (slot)
235+ return slot->type;
236+ else
237+ return NULL;
238+}
239+
240+/* Return the size of storage in bits for INTEGER, FLOAT, or ENUM. */
241+
242+static int
243+get_bitsize (ctf_file_t *fp, ctf_id_t tid, uint32_t kind)
244+{
245+ ctf_encoding_t cet;
246+
247+ if ((kind == CTF_K_INTEGER || kind == CTF_K_ENUM
248+ || kind == CTF_K_FLOAT)
249+ && ctf_type_reference (fp, tid) != CTF_ERR
250+ && ctf_type_encoding (fp, tid, &cet) != CTF_ERR)
251+ {
252+ return cet.cte_bits;
253+ }
254+
255+ return 0;
256+}
257+
258+/* Set SYM's address, with NAME, from its minimal symbol entry. */
259+
260+static void
261+set_symbol_address (struct objfile *of, struct symbol *sym, const char *name)
262+{
263+ struct bound_minimal_symbol msym;
264+
265+ msym = lookup_minimal_symbol (name, NULL, of);
266+ if (msym.minsym != NULL)
267+ {
268+ SYMBOL_VALUE_ADDRESS (sym) = BMSYMBOL_VALUE_ADDRESS (msym);
269+ SYMBOL_ACLASS_INDEX (sym) = LOC_STATIC;
270+ SYMBOL_SECTION (sym) = MSYMBOL_SECTION (msym.minsym);
271+ }
272+}
273+
274+/* Create the vector of fields, and attach it to TYPE. */
275+
276+static void
277+attach_fields_to_type (struct field_info *fip, struct type *type)
278+{
279+ int nfields = fip->nfields;
280+
281+ if (!nfields)
282+ return;
283+
284+ /* Record the field count, allocate space for the array of fields. */
285+ TYPE_NFIELDS (type) = nfields;
286+ TYPE_FIELDS (type) = (struct field *)
287+ TYPE_ZALLOC (type, sizeof (struct field) * nfields);
288+
289+ /* Copy the saved-up fields into the field vector. */
290+ for (int i = 0; i < nfields; ++i)
291+ {
292+ struct nextfield &field = fip->fields[i];
293+ TYPE_FIELD (type, i) = field.field;
294+ }
295+}
296+
297+/* Allocate a floating-point type of size BITS and name NAME. Pass NAME_HINT
298+ (which may be different from NAME) to the architecture back-end to allow
299+ it to guess the correct format if necessary. */
300+
301+static struct type *
302+ctf_init_float_type (struct objfile *objfile,
303+ int bits,
304+ const char *name,
305+ const char *name_hint)
306+{
307+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
308+ const struct floatformat **format;
309+ struct type *type;
310+
311+ format = gdbarch_floatformat_for_type (gdbarch, name_hint, bits);
312+ if (format)
313+ type = init_float_type (objfile, bits, name, format);
314+ else
315+ type = init_type (objfile, TYPE_CODE_ERROR, bits, name);
316+
317+ return type;
318+}
319+
320+/* Callback to add member NAME to a struct/union type. TID is the type
321+ of struct/union member, OFFSET is the offset of member in bits
322+ (gdbarch_bits_big_endian(), and ARG contains the field_info. */
323+
324+static int
325+ctf_add_member_cb (const char *name,
326+ ctf_id_t tid,
327+ unsigned long offset,
328+ void *arg)
329+{
330+ struct field_info *fip = (struct field_info *)arg;
331+ ctf_context_t *ccp = &fip->cur_context;
332+ struct nextfield new_field;
333+ struct field *fp;
334+ struct type *t;
335+ uint32_t kind;
336+
337+ fp = &new_field.field;
338+ FIELD_NAME (*fp) = name;
339+
340+ kind = ctf_type_kind (ccp->fp, tid);
341+ t = get_tid_type (ccp->of, tid);
342+ if (!t)
343+ {
344+ t = read_type_record (ccp, tid);
345+ if (!t)
346+ {
347+ complaint (_("ctf_add_member_cb: %s has NO type (%ld)"), name, tid);
348+ t = objfile_type (ccp->of)->builtin_error;
349+ set_tid_type (ccp->of, tid, t);
350+ }
351+ }
352+
353+ if (kind == CTF_K_STRUCT || kind == CTF_K_UNION)
354+ {
355+ process_struct_members (ccp, tid, t);
356+ }
357+
358+ FIELD_TYPE (*fp) = t;
359+ SET_FIELD_BITPOS (*fp, offset / TARGET_CHAR_BIT);
360+ FIELD_BITSIZE (*fp) = get_bitsize (ccp->fp, tid, kind);
361+
362+ fip->fields.emplace_back (new_field);
363+ fip->nfields++;
364+
365+ return 0;
366+}
367+
368+/* Callback to add member NAME of EVAL to an enumeration type.
369+ ARG contains the field_info. */
370+
371+static int
372+ctf_add_enum_member_cb (const char *name, int eval, void *arg)
373+{
374+ struct field_info *fip = (struct field_info *)arg;
375+ struct nextfield new_field;
376+ struct field *fp;
377+ ctf_context_t *ccp = &fip->cur_context;
378+
379+ fp = &new_field.field;
380+ FIELD_NAME (*fp) = name;
381+ FIELD_TYPE (*fp) = NULL;
382+ SET_FIELD_ENUMVAL (*fp, eval);
383+ FIELD_BITSIZE (*fp) = 0;
384+
385+ if (name)
386+ {
387+ struct symbol *sym = allocate_symbol (ccp->of);
388+ OBJSTAT (ccp->of, n_syms++);
389+
390+ SYMBOL_SET_LANGUAGE (sym, language_c, &ccp->of->objfile_obstack);
391+ SYMBOL_SET_NAMES (sym, name, strlen (name), 0, ccp->of);
392+ SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
393+ SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
394+ SYMBOL_TYPE (sym) = fip->ptype;
395+ add_symbol_to_list (sym, ccp->builder->get_global_symbols ());
396+ }
397+
398+ fip->fields.emplace_back (new_field);
399+ fip->nfields++;
400+
401+ return 0;
402+}
403+
404+/* Add a new symbol entry, with its name from TP, its access index and
405+ domain from TP's kind, and its type from TPYE. */
406+
407+static struct symbol *
408+new_symbol (ctf_context_t *ccp, struct type *type, ctf_id_t tid)
409+{
410+ struct objfile *objfile = ccp->of;
411+ ctf_file_t *fp = ccp->fp;
412+ struct symbol *sym = NULL;
413+
414+ const char *name = ctf_type_aname_raw (fp, tid);
415+ if (name)
416+ {
417+ sym = allocate_symbol (objfile);
418+ OBJSTAT (objfile, n_syms++);
419+
420+ SYMBOL_SET_LANGUAGE (sym, language_c, &objfile->objfile_obstack);
421+ SYMBOL_SET_NAMES (sym, xstrdup (name), strlen (name), 0, objfile);
422+ SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
423+ SYMBOL_ACLASS_INDEX (sym) = LOC_OPTIMIZED_OUT;
424+
425+ if (type != NULL)
426+ SYMBOL_TYPE (sym) = type;
427+
428+ uint32_t kind = ctf_type_kind (fp, tid);
429+ switch (kind)
430+ {
431+ case CTF_K_STRUCT:
432+ case CTF_K_UNION:
433+ case CTF_K_ENUM:
434+ SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF;
435+ SYMBOL_DOMAIN (sym) = STRUCT_DOMAIN;
436+ break;
437+ case CTF_K_FUNCTION:
438+ SYMBOL_ACLASS_INDEX (sym) = LOC_STATIC;
439+ break;
440+ case CTF_K_CONST:
441+ if (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_VOID)
442+ SYMBOL_TYPE (sym) = objfile_type (objfile)->builtin_int;
443+ break;
444+ case CTF_K_TYPEDEF:
445+ case CTF_K_INTEGER:
446+ case CTF_K_FLOAT:
447+ SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF;
448+ SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
449+ break;
450+ case CTF_K_POINTER:
451+ break;
452+ case CTF_K_VOLATILE:
453+ case CTF_K_RESTRICT:
454+ break;
455+ case CTF_K_SLICE:
456+ case CTF_K_ARRAY:
457+ case CTF_K_UNKNOWN:
458+ break;
459+ }
460+
461+ add_symbol_to_list (sym, ccp->builder->get_global_symbols ());
462+ }
463+
464+ return sym;
465+}
466+
467+/* Given a TID of kind CTF_K_INTEGER or CTF_K_FLOAT, find a representation
468+ and create the symbol for it. */
469+
470+static struct type *
471+read_base_type (ctf_context_t *ccp, ctf_id_t tid)
472+{
473+ struct objfile *of = ccp->of;
474+ ctf_file_t *fp = ccp->fp;
475+ ctf_encoding_t cet;
476+ struct type *type = NULL;
477+ const char *name;
478+ uint32_t kind;
479+
480+ if (ctf_type_encoding (fp, tid, &cet))
481+ {
482+ complaint (_("ctf_type_encoding read_base_type failed - %s"),
483+ ctf_errmsg (ctf_errno (fp)));
484+ return NULL;
485+ }
486+
487+ name = ctf_type_aname_raw (fp, tid);
488+ if (!name || (name && !strlen (name)))
489+ {
490+ name = ctf_type_aname (fp, tid);
491+ if (!name)
492+ complaint (_("ctf_type_aname read_base_type failed - %s"),
493+ ctf_errmsg (ctf_errno (fp)));
494+ }
495+
496+ kind = ctf_type_kind (fp, tid);
497+ if (kind == CTF_K_INTEGER)
498+ {
499+ uint32_t issigned, ischar, isbool;
500+ struct gdbarch *gdbarch = get_objfile_arch (of);
501+
502+ issigned = cet.cte_format & CTF_INT_SIGNED;
503+ ischar = cet.cte_format & CTF_INT_CHAR;
504+ isbool = cet.cte_format & CTF_INT_BOOL;
505+ if (ischar)
506+ type = init_character_type (of, TARGET_CHAR_BIT, !issigned, name);
507+ else if (isbool)
508+ type = init_boolean_type (of, gdbarch_int_bit (gdbarch),
509+ !issigned, name);
510+ else
511+ {
512+ int bits;
513+ if (cet.cte_bits && ((cet.cte_bits % TARGET_CHAR_BIT) == 0))
514+ bits = cet.cte_bits;
515+ else
516+ bits = gdbarch_int_bit (gdbarch);
517+ type = init_integer_type (of, bits, !issigned, name);
518+ }
519+ }
520+ else if (kind == CTF_K_FLOAT)
521+ {
522+ uint32_t isflt;
523+ isflt = !((cet.cte_format & CTF_FP_IMAGRY) == CTF_FP_IMAGRY
524+ || (cet.cte_format & CTF_FP_DIMAGRY) == CTF_FP_DIMAGRY
525+ || (cet.cte_format & CTF_FP_LDIMAGRY) == CTF_FP_LDIMAGRY);
526+ if (isflt)
527+ {
528+ type = ctf_init_float_type (of, cet.cte_bits, name, name);
529+ }
530+ else
531+ {
532+ struct type *t;
533+ t = ctf_init_float_type (of, cet.cte_bits / 2, NULL, name);
534+ type = init_complex_type (of, name, t);
535+ }
536+ }
537+ else
538+ {
539+ complaint (_("read_base_type: unsupported base kind (%d)"), kind);
540+ type = init_type (of, TYPE_CODE_ERROR, cet.cte_bits, name);
541+ }
542+
543+ if (name && strcmp (name, "char") == 0)
544+ TYPE_NOSIGN (type) = 1;
545+
546+ return set_tid_type (of, tid, type);
547+}
548+
549+static void
550+process_base_type (ctf_context_t *ccp, ctf_id_t tid)
551+{
552+ struct type *type;
553+
554+ type = read_base_type (ccp, tid);
555+ new_symbol (ccp, type, tid);
556+}
557+
558+/* Start a structure or union scope (definition) with TID and TP to create
559+ a type for the structure or union.
560+
561+ Fill in the type's name and general properties. The members will not be
562+ processed, nor a symbol table entry be done until process_structure_type
563+ (assuming the type has a name). */
564+
565+static struct type *
566+read_structure_type (ctf_context_t *ccp, ctf_id_t tid)
567+{
568+ struct objfile *of = ccp->of;
569+ ctf_file_t *fp = ccp->fp;
570+ struct type *type;
571+ const char *name;
572+ uint32_t kind;
573+
574+ type = alloc_type (of);
575+ name = ctf_type_aname_raw (fp, tid);
576+ if (name && strlen (name))
577+ TYPE_NAME (type) = name;
578+ kind = ctf_type_kind (fp, tid);
579+ if (kind == CTF_K_UNION)
580+ {
581+ TYPE_CODE (type) = TYPE_CODE_UNION;
582+ }
583+ else
584+ {
585+ TYPE_CODE (type) = TYPE_CODE_STRUCT;
586+ }
587+ TYPE_LENGTH (type) = ctf_type_size (fp, tid);
588+ set_type_align (type, ctf_type_align (fp, tid));
589+
590+ return set_tid_type (ccp->of, tid, type);
591+}
592+
593+/* Given a tid of CTF_K_STRUCT or CTF_K_UNION, process all its members
594+ and create the symbol for it. */
595+
596+static void
597+process_struct_members (ctf_context_t *ccp,
598+ ctf_id_t tid,
599+ struct type *type)
600+{
601+ ctf_file_t *fp = ccp->fp;
602+ struct field_info fi;
603+
604+ fi.cur_context.fp = fp;
605+ fi.cur_context.of = ccp->of;
606+ fi.cur_context.builder = ccp->builder;
607+ if (ctf_member_iter (fp, tid, ctf_add_member_cb, &fi) == CTF_ERR)
608+ {
609+ complaint (_("ctf_member_iter process_struct_members failed - %s"),
610+ ctf_errmsg (ctf_errno (fp)));
611+ }
612+
613+ /* Attach fields to the type. */
614+ attach_fields_to_type (&fi, type);
615+
616+ new_symbol (ccp, type, tid);
617+}
618+
619+static void
620+process_structure_type (ctf_context_t *ccp,
621+ ctf_id_t tid)
622+{
623+ struct type *type;
624+
625+ type = read_structure_type (ccp, tid);
626+ process_struct_members (ccp, tid, type);
627+}
628+
629+/* Create a function type for TID, set its return type using TP. */
630+
631+static struct type *
632+read_func_kind_type (ctf_context_t *ccp, ctf_id_t tid)
633+{
634+ struct objfile *objfile = ccp->of;
635+ ctf_file_t *fp = ccp->fp;
636+ struct type *type, *rettype;
637+ ctf_funcinfo_t cfi;
638+ const char *name;
639+
640+ type = alloc_type (objfile);
641+ name = ctf_type_aname_raw (fp, tid);
642+ if (name && strlen (name))
643+ TYPE_NAME (type) = name;
644+ TYPE_CODE (type) = TYPE_CODE_FUNC;
645+ ctf_func_type_info (fp, tid, &cfi);
646+ rettype = get_tid_type (objfile, cfi.ctc_return);
647+ TYPE_TARGET_TYPE (type) = rettype;
648+ set_type_align (type, ctf_type_align (fp, tid));
649+
650+ return set_tid_type (objfile, tid, type);
651+}
652+
653+/* Given a TID of CTF_K_ENUM with type node TP, process all the members of
654+ the enumeration, and create the symbol for the enumeration type. */
655+
656+static struct type *
657+read_enum_type (ctf_context_t *ccp,
658+ ctf_id_t tid)
659+{
660+ struct objfile *of = ccp->of;
661+ ctf_file_t *fp = ccp->fp;
662+ struct type *type, *target_type;
663+ ctf_funcinfo_t fi;
664+ const char *name;
665+
666+ type = alloc_type (of);
667+ name = ctf_type_aname_raw (fp, tid);
668+ if (name && strlen (name))
669+ TYPE_NAME (type) = name;
670+ TYPE_CODE (type) = TYPE_CODE_ENUM;
671+ TYPE_LENGTH (type) = ctf_type_size (fp, tid);
672+ ctf_func_type_info (fp, tid, &fi);
673+ target_type = get_tid_type (of, fi.ctc_return);
674+ TYPE_TARGET_TYPE (type) = target_type;
675+ set_type_align (type, ctf_type_align (fp, tid));
676+
677+ return set_tid_type (of, tid, type);
678+}
679+
680+static void
681+process_enum_type (ctf_context_t *ccp,
682+ ctf_id_t tid)
683+{
684+ ctf_file_t *fp = ccp->fp;
685+ struct type *type;
686+ struct field_info fi;
687+
688+ type = read_enum_type (ccp, tid);
689+
690+ fi.cur_context.fp = fp;
691+ fi.cur_context.of = ccp->of;
692+ fi.cur_context.builder = ccp->builder;
693+ fi.ptype = type;
694+ if (ctf_enum_iter (fp, tid, ctf_add_enum_member_cb, &fi) == CTF_ERR)
695+ {
696+ complaint (_("ctf_enum_iter process_enum_type failed - %s"),
697+ ctf_errmsg (ctf_errno (fp)));
698+ }
699+
700+ /* Attach fields to the type. */
701+ attach_fields_to_type (&fi, type);
702+
703+ new_symbol (ccp, type, tid);
704+}
705+
706+/* Add given cv-qualifiers CNST+VOLTL to the BASE_TYPE of array TID. */
707+
708+static struct type *
709+add_array_cv_type (ctf_context_t *ccp,
710+ ctf_id_t tid,
711+ struct type *base_type,
712+ int cnst,
713+ int voltl)
714+{
715+ struct type *el_type, *inner_array;
716+
717+ base_type = copy_type (base_type);
718+ inner_array = base_type;
719+
720+ while (TYPE_CODE (TYPE_TARGET_TYPE (inner_array)) == TYPE_CODE_ARRAY)
721+ {
722+ TYPE_TARGET_TYPE (inner_array) =
723+ copy_type (TYPE_TARGET_TYPE (inner_array));
724+ inner_array = TYPE_TARGET_TYPE (inner_array);
725+ }
726+
727+ el_type = TYPE_TARGET_TYPE (inner_array);
728+ cnst |= TYPE_CONST (el_type);
729+ voltl |= TYPE_VOLATILE (el_type);
730+ TYPE_TARGET_TYPE (inner_array) = make_cv_type (cnst, voltl, el_type, NULL);
731+
732+ return set_tid_type (ccp->of, tid, base_type);
733+}
734+
735+/* Read all information from a CTF_K_ARRAY TID with type node TP. */
736+
737+static struct type *
738+read_array_type (ctf_context_t *ccp, ctf_id_t tid)
739+{
740+ struct objfile *objfile = ccp->of;
741+ ctf_file_t *fp = ccp->fp;
742+ struct type *element_type, *range_type, *idx_type;
743+ struct type *type;
744+ ctf_arinfo_t ar;
745+
746+ if (ctf_array_info (fp, tid, &ar) == CTF_ERR)
747+ {
748+ complaint (_("ctf_array_info read_array_type failed - %s"),
749+ ctf_errmsg (ctf_errno (fp)));
750+ return NULL;
751+ }
752+ element_type = get_tid_type (objfile, ar.ctr_contents);
753+ if (!element_type)
754+ return NULL;
755+ idx_type = get_tid_type (objfile, ar.ctr_index);
756+ if (!idx_type)
757+ idx_type = objfile_type (objfile)->builtin_int;
758+
759+ range_type = create_static_range_type (NULL, idx_type, 0, ar.ctr_nelems-1);
760+ type = create_array_type (NULL, element_type, range_type);
761+ if (ar.ctr_nelems <= 1) /* Check if undefined upper bound. */
762+ {
763+ TYPE_HIGH_BOUND_KIND (range_type) = PROP_UNDEFINED;
764+ TYPE_LENGTH (type) = 0;
765+ TYPE_TARGET_STUB (type) = 1;
766+ }
767+ else
768+ {
769+ TYPE_LENGTH (type) = ctf_type_size (fp, tid);
770+ }
771+ set_type_align (type, ctf_type_align (fp, tid));
772+
773+ return set_tid_type (objfile, tid, type);
774+}
775+
776+/* Read TID of kind CTF_K_CONST with base type BTID. */
777+
778+static struct type *
779+read_const_type (ctf_context_t *ccp, ctf_id_t tid, ctf_id_t btid)
780+{
781+ struct objfile *objfile = ccp->of;
782+ struct type *base_type, *cv_type;
783+
784+ base_type = get_tid_type (objfile, btid);
785+ if (base_type == NULL)
786+ {
787+ base_type = read_type_record (ccp, btid);
788+ if (!base_type)
789+ {
790+ complaint (_("read_const_type: NULL base type (%ld)"), btid);
791+ base_type = objfile_type (objfile)->builtin_error;
792+ }
793+ }
794+ cv_type = make_cv_type (1, TYPE_VOLATILE (base_type), base_type, 0);
795+
796+ return set_tid_type (objfile, tid, cv_type);
797+}
798+
799+/* Read TID of kind CTF_K_VOLATILE with base type BTID. */
800+
801+static struct type *
802+read_volatile_type (ctf_context_t *ccp, ctf_id_t tid, ctf_id_t btid)
803+{
804+ struct objfile *objfile = ccp->of;
805+ ctf_file_t *fp = ccp->fp;
806+ struct type *base_type, *cv_type;
807+
808+ base_type = get_tid_type (objfile, btid);
809+ if (!base_type)
810+ {
811+ complaint (_("read_volatile_type: NULL base type (%ld)"), btid);
812+ base_type = objfile_type (objfile)->builtin_error;
813+ }
814+
815+ if (ctf_type_kind (fp, btid) == CTF_K_ARRAY)
816+ return add_array_cv_type (ccp, tid, base_type, 0, 1);
817+ cv_type = make_cv_type (TYPE_CONST (base_type), 1, base_type, 0);
818+
819+ return set_tid_type (objfile, tid, cv_type);
820+}
821+
822+/* Read TID of kind CTF_K_RESTRICT with base type BTID. */
823+
824+static struct type *
825+read_restrict_type (ctf_context_t *ccp, ctf_id_t tid, ctf_id_t btid)
826+{
827+ struct objfile *objfile = ccp->of;
828+ struct type *base_type, *cv_type;
829+
830+ base_type = get_tid_type (objfile, btid);
831+ if (base_type == NULL)
832+ {
833+ base_type = read_type_record (ccp, btid);
834+ if (!base_type)
835+ {
836+ complaint (_("read_restrict_type: NULL base type (%ld)"), btid);
837+ base_type = objfile_type (objfile)->builtin_error;
838+ }
839+ }
840+ cv_type = make_restrict_type (base_type);
841+
842+ return set_tid_type (objfile, tid, cv_type);
843+}
844+
845+/* Read TID of kind CTF_K_TYPEDEF with its NAME and base type BTID. */
846+
847+static struct type *
848+read_typedef_type (ctf_context_t *ccp, ctf_id_t tid,
849+ ctf_id_t btid, const char *name)
850+{
851+ struct objfile *objfile = ccp->of;
852+ struct type *this_type, *target_type;
853+
854+ this_type = init_type (objfile, TYPE_CODE_TYPEDEF, 0, name);
855+ set_tid_type (objfile, tid, this_type);
856+ target_type = get_tid_type (objfile, btid);
857+ if (target_type != this_type)
858+ TYPE_TARGET_TYPE (this_type) = target_type;
859+ else
860+ TYPE_TARGET_TYPE (this_type) = NULL;
861+ TYPE_TARGET_STUB (this_type) = TYPE_TARGET_TYPE (this_type)? 1 : 0;
862+
863+ return set_tid_type (objfile, tid, this_type);
864+}
865+
866+/* Read TID of kind CTF_K_POINTER with base type BTID. */
867+
868+static struct type *
869+read_pointer_type (ctf_context_t *ccp, ctf_id_t tid, ctf_id_t btid)
870+{
871+ struct objfile *of = ccp->of;
872+ struct type *target_type, *type;
873+
874+ target_type = get_tid_type (of, btid);
875+ if (!target_type)
876+ {
877+ target_type = read_type_record (ccp, btid);
878+ if (!target_type)
879+ {
880+ complaint (_("read_pointer_type: NULL target type (%ld)"), btid);
881+ target_type = objfile_type (ccp->of)->builtin_error;
882+ }
883+ }
884+
885+ type = lookup_pointer_type (target_type);
886+ set_type_align (type, ctf_type_align (ccp->fp, tid));
887+
888+ return set_tid_type (of, tid, type);
889+}
890+
891+/* Read information associated with type TID. */
892+
893+static struct type *
894+read_type_record (ctf_context_t *ccp, ctf_id_t tid)
895+{
896+ ctf_file_t *fp = ccp->fp;
897+ const char *name;
898+ uint32_t kind;
899+ struct type *type = NULL;
900+ ctf_id_t btid;
901+
902+ kind = ctf_type_kind (fp, tid);
903+ switch (kind)
904+ {
905+ case CTF_K_STRUCT:
906+ case CTF_K_UNION:
907+ type = read_structure_type (ccp, tid);
908+ break;
909+ case CTF_K_ENUM:
910+ type = read_enum_type (ccp, tid);
911+ break;
912+ case CTF_K_FUNCTION:
913+ type = read_func_kind_type (ccp, tid);
914+ break;
915+ case CTF_K_CONST:
916+ btid = ctf_type_reference (fp, tid);
917+ type = read_const_type (ccp, tid, btid);
918+ break;
919+ case CTF_K_TYPEDEF:
920+ name = ctf_type_aname_raw (fp, tid);
921+ btid = ctf_type_reference (fp, tid);
922+ type = read_typedef_type (ccp, tid, btid, name);
923+ break;
924+ case CTF_K_VOLATILE:
925+ btid = ctf_type_reference (fp, tid);
926+ type = read_volatile_type (ccp, tid, btid);
927+ break;
928+ case CTF_K_RESTRICT:
929+ btid = ctf_type_reference (fp, tid);
930+ type = read_restrict_type (ccp, tid, btid);
931+ break;
932+ case CTF_K_POINTER:
933+ btid = ctf_type_reference (fp, tid);
934+ type = read_pointer_type (ccp, tid, btid);
935+ break;
936+ case CTF_K_INTEGER:
937+ case CTF_K_FLOAT:
938+ type = read_base_type (ccp, tid);
939+ break;
940+ case CTF_K_ARRAY:
941+ type = read_array_type (ccp, tid);
942+ break;
943+ case CTF_K_UNKNOWN:
944+ break;
945+ default:
946+ break;
947+ }
948+
949+ return type;
950+}
951+
952+/* Callback to add type TID to the symbol table. */
953+
954+static int
955+ctf_add_type_cb (ctf_id_t tid, void *arg)
956+{
957+ ctf_context_t *ccp = (ctf_context_t *) arg;
958+ struct type *type;
959+ uint32_t kind;
960+
961+ /* Check if tid's type has already been defined. */
962+ type = get_tid_type (ccp->of, tid);
963+ if (type)
964+ return 0;
965+
966+ ctf_id_t btid = ctf_type_reference (ccp->fp, tid);
967+ kind = ctf_type_kind (ccp->fp, tid);
968+ switch (kind)
969+ {
970+ case CTF_K_STRUCT:
971+ case CTF_K_UNION:
972+ process_structure_type (ccp, tid);
973+ break;
974+ case CTF_K_ENUM:
975+ process_enum_type (ccp, tid);
976+ break;
977+ case CTF_K_FUNCTION:
978+ type = read_func_kind_type (ccp, tid);
979+ new_symbol (ccp, type, tid);
980+ break;
981+ case CTF_K_INTEGER:
982+ case CTF_K_FLOAT:
983+ process_base_type (ccp, tid);
984+ break;
985+ case CTF_K_TYPEDEF:
986+ new_symbol (ccp, read_type_record (ccp, tid), tid);
987+ break;
988+ case CTF_K_CONST:
989+ type = read_const_type (ccp, tid, btid);
990+ new_symbol (ccp, type, tid);
991+ break;
992+ case CTF_K_VOLATILE:
993+ type = read_volatile_type (ccp, tid, btid);
994+ new_symbol (ccp, type, tid);
995+ break;
996+ case CTF_K_RESTRICT:
997+ type = read_restrict_type (ccp, tid, btid);
998+ new_symbol (ccp, type, tid);
999+ break;
1000+ case CTF_K_POINTER:
1001+ type = read_pointer_type (ccp, tid, btid);
1002+ new_symbol (ccp, type, tid);
1003+ break;
1004+ case CTF_K_ARRAY:
1005+ type = read_array_type (ccp, tid);
1006+ new_symbol (ccp, type, tid);
1007+ break;
1008+ case CTF_K_UNKNOWN:
1009+ break;
1010+ default:
1011+ break;
1012+ }
1013+
1014+ return 0;
1015+}
1016+
1017+/* Callback to add variable NAME with TID to the symbol table. */
1018+
1019+static int
1020+ctf_add_var_cb (const char *name, ctf_id_t id, void *arg)
1021+{
1022+ ctf_context_t *ccp = (ctf_context_t *) arg;
1023+ struct symbol *sym = NULL;
1024+ struct type *type;
1025+ uint32_t kind;
1026+
1027+ type = get_tid_type (ccp->of, id);
1028+
1029+ kind = ctf_type_kind (ccp->fp, id);
1030+ switch (kind)
1031+ {
1032+ case CTF_K_FUNCTION:
1033+ if (name && !strcmp(name, "main"))
1034+ set_objfile_main_name (ccp->of, name, language_c);
1035+ break;
1036+ case CTF_K_INTEGER:
1037+ case CTF_K_FLOAT:
1038+ case CTF_K_VOLATILE:
1039+ case CTF_K_RESTRICT:
1040+ case CTF_K_TYPEDEF:
1041+ case CTF_K_CONST:
1042+ case CTF_K_POINTER:
1043+ case CTF_K_ARRAY:
1044+ if (type)
1045+ {
1046+ sym = new_symbol (ccp, type, id);
1047+ SYMBOL_SET_NAMES (sym, name, strlen (name), 0, ccp->of);
1048+ }
1049+ break;
1050+ case CTF_K_STRUCT:
1051+ case CTF_K_UNION:
1052+ case CTF_K_ENUM:
1053+ if (!type)
1054+ {
1055+ complaint (_("ctf_add_var_cb: %s has NO type (%ld)"), name, id);
1056+ type = objfile_type (ccp->of)->builtin_error;
1057+ }
1058+ sym = allocate_symbol (ccp->of);
1059+ OBJSTAT (ccp->of, n_syms++);
1060+ SYMBOL_TYPE (sym) = type;
1061+ SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
1062+ SYMBOL_ACLASS_INDEX (sym) = LOC_OPTIMIZED_OUT;
1063+ SYMBOL_SET_NAMES (sym, name, strlen (name), 0, ccp->of);
1064+ add_symbol_to_list (sym, ccp->builder->get_global_symbols ());
1065+ break;
1066+ default:
1067+ complaint (_("ctf_add_var_cb: kind unsupported (%d)"), kind);
1068+ break;
1069+ }
1070+
1071+ if (sym)
1072+ {
1073+ set_symbol_address (ccp->of, sym, name);
1074+ }
1075+
1076+ return 0;
1077+}
1078+
1079+/* Add an ELF STT_OBJ symbol with index IDX to the symbol table. */
1080+
1081+struct symbol *
1082+add_stt_obj (ctf_context_t *ccp, unsigned long idx)
1083+{
1084+ const char *name;
1085+ struct symbol *sym;
1086+ struct type *type;
1087+ ctf_id_t tid;
1088+
1089+ if ((tid = ctf_lookup_by_symbol (ccp->fp, idx)) == CTF_ERR)
1090+ return NULL;
1091+
1092+ type = get_tid_type (ccp->of, tid);
1093+ if (type == NULL)
1094+ return NULL;
1095+
1096+ name = ctf_type_aname_raw (ccp->fp, idx);
1097+ if (name == NULL)
1098+ return NULL;
1099+ sym = new_symbol (ccp, type, tid);
1100+ SYMBOL_SET_NAMES (sym, name, strlen (name), 0, ccp->of);
1101+
1102+ return sym;
1103+}
1104+
1105+/* Add an ELF STT_FUNC symbol with index IDX to the symbol table. */
1106+
1107+struct symbol *
1108+add_stt_func (ctf_context_t *ccp, unsigned long idx)
1109+{
1110+ struct type *ftype, *atyp, *rettyp;
1111+ const char *name;
1112+ struct symbol *sym;
1113+ ctf_funcinfo_t finfo;
1114+ ctf_id_t argv[32];
1115+ uint32_t argc;
1116+ ctf_id_t tid;
1117+ struct type *void_type = objfile_type (ccp->of)->builtin_void;
1118+
1119+ if (ctf_func_info (ccp->fp, idx, &finfo) == CTF_ERR)
1120+ return NULL;
1121+
1122+ argc = finfo.ctc_argc;
1123+ if (ctf_func_args (ccp->fp, idx, argc, argv) == CTF_ERR)
1124+ return NULL;
1125+
1126+ name = ctf_type_aname_raw (ccp->fp, idx);
1127+ if (name == NULL)
1128+ return NULL;
1129+ tid = ctf_lookup_by_symbol (ccp->fp, idx);
1130+ ftype = get_tid_type (ccp->of, tid);
1131+ if (finfo.ctc_flags & CTF_FUNC_VARARG)
1132+ TYPE_VARARGS (ftype) = 1;
1133+ TYPE_NFIELDS (ftype) = argc;
1134+ /* If argc is 0, it has a "void" type. */
1135+ if (argc)
1136+ TYPE_FIELDS (ftype) = (struct field *)
1137+ TYPE_ZALLOC (ftype, argc * sizeof (struct field));
1138+
1139+ /* TYPE_FIELD_TYPE must never be NULL. Fill it with void_type, if failed
1140+ to find the argument type. */
1141+ for (int iparam = 0; iparam < argc; iparam++)
1142+ {
1143+ atyp = get_tid_type (ccp->of, argv[iparam]);
1144+ if (atyp)
1145+ TYPE_FIELD_TYPE (ftype, iparam) = atyp;
1146+ else
1147+ TYPE_FIELD_TYPE (ftype, iparam) = void_type;
1148+ }
1149+
1150+ sym = new_symbol (ccp, ftype, tid);
1151+ rettyp = get_tid_type (ccp->of, finfo.ctc_return);
1152+ if (rettyp != NULL)
1153+ SYMBOL_TYPE (sym) = rettyp;
1154+ else
1155+ SYMBOL_TYPE (sym) = void_type;
1156+ SYMBOL_SET_NAMES (sym, name, strlen (name), 0, ccp->of);
1157+
1158+ return sym;
1159+}
1160+
1161+/* Get text segment base for OBJFILE, TSIZE contains the segment size. */
1162+
1163+static CORE_ADDR
1164+get_of_text_range (struct objfile *of, int *tsize)
1165+{
1166+ CORE_ADDR text_base;
1167+ bfd *abfd = of->obfd;
1168+ const asection *codes;
1169+
1170+ codes = bfd_get_section_by_name (abfd, ".text");
1171+ if (!codes)
1172+ {
1173+ text_base = 0;
1174+ *tsize = 0;
1175+ }
1176+ else
1177+ {
1178+ text_base = bfd_section_vma (codes);
1179+ *tsize = codes->size;
1180+ }
1181+
1182+ return text_base;
1183+}
1184+
1185+/* Start a symtab for OBJFILE in CTF format. */
1186+
1187+static void
1188+ctf_start_symtab (struct partial_symtab *pst,
1189+ struct objfile *of, CORE_ADDR text_offset)
1190+{
1191+ ctf_context_t *ccp;
1192+
1193+ ccp = (ctf_context_t *) pst->read_symtab_private;
1194+ ccp->builder = new struct buildsym_compunit
1195+ (of, of->original_name, NULL,
1196+ language_c, text_offset);
1197+ ccp->builder->record_debugformat ("ctf");
1198+}
1199+
1200+/* Finish reading symbol/type definitions in CTF format.
1201+ END_ADDR is the end address of the file's text. SECTION is
1202+ the .text section number. */
1203+
1204+static struct compunit_symtab *
1205+ctf_end_symtab (struct partial_symtab *pst,
1206+ CORE_ADDR end_addr, int section)
1207+{
1208+ ctf_context_t *ccp;
1209+
1210+ ccp = (ctf_context_t *) pst->read_symtab_private;
1211+ struct compunit_symtab *result
1212+ = ccp->builder->end_symtab (end_addr, section);
1213+ delete ccp->builder;
1214+ ccp->builder = NULL;
1215+ return result;
1216+}
1217+
1218+/* Read in full symbols for PST, and anything it depends on. */
1219+
1220+static void
1221+psymtab_to_symtab (struct partial_symtab *pst)
1222+{
1223+ struct symbol *sym;
1224+ ctf_context_t *ccp;
1225+
1226+ if (pst->readin == 1)
1227+ return;
1228+
1229+ ccp = (ctf_context_t *) pst->read_symtab_private;
1230+
1231+ /* Iterate over entries in data types section. */
1232+ if (ctf_type_iter (ccp->fp, ctf_add_type_cb, ccp) == CTF_ERR)
1233+ {
1234+ complaint (_("ctf_type_iter psymtab_to_symtab failed - %s"),
1235+ ctf_errmsg (ctf_errno (ccp->fp)));
1236+ }
1237+
1238+
1239+ /* Iterate over entries in variable info section. */
1240+ if (ctf_variable_iter (ccp->fp, ctf_add_var_cb, ccp) == CTF_ERR)
1241+ {
1242+ complaint (_("ctf_variable_iter psymtab_to_symtab failed - %s"),
1243+ ctf_errmsg (ctf_errno (ccp->fp)));
1244+ }
1245+
1246+ /* Add entries in data objects and function info sections. */
1247+ for (unsigned long i = 0; ; i++)
1248+ {
1249+ sym = add_stt_obj (ccp, i);
1250+ if (!sym)
1251+ {
1252+ if (ctf_errno (ccp->fp) == EINVAL
1253+ || ctf_errno (ccp->fp) == ECTF_NOSYMTAB)
1254+ break;
1255+ sym = add_stt_func (ccp, i);
1256+ }
1257+ if (!sym)
1258+ continue;
1259+
1260+ set_symbol_address (ccp->of, sym, SYMBOL_LINKAGE_NAME (sym));
1261+ }
1262+
1263+ pst->readin = 1;
1264+}
1265+
1266+/* Expand partial symbol table PST into a full symbol table.
1267+ PST is not NULL. */
1268+
1269+static void
1270+ctf_read_symtab (struct partial_symtab *pst,
1271+ struct objfile *objfile)
1272+{
1273+ if (pst->readin)
1274+ {
1275+ warning (_("bug: psymtab for %s is already read in."),
1276+ pst->filename);
1277+ }
1278+ else
1279+ {
1280+ if (info_verbose)
1281+ {
1282+ printf_filtered (_("Reading in CTF data for %s..."),
1283+ pst->filename);
1284+ gdb_flush (gdb_stdout);
1285+ }
1286+
1287+ /* Start a symtab. */
1288+ CORE_ADDR text_offset; /* Start of text segment. */
1289+ int tsize;
1290+
1291+ text_offset = get_of_text_range (objfile, &tsize);
1292+ ctf_start_symtab (pst, objfile, text_offset);
1293+ psymtab_to_symtab (pst);
1294+
1295+ pst->set_text_low (text_offset);
1296+ pst->set_text_high (text_offset+tsize);
1297+ pst->compunit_symtab = ctf_end_symtab (pst, text_offset + tsize,
1298+ SECT_OFF_TEXT (objfile));
1299+
1300+ /* Finish up the debug error message. */
1301+ if (info_verbose)
1302+ printf_filtered (_("done.\n"));
1303+ }
1304+}
1305+
1306+/* Cleanup function for the ctf_file_key data. */
1307+
1308+static void
1309+ctf_close_objfile (struct objfile *of, void *datum)
1310+{
1311+ ctf_file_t *fp = static_cast<ctf_file_t *> (datum);
1312+ ctf_archive_t *arc = ctf_get_arc (fp);
1313+ ctf_file_close (fp);
1314+ ctf_close (arc);
1315+}
1316+
1317+/* Allocate a new partial_symtab NAME. */
1318+/* Each source file that has not been fully read in is represented by
1319+ a partial_symtab. This contains the information on where in the
1320+ executable the debugging symbols for a specific file are, and a
1321+ list of names of global symbols which are located in this file.
1322+ They are all chained on partial symtab lists.
1323+
1324+ Even after the source file has been read into a symtab, the
1325+ partial_symtab remains around. They are allocated on an obstack,
1326+ objfile_obstack. */
1327+
1328+static struct partial_symtab *
1329+create_partial_symtab (const char *name,
1330+ ctf_file_t *cfp,
1331+ struct objfile *objfile)
1332+{
1333+ struct partial_symtab *pst;
1334+ static ctf_context_t ccx;
1335+
1336+ pst = start_psymtab_common (objfile, name, 0);
1337+
1338+ ccx.fp = cfp;
1339+ ccx.of = objfile;
1340+ pst->read_symtab_private = (void *)&ccx;
1341+ pst->read_symtab = ctf_read_symtab;
1342+
1343+ return pst;
1344+}
1345+
1346+/* Callback to add type TID to partial symbol table. */
1347+
1348+static int
1349+ctf_psymtab_type_cb (ctf_id_t tid, void *arg)
1350+{
1351+ ctf_context_t *ccp;
1352+ const char *name;
1353+ uint32_t kind;
1354+ short section = -1;
1355+
1356+ ccp = (ctf_context_t *)arg;
1357+ name = ctf_type_aname_raw (ccp->fp, tid);
1358+ if (!name || (name && !strlen (name)))
1359+ return 0;
1360+
1361+ domain_enum domain = UNDEF_DOMAIN;
1362+ enum address_class aclass = LOC_UNDEF;
1363+ kind = ctf_type_kind (ccp->fp, tid);
1364+ switch (kind)
1365+ {
1366+ case CTF_K_STRUCT:
1367+ case CTF_K_UNION:
1368+ case CTF_K_ENUM:
1369+ domain = STRUCT_DOMAIN;
1370+ aclass = LOC_TYPEDEF;
1371+ break;
1372+ case CTF_K_FUNCTION:
1373+ case CTF_K_FORWARD:
1374+ domain = VAR_DOMAIN;
1375+ aclass = LOC_STATIC;
1376+ section = SECT_OFF_TEXT (ccp->of);
1377+ break;
1378+ case CTF_K_CONST:
1379+ domain = VAR_DOMAIN;
1380+ aclass = LOC_STATIC;
1381+ break;
1382+ case CTF_K_TYPEDEF:
1383+ case CTF_K_POINTER:
1384+ case CTF_K_VOLATILE:
1385+ case CTF_K_RESTRICT:
1386+ domain = VAR_DOMAIN;
1387+ aclass = LOC_TYPEDEF;
1388+ break;
1389+ case CTF_K_INTEGER:
1390+ case CTF_K_FLOAT:
1391+ domain = VAR_DOMAIN;
1392+ aclass = LOC_TYPEDEF;
1393+ break;
1394+ case CTF_K_ARRAY:
1395+ case CTF_K_UNKNOWN:
1396+ return 0;
1397+ }
1398+
1399+ add_psymbol_to_list (name, strlen (name), 1,
1400+ domain, aclass, section,
1401+ psymbol_placement::GLOBAL,
1402+ 0, language_c, ccp->of);
1403+
1404+ return 0;
1405+}
1406+
1407+/* Callback to add variable NAME with ID to partial symbol table. */
1408+
1409+static int
1410+ctf_psymtab_var_cb (const char *name, ctf_id_t id, void *arg)
1411+{
1412+ ctf_context_t *ccp = (ctf_context_t *) arg;
1413+
1414+ add_psymbol_to_list (name, strlen (name), 1,
1415+ VAR_DOMAIN, LOC_STATIC, -1,
1416+ psymbol_placement::GLOBAL,
1417+ 0, language_c, ccp->of);
1418+ return 0;
1419+}
1420+
1421+/* Setup partial_symtab's describing each source file for which
1422+ debugging information is available. */
1423+
1424+static void
1425+scan_partial_symbols (ctf_file_t *cfp, struct objfile *of)
1426+{
1427+ ctf_context_t ccx;
1428+ bfd *abfd = of->obfd;
1429+ const char *name = bfd_get_filename (abfd);
1430+ struct partial_symtab *pst = create_partial_symtab (name, cfp, of);
1431+
1432+ ccx.fp = cfp;
1433+ ccx.of = of;
1434+ if (ctf_type_iter (cfp, ctf_psymtab_type_cb, &ccx) == CTF_ERR)
1435+ {
1436+ complaint (_("ctf_type_iter scan_partial_symbols failed - %s"),
1437+ ctf_errmsg (ctf_errno (cfp)));
1438+ }
1439+
1440+ if (ctf_variable_iter (cfp, ctf_psymtab_var_cb, &ccx) == CTF_ERR)
1441+ {
1442+ complaint (_("ctf_variable_iter scan_partial_symbols failed - %s"),
1443+ ctf_errmsg (ctf_errno (cfp)));
1444+ }
1445+
1446+ /* Scan CTF object and function sections which correspond to each
1447+ STT_FUNC or STT_OBJECT entry in the symbol table,
1448+ pick up what init_symtab has done. */
1449+ for (unsigned long idx = 0; ; idx++)
1450+ {
1451+ ctf_id_t tid;
1452+ if ((tid = ctf_lookup_by_symbol (cfp, idx)) == CTF_ERR)
1453+ {
1454+ if (ctf_errno (cfp) == EINVAL
1455+ || ctf_errno (cfp) == ECTF_NOSYMTAB)
1456+ // case ECTF_SYMRANGE:
1457+ break;
1458+ else
1459+ continue;
1460+ }
1461+ const char *tname = ctf_type_aname_raw (cfp, tid);
1462+ uint32_t kind = ctf_type_kind (cfp, tid);
1463+ address_class aclass;
1464+ domain_enum tdomain;
1465+ switch (kind)
1466+ {
1467+ case CTF_K_STRUCT:
1468+ case CTF_K_UNION:
1469+ case CTF_K_ENUM:
1470+ tdomain = STRUCT_DOMAIN;
1471+ break;
1472+ default:
1473+ tdomain = VAR_DOMAIN;
1474+ break;
1475+ }
1476+
1477+ if (kind == CTF_K_FUNCTION)
1478+ aclass = LOC_STATIC;
1479+ else if (kind == CTF_K_CONST)
1480+ aclass = LOC_CONST;
1481+ else
1482+ aclass = LOC_TYPEDEF;
1483+
1484+ add_psymbol_to_list (tname, strlen (name), 1,
1485+ tdomain, aclass, -1,
1486+ psymbol_placement::STATIC,
1487+ 0, language_c, of);
1488+ }
1489+
1490+ end_psymtab_common (of, pst);
1491+}
1492+
1493+/* Read CTF debugging information from a BFD section. This is
1494+ called from elfread.c. It does a quick pass through the
1495+ .ctf section to set up the partial symbol table. */
1496+
1497+void
1498+elfctf_build_psymtabs (struct objfile *of)
1499+{
1500+ bfd *abfd = of->obfd;
1501+ int err;
1502+
1503+ ctf_archive_t *arc = ctf_bfdopen (abfd, &err);
1504+ if (!arc)
1505+ error (_("ctf_bfdopen failed on %s - %s"),
1506+ bfd_get_filename (abfd), ctf_errmsg (err));
1507+
1508+ ctf_file_t *fp = ctf_arc_open_by_name (arc, NULL, &err);
1509+ if (!fp)
1510+ error (_("ctf_arc_open_by_name failed on %s - %s"),
1511+ bfd_get_filename (abfd), ctf_errmsg (err));
1512+ set_objfile_data (of, ctf_file_key, fp);
1513+
1514+ scan_partial_symbols (fp, of);
1515+}
1516+
1517+void
1518+_initialize_ctfread (void)
1519+{
1520+ ctf_file_key
1521+ = register_objfile_data_with_cleanup (NULL, ctf_close_objfile);
1522+}
--- /dev/null
+++ b/gdb/ctfread.h
@@ -0,0 +1,25 @@
1+/* CTF debugging format support for GDB.
2+
3+ Copyright (C) 2019 Free Software Foundation, Inc.
4+
5+ This file is part of GDB.
6+
7+ This program is free software; you can redistribute it and/or modify
8+ it under the terms of the GNU General Public License as published by
9+ the Free Software Foundation; either version 3 of the License, or
10+ (at your option) any later version.
11+
12+ This program is distributed in the hope that it will be useful,
13+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ GNU General Public License for more details.
16+
17+ You should have received a copy of the GNU General Public License
18+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
19+
20+#ifndef CTFREAD_H
21+#define CTFREAD_H
22+
23+extern void elfctf_build_psymtabs (struct objfile *objfile);
24+
25+#endif /* CTFREAD_H */
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -47,6 +47,7 @@
4747 #include "location.h"
4848 #include "auxv.h"
4949 #include "mdebugread.h"
50+#include "ctfread.h"
5051
5152 /* Forward declarations. */
5253 extern const struct sym_fns elf_sym_fns_gdb_index;
@@ -61,6 +62,7 @@ struct elfinfo
6162 {
6263 asection *stabsect; /* Section pointer for .stab section */
6364 asection *mdebugsect; /* Section pointer for .mdebug section */
65+ asection *ctfsect; /* Section pointer for .ctf section */
6466 };
6567
6668 /* Type for per-BFD data. */
@@ -188,6 +190,10 @@ elf_locate_sections (bfd *ignore_abfd, asection *sectp, void *eip)
188190 {
189191 ei->mdebugsect = sectp;
190192 }
193+ else if (strcmp (sectp->name, ".ctf") == 0)
194+ {
195+ ei->ctfsect = sectp;
196+ }
191197 }
192198
193199 static struct minimal_symbol *
@@ -1053,7 +1059,8 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags,
10531059 go away once all types of symbols are in the per-BFD object. */
10541060 if (objfile->per_bfd->minsyms_read
10551061 && ei->stabsect == NULL
1056- && ei->mdebugsect == NULL)
1062+ && ei->mdebugsect == NULL
1063+ && ei->ctfsect == NULL)
10571064 {
10581065 if (symtab_create_debug)
10591066 fprintf_unfiltered (gdb_stdlog,
@@ -1194,6 +1201,7 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
11941201 {
11951202 bfd *abfd = objfile->obfd;
11961203 struct elfinfo ei;
1204+ bool has_dwarf2 = true;
11971205
11981206 memset ((char *) &ei, 0, sizeof (ei));
11991207 if (!(objfile->flags & OBJF_READNEVER))
@@ -1296,6 +1304,14 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
12961304 symbol_file_add_separate (debug_bfd.get (), debugfile.c_str (),
12971305 symfile_flags, objfile);
12981306 }
1307+ else
1308+ has_dwarf2 = false;
1309+ }
1310+
1311+ /* Read the CTF section only if there is no DWARF info. */
1312+ if (!has_dwarf2 && ei.ctfsect)
1313+ {
1314+ elfctf_build_psymtabs (objfile);
12991315 }
13001316 }
13011317
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -46,7 +46,6 @@
4646 #include "osdata.h"
4747 #include "gdbsupport/gdb_splay_tree.h"
4848 #include "tracepoint.h"
49-#include "ctf.h"
5049 #include "ada-lang.h"
5150 #include "linespec.h"
5251 #include "extension.h"
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,13 @@
1+2019-09-24 Weimin Pan <weimin.pan@oracle.com>
2+
3+ * gdb.base/ctf-whatis.exp: New file.
4+ * gdb.base/ctf-whatis.c: New file.
5+ * gdb.base/ctf-ptype.exp: New file.
6+ * gdb.base/ctf-ptype.c: New file.
7+ * gdb.base/ctf-constvars.exp: New file.
8+ * gdb.base/ctf-constvars.c: New file.
9+ * gdb.base/ctf-cvexpr.exp: New file.
10+
111 2019-09-22 Tom de Vries <tdevries@suse.de>
212
313 * gdb.base/restore.exp: Allow register variables to be optimized out at
--- /dev/null
+++ b/gdb/testsuite/gdb.base/ctf-constvars.c
@@ -0,0 +1,116 @@
1+/* This test program is part of GDB, the GNU debugger.
2+
3+ Copyright 2019 Free Software Foundation, Inc.
4+
5+ This program is free software; you can redistribute it and/or modify
6+ it under the terms of the GNU General Public License as published by
7+ the Free Software Foundation; either version 3 of the License, or
8+ (at your option) any later version.
9+
10+ This program is distributed in the hope that it will be useful,
11+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+ GNU General Public License for more details.
14+
15+ You should have received a copy of the GNU General Public License
16+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
17+
18+const char laconic = 'A';
19+const char *const lewd=&laconic;
20+
21+/* volatile variables */
22+
23+volatile char vox = 'B';
24+volatile unsigned char victuals = 'C';
25+volatile short vixen = 200;
26+volatile unsigned short vitriol = 300;
27+volatile long vellum = 1000;
28+volatile unsigned long valve = 2000;
29+volatile float vacuity = 3.0;
30+volatile double vertigo = 10;
31+
32+/* pointers to volatile variables */
33+
34+volatile char * vampire = &vox;
35+volatile unsigned char * viper = &victuals;
36+volatile short * vigour = &vixen;
37+volatile unsigned short * vapour = &vitriol;
38+volatile long * ventricle = &vellum;
39+volatile unsigned long * vigintillion = &valve;
40+volatile float * vocation = &vacuity;
41+volatile double * veracity = &vertigo;
42+
43+/* volatile pointers to volatile variables */
44+
45+volatile char * volatile vapidity = &vox;
46+volatile unsigned char * volatile velocity = &victuals;
47+volatile short * volatile veneer = &vixen;
48+volatile unsigned short * volatile video = &vitriol;
49+volatile long * volatile vacuum = &vellum;
50+volatile unsigned long * volatile veniality = &valve;
51+volatile float * volatile vitality = &vacuity;
52+volatile double * volatile voracity = &vertigo;
53+
54+/* volatile arrays */
55+
56+volatile char violent[2];
57+volatile unsigned char violet[2];
58+volatile short vips[2];
59+volatile unsigned short virgen[2];
60+volatile long vulgar[2];
61+volatile unsigned long vulture[2];
62+volatile float vilify[2];
63+volatile double villar[2];
64+
65+/* const volatile vars */
66+
67+const volatile char victor = 'Y';
68+
69+/* pointers to const volatiles */
70+
71+const volatile char * victory = &victor;
72+
73+/* const pointers to const volatile vars */
74+
75+const volatile char * const cavern = &victor;
76+
77+/* volatile pointers to const vars */
78+
79+const char * volatile caveat = &laconic;
80+const unsigned char * volatile covenant;
81+
82+/* volatile pointers to const volatile vars */
83+
84+const volatile char * volatile vizier = &victor;
85+const volatile unsigned char * volatile vanadium;
86+
87+/* const volatile pointers */
88+
89+char * const volatile vane;
90+unsigned char * const volatile veldt;
91+
92+/* const volatile pointers to const vars */
93+
94+const char * const volatile cove;
95+const unsigned char * const volatile cavity;
96+
97+/* const volatile pointers to volatile vars */
98+
99+volatile char * const volatile vagus;
100+volatile unsigned char * const volatile vagrancy;
101+
102+/* const volatile pointers to const volatile */
103+
104+const volatile char * const volatile vagary;
105+const volatile unsigned char * const volatile vendor;
106+
107+/* const volatile arrays */
108+
109+const volatile char vindictive[2];
110+const volatile unsigned char vegetation[2];
111+
112+int
113+main (void)
114+{
115+ return 0;
116+}
--- /dev/null
+++ b/gdb/testsuite/gdb.base/ctf-constvars.exp
@@ -0,0 +1,114 @@
1+# Copyright 2019 Free Software Foundation, Inc.
2+
3+# This program is free software; you can redistribute it and/or modify
4+# it under the terms of the GNU General Public License as published by
5+# the Free Software Foundation; either version 3 of the License, or
6+# (at your option) any later version.
7+#
8+# This program is distributed in the hope that it will be useful,
9+# but WITHOUT ANY WARRANTY; without even the implied warranty of
10+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+# GNU General Public License for more details.
12+#
13+# You should have received a copy of the GNU General Public License
14+# along with this program. If not, see <http://www.gnu.org/licenses/>. */
15+
16+# This file is a subset of constvars.exp, written by
17+# Elena Zannoni (elz@apollo.hp.com)
18+#
19+# This file is part of the gdb testsuite
20+#
21+# tests for const variables
22+# const pointers to vars
23+# pointers to const variables
24+# const pointers to const vars
25+# with mixed types
26+
27+#
28+# test running programs
29+#
30+# -gt generates full-fledged CTF.
31+
32+standard_testfile .c
33+set opts "additional_flags=-gt"
34+
35+if { [prepare_for_testing "failed to prepare" ${testfile} \
36+ [list $srcfile] [list $opts nowarnings]] } {
37+ return 0
38+}
39+
40+#
41+# set it up at a breakpoint so we can play with the variable values
42+#
43+if ![runto_main] then {
44+ perror "couldn't run to breakpoint"
45+ continue
46+}
47+
48+# test vars and pointers
49+
50+proc do_constvar_tests {} {
51+ gdb_test "print vox" " = 66 'B'"
52+ gdb_test "ptype vox" "type = volatile char"
53+ gdb_test "print victuals" " = 67 'C'"
54+ gdb_test "ptype victuals" "type = volatile unsigned char"
55+ gdb_test "print vixen" " = 200"
56+ gdb_test "ptype vixen" "type = volatile short.*"
57+ gdb_test "print vitriol" " = 300"
58+ gdb_test "ptype vitriol" "type = volatile (unsigned short|short unsigned)( int)?"
59+ gdb_test "print vellum" " = 1000"
60+ gdb_test "ptype vellum" "type = volatile long.*"
61+ gdb_test "print valve" " = 2000"
62+ gdb_test "ptype valve" "type = volatile (unsigned long|long unsigned)( int)?"
63+ gdb_test "print vacuity" " = 3"
64+ gdb_test "ptype vacuity" "type = volatile float"
65+ gdb_test "print vertigo" " = 10"
66+ gdb_test "ptype vertigo" "type = volatile double"
67+ gdb_test "print laconic" " = 65 'A'"
68+
69+ gdb_test "ptype vampire" "type = volatile char.*"
70+ gdb_test "ptype viper" "type = volatile unsigned char.*"
71+ gdb_test "ptype vigour" "type = volatile short.*"
72+ gdb_test "ptype vapour" "type = volatile (unsigned short|short unsigned)( int)?.*"
73+ gdb_test "ptype ventricle" "type = volatile long.*"
74+ gdb_test "ptype vigintillion" "type = volatile (unsigned long|long unsigned)( int)?.*"
75+ gdb_test "ptype vocation" "type = volatile float.*"
76+ gdb_test "ptype veracity" "type = volatile double.*"
77+
78+ gdb_test "ptype vapidity" "type = volatile char.* volatile"
79+ gdb_test "ptype velocity" "type = volatile unsigned char.* volatile"
80+ gdb_test "ptype veneer" "type = volatile short.* volatile"
81+ gdb_test "ptype video" "type = volatile (unsigned short|short unsigned)( int)?.* volatile"
82+ gdb_test "ptype vacuum" "type = volatile long.* volatile"
83+ gdb_test "ptype veniality" "type = volatile (unsigned long|long unsigned)( int)?.* volatile"
84+ gdb_test "ptype vitality" "type = volatile float.* volatile"
85+ gdb_test "ptype voracity" "type = volatile double.* volatile"
86+
87+ gdb_test "ptype violent" "type = volatile char \\\[2\\\]"
88+ gdb_test "ptype violet" "type = volatile unsigned char \\\[2\\\]"
89+ gdb_test "ptype vips" "type = volatile short.* \\\[2\\\]"
90+ gdb_test "ptype virgen" "type = volatile unsigned short.* \\\[2\\\]"
91+ gdb_test "ptype vulgar" "type = volatile long.* \\\[2\\\]"
92+ gdb_test "ptype vulture" "type = volatile (unsigned long|long unsigned)( int)? \\\[2\\\]"
93+ gdb_test "ptype vilify" "type = volatile float \\\[2\\\]"
94+ gdb_test "ptype villar" "type = volatile double \\\[2\\\]"
95+
96+ gdb_test "print victor" " = 89 'Y'"
97+ gdb_test "ptype victor" "type = const volatile char"
98+ gdb_test "ptype victory" "type = const volatile char.*"
99+ gdb_test "ptype cavern" "type = const volatile char.* const"
100+ gdb_test "ptype caveat" "type = const char.* volatile"
101+ gdb_test "ptype covenant" "type = const unsigned char.* volatile"
102+ gdb_test "ptype vanadium" "type = const volatile unsigned char.* volatile"
103+
104+ gdb_test "ptype cove" "type = const char.* const volatile"
105+ gdb_test "ptype cavity" "type = const unsigned char.* const volatile"
106+ gdb_test "ptype vagus" "type = volatile char.* const volatile"
107+ gdb_test "ptype vagrancy" "type = volatile unsigned char.* const volatile"
108+ gdb_test "ptype vagary" "type = const volatile char.* const volatile"
109+ gdb_test "ptype vendor" "type = const volatile unsigned char.* const volatile"
110+ gdb_test "ptype vindictive" "type = const volatile char \\\[2\\\]"
111+ gdb_test "ptype vegetation" "type = const volatile unsigned char \\\[2\\\]"
112+}
113+
114+do_constvar_tests
--- /dev/null
+++ b/gdb/testsuite/gdb.base/ctf-cvexpr.exp
@@ -0,0 +1,495 @@
1+# Copyright (C) 2019 Free Software Foundation, Inc.
2+
3+# This program is free software; you can redistribute it and/or modify
4+# it under the terms of the GNU General Public License as published by
5+# the Free Software Foundation; either version 3 of the License, or
6+# (at your option) any later version.
7+#
8+# This program is distributed in the hope that it will be useful,
9+# but WITHOUT ANY WARRANTY; without even the implied warranty of
10+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+# GNU General Public License for more details.
12+#
13+# You should have received a copy of the GNU General Public License
14+# along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
16+# This file is a subset of cvexpr.exp written by
17+# Michael Snyder, Red Hat, Inc., 9/20/2001
18+
19+# This file is part of the gdb testsuite
20+# Tests for type expressions using const and volatile keywords.
21+
22+#
23+# test running programs
24+#
25+# -gt generates full-fledged CTF.
26+
27+standard_testfile cvexpr.c
28+set opts "additional_flags=-gt"
29+
30+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
31+ untested "failed to compile"
32+ return -1
33+}
34+
35+clean_restart ${binfile}
36+
37+gdb_test_no_output "set print sevenbit-strings"
38+gdb_test_no_output "set print address off"
39+gdb_test_no_output "set width 0"
40+
41+set ws "\[ \t\]*"
42+
43+#
44+# Test casting a scalar to const
45+#
46+
47+gdb_test "whatis (const char) v_char" \
48+ "type = const char" \
49+ "(const char)"
50+gdb_test "whatis (const signed char) v_signed_char" \
51+ "type = const signed char" \
52+ "(const signed char)"
53+gdb_test "whatis (const unsigned char) v_unsigned_char" \
54+ "type = const (unsigned char|char)" \
55+ "(const unsigned char)"
56+gdb_test "whatis (const short) v_short" \
57+ "type = const (short|short int)" \
58+ "(const short)"
59+gdb_test "whatis (const signed short) v_signed_short" \
60+ "type = const (short|short int|signed short|signed short int)" \
61+ "(const signed short)"
62+gdb_test "whatis (const unsigned short) v_unsigned_short" \
63+ "type = const (unsigned short|short unsigned int)" \
64+ "(const unsigned short)"
65+gdb_test "whatis (const int) v_int" \
66+ "type = const int" \
67+ "(const int)"
68+gdb_test "whatis (const signed int) v_signed_int" \
69+ "type = const (signed int|int)" \
70+ "(const signed int)"
71+gdb_test "whatis (const unsigned int) v_unsigned_int" \
72+ "type = const unsigned int" \
73+ "(const unsigned int)"
74+gdb_test "whatis (const long) v_long" \
75+ "type = const (long|long int)" \
76+ "(const long)"
77+gdb_test "whatis (const signed long) v_signed_long" \
78+ "type = const (signed |)long( int|)" \
79+ "(const signed long)"
80+gdb_test "whatis (const unsigned long) v_unsigned_long" \
81+ "type = const (unsigned long|long unsigned int)" \
82+ "(const unsigned long)"
83+gdb_test "whatis (const long long) v_long_long" \
84+ "type = const long long( int|)" \
85+ "(const long long)"
86+gdb_test "whatis (const signed long long) v_signed_long_long" \
87+ "type = const (signed |)long long( int|)" \
88+ "(const signed long long)"
89+gdb_test "whatis (const unsigned long long) v_unsigned_long_long" \
90+ "type = const (unsigned long long|long long unsigned int)" \
91+ "(const unsigned long long)"
92+gdb_test "whatis (const float) v_float" \
93+ "type = const float" \
94+ "(const float)"
95+gdb_test "whatis (const double) v_double" \
96+ "type = const double" \
97+ "(const double)"
98+
99+#
100+# Test casting a scalar to volatile
101+#
102+
103+gdb_test "whatis (volatile char) v_char" \
104+ "type = volatile char" \
105+ "(volatile char)"
106+gdb_test "whatis (volatile signed char) v_signed_char" \
107+ "type = volatile signed char" \
108+ "(volatile signed char)"
109+gdb_test "whatis (volatile unsigned char) v_unsigned_char" \
110+ "type = volatile (unsigned char|char)" \
111+ "(volatile unsigned char)"
112+gdb_test "whatis (volatile short) v_short" \
113+ "type = volatile (short|short int)" \
114+ "(volatile short)"
115+gdb_test "whatis (volatile signed short) v_signed_short" \
116+ "type = volatile (short|short int|signed short|signed short int)" \
117+ "(volatile signed short)"
118+gdb_test "whatis (volatile unsigned short) v_unsigned_short" \
119+ "type = volatile (unsigned short|short unsigned int)" \
120+ "(volatile unsigned short)"
121+gdb_test "whatis (volatile int) v_int" \
122+ "type = volatile int" \
123+ "(volatile int)"
124+gdb_test "whatis (volatile signed int) v_signed_int" \
125+ "type = volatile (signed int|int)" \
126+ "(volatile signed int)"
127+gdb_test "whatis (volatile unsigned int) v_unsigned_int" \
128+ "type = volatile unsigned int" \
129+ "(volatile unsigned int)"
130+gdb_test "whatis (volatile long) v_long" \
131+ "type = volatile (long|long int)" \
132+ "(volatile long)"
133+gdb_test "whatis (volatile signed long) v_signed_long" \
134+ "type = volatile (signed |)long( int|)" \
135+ "(volatile signed long)"
136+gdb_test "whatis (volatile unsigned long) v_unsigned_long" \
137+ "type = volatile (unsigned long|long unsigned int)" \
138+ "(volatile unsigned long)"
139+gdb_test "whatis (volatile long long) v_long_long" \
140+ "type = volatile long long( int|)" \
141+ "(volatile long long)"
142+gdb_test "whatis (volatile signed long long) v_signed_long_long" \
143+ "type = volatile (signed |)long long( int|)" \
144+ "(volatile signed long long)"
145+gdb_test "whatis (volatile unsigned long long) v_unsigned_long_long" \
146+ "type = volatile (unsigned long long|long long unsigned int)" \
147+ "(volatile unsigned long long)"
148+gdb_test "whatis (volatile float) v_float" \
149+ "type = volatile float" \
150+ "(volatile float)"
151+gdb_test "whatis (volatile double) v_double" \
152+ "type = volatile double" \
153+ "(volatile double)"
154+
155+#
156+# Combine const and volatile
157+#
158+
159+gdb_test "whatis (const volatile int) v_int" \
160+ "type = const volatile int" \
161+ "(const volatile int)"
162+gdb_test "whatis (volatile const int) v_int" \
163+ "type = const volatile int" \
164+ "(volatile const int)"
165+gdb_test "whatis (const int volatile) v_int" \
166+ "type = const volatile int" \
167+ "(const int volatile)"
168+gdb_test "whatis (volatile int const) v_int" \
169+ "type = const volatile int" \
170+ "(volatile int const)"
171+gdb_test "whatis (int const volatile) v_int" \
172+ "type = const volatile int" \
173+ "(int const volatile)"
174+gdb_test "whatis (int volatile const) v_int" \
175+ "type = const volatile int" \
176+ "(int volatile const)"
177+
178+gdb_test "whatis (const volatile int *) v_int_pointer" \
179+ "type = const volatile int${ws}\\*" \
180+ "(const volatile int *)"
181+gdb_test "whatis (volatile const int *) v_int_pointer" \
182+ "type = const volatile int${ws}\\*" \
183+ "(volatile const int *)"
184+gdb_test "whatis (const int volatile *) v_int_pointer" \
185+ "type = const volatile int${ws}\\*" \
186+ "(const int volatile)"
187+gdb_test "whatis (volatile int const *) v_int_pointer" \
188+ "type = const volatile int${ws}\\*" \
189+ "(volatile int const *)"
190+gdb_test "whatis (int const volatile *) v_int_pointer" \
191+ "type = const volatile int${ws}\\*" \
192+ "(int const volatile *)"
193+gdb_test "whatis (int volatile const *) v_int_pointer" \
194+ "type = const volatile int${ws}\\*" \
195+ "(int volatile const *)"
196+gdb_test "whatis (int * const volatile) v_int_pointer" \
197+ "type = int${ws}\\*${ws}const volatile" \
198+ "(int * const volatile)"
199+gdb_test "whatis (int * volatile const) v_int_pointer" \
200+ "type = int${ws}\\*${ws}const volatile" \
201+ "(int * volatile const)"
202+
203+
204+#
205+# Put 'signed' and 'unsigned' before const/volatile (FIXME)
206+#
207+
208+#gdb_test "whatis (signed const char) v_signed_char" \
209+# "type = const char" \
210+# "(signed const char)"
211+#gdb_test "whatis (unsigned const char) v_unsigned_char" \
212+# "type = const (unsigned char|char)" \
213+# "(unsigned const char)"
214+#gdb_test "whatis (signed const short) v_signed_short" \
215+# "type = const (short|short int|signed short|signed short int)" \
216+# "(signed const short)"
217+#gdb_test "whatis (unsigned const short) v_unsigned_short" \
218+# "type = const (unsigned short|short unsigned int)" \
219+# "(unsigned const short)"
220+#gdb_test "whatis (signed const int) v_signed_int" \
221+# "type = const (signed int|int)" \
222+# "(signed const int)"
223+#gdb_test "whatis (unsigned const int) v_unsigned_int" \
224+# "type = const unsigned int" \
225+# "(unsigned const int)"
226+#gdb_test "whatis (signed const long) v_signed_long" \
227+# "type = const (signed |)long( int|)" \
228+# "(signed const long)"
229+#gdb_test "whatis (unsigned const long) v_unsigned_long" \
230+# "type = const (unsigned long|long unsigned int)" \
231+# "(unsigned const long)"
232+#gdb_test "whatis (signed const long long) v_signed_long_long" \
233+# "type = const (signed |)long long( int|)" \
234+# "(signed const long long)"
235+#gdb_test "whatis (unsigned const long long) v_unsigned_long_long" \
236+# "type = const (unsigned long long|long long unsigned int)" \
237+# "(const unsigned long long)"
238+
239+#gdb_test "whatis (signed volatile char) v_signed_char" \
240+# "type = volatile char" \
241+# "(signed volatile char)"
242+#gdb_test "whatis (unsigned volatile char) v_unsigned_char" \
243+# "type = volatile (unsigned char|char)" \
244+# "(unsigned volatile char)"
245+#gdb_test "whatis (signed volatile short) v_signed_short" \
246+# "type = volatile (short|short int|signed short|signed short int)" \
247+# "(signed volatile short)"
248+#gdb_test "whatis (unsigned volatile short) v_unsigned_short" \
249+# "type = volatile (unsigned short|short unsigned int)" \
250+# "(unsigned volatile short)"
251+#gdb_test "whatis (signed volatile int) v_signed_int" \
252+# "type = volatile (signed int|int)" \
253+# "(signed volatile int)"
254+#gdb_test "whatis (unsigned volatile int) v_unsigned_int" \
255+# "type = volatile unsigned int" \
256+# "(unsigned volatile int)"
257+#gdb_test "whatis (signed volatile long) v_signed_long" \
258+# "type = volatile (signed |)long( int|)" \
259+# "(signed volatile long)"
260+#gdb_test "whatis (unsigned volatile long) v_unsigned_long" \
261+# "type = volatile (unsigned long|long unsigned int)" \
262+# "(unsigned volatile long)"
263+#gdb_test "whatis (signed volatile long long) v_signed_long_long" \
264+# "type = volatile (signed |)long long( int|)" \
265+# "(signed volatile long long)"
266+#gdb_test "whatis (unsigned volatile long long) v_unsigned_long_long" \
267+# "type = volatile (unsigned long long|long long unsigned int)" \
268+# "(unsigned volatile long long)"
269+
270+#
271+# Now put the 'const' and 'volatile' keywords after the base type.
272+#
273+
274+gdb_test "whatis (char const) v_char" \
275+ "type = const char" \
276+ "(char const)"
277+gdb_test "whatis (signed char const) v_signed_char" \
278+ "type = const signed char" \
279+ "(signed char const)"
280+gdb_test "whatis (unsigned char const) v_unsigned_char" \
281+ "type = const (unsigned char|char)" \
282+ "(unsigned char const)"
283+gdb_test "whatis (short const) v_short" \
284+ "type = const (short|short int)" \
285+ "(short const)"
286+gdb_test "whatis (signed short const) v_signed_short" \
287+ "type = const (short|short int|signed short|signed short int)" \
288+ "(signed short const)"
289+gdb_test "whatis (unsigned short const) v_unsigned_short" \
290+ "type = const (unsigned short|short unsigned int)" \
291+ "(unsigned short const)"
292+gdb_test "whatis (int const) v_int" \
293+ "type = const int" \
294+ "(int const)"
295+gdb_test "whatis (signed int const) v_signed_int" \
296+ "type = const (signed int|int)" \
297+ "(signed int const)"
298+gdb_test "whatis (unsigned int const) v_unsigned_int" \
299+ "type = const unsigned int" \
300+ "(unsigned int const)"
301+gdb_test "whatis (long const) v_long" \
302+ "type = const (long|long int)" \
303+ "(long const)"
304+gdb_test "whatis (signed long const) v_signed_long" \
305+ "type = const (signed |)long( int|)" \
306+ "(signed long const)"
307+gdb_test "whatis (unsigned long const) v_unsigned_long" \
308+ "type = const (unsigned long|long unsigned int)" \
309+ "(unsigned long const)"
310+gdb_test "whatis (long long const) v_long_long" \
311+ "type = const long long( int|)" \
312+ "(long long const)"
313+gdb_test "whatis (signed long long const) v_signed_long_long" \
314+ "type = const (signed |)long long( int|)" \
315+ "(signed long long const)"
316+gdb_test "whatis (unsigned long long const) v_unsigned_long_long" \
317+ "type = const (unsigned long long|long long unsigned int)" \
318+ "(unsigned long long const)"
319+gdb_test "whatis (float const) v_float" \
320+ "type = const float" \
321+ "(float const)"
322+gdb_test "whatis (double const) v_double" \
323+ "type = const double" \
324+ "(double const)"
325+
326+gdb_test "whatis (char volatile) v_char" \
327+ "type = volatile char" \
328+ "(char volatile)"
329+gdb_test "whatis (signed char volatile) v_signed_char" \
330+ "type = volatile signed char" \
331+ "(signed char volatile)"
332+gdb_test "whatis (unsigned char volatile) v_unsigned_char" \
333+ "type = volatile (unsigned char|char)" \
334+ "(unsigned char volatile)"
335+gdb_test "whatis (short volatile) v_short" \
336+ "type = volatile (short|short int)" \
337+ "(short volatile)"
338+gdb_test "whatis (signed short volatile) v_signed_short" \
339+ "type = volatile (short|short int|signed short|signed short int)" \
340+ "(signed short volatile)"
341+gdb_test "whatis (unsigned short volatile) v_unsigned_short" \
342+ "type = volatile (unsigned short|short unsigned int)" \
343+ "(unsigned short volatile)"
344+gdb_test "whatis (int volatile) v_int" \
345+ "type = volatile int" \
346+ "(int volatile)"
347+gdb_test "whatis (signed int volatile) v_signed_int" \
348+ "type = volatile (signed int|int)" \
349+ "(signed int volatile)"
350+gdb_test "whatis (unsigned int volatile) v_unsigned_int" \
351+ "type = volatile unsigned int" \
352+ "(unsigned int volatile)"
353+gdb_test "whatis (long volatile) v_long" \
354+ "type = volatile (long|long int)" \
355+ "(long volatile)"
356+gdb_test "whatis (signed long volatile) v_signed_long" \
357+ "type = volatile (signed |)long( int|)" \
358+ "(signed long volatile)"
359+gdb_test "whatis (unsigned long volatile) v_unsigned_long" \
360+ "type = volatile (unsigned long|long unsigned int)" \
361+ "(unsigned long volatile)"
362+gdb_test "whatis (long long volatile) v_long_long" \
363+ "type = volatile long long( int|)" \
364+ "(long long volatile)"
365+gdb_test "whatis (signed long long volatile) v_signed_long_long" \
366+ "type = volatile (signed |)long long( int|)" \
367+ "(signed long long volatile)"
368+gdb_test "whatis (unsigned long long volatile) v_unsigned_long_long" \
369+ "type = volatile (unsigned long long|long long unsigned int)" \
370+ "(unsigned long long volatile)"
371+gdb_test "whatis (float volatile) v_float" \
372+ "type = volatile float" \
373+ "(float volatile)"
374+gdb_test "whatis (double volatile) v_double" \
375+ "type = volatile double" \
376+ "(double volatile)"
377+
378+#
379+# enums
380+#
381+
382+gdb_test "whatis (const enum misordered) v_misordered" \
383+ "type = const enum misordered" \
384+ "(const enum misordered)"
385+gdb_test "whatis (enum misordered const) v_misordered" \
386+ "type = const enum misordered" \
387+ "(enum misordered const)"
388+gdb_test "whatis (volatile enum misordered) v_misordered" \
389+ "type = volatile enum misordered" \
390+ "(volatile enum misordered)"
391+gdb_test "whatis (enum misordered volatile) v_misordered" \
392+ "type = volatile enum misordered" \
393+ "(enum misordered volatile)"
394+
395+#
396+# Pointers
397+#
398+
399+gdb_test "whatis (const int *) v_int_pointer" \
400+ "type = const int${ws}\\*" \
401+ "(const int *)"
402+gdb_test "whatis (int const *) v_int_pointer" \
403+ "type = const int${ws}\\*" \
404+ "(int const *)"
405+gdb_test "whatis (int * const) v_int_pointer" \
406+ "type = int \\*${ws}const" \
407+ "(int * const)"
408+gdb_test "whatis (const int * const) v_int_pointer" \
409+ "type = const int${ws}\\*${ws}const" \
410+ "(const int * const)"
411+gdb_test "whatis (int const * const) v_int_pointer" \
412+ "type = const int${ws}\\*${ws}const" \
413+ "(int const * const)"
414+
415+gdb_test "whatis (const int **) v_int_pointer_pointer" \
416+ "type = const int${ws}\\*${ws}\\*" \
417+ "(const int **)"
418+gdb_test "whatis (int const **) v_int_pointer_pointer" \
419+ "type = const int${ws}\\*${ws}\\*" \
420+ "(int const **)"
421+gdb_test "whatis (int ** const) v_int_pointer_pointer" \
422+ "type = int \\*${ws}\\*${ws}const" \
423+ "(int ** const)"
424+gdb_test "whatis (const int * const *) v_int_pointer_pointer" \
425+ "type = const int${ws}\\*${ws}const${ws}\\*" \
426+ "(const int * const *)"
427+gdb_test "whatis (int const * const *) v_int_pointer_pointer" \
428+ "type = const int${ws}\\*${ws}const${ws}\\*" \
429+ "(int const * const *)"
430+gdb_test "whatis (const int * const * const) v_int_pointer_pointer" \
431+ "type = const int${ws}\\*${ws}const${ws}\\*${ws}const" \
432+ "(const int * const * const)"
433+gdb_test "whatis (int const * const * const) v_int_pointer_pointer" \
434+ "type = const int${ws}\\*${ws}const${ws}\\*${ws}const" \
435+ "(int const * const * const)"
436+
437+#
438+# Arrays TODO
439+#
440+
441+#
442+# Pointers to arrays, arrays of pointers TODO
443+#
444+
445+#
446+# Structs and Unions
447+#
448+
449+gdb_test "whatis (const struct t_struct) v_struct1" \
450+ "type = const struct t_struct" \
451+ "(const struct t_struct)"
452+gdb_test "whatis (const union t_union) v_union" \
453+ "type = const union t_union" \
454+ "(const union t_union)"
455+gdb_test "whatis (struct t_struct const) v_struct1" \
456+ "type = const struct t_struct" \
457+ "(struct t_struct const)"
458+gdb_test "whatis (union t_union const) v_union" \
459+ "type = const union t_union" \
460+ "(union t_union const)"
461+gdb_test "whatis (const struct t_struct *) &v_struct1" \
462+ "type = const struct t_struct${ws}\\*" \
463+ "(const struct t_struct *)"
464+gdb_test "whatis (const union t_union *) &v_union" \
465+ "type = const union t_union${ws}\\*" \
466+ "(const union t_union *)"
467+gdb_test "whatis (struct t_struct const *) &v_struct1" \
468+ "type = const struct t_struct${ws}\\*" \
469+ "(struct t_struct const *)"
470+gdb_test "whatis (union t_union const *) &v_union" \
471+ "type = const union t_union${ws}\\*" \
472+ "(union t_union const *)"
473+gdb_test "whatis (struct t_struct * const) &v_struct1" \
474+ "type = struct t_struct${ws}\\*${ws}const" \
475+ "(struct t_struct * const)"
476+gdb_test "whatis (union t_union * const) &v_union" \
477+ "type = union t_union${ws}\\*${ws}const" \
478+ "(union t_union * const)"
479+gdb_test "whatis (const struct t_struct * const) &v_struct1" \
480+ "type = const struct t_struct${ws}\\*${ws}const" \
481+ "(const struct t_struct * const)"
482+gdb_test "whatis (const union t_union * const) &v_union" \
483+ "type = const union t_union${ws}\\*${ws}const" \
484+ "(const union t_union * const)"
485+gdb_test "whatis (struct t_struct const * const) &v_struct1" \
486+ "type = const struct t_struct${ws}\\*${ws}const" \
487+ "(struct t_struct const * const)"
488+gdb_test "whatis (union t_union const * const) &v_union" \
489+ "type = const union t_union${ws}\\*${ws}const" \
490+ "(union t_union const * const)"
491+
492+#
493+# Function pointers TODO
494+#
495+
--- /dev/null
+++ b/gdb/testsuite/gdb.base/ctf-ptype.c
@@ -0,0 +1,305 @@
1+/* This test program is part of GDB, the GNU debugger.
2+
3+ Copyright 2019 Free Software Foundation, Inc.
4+
5+ This program is free software; you can redistribute it and/or modify
6+ it under the terms of the GNU General Public License as published by
7+ the Free Software Foundation; either version 3 of the License, or
8+ (at your option) any later version.
9+
10+ This program is distributed in the hope that it will be useful,
11+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+ GNU General Public License for more details.
14+
15+ You should have received a copy of the GNU General Public License
16+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
17+
18+/*
19+ * Test file with lots of different types, for testing the
20+ * "ptype" command on CTF data. It's devired from ptype.c.
21+ */
22+
23+/*
24+ * First the basic C types.
25+ */
26+
27+#if !defined (__STDC__) && !defined (_AIX)
28+#define signed /**/
29+#endif
30+
31+char v_char;
32+signed char v_signed_char;
33+unsigned char v_unsigned_char;
34+
35+short v_short;
36+signed short v_signed_short;
37+unsigned short v_unsigned_short;
38+
39+int v_int;
40+signed int v_signed_int;
41+unsigned int v_unsigned_int;
42+
43+long v_long;
44+signed long v_signed_long;
45+unsigned long v_unsigned_long;
46+
47+float v_float;
48+double v_double;
49+
50+/**** arrays *******/
51+
52+char v_char_array[2];
53+signed char v_signed_char_array[2];
54+unsigned char v_unsigned_char_array[2];
55+
56+short v_short_array[2];
57+signed short v_signed_short_array[2];
58+unsigned short v_unsigned_short_array[2];
59+
60+int v_int_array[2];
61+signed int v_signed_int_array[2];
62+unsigned int v_unsigned_int_array[2];
63+
64+long v_long_array[2];
65+signed long v_signed_long_array[2];
66+unsigned long v_unsigned_long_array[2];
67+
68+float v_float_array[2];
69+double v_double_array[2];
70+
71+/* PR 3742 */
72+typedef char t_char_array[];
73+t_char_array *pv_char_array;
74+
75+/**** pointers *******/
76+
77+char *v_char_pointer;
78+signed char *v_signed_char_pointer;
79+unsigned char *v_unsigned_char_pointer;
80+
81+short *v_short_pointer;
82+signed short *v_signed_short_pointer;
83+unsigned short *v_unsigned_short_pointer;
84+
85+int *v_int_pointer;
86+signed int *v_signed_int_pointer;
87+unsigned int *v_unsigned_int_pointer;
88+
89+long *v_long_pointer;
90+signed long *v_signed_long_pointer;
91+unsigned long *v_unsigned_long_pointer;
92+
93+float *v_float_pointer;
94+double *v_double_pointer;
95+
96+/**** structs *******/
97+
98+struct t_struct {
99+ char v_char_member;
100+ short v_short_member;
101+ int v_int_member;
102+ long v_long_member;
103+ float v_float_member;
104+ double v_double_member;
105+} v_struct1;
106+
107+struct t_struct *v_t_struct_p;
108+
109+struct {
110+ char v_char_member;
111+ short v_short_member;
112+ int v_int_member;
113+ long v_long_member;
114+ float v_float_member;
115+ double v_double_member;
116+} v_struct2;
117+
118+/* typedef'd struct without a tag. */
119+typedef struct {
120+ double v_double_member;
121+ int v_int_member;
122+} t_struct3;
123+/* GCC seems to want a variable of this type, or else it won't put out
124+ a symbol. */
125+t_struct3 v_struct3;
126+
127+/**** unions *******/
128+
129+union t_union {
130+ char v_char_member;
131+ short v_short_member;
132+ int v_int_member;
133+ long v_long_member;
134+ float v_float_member;
135+ double v_double_member;
136+} v_union;
137+
138+union {
139+ char v_char_member;
140+ short v_short_member;
141+ int v_int_member;
142+ long v_long_member;
143+ float v_float_member;
144+ double v_double_member;
145+} v_union2;
146+
147+/* typedef'd union without a tag. */
148+typedef union {
149+ double v_double_member;
150+ int v_int_member;
151+} t_union3;
152+/* GCC seems to want a variable of this type, or else it won't put out
153+ a symbol. */
154+t_union3 v_union3;
155+
156+/**** Some misc more complicated things *******/
157+
158+struct outer_struct {
159+ int outer_int;
160+ struct inner_struct {
161+ int inner_int;
162+ long inner_long;
163+ }inner_struct_instance;
164+ union inner_union {
165+ int inner_union_int;
166+ long inner_union_long;
167+ }inner_union_instance;
168+ long outer_long;
169+} nested_su;
170+
171+struct highest
172+{
173+ int a;
174+ struct
175+ {
176+ int b;
177+ struct { int c; } anonymous_level_2;
178+ } anonymous_level_1;
179+} the_highest;
180+
181+/**** Enumerations *******/
182+
183+enum
184+/* Work around the bug for compilers which don't put out the right stabs. */
185+#if __GNUC__ < 2 && !defined (_AIX)
186+primary1_tag
187+#endif
188+{red1, green1, blue1} primary1;
189+
190+enum {red, green, blue} primary;
191+enum colors {yellow, purple, pink} nonprimary;
192+
193+enum {chevy, ford} clunker;
194+enum cars {bmw, porsche} sportscar;
195+
196+#undef FALSE
197+#undef TRUE
198+typedef enum {FALSE, TRUE} boolean;
199+boolean v_boolean;
200+/*note: aCC has bool type predefined with 'false' and 'true'*/
201+typedef enum bvals {my_false, my_true} boolean2;
202+boolean2 v_boolean2;
203+
204+enum misordered {two = 2, one = 1, zero = 0, three = 3};
205+
206+/* Seems like we need a variable of this type to get the type to be put
207+ in the executable, at least for AIX xlc. */
208+enum misordered v_misordered = three;
209+
210+/**** Pointers to functions *******/
211+
212+typedef int (*func_type) (int (*) (int, float), float);
213+double (*old_fptr) ();
214+double (*new_fptr) (void);
215+int (*fptr) (int, float);
216+int *(*fptr2) (int (*) (int, float), float);
217+int (*xptr) (int (*) (), int (*) (void), int);
218+int (*(*ffptr) (char)) (short);
219+int (*(*(*fffptr) (char)) (short)) (long);
220+
221+func_type v_func_type;
222+
223+int main ()
224+{
225+ /* Ensure that malloc is a pointer type; avoid use of "void" and any include files. */
226+/* extern char *malloc();*/
227+
228+ /* Some of the tests in ptype.exp require invoking malloc, so make
229+ sure it is linked in to this program. */
230+ v_char_pointer = (char *) malloc (1);
231+
232+ /* Some linkers (e.g. on AIX) remove unreferenced variables,
233+ so make sure to reference them. */
234+ primary = blue;
235+ primary1 = blue1;
236+ nonprimary = pink;
237+ sportscar = porsche;
238+ clunker = ford;
239+ v_struct1.v_int_member = 5;
240+ v_struct2.v_int_member = 6;
241+ v_struct3.v_int_member = 7;
242+
243+ v_char = 0;
244+ v_signed_char = 0;
245+ v_unsigned_char = 0;
246+
247+ v_short = 0;
248+ v_signed_short = 0;
249+ v_unsigned_short = 0;
250+
251+ v_int = 0;
252+ v_signed_int = 0;
253+ v_unsigned_int = 0;
254+
255+ v_long = 0;
256+ v_signed_long = 0;
257+ v_unsigned_long = 0;
258+
259+ v_float = 0;
260+ v_double = 0;
261+
262+ v_char_array[0] = 0;
263+ v_signed_char_array[0] = 0;
264+ v_unsigned_char_array[0] = 0;
265+
266+ v_short_array[0] = 0;
267+ v_signed_short_array[0] = 0;
268+ v_unsigned_short_array[0] = 0;
269+
270+ v_int_array[0] = 0;
271+ v_signed_int_array[0] = 0;
272+ v_unsigned_int_array[0] = 0;
273+
274+ v_long_array[0] = 0;
275+ v_signed_long_array[0] = 0;
276+ v_unsigned_long_array[0] = 0;
277+
278+ v_float_array[0] = 0;
279+ v_double_array[0] = 0;
280+
281+ v_char_pointer = 0;
282+ v_signed_char_pointer = 0;
283+ v_unsigned_char_pointer = 0;
284+
285+ v_short_pointer = 0;
286+ v_signed_short_pointer = 0;
287+ v_unsigned_short_pointer = 0;
288+
289+ v_int_pointer = 0;
290+ v_signed_int_pointer = 0;
291+ v_unsigned_int_pointer = 0;
292+
293+ v_long_pointer = 0;
294+ v_signed_long_pointer = 0;
295+ v_unsigned_long_pointer = 0;
296+
297+ v_float_pointer = 0;
298+ v_double_pointer = 0;
299+
300+ nested_su.outer_int = 0;
301+ v_t_struct_p = 0;
302+
303+ the_highest.a = 0;
304+ return 0;
305+}
--- /dev/null
+++ b/gdb/testsuite/gdb.base/ctf-ptype.exp
@@ -0,0 +1,288 @@
1+# Copyright 2019 Free Software Foundation, Inc.
2+
3+# This program is free software; you can redistribute it and/or modify
4+# it under the terms of the GNU General Public License as published by
5+# the Free Software Foundation; either version 3 of the License, or
6+# (at your option) any later version.
7+#
8+# This program is distributed in the hope that it will be useful,
9+# but WITHOUT ANY WARRANTY; without even the implied warranty of
10+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+# GNU General Public License for more details.
12+#
13+# You should have received a copy of the GNU General Public License
14+# along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
16+# This file is a subset of ptype.exp written by Rob Savoye. (rob@cygnus.com)
17+
18+#
19+# test running programs
20+#
21+# -gt generates full-fledged CTF.
22+
23+standard_testfile .c
24+set opts "additional_flags=-gt"
25+
26+if { [prepare_for_testing "failed to prepare" ${testfile} \
27+ [list $srcfile] [list $opts nowarnings]] } {
28+ return 0
29+}
30+
31+# Create and source the file that provides information about the compiler
32+# used to compile the test case.
33+if [get_compiler_info] {
34+ return -1
35+}
36+
37+# Test ptype of unnamed enumeration members before any action causes
38+# the partial symbol table to be expanded to full symbols. This fails
39+# with stabs compilers which fail to use a nameless stab (such as
40+# pre-2.4.5 versions of gcc and most non-gcc compilers).
41+
42+gdb_test_multiple "ptype red1" "ptype unnamed enumeration member" {
43+ -re "type = enum primary1_tag \{red1, green1, blue1\}.*$gdb_prompt $" {
44+ # The workaround is in effect. As this is a compiler, not GDB,
45+ # bug, we'll make it a PASS but perhaps it should be an XFAIL.
46+ pass "ptype unnamed enumeration member (worked around)"
47+ }
48+ -re "type = enum \{red1, green1, blue1\}.*$gdb_prompt $" {
49+ pass "ptype unnamed enumeration member"
50+ }
51+}
52+
53+#
54+# test ptype command with structures
55+#
56+# Here and elsewhere, we accept
57+# "long", "long int", or "int" for long variables (whatis.exp already
58+# has an XFAIL for "int" (Sun cc bug), so no need to fail it here).
59+gdb_test "ptype struct t_struct" "type = struct t_struct \{.*\[\r\n\] (unsigned |)char v_char_member;.*\[\r\n\] (short|short int) v_short_member;.*\[\r\n\] int v_int_member;.*\[\r\n\] (long|long int|int) v_long_member;.*\[\r\n\] float v_float_member;.*\[\r\n\] double v_double_member;.*\[\r\n\]\}.*" "ptype structure"
60+
61+
62+# Test the equivalence between '.' and '->' for struct member references.
63+
64+if [gdb_test "ptype v_t_struct_p.v_float_member" "type = float"]<0 then {
65+ return -1
66+}
67+if [gdb_test "ptype v_t_struct_p->v_float_member" "type = float"]<0 then {
68+ return -1
69+}
70+if [gdb_test "ptype v_t_struct_p.v_float_member" "type = float"]<0 then {
71+ return -1
72+}
73+if [gdb_test "ptype v_t_struct_p->v_float_member" "type = float"]<0 then {
74+ return -1
75+}
76+
77+#
78+# test ptype command with unions
79+#
80+gdb_test "ptype union t_union" "type = union t_union \{.*\[\r\n\] (unsigned |)char v_char_member;.*\[\r\n\] (short|short int) v_short_member;.*\[\r\n\] int v_int_member;.*\[\r\n\] (long|long int|int) v_long_member;.*\[\r\n\] float v_float_member;.*\[\r\n\] double v_double_member;.*\[\r\n\]\}.*" "ptype union"
81+
82+#
83+# test ptype command with enums
84+#
85+
86+gdb_test "ptype primary" "type = enum .red, green, blue.*" "ptype unnamed enumeration"
87+
88+gdb_test "ptype enum colors" "type = enum colors \{yellow, purple, pink\}.*" "ptype named enumeration"
89+
90+
91+#
92+# test ptype command with enums as typedef
93+#
94+gdb_test "ptype boolean" "type = enum (boolean |)\{FALSE, TRUE\}.*" "ptype unnamed typedef'd enumeration"
95+
96+gdb_test "list main" ".*"
97+
98+# Same thing with struct and union.
99+gdb_test "ptype t_struct3" "type = struct (t_struct3 |)\{.*
100+ *double v_double_member;.*
101+ *int v_int_member;.*\}" "printing typedef'd struct"
102+
103+gdb_test "ptype t_union3" "type = union (t_union3 |)\{.*
104+ *double v_double_member;.*
105+ *int v_int_member;.*\}" "printing typedef'd union"
106+
107+gdb_test "ptype enum bvals" "type = enum bvals \{my_false, my_true\}.*" "ptype named typedef'd enumf'd enum"
108+
109+#
110+# test ptype command with out-of-order enum values
111+#
112+gdb_test "ptype enum misordered" "type = enum misordered \{two = 2, one = 1, zero = 0, three = 3\}.*" "ptype misordered enumeration"
113+
114+#
115+# test ptype command with a named enum's value
116+#
117+gdb_test "ptype three" "type = enum misordered \{two = 2, one = 1, zero = 0, three = 3\}.*" "ptype named enumeration member"
118+
119+gdb_test "ptype red" "type = enum \{red, green, blue\}.*" "ptype unnamed enumeration member #2"
120+
121+#
122+# test ptype command with arrays
123+#
124+gdb_test "ptype v_char_array" "type = char .2..*" "ptype char array"
125+
126+gdb_test "ptype v_signed_char_array" "type = (|signed )char .2..*" "ptype signed char array"
127+
128+gdb_test "ptype v_unsigned_char_array" "type = unsigned char .2..*" "ptype unsigned char array"
129+
130+gdb_test "ptype v_int_array" "type = int .2..*" "ptype int array"
131+
132+gdb_test "ptype v_signed_int_array" "type = int .2..*" "ptype signed int array"
133+
134+gdb_test "ptype v_unsigned_int_array" "type = unsigned int .2..*" "ptype unsigned int array"
135+
136+gdb_test "ptype v_long_array" "type = (long|int|long int) .2..*" "ptype long array"
137+
138+gdb_test "ptype v_signed_long_array" "type = (long|int|long int) .2..*" "ptype signed long array"
139+
140+gdb_test "ptype v_unsigned_long_array" "type = unsigned long .2..*" "ptype unsigned long array"
141+
142+gdb_test "ptype v_float_array" "type = float .2..*" "ptype float array"
143+
144+gdb_test "ptype v_double_array" "type = double .2..*" "ptype double array"
145+
146+gdb_test "ptype pv_char_array" "type = (|unsigned )char \\(\\*\\)\\\[0?\\\]"
147+
148+#
149+# test ptype command with pointers
150+#
151+gdb_test "ptype v_char_pointer" "type = char \*.*" "ptype char pointer"
152+
153+gdb_test "ptype v_short_pointer" "type = short \*.*" "ptype short pointer"
154+
155+gdb_test "ptype v_long_pointer" "type = long \*.*" "ptype long pointer"
156+
157+gdb_test "ptype v_int_pointer" "type = int \*.*" "ptype int pointer"
158+
159+gdb_test "ptype v_signed_long_pointer" "type = long \*.*" "ptype signed long pointer"
160+
161+gdb_test "ptype v_unsigned_long_pointer" "type = unsigned long \*.*" "ptype unsigned long pointer"
162+
163+gdb_test "ptype v_float_pointer" "type = float \*.*" "ptype float pointer"
164+
165+gdb_test "ptype v_double_pointer" "type = double \*.*" "ptype double pointer"
166+
167+#
168+# test ptype command with basic C types
169+#
170+gdb_test "ptype v_short" "type = short(| int).*" "ptype short"
171+
172+gdb_test "ptype v_int" "type = int.*" "ptype int"
173+
174+#
175+# test ptype command with nested structure and union
176+#
177+gdb_test "ptype struct outer_struct" "type = struct outer_struct \{.*\[\r\n\]+\
178+.*int outer_int;.*\[\r\n\]+\
179+.*(struct|) inner_struct inner_struct_instance;.*\[\r\n\]+\
180+.*(union|) inner_union inner_union_instance;.*\[\r\n\]+\
181+.*(long|long int|int) outer_long;.*\[\r\n\]\}.*" "ptype outer structure"
182+
183+gdb_test "ptype struct inner_struct" "type = struct inner_struct \{.*\[\r\n\] int inner_int;.*\[\r\n\] (long|long int|int) inner_long;.*\[\r\n\]\}.*" "ptype inner structure"
184+
185+gdb_test "ptype union inner_union" "type = union inner_union \{.*\[\r\n\] int inner_union_int;.*\[\r\n\] (long|long int|int) inner_union_long;.*\[\r\n\]\}.*" "ptype inner union"
186+
187+gdb_test "ptype nested_su" "type = struct outer_struct \{.*\[\r\n\] int outer_int;.*\[\r\n\] (struct |)inner_struct inner_struct_instance;.*\[\r\n\] (union |)inner_union inner_union_instance;.*\[\r\n\] (long|long int|int) outer_long;.*\[\r\n\]\}.*" "ptype nested structure"
188+
189+gdb_test "ptype nested_su.outer_int" "type = int.*" "ptype outer int"
190+
191+gdb_test "ptype nested_su.inner_struct_instance" "type = struct inner_struct \{.*\[\r\n\] int inner_int;.*\[\r\n\] (long|long int|int) inner_long;.*\[\r\n\]\}.*" "ptype nested structure #2"
192+
193+gdb_test "ptype nested_su.inner_struct_instance.inner_int" "type = int.*" "ptype inner int"
194+
195+gdb_test "ptype nested_su.inner_union_instance" "type = union inner_union \{.*\[\r\n\] int inner_union_int;.*\[\r\n\] (long|long int|int) inner_union_long;.*\[\r\n\]\}.*" "ptype nested union"
196+
197+# Print the type description of variable the_highest, and verify that
198+# the type description for the fields whose type is anonymous are
199+# correctly printed (at nesting level 1 and 2).
200+
201+gdb_test "ptype the_highest" \
202+ "type = struct highest \{.*\[\r\n\] *int a;.*\[\r\n\] *struct \{.*\[\r\n\] *int b;.*\[\r\n\] *struct \{\.\.\.\} anonymous_level_2;.*\[\r\n\] *\} anonymous_level_1;.*\[\r\n\]}.*" \
203+ "ptype the_highest"
204+
205+# Print the type descrption for one of the fields of variable the_highest.
206+# The purpose is to verify that the type of a field that was printed above
207+# as "struct {...}" is now printed in a more descriptive way (because the
208+# nesting level is now one level less).
209+
210+gdb_test "ptype the_highest.anonymous_level_1" \
211+ "type = struct \{.*\[\r\n\] *int b;.*\[\r\n\] *struct \{.*\[\r\n\] *int c;.*\[\r\n\] *\} anonymous_level_2;.*\[\r\n\]}.*" \
212+ "ptype the_highest"
213+
214+# Print the type of the identifier ID, and check the response:
215+# - Expect to see PROTOTYPED as the type. PROTOTYPED is not a regular
216+# expression; it's a literal string.
217+# - If we instead see the unprototyped type PLAIN, and we're using STABS
218+# generated by GCC, that's an xfail; as of 9 Feb 2002, GCC never emits
219+# prototyped function types in STABS. Like PROTOTYPED, PLAIN is a
220+# literal string, not a regular expression.
221+# - If we see OVERPROTOTYPED, it's an xfail for RealView; RealView
222+# does not distinguish prototyped and unprototyped functions, and
223+# GDB defaults to prototyped.
224+# - Otherwise, it's a failure.
225+proc ptype_maybe_prototyped { id prototyped plain { overprototyped "NO-MATCH" } } {
226+ global gdb_prompt
227+ global gcc_compiled
228+
229+ # Turn the arguments, which are literal strings, into
230+ # regular expressions by quoting any special characters they contain.
231+ foreach var { prototyped plain overprototyped } {
232+ eval "set val \$$var"
233+ regsub -all "\[\]\[*()\]" $val "\\\\&" val
234+ regsub -all "short int" $val "short( int)?" val
235+ regsub -all "long int" $val "long( int)?" val
236+ eval "set $var \$val"
237+ }
238+
239+ gdb_test_multiple "ptype $id" "ptype $id" {
240+ -re "type = $prototyped\[\r\n\]+$gdb_prompt $" {
241+ pass "ptype $id"
242+ }
243+ -re "type = $plain\[\r\n\]+$gdb_prompt $" {
244+ if {$gcc_compiled} { setup_xfail_format "stabs" }
245+ fail "ptype $id (compiler doesn't emit prototyped types)"
246+ }
247+ -re "type = $overprototyped\[\r\n\]+$gdb_prompt $" {
248+ if { [test_compiler_info "armcc-*"] } {
249+ setup_xfail "*-*-*"
250+ }
251+ fail "ptype $id (compiler doesn't emit unprototyped types)"
252+ }
253+ }
254+}
255+
256+ptype_maybe_prototyped "old_fptr" "double (*)()" "double (*)()" \
257+ "double (*)(void)"
258+
259+# Test printing type of string constants and array constants, but
260+# requires a running process. These call malloc, and can take a long
261+# time to execute over a slow serial link, so increase the timeout.
262+
263+if [runto_main] then {
264+
265+ if [target_info exists gdb,cannot_call_functions] {
266+ unsupported "this target can not call functions"
267+ continue
268+ }
269+
270+ # We need to up this because this can be really slow on some boards.
271+ # (malloc() is called as part of the test).
272+ set prev_timeout $timeout
273+ set timeout 60
274+
275+ gdb_test "ptype \"abc\"" "type = char \\\[4\\\]"
276+ gdb_test "ptype {'a','b','c'}" "type = char \\\[3\\\]"
277+ gdb_test "ptype {0,1,2}" "type = int \\\[3\\\]"
278+ gdb_test "ptype {(long)0,(long)1,(long)2}" "type = long \\\[3\\\]"
279+ gdb_test "ptype {(float)0,(float)1,(float)2}" "type = float \\\[3\\\]"
280+ gdb_test "ptype {{0,1,2},{3,4,5}}" "type = int \\\[2\\\]\\\[3\\\]"
281+ gdb_test "ptype {4,5,6}\[2\]" "type = int"
282+ gdb_test "ptype *&{4,5,6}\[1\]" "Attempt to take address of value not located in memory."
283+
284+ set timeout $prev_timeout
285+
286+ # Test ptype of user register
287+ gdb_test "ptype \$pc" "void \\(\\*\\)\\(\\)" "ptype \$pc"
288+}
--- /dev/null
+++ b/gdb/testsuite/gdb.base/ctf-whatis.c
@@ -0,0 +1,282 @@
1+/* This test program is part of GDB, the GNU debugger.
2+
3+ Copyright 2019 Free Software Foundation, Inc.
4+
5+ This program is free software; you can redistribute it and/or modify
6+ it under the terms of the GNU General Public License as published by
7+ the Free Software Foundation; either version 3 of the License, or
8+ (at your option) any later version.
9+
10+ This program is distributed in the hope that it will be useful,
11+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+ GNU General Public License for more details.
14+
15+ You should have received a copy of the GNU General Public License
16+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
17+
18+/*
19+ * Test file with lots of different types, for testing the
20+ * "whatis" command on CTF data. It's derived from whatis.c.
21+ */
22+
23+/*
24+ * First the basic C types.
25+ */
26+
27+char v_char;
28+signed char v_signed_char;
29+unsigned char v_unsigned_char;
30+
31+short v_short;
32+signed short v_signed_short;
33+unsigned short v_unsigned_short;
34+
35+int v_int;
36+signed int v_signed_int;
37+unsigned int v_unsigned_int;
38+
39+long v_long;
40+signed long v_signed_long;
41+unsigned long v_unsigned_long;
42+
43+#ifndef NO_LONG_LONG
44+long long v_long_long;
45+signed long long v_signed_long_long;
46+unsigned long long v_unsigned_long_long;
47+#endif
48+
49+float v_float;
50+double v_double;
51+
52+/*
53+ * Now some derived types, which are arrays, functions-returning,
54+ * pointers, structures, unions, and enumerations.
55+ */
56+
57+/**** arrays *******/
58+
59+char v_char_array[2];
60+signed char v_signed_char_array[2];
61+unsigned char v_unsigned_char_array[2];
62+
63+short v_short_array[2];
64+signed short v_signed_short_array[2];
65+unsigned short v_unsigned_short_array[2];
66+
67+int v_int_array[2];
68+signed int v_signed_int_array[2];
69+unsigned int v_unsigned_int_array[2];
70+
71+long v_long_array[2];
72+signed long v_signed_long_array[2];
73+unsigned long v_unsigned_long_array[2];
74+
75+#ifndef NO_LONG_LONG
76+long long v_long_long_array[2];
77+signed long long v_signed_long_long_array[2];
78+unsigned long long v_unsigned_long_long_array[2];
79+#endif
80+
81+float v_float_array[2];
82+double v_double_array[2];
83+
84+/**** pointers *******/
85+
86+/* Make sure they still print as pointer to foo even there is a typedef
87+ for that type. Test this not just for char *, which might be
88+ a special case kludge in GDB (Unix system include files like to define
89+ caddr_t), but for a variety of types. */
90+typedef char *char_addr;
91+char_addr a_char_addr;
92+typedef unsigned short *ushort_addr;
93+ushort_addr a_ushort_addr;
94+typedef signed long *slong_addr;
95+slong_addr a_slong_addr;
96+#ifndef NO_LONG_LONG
97+typedef signed long long *slong_long_addr;
98+slong_long_addr a_slong_long_addr;
99+#endif
100+
101+char *v_char_pointer;
102+signed char *v_signed_char_pointer;
103+unsigned char *v_unsigned_char_pointer;
104+
105+short *v_short_pointer;
106+signed short *v_signed_short_pointer;
107+unsigned short *v_unsigned_short_pointer;
108+
109+int *v_int_pointer;
110+signed int *v_signed_int_pointer;
111+unsigned int *v_unsigned_int_pointer;
112+
113+long *v_long_pointer;
114+signed long *v_signed_long_pointer;
115+unsigned long *v_unsigned_long_pointer;
116+
117+#ifndef NO_LONG_LONG
118+long long *v_long_long_pointer;
119+signed long long *v_signed_long_long_pointer;
120+unsigned long long *v_unsigned_long_long_pointer;
121+#endif
122+
123+float *v_float_pointer;
124+double *v_double_pointer;
125+
126+/**** structs *******/
127+
128+struct t_struct {
129+ char v_char_member;
130+ short v_short_member;
131+ int v_int_member;
132+ long v_long_member;
133+#ifndef NO_LONG_LONG
134+ long long v_long_long_member;
135+#endif
136+ float v_float_member;
137+ double v_double_member;
138+} v_struct1, *v_struct_ptr1;
139+
140+struct {
141+ char v_char_member;
142+ short v_short_member;
143+ int v_int_member;
144+ long v_long_member;
145+#ifndef NO_LONG_LONG
146+ long long v_long_long_member;
147+#endif
148+ float v_float_member;
149+ double v_double_member;
150+} v_struct2, *v_struct_ptr2;
151+
152+/**** unions *******/
153+
154+union t_union {
155+ char v_char_member;
156+ short v_short_member;
157+ int v_int_member;
158+ long v_long_member;
159+#ifndef NO_LONG_LONG
160+ long long v_long_long_member;
161+#endif
162+ float v_float_member;
163+ double v_double_member;
164+} v_union, *v_union_ptr;
165+
166+union {
167+ char v_char_member;
168+ short v_short_member;
169+ int v_int_member;
170+ long v_long_member;
171+#ifndef NO_LONG_LONG
172+ long long v_long_long_member;
173+#endif
174+ float v_float_member;
175+ double v_double_member;
176+} v_union2, *v_union_ptr2;
177+
178+/**** Some misc more complicated things *******/
179+
180+struct outer_struct {
181+ int outer_int;
182+ struct inner_struct {
183+ int inner_int;
184+ long inner_long;
185+ }inner_struct_instance;
186+ union inner_union {
187+ int inner_union_int;
188+ long inner_union_long;
189+ }inner_union_instance;
190+ long outer_long;
191+} nested_su;
192+
193+/***********/
194+
195+int main ()
196+{
197+ /* Some linkers (e.g. on AIX) remove unreferenced variables,
198+ so make sure to reference them. */
199+ v_char = 0;
200+ v_signed_char = 1;
201+ v_unsigned_char = 2;
202+
203+ v_short = 3;
204+ v_signed_short = 4;
205+ v_unsigned_short = 5;
206+
207+ v_int = 6;
208+ v_signed_int = 7;
209+ v_unsigned_int = 8;
210+
211+ v_long = 9;
212+ v_signed_long = 10;
213+ v_unsigned_long = 11;
214+
215+#ifndef NO_LONG_LONG
216+ v_long_long = 12;
217+ v_signed_long_long = 13;
218+ v_unsigned_long_long = 14;
219+#endif
220+
221+ v_float = 100.0;
222+ v_double = 200.0;
223+
224+
225+ v_char_array[0] = v_char;
226+ v_signed_char_array[0] = v_signed_char;
227+ v_unsigned_char_array[0] = v_unsigned_char;
228+
229+ v_short_array[0] = v_short;
230+ v_signed_short_array[0] = v_signed_short;
231+ v_unsigned_short_array[0] = v_unsigned_short;
232+
233+ v_int_array[0] = v_int;
234+ v_signed_int_array[0] = v_signed_int;
235+ v_unsigned_int_array[0] = v_unsigned_int;
236+
237+ v_long_array[0] = v_long;
238+ v_signed_long_array[0] = v_signed_long;
239+ v_unsigned_long_array[0] = v_unsigned_long;
240+
241+#ifndef NO_LONG_LONG
242+ v_long_long_array[0] = v_long_long;
243+ v_signed_long_long_array[0] = v_signed_long_long;
244+ v_unsigned_long_long_array[0] = v_unsigned_long_long;
245+#endif
246+
247+ v_float_array[0] = v_float;
248+ v_double_array[0] = v_double;
249+
250+ v_char_pointer = &v_char;
251+ v_signed_char_pointer = &v_signed_char;
252+ v_unsigned_char_pointer = &v_unsigned_char;
253+
254+ v_short_pointer = &v_short;
255+ v_signed_short_pointer = &v_signed_short;
256+ v_unsigned_short_pointer = &v_unsigned_short;
257+
258+ v_int_pointer = &v_int;
259+ v_signed_int_pointer = &v_signed_int;
260+ v_unsigned_int_pointer = &v_unsigned_int;
261+
262+ v_long_pointer = &v_long;
263+ v_signed_long_pointer = &v_signed_long;
264+ v_unsigned_long_pointer = &v_unsigned_long;
265+
266+#ifndef NO_LONG_LONG
267+ v_long_long_pointer = &v_long_long;
268+ v_signed_long_long_pointer = &v_signed_long_long;
269+ v_unsigned_long_long_pointer = &v_unsigned_long_long;
270+#endif
271+
272+ v_float_pointer = &v_float;
273+ v_double_pointer = &v_double;
274+
275+ v_union2.v_short_member = v_union.v_short_member;
276+
277+ v_struct1.v_char_member = 0;
278+ v_struct2.v_char_member = 0;
279+
280+ nested_su.outer_int = 0;
281+ return 0;
282+}
--- /dev/null
+++ b/gdb/testsuite/gdb.base/ctf-whatis.exp
@@ -0,0 +1,413 @@
1+# Copyright 2019 Free Software Foundation, Inc.
2+
3+# This program is free software; you can redistribute it and/or modify
4+# it under the terms of the GNU General Public License as published by
5+# the Free Software Foundation; either version 3 of the License, or
6+# (at your option) any later version.
7+#
8+# This program is distributed in the hope that it will be useful,
9+# but WITHOUT ANY WARRANTY; without even the implied warranty of
10+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+# GNU General Public License for more details.
12+#
13+# You should have received a copy of the GNU General Public License
14+# along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
16+# This file is a subset of whatis.exp written by Rob Savoye. (rob@cygnus.com)
17+
18+#
19+# test running programs
20+#
21+# -gt generates full-fledged CTF.
22+
23+standard_testfile .c
24+set opts "additional_flags=-gt"
25+
26+if { [prepare_for_testing "failed to prepare" ${testfile} \
27+ [list $srcfile] [list $opts nowarnings]] } {
28+ return 0
29+}
30+
31+# Create and source the file that provides information about the compiler
32+# used to compile the test case.
33+if [get_compiler_info] {
34+ return -1
35+}
36+
37+# Start with a fresh gdb.
38+
39+clean_restart $binfile
40+
41+# Define a procedure to set up an xfail for all targets that put out a
42+# `long' type as an `int' type.
43+# Sun cc has this problem.
44+# It was said that COFF targets can not distinguish int from long either.
45+
46+proc setup_xfail_on_long_vs_int {} {
47+ global gcc_compiled
48+
49+ if {!$gcc_compiled} {
50+ setup_xfail "*-sun-sunos4*" "i*86-sequent-bsd*"
51+ }
52+}
53+
54+#
55+# Test whatis command with basic C types
56+#
57+# The name printed now (as of 23 May 1993) is whatever name the compiler
58+# uses in the stabs. So we need to deal with names both from gcc and
59+# native compilers.
60+#
61+
62+gdb_test "whatis v_char" \
63+ "type = (unsigned char|char)" \
64+ "whatis char"
65+
66+gdb_test "whatis v_signed_char" \
67+ "type = (signed char|char)" \
68+ "whatis signed char"
69+
70+gdb_test "whatis v_unsigned_char" \
71+ "type = unsigned char" \
72+ "whatis unsigned char"
73+
74+gdb_test "whatis v_short" \
75+ "type = (short|short int)" \
76+ "whatis short"
77+
78+gdb_test "whatis v_signed_short" \
79+ "type = (short|short int|signed short|signed short int)" \
80+ "whatis signed short"
81+
82+gdb_test "whatis v_unsigned_short" \
83+ "type = (unsigned short|short unsigned int)" \
84+ "whatis unsigned short"
85+
86+gdb_test "whatis v_int" \
87+ "type = int" \
88+ "whatis int"
89+
90+gdb_test "whatis v_signed_int" \
91+ "type = (signed |)int" \
92+ "whatis signed int"
93+
94+gdb_test "whatis v_unsigned_int" \
95+ "type = unsigned int" \
96+ "whatis unsigned int"
97+
98+setup_xfail_on_long_vs_int
99+# AIX xlc gets this wrong and unsigned long right. Go figure.
100+if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"}
101+gdb_test "whatis v_long" \
102+ "type = (long|long int)" \
103+ "whatis long"
104+
105+setup_xfail_on_long_vs_int
106+# AIX xlc gets this wrong and unsigned long right. Go figure.
107+if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"}
108+gdb_test "whatis v_signed_long" \
109+ "type = (signed |)(long|long int)" \
110+ "whatis signed long"
111+
112+setup_xfail_on_long_vs_int
113+gdb_test "whatis v_unsigned_long" \
114+ "type = (unsigned long|long unsigned int)" \
115+ "whatis unsigned long"
116+
117+
118+if ![target_info exists no_long_long] {
119+ gdb_test "whatis v_unsigned_long_long" \
120+ "type = (unsigned long long|long long unsigned int)" \
121+ "whatis unsigned long long"
122+}
123+
124+gdb_test "whatis v_float" \
125+ "type = float" \
126+ "whatis float"
127+
128+gdb_test "whatis v_double" \
129+ "type = double" \
130+ "whatis double"
131+
132+
133+# test whatis command with arrays
134+#
135+# We already tested whether char prints as "char", so here we accept
136+# "unsigned char", "signed char", and other perversions. No need for more
137+# than one xfail for the same thing.
138+gdb_test "whatis v_char_array" \
139+ "type = (signed |unsigned |)char \\\[2\\\]" \
140+ "whatis char array"
141+
142+gdb_test "whatis v_signed_char_array" \
143+ "type = (signed |unsigned |)char \\\[2\\\]" \
144+ "whatis signed char array"
145+
146+gdb_test "whatis v_unsigned_char_array" \
147+ "type = unsigned char \\\[2\\\]" \
148+ "whatis unsigned char array"
149+
150+gdb_test "whatis v_short_array" \
151+ "type = (short|short int) \\\[2\\\]" \
152+ "whatis short array"
153+
154+gdb_test "whatis v_signed_short_array" \
155+ "type = (signed |)(short|short int) \\\[2\\\]" \
156+ "whatis signed short array"
157+
158+gdb_test "whatis v_unsigned_short_array" \
159+ "type = (unsigned short|short unsigned int) \\\[2\\\]" \
160+ "whatis unsigned short array"
161+
162+gdb_test "whatis v_int_array" \
163+ "type = int \\\[2\\\]" \
164+ "whatis int array"
165+
166+gdb_test "whatis v_signed_int_array" \
167+ "type = (signed |)int \\\[2\\\]" \
168+ "whatis signed int array"
169+
170+gdb_test "whatis v_unsigned_int_array" \
171+ "type = unsigned int \\\[2\\\]" \
172+ "whatis unsigned int array"
173+
174+# We already tested whether long prints as long, so here we accept int
175+# No need for more than one xfail for the same thing.
176+gdb_test "whatis v_long_array" \
177+ "type = (int|long|long int) \\\[2\\\]" \
178+ "whatis long array"
179+
180+gdb_test "whatis v_signed_long_array" \
181+ "type = (signed |)(int|long|long int) \\\[2\\\]" \
182+ "whatis signed long array"
183+
184+gdb_test "whatis v_unsigned_long_array" \
185+ "type = (unsigned (int|long|long int)|long unsigned int) \\\[2\\\]" \
186+ "whatis unsigned long array"
187+
188+if ![target_info exists no_long_long] {
189+ gdb_test "whatis v_unsigned_long_long_array" \
190+ "type = (unsigned long long|long long unsigned int) \\\[2\\\]" \
191+ "whatis unsigned long array"
192+}
193+
194+gdb_test "whatis v_float_array" \
195+ "type = float \\\[2\\\]" \
196+ "whatis float array"
197+
198+gdb_test "whatis v_double_array" \
199+ "type = double \\\[2\\\]" \
200+ "whatis double array"
201+
202+
203+# test whatis command with pointers
204+#
205+# We already tested whether char prints as char, so accept various perversions
206+# here. We especially want to make sure we test that it doesn't print as
207+# caddr_t.
208+gdb_test "whatis v_char_pointer" \
209+ "type = (unsigned |signed |)char \\*" \
210+ "whatis char pointer"
211+
212+gdb_test "whatis v_signed_char_pointer" \
213+ "type = (unsigned |signed |)char \\*" \
214+ "whatis signed char pointer"
215+
216+gdb_test "whatis v_unsigned_char_pointer" \
217+ "type = unsigned char \\*" \
218+ "whatis unsigned char pointer"
219+
220+gdb_test "whatis v_short_pointer" \
221+ "type = (short|short int) \\*" \
222+ "whatis short pointer"
223+
224+gdb_test "whatis v_signed_short_pointer" \
225+ "type = (signed |)(short|short int) \\*" \
226+ "whatis signed short pointer"
227+
228+gdb_test "whatis v_unsigned_short_pointer" \
229+ "type = (unsigned short|short unsigned int) \\*" \
230+ "whatis unsigned short pointer"
231+
232+gdb_test "whatis v_int_pointer" \
233+ "type = int \\*" \
234+ "whatis int pointer"
235+
236+gdb_test "whatis v_signed_int_pointer" \
237+ "type = (signed |)int \\*" \
238+ "whatis signed int pointer"
239+
240+gdb_test "whatis v_unsigned_int_pointer" \
241+ "type = unsigned int \\*" \
242+ "whatis unsigned int pointer"
243+
244+# We already tested whether long prints as long, so here we accept int
245+gdb_test "whatis v_long_pointer" \
246+ "type = (long|int|long int) \\*" \
247+ "whatis long pointer"
248+
249+gdb_test "whatis v_signed_long_pointer" \
250+ "type = (signed |)(long|int|long int) \\*" \
251+ "whatis signed long pointer"
252+
253+gdb_test "whatis v_unsigned_long_pointer" \
254+ "type = (unsigned (int|long|long int)|long unsigned int) \\*" \
255+ "whatis unsigned long pointer"
256+
257+if ![target_info exists no_long_long] {
258+ gdb_test "whatis v_long_long_pointer" \
259+ "type = long long(| int) \\*" \
260+ "whatis long long pointer"
261+
262+ gdb_test "whatis v_signed_long_long_pointer" \
263+ "type = (signed |)long long(| int) \\*" \
264+ "whatis signed long long pointer"
265+
266+ gdb_test "whatis v_unsigned_long_long_pointer" \
267+ "type = (unsigned long long|long long unsigned int) \\*" \
268+ "whatis unsigned long long pointer"
269+}
270+
271+gdb_test "whatis v_float_pointer" \
272+ "type = float \\*" \
273+ "whatis float pointer"
274+
275+gdb_test "whatis v_double_pointer" \
276+ "type = double \\*" \
277+ "whatis double pointer"
278+
279+
280+# test whatis command with structure types
281+
282+# First with a type argument, with both "set print object" set to "on"
283+# and "off", ending with "off" for the following tests.
284+foreach_with_prefix print_object {"on" "off"} {
285+ gdb_test_no_output "set print object $print_object"
286+
287+ gdb_test "whatis struct t_struct" \
288+ "type = struct t_struct" \
289+ "whatis named structure using type name"
290+
291+ gdb_test "whatis struct t_struct *" \
292+ "type = struct t_struct \\*" \
293+ "whatis named structure using type name and pointer"
294+
295+ gdb_test "whatis struct t_struct &" \
296+ "type = struct t_struct &" \
297+ "whatis named structure using type name and reference"
298+}
299+
300+# Now with an expression argument.
301+
302+gdb_test "whatis v_struct_ptr1" \
303+ "type = struct t_struct \\*"
304+
305+gdb_test "whatis &v_struct_ptr1" \
306+ "type = struct t_struct \\*\\*"
307+
308+gdb_test "whatis v_struct_ptr1->v_char_member" \
309+ "type = char"
310+
311+gdb_test "whatis v_struct_ptr2->v_char_member" \
312+ "type = char"
313+
314+gdb_test "whatis &(v_struct_ptr1->v_char_member)" \
315+ "type = char \\*"
316+
317+gdb_test "whatis &(v_struct_ptr2->v_char_member)" \
318+ "type = char \\*"
319+
320+# test whatis command with union types
321+
322+gdb_test "whatis union t_union" \
323+ "type = union t_union" \
324+ "whatis named union using type name"
325+
326+gdb_test "whatis v_union_ptr" \
327+ "type = union t_union \\*"
328+
329+gdb_test "whatis &v_union_ptr" \
330+ "type = union t_union \\*\\*"
331+
332+gdb_test "whatis v_union_ptr->v_char_member" \
333+ "type = char"
334+
335+gdb_test "whatis v_union_ptr2->v_char_member" \
336+ "type = char"
337+
338+gdb_test "whatis &(v_union_ptr->v_char_member)" \
339+ "type = char \\*"
340+
341+gdb_test "whatis &(v_union_ptr2->v_char_member)" \
342+ "type = char \\*"
343+
344+# test whatis command with nested struct and union
345+gdb_test "whatis nested_su" \
346+ "type = struct outer_struct" \
347+ "whatis outer structure"
348+
349+gdb_test "whatis nested_su.outer_int" \
350+ "type = int" \
351+ "whatis outer structure member"
352+
353+gdb_test "whatis nested_su.inner_struct_instance" \
354+ "type = struct inner_struct" \
355+ "whatis inner structure"
356+
357+gdb_test "whatis nested_su.inner_struct_instance.inner_int" \
358+ "type = int" \
359+ "whatis inner structure member"
360+
361+gdb_test "whatis nested_su.inner_union_instance" \
362+ "type = union inner_union" \
363+ "whatis inner union"
364+
365+gdb_test "whatis nested_su.inner_union_instance.inner_union_int" \
366+ "type = int" \
367+ "whatis inner union member"
368+
369+# Using stabs we will mark these functions as prototyped. This
370+# is harmless but causes an extra VOID to be printed.
371+set void "(void|)"
372+
373+# Regression tests for PR 9514.
374+
375+gdb_test "whatis void (**)()" \
376+ "type = void \\(\\*\\*\\)\\(\\)" \
377+ "whatis applied to pointer to pointer to function"
378+
379+gdb_test "whatis void (** const)()" \
380+ "type = void \\(\\*\\* const\\)\\(\\)" \
381+ "whatis applied to const pointer to pointer to function"
382+
383+gdb_test "whatis void (* const *)()" \
384+ "type = void \\(\\* const \\*\\)\\(\\)" \
385+ "whatis applied to pointer to const pointer to function"
386+
387+gdb_test "whatis int *(*)()" \
388+ "type = int \\*\\(\\*\\)\\(\\)" \
389+ "whatis applied to pointer to function returning pointer to int"
390+
391+gdb_test "whatis int *(**)()" \
392+ "type = int \\*\\(\\*\\*\\)\\(\\)" \
393+ "whatis applied to pointer to pointer to function returning pointer to int"
394+
395+gdb_test "whatis char (*(*)())\[23\]" \
396+ "type = char \\(\\*\\(\\*\\)\\(\\)\\)\\\[23\\\]" \
397+ "whatis applied to pointer to function returning pointer to array"
398+
399+gdb_test "whatis int (*)(int, int)" \
400+ "type = int \\(\\*\\)\\(int, int\\)" \
401+ "whatis applied to pointer to function taking int,int and returning int"
402+
403+gdb_test "whatis int (*)(const int *, ...)" \
404+ "type = int \\(\\*\\)\\(const int \\*, \\.\\.\\.\\)" \
405+ "whatis applied to pointer to function taking const int ptr and varargs and returning int"
406+
407+gdb_test "whatis int (*)(void, int, int)" \
408+ "parameter types following 'void'" \
409+ "whatis applied to function with types trailing 'void'"
410+
411+gdb_test "whatis int (*)(int, void, int)" \
412+ "'void' invalid as parameter type" \
413+ "whatis applied to function with 'void' parameter type"
--- a/gdb/ctf.h
+++ b/gdb/tracectf.h
@@ -17,8 +17,8 @@
1717 You should have received a copy of the GNU General Public License
1818 along with this program. If not, see <http://www.gnu.org/licenses/>. */
1919
20-#ifndef CTF_H
21-#define CTF_H
20+#ifndef TRACECTF_H
21+#define TRACECTF_H
2222
2323 extern struct trace_file_writer *ctf_trace_file_writer_new (void);
2424
--- a/gdb/tracefile.c
+++ b/gdb/tracefile.c
@@ -19,7 +19,7 @@
1919
2020 #include "defs.h"
2121 #include "tracefile.h"
22-#include "ctf.h"
22+#include "tracectf.h"
2323 #include "exec.h"
2424 #include "regcache.h"
2525 #include "gdbsupport/byte-vector.h"
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -51,7 +51,6 @@
5151 #include "memrange.h"
5252 #include "cli/cli-utils.h"
5353 #include "probe.h"
54-#include "ctf.h"
5554 #include "gdbsupport/filestuff.h"
5655 #include "gdbsupport/rsp-low.h"
5756 #include "tracefile.h"