summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base/ctf-constvars.c
diff options
context:
space:
mode:
authorWeimin Pan <weimin.pan@oracle.com>2019-10-07 00:46:52 +0000
committerWeimin Pan <weimin.pan@oracle.com>2019-10-07 02:26:27 +0000
commit30d1f0184953478d14641c495261afd06ebfabac (patch)
tree8fde16f1b36e4bc889e54f9803d94cee835b66be /gdb/testsuite/gdb.base/ctf-constvars.c
parent518fe38cd9c206b2a239d9b93677017203c385cb (diff)
downloadbinutils-gdb-30d1f0184953478d14641c495261afd06ebfabac.tar.gz
gdb: CTF support
This patch adds the CTF (Compact Ansi-C Type Format) support in gdb. Two submissions on which this gdb work depends were posted earlier in May: * On the binutils mailing list - adding libctf which creates, updates, reads, and manipulates the CTF data. * On the gcc mailing list - expanding gcc to directly emit the CFT data with a new command line option -gt. CTF is a reduced form of debugging information whose main purpose is to describe the type of C entities such as structures, unions, typedefs and function arguments at the global scope only. It does not contain debug information about source lines, location expressions, or local variables. For more information on CTF, see the documentation in the libdtrace-ctf source tree, available here: <https://raw.githubusercontent.com/oracle/libdtrace-ctf/master/doc/ctf-format>. This patch expands struct elfinfo by adding the .ctf section, which contains CTF debugging info, and modifies elf_symfile_read() to read it. If both DWARF and CTF exist in a program, only DWARF will be read. CTF data will be read only when there is no DWARF. The two-stage symbolic reading and setting strategy, partial and full, was used. File ctfread.c contains functions to transform CTF data into gdb's internal symbol table structures by iterately reading entries from CTF sections of "data objects", "function info", "variable info", and "data types" when setting up either partial or full symbol table. If the ELF symbol table is available, e.g. not stripped, the CTF reader will associate the found type information with these symbol entries. Due to the proximity between DWARF and CTF (CTF being a much simplified subset of DWARF), some DWARF implementation was reused to support CTF. Test cases ctf-constvars.exp, ctf-cvexpr.exp, ctf-ptype.exp, and ctf-whatis.exp have been added to verify the correctness of this support. This patch has missing features and limitations which we will add and address in the future patches. gdb/ChangeLog +2019-10-07 Weimin Pan <weimin.pan@oracle.com> + + * gdb/ctfread.c: New file. + * gdb/ctfread.h: New file. + * gdb/elfread.c: Include ctfread.h. + (struct elfinfo text_p): New member ctfsect. + (elf_locate_sections): Mark CTF section. + (elf_symfile_read): Call elfctf_build_psymtabs. + * gdb/Makefile.in (LIBCTF): Add. + (CLIBS): Use it. + (CDEPS): Likewise. + (DIST): Add ctfread.c. + * Makefile.def (dependencies): Add all-libctf to all-gdb + * Makefile.in: Add "all-gdb: maybe-all-libctf" + gdb/testsuite/ChangeLog +2019-10-07 Weimin Pan <weimin.pan@oracle.com> + + * gdb.base/ctf-whatis.exp: New file. + * gdb.base/ctf-whatis.c: New file. + * gdb.base/ctf-ptype.exp: New file. + * gdb.base/ctf-ptype.c: New file. + * gdb.base/ctf-constvars.exp: New file. + * gdb.base/ctf-constvars.c: New file. + * gdb.base/ctf-cvexpr.exp: New file. +
Diffstat (limited to 'gdb/testsuite/gdb.base/ctf-constvars.c')
-rw-r--r--gdb/testsuite/gdb.base/ctf-constvars.c116
1 files changed, 116 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.base/ctf-constvars.c b/gdb/testsuite/gdb.base/ctf-constvars.c
new file mode 100644
index 00000000000..75f4250d474
--- /dev/null
+++ b/gdb/testsuite/gdb.base/ctf-constvars.c
@@ -0,0 +1,116 @@
+/* This test program is part of GDB, the GNU debugger.
+
+ Copyright 2019 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+const char laconic = 'A';
+const char *const lewd=&laconic;
+
+/* volatile variables */
+
+volatile char vox = 'B';
+volatile unsigned char victuals = 'C';
+volatile short vixen = 200;
+volatile unsigned short vitriol = 300;
+volatile long vellum = 1000;
+volatile unsigned long valve = 2000;
+volatile float vacuity = 3.0;
+volatile double vertigo = 10;
+
+/* pointers to volatile variables */
+
+volatile char * vampire = &vox;
+volatile unsigned char * viper = &victuals;
+volatile short * vigour = &vixen;
+volatile unsigned short * vapour = &vitriol;
+volatile long * ventricle = &vellum;
+volatile unsigned long * vigintillion = &valve;
+volatile float * vocation = &vacuity;
+volatile double * veracity = &vertigo;
+
+/* volatile pointers to volatile variables */
+
+volatile char * volatile vapidity = &vox;
+volatile unsigned char * volatile velocity = &victuals;
+volatile short * volatile veneer = &vixen;
+volatile unsigned short * volatile video = &vitriol;
+volatile long * volatile vacuum = &vellum;
+volatile unsigned long * volatile veniality = &valve;
+volatile float * volatile vitality = &vacuity;
+volatile double * volatile voracity = &vertigo;
+
+/* volatile arrays */
+
+volatile char violent[2];
+volatile unsigned char violet[2];
+volatile short vips[2];
+volatile unsigned short virgen[2];
+volatile long vulgar[2];
+volatile unsigned long vulture[2];
+volatile float vilify[2];
+volatile double villar[2];
+
+/* const volatile vars */
+
+const volatile char victor = 'Y';
+
+/* pointers to const volatiles */
+
+const volatile char * victory = &victor;
+
+/* const pointers to const volatile vars */
+
+const volatile char * const cavern = &victor;
+
+/* volatile pointers to const vars */
+
+const char * volatile caveat = &laconic;
+const unsigned char * volatile covenant;
+
+/* volatile pointers to const volatile vars */
+
+const volatile char * volatile vizier = &victor;
+const volatile unsigned char * volatile vanadium;
+
+/* const volatile pointers */
+
+char * const volatile vane;
+unsigned char * const volatile veldt;
+
+/* const volatile pointers to const vars */
+
+const char * const volatile cove;
+const unsigned char * const volatile cavity;
+
+/* const volatile pointers to volatile vars */
+
+volatile char * const volatile vagus;
+volatile unsigned char * const volatile vagrancy;
+
+/* const volatile pointers to const volatile */
+
+const volatile char * const volatile vagary;
+const volatile unsigned char * const volatile vendor;
+
+/* const volatile arrays */
+
+const volatile char vindictive[2];
+const volatile unsigned char vegetation[2];
+
+int
+main (void)
+{
+ return 0;
+}