
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. +
114 lines
4.8 KiB
Text
114 lines
4.8 KiB
Text
# 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/>. */
|
|
|
|
# This file is a subset of constvars.exp, written by
|
|
# Elena Zannoni (elz@apollo.hp.com)
|
|
#
|
|
# This file is part of the gdb testsuite
|
|
#
|
|
# tests for const variables
|
|
# const pointers to vars
|
|
# pointers to const variables
|
|
# const pointers to const vars
|
|
# with mixed types
|
|
|
|
#
|
|
# test running programs
|
|
#
|
|
# -gt generates full-fledged CTF.
|
|
|
|
standard_testfile .c
|
|
set opts "additional_flags=-gt"
|
|
|
|
if { [prepare_for_testing "failed to prepare" ${testfile} \
|
|
[list $srcfile] [list $opts nowarnings]] } {
|
|
return 0
|
|
}
|
|
|
|
#
|
|
# set it up at a breakpoint so we can play with the variable values
|
|
#
|
|
if ![runto_main] then {
|
|
perror "couldn't run to breakpoint"
|
|
continue
|
|
}
|
|
|
|
# test vars and pointers
|
|
|
|
proc do_constvar_tests {} {
|
|
gdb_test "print vox" " = 66 'B'"
|
|
gdb_test "ptype vox" "type = volatile char"
|
|
gdb_test "print victuals" " = 67 'C'"
|
|
gdb_test "ptype victuals" "type = volatile unsigned char"
|
|
gdb_test "print vixen" " = 200"
|
|
gdb_test "ptype vixen" "type = volatile short.*"
|
|
gdb_test "print vitriol" " = 300"
|
|
gdb_test "ptype vitriol" "type = volatile (unsigned short|short unsigned)( int)?"
|
|
gdb_test "print vellum" " = 1000"
|
|
gdb_test "ptype vellum" "type = volatile long.*"
|
|
gdb_test "print valve" " = 2000"
|
|
gdb_test "ptype valve" "type = volatile (unsigned long|long unsigned)( int)?"
|
|
gdb_test "print vacuity" " = 3"
|
|
gdb_test "ptype vacuity" "type = volatile float"
|
|
gdb_test "print vertigo" " = 10"
|
|
gdb_test "ptype vertigo" "type = volatile double"
|
|
gdb_test "print laconic" " = 65 'A'"
|
|
|
|
gdb_test "ptype vampire" "type = volatile char.*"
|
|
gdb_test "ptype viper" "type = volatile unsigned char.*"
|
|
gdb_test "ptype vigour" "type = volatile short.*"
|
|
gdb_test "ptype vapour" "type = volatile (unsigned short|short unsigned)( int)?.*"
|
|
gdb_test "ptype ventricle" "type = volatile long.*"
|
|
gdb_test "ptype vigintillion" "type = volatile (unsigned long|long unsigned)( int)?.*"
|
|
gdb_test "ptype vocation" "type = volatile float.*"
|
|
gdb_test "ptype veracity" "type = volatile double.*"
|
|
|
|
gdb_test "ptype vapidity" "type = volatile char.* volatile"
|
|
gdb_test "ptype velocity" "type = volatile unsigned char.* volatile"
|
|
gdb_test "ptype veneer" "type = volatile short.* volatile"
|
|
gdb_test "ptype video" "type = volatile (unsigned short|short unsigned)( int)?.* volatile"
|
|
gdb_test "ptype vacuum" "type = volatile long.* volatile"
|
|
gdb_test "ptype veniality" "type = volatile (unsigned long|long unsigned)( int)?.* volatile"
|
|
gdb_test "ptype vitality" "type = volatile float.* volatile"
|
|
gdb_test "ptype voracity" "type = volatile double.* volatile"
|
|
|
|
gdb_test "ptype violent" "type = volatile char \\\[2\\\]"
|
|
gdb_test "ptype violet" "type = volatile unsigned char \\\[2\\\]"
|
|
gdb_test "ptype vips" "type = volatile short.* \\\[2\\\]"
|
|
gdb_test "ptype virgen" "type = volatile unsigned short.* \\\[2\\\]"
|
|
gdb_test "ptype vulgar" "type = volatile long.* \\\[2\\\]"
|
|
gdb_test "ptype vulture" "type = volatile (unsigned long|long unsigned)( int)? \\\[2\\\]"
|
|
gdb_test "ptype vilify" "type = volatile float \\\[2\\\]"
|
|
gdb_test "ptype villar" "type = volatile double \\\[2\\\]"
|
|
|
|
gdb_test "print victor" " = 89 'Y'"
|
|
gdb_test "ptype victor" "type = const volatile char"
|
|
gdb_test "ptype victory" "type = const volatile char.*"
|
|
gdb_test "ptype cavern" "type = const volatile char.* const"
|
|
gdb_test "ptype caveat" "type = const char.* volatile"
|
|
gdb_test "ptype covenant" "type = const unsigned char.* volatile"
|
|
gdb_test "ptype vanadium" "type = const volatile unsigned char.* volatile"
|
|
|
|
gdb_test "ptype cove" "type = const char.* const volatile"
|
|
gdb_test "ptype cavity" "type = const unsigned char.* const volatile"
|
|
gdb_test "ptype vagus" "type = volatile char.* const volatile"
|
|
gdb_test "ptype vagrancy" "type = volatile unsigned char.* const volatile"
|
|
gdb_test "ptype vagary" "type = const volatile char.* const volatile"
|
|
gdb_test "ptype vendor" "type = const volatile unsigned char.* const volatile"
|
|
gdb_test "ptype vindictive" "type = const volatile char \\\[2\\\]"
|
|
gdb_test "ptype vegetation" "type = const volatile unsigned char \\\[2\\\]"
|
|
}
|
|
|
|
do_constvar_tests
|