aboutsummaryrefslogtreecommitdiff
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/elfread.c
parentRenaming of ctf (the trace format) files (diff)
downloadbinutils-gdb-30d1f0184953478d14641c495261afd06ebfabac.tar.gz
binutils-gdb-30d1f0184953478d14641c495261afd06ebfabac.tar.bz2
binutils-gdb-30d1f0184953478d14641c495261afd06ebfabac.zip
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/elfread.c')
-rw-r--r--gdb/elfread.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/gdb/elfread.c b/gdb/elfread.c
index d2a7bcf8aa6..53bdd356594 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -47,6 +47,7 @@
#include "location.h"
#include "auxv.h"
#include "mdebugread.h"
+#include "ctfread.h"
/* Forward declarations. */
extern const struct sym_fns elf_sym_fns_gdb_index;
@@ -61,6 +62,7 @@ struct elfinfo
{
asection *stabsect; /* Section pointer for .stab section */
asection *mdebugsect; /* Section pointer for .mdebug section */
+ asection *ctfsect; /* Section pointer for .ctf section */
};
/* Type for per-BFD data. */
@@ -188,6 +190,10 @@ elf_locate_sections (bfd *ignore_abfd, asection *sectp, void *eip)
{
ei->mdebugsect = sectp;
}
+ else if (strcmp (sectp->name, ".ctf") == 0)
+ {
+ ei->ctfsect = sectp;
+ }
}
static struct minimal_symbol *
@@ -1059,7 +1065,8 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags,
go away once all types of symbols are in the per-BFD object. */
if (objfile->per_bfd->minsyms_read
&& ei->stabsect == NULL
- && ei->mdebugsect == NULL)
+ && ei->mdebugsect == NULL
+ && ei->ctfsect == NULL)
{
if (symtab_create_debug)
fprintf_unfiltered (gdb_stdlog,
@@ -1200,6 +1207,7 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
{
bfd *abfd = objfile->obfd;
struct elfinfo ei;
+ bool has_dwarf2 = true;
memset ((char *) &ei, 0, sizeof (ei));
if (!(objfile->flags & OBJF_READNEVER))
@@ -1302,6 +1310,14 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
symbol_file_add_separate (debug_bfd.get (), debugfile.c_str (),
symfile_flags, objfile);
}
+ else
+ has_dwarf2 = false;
+ }
+
+ /* Read the CTF section only if there is no DWARF info. */
+ if (!has_dwarf2 && ei.ctfsect)
+ {
+ elfctf_build_psymtabs (objfile);
}
}