DWARF-5: .debug_names index consumer

Some testcases needed to be updated as they were missing
.debug_aranges.  While that does not matter for no-index (as GDB
builds the mapping internally during dwarf2_build_psymtabs_hard) and
neither for .gdb_index (as GDB uses that internally built mapping
which it stores into .gdb_index) it does matter for .debug_names as
that simply assumes existing .debug_aranges from GCC.

gdb/ChangeLog:
2017-12-08  Jan Kratochvil  <jan.kratochvil@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	* defs.h (elf_sym_fns_debug_names): New declaration.
	* dwarf2read.c: Include "hash_enum.h".
	(mapped_debug_names): New.
	(struct dwarf2_per_objfile): Add debug_names, debug_aranges and
	debug_names_table.
	(dwarf2_elf_names): Add ".debug_names" and ".debug_aranges".
	(struct dwz_file): Add debug_names.
	(dwarf2_per_objfile::locate_sections): Handle debug_names and
	debug_aranges.
	(locate_dwz_sections): Handle debug_names.
	(create_signatured_type_table_from_debug_names)
	(create_addrmap_from_aranges): New.
	(dwarf2_read_index): Update function comment.
	(dwarf5_augmentation): Moved up.
	(read_debug_names_from_section, create_cus_from_debug_names_list)
	(create_cus_from_debug_names, dwarf2_read_debug_names): New.
	(dwarf5_djb_hash): Moved up.
	(dw2_debug_names_iterator): New.
	(read_indirect_string_at_offset): New declaration.
	(mapped_debug_names::namei_to_name)
	(dw2_debug_names_iterator::find_vec_in_debug_names)
	(dw2_debug_names_iterator::next, dw2_debug_names_lookup_symbol)
	(dw2_debug_names_dump, dw2_debug_names_expand_symtabs_for_function)
	(dw2_debug_names_expand_symtabs_matching, dwarf2_debug_names_functions):
	New.
	(dwarf2_initialize_objfile): Return also elf_sym_fns_debug_names.
	(debug_names::djb_hash): Rename it to dwarf5_djb_hash.
	(debug_names::build): Update djb_hash caller.
	(write_debug_names): Move out and rename augmentation to
	dwarf5_augmentation.
	* elfread.c (elf_sym_fns_debug_names): New.
	* psymtab.h (dwarf2_debug_names_functions): New declaration.
	* symfile.h (struct dwarf2_debug_sections): Add debug_names and
	debug_aranges.
	* xcoffread.c (dwarf2_xcoff_names): Add debug_names and debug_aranges.

gdb/testsuite/ChangeLog:
2017-12-08  Jan Kratochvil  <jan.kratochvil@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	* gdb.base/maint.exp (check for .gdb_index): Check also for
	.debug_names.
	* gdb.dlang/watch-loc.c (.debug_aranges): New.
	* gdb.dwarf2/dw2-case-insensitive-debug.S: Likewise.
	* gdb.dwarf2/gdb-index.exp (check if index present, .gdb_index used)
	(.gdb_index used after symbol reloading): Support also .debug_names.
	* gdb.mi/dw2-ref-missing-frame-func.c (.debug_aranges): New.
This commit is contained in:
Jan Kratochvil 2017-12-08 22:44:12 +00:00 committed by Pedro Alves
parent e5fa6583a7
commit 927aa2e778
13 changed files with 1257 additions and 29 deletions

View File

@ -1,3 +1,42 @@
2017-12-08 Jan Kratochvil <jan.kratochvil@redhat.com>
Pedro Alves <palves@redhat.com>
* defs.h (elf_sym_fns_debug_names): New declaration.
* dwarf2read.c: Include "hash_enum.h".
(mapped_debug_names): New.
(struct dwarf2_per_objfile): Add debug_names, debug_aranges and
debug_names_table.
(dwarf2_elf_names): Add ".debug_names" and ".debug_aranges".
(struct dwz_file): Add debug_names.
(dwarf2_per_objfile::locate_sections): Handle debug_names and
debug_aranges.
(locate_dwz_sections): Handle debug_names.
(create_signatured_type_table_from_debug_names)
(create_addrmap_from_aranges): New.
(dwarf2_read_index): Update function comment.
(dwarf5_augmentation): Moved up.
(read_debug_names_from_section, create_cus_from_debug_names_list)
(create_cus_from_debug_names, dwarf2_read_debug_names): New.
(dwarf5_djb_hash): Moved up.
(dw2_debug_names_iterator): New.
(read_indirect_string_at_offset): New declaration.
(mapped_debug_names::namei_to_name)
(dw2_debug_names_iterator::find_vec_in_debug_names)
(dw2_debug_names_iterator::next, dw2_debug_names_lookup_symbol)
(dw2_debug_names_dump, dw2_debug_names_expand_symtabs_for_function)
(dw2_debug_names_expand_symtabs_matching, dwarf2_debug_names_functions):
New.
(dwarf2_initialize_objfile): Return also elf_sym_fns_debug_names.
(debug_names::djb_hash): Rename it to dwarf5_djb_hash.
(debug_names::build): Update djb_hash caller.
(write_debug_names): Move out and rename augmentation to
dwarf5_augmentation.
* elfread.c (elf_sym_fns_debug_names): New.
* psymtab.h (dwarf2_debug_names_functions): New declaration.
* symfile.h (struct dwarf2_debug_sections): Add debug_names and
debug_aranges.
* xcoffread.c (dwarf2_xcoff_names): Add debug_names and debug_aranges.
2017-12-08 Pedro Alves <palves@redhat.com>
* common/hash_enum.h: New file.

View File

@ -683,6 +683,7 @@ extern void initialize_inferiors (void);
extern const struct sym_fns elf_sym_fns_lazy_psyms;
extern const struct sym_fns elf_sym_fns_gdb_index;
extern const struct sym_fns elf_sym_fns_debug_names;
/* * Special block numbers */

File diff suppressed because it is too large Load Diff

View File

@ -1403,6 +1403,23 @@ const struct sym_fns elf_sym_fns_gdb_index =
&dwarf2_gdb_index_functions
};
/* The same as elf_sym_fns, but not registered and uses the
DWARF-specific .debug_names index rather than psymtab. */
const struct sym_fns elf_sym_fns_debug_names =
{
elf_new_init, /* init anything gbl to entire symab */
elf_symfile_init, /* read initial info, setup for sym_red() */
elf_symfile_read, /* read a symbol file into symtab */
NULL, /* sym_read_psymbols */
elf_symfile_finish, /* finished with file, cleanup */
default_symfile_offsets, /* Translate ext. to int. relocatin */
elf_symfile_segments, /* Get segment information from a file. */
NULL,
default_symfile_relocate, /* Relocate a debug section. */
&elf_probe_fns, /* sym_probe_fns */
&dwarf2_debug_names_functions
};
/* STT_GNU_IFUNC resolver vector to be installed to gnu_ifunc_fns_p. */
static const struct gnu_ifunc_fns elf_gnu_ifunc_fns =

View File

@ -33,6 +33,7 @@ extern struct bcache *psymbol_bcache_get_bcache (struct psymbol_bcache *);
extern const struct quick_symbol_functions psym_functions;
extern const struct quick_symbol_functions dwarf2_gdb_index_functions;
extern const struct quick_symbol_functions dwarf2_debug_names_functions;
/* Ensure that the partial symbols for OBJFILE have been loaded. If
VERBOSE is non-zero, then this will print a message when symbols

View File

@ -582,6 +582,8 @@ struct dwarf2_debug_sections {
struct dwarf2_section_names frame;
struct dwarf2_section_names eh_frame;
struct dwarf2_section_names gdb_index;
struct dwarf2_section_names debug_names;
struct dwarf2_section_names debug_aranges;
/* This field has no meaning, but exists solely to catch changes to
this structure which are not reflected in some instance. */
int sentinel;

View File

@ -1,3 +1,14 @@
2017-12-08 Jan Kratochvil <jan.kratochvil@redhat.com>
Pedro Alves <palves@redhat.com>
* gdb.base/maint.exp (check for .gdb_index): Check also for
.debug_names.
* gdb.dlang/watch-loc.c (.debug_aranges): New.
* gdb.dwarf2/dw2-case-insensitive-debug.S: Likewise.
* gdb.dwarf2/gdb-index.exp (check if index present, .gdb_index used)
(.gdb_index used after symbol reloading): Support also .debug_names.
* gdb.mi/dw2-ref-missing-frame-func.c (.debug_aranges): New.
2017-12-08 Yao Qi <yao.qi@linaro.org>
* gdb.arch/aarch64-tagged-pointer.c (main): Update.

View File

@ -89,10 +89,13 @@ if ![runto_main] then {
perror "tests suppressed"
}
# If we're using .gdb_index there will be no psymtabs.
# If we're using .gdb_index or .debug_names there will be no psymtabs.
set have_gdb_index 0
gdb_test_multiple "maint info sections .gdb_index" "check for .gdb_index" {
-re ": .gdb_index.*$gdb_prompt $" {
gdb_test_multiple "maint info sections .gdb_index .debug_names" "check for .gdb_index" {
-re ": \\.gdb_index .*\r\n$gdb_prompt $" {
set have_gdb_index 1
}
-re ": \\.debug_names .*\r\n$gdb_prompt $" {
set have_gdb_index 1
}
-re ".*$gdb_prompt $" {

View File

@ -34,3 +34,23 @@ main (void)
return _Dmain ();
}
/* The .debug_names-based index support depends on .debug_aranges
generated by GCC. (.gdb_index includes a gdb-generated map
instead.) */
asm (
" .pushsection .debug_aranges,\"\",@progbits \n"
" .4byte .Laranges_end - .Laranges_start \n" // Length of Address Ranges Info
".Laranges_start: \n"
" .2byte 0x2 \n" // DWARF Version
" .4byte 0 \n" // .Ldebug_info0 - Offset of Compilation Unit Info
" .byte 4 \n" // Size of Address
" .byte 0 \n" // Size of Segment Descriptor
" .2byte 0 \n" // Pad to 16 byte boundary
" .2byte 0 \n"
" .4byte _Dmain \n" // Address
" .4byte 0x1000 \n" // Length
" .4byte 0 \n"
" .4byte 0 \n"
".Laranges_end: \n"
" .popsection \n"
);

View File

@ -57,6 +57,24 @@
.byte 0 /* End of children of CU */
.Lcu1_end:
/* The .debug_names-based index support depends on
.debug_aranges generated by GCC. (.gdb_index includes a
gdb-generated map instead.) */
.section .debug_aranges,"",@progbits
.4byte .Laranges_end - .Laranges_start // Length of Address Ranges Info
.Laranges_start:
.2byte 0x2 // DWARF Version
.4byte 0 // .Ldebug_info0 - Offset of Compilation Unit Info
.byte PTRBITS / 8 // Size of Address
.byte 0 // Size of Segment Descriptor
.2byte 0 // Pad to 16 byte boundary
.2byte 0
PTRBYTE cu_text_start // Address
PTRBYTE 0x1000 // cu_text_end - cu_text_start // Length
PTRBYTE 0
PTRBYTE 0
.Laranges_end:
/* Abbrev table */
.section .debug_abbrev
.Labbrev1_begin:

View File

@ -58,7 +58,7 @@ proc add_gdb_index { program } {
return ${program_with_index}
}
# Build a copy of the program with .gdb_index.
# Build a copy of the program with an index (.gdb_index/.debug_names).
# But only if the toolchain didn't already create one: gdb doesn't support
# building an index from a program already using one.
@ -67,6 +67,9 @@ gdb_test_multiple "mt print objfiles ${testfile}" $test {
-re "gdb_index.*${gdb_prompt} $" {
set binfile_with_index $binfile
}
-re "debug_names.*${gdb_prompt} $" {
set binfile_with_index $binfile
}
-re "Psymtabs.*${gdb_prompt} $" {
set binfile_with_index [add_gdb_index $binfile]
if { ${binfile_with_index} == "" } {
@ -75,16 +78,16 @@ gdb_test_multiple "mt print objfiles ${testfile}" $test {
}
}
# Ok, we have a copy of $binfile with .gdb_index.
# Ok, we have a copy of $binfile with an index.
# Restart gdb and verify the index was used.
clean_restart ${binfile_with_index}
gdb_test "mt print objfiles ${testfile}" \
"gdb_index.*" \
".gdb_index used"
"(gdb_index|debug_names).*" \
"index used"
# Make gdb re-read symbols and see if .gdb_index still gets used.
# symtab/15885
# Make gdb re-read symbols and see if .gdb_index/.debug_names still
# gets used. symtab/15885
# There is gdb_touch_execfile, but it doesn't handle remote hosts.
# Is touch portable enough?
@ -98,5 +101,5 @@ if ![runto_main] {
return -1
}
gdb_test "mt print objfiles ${testfile}" \
"gdb_index.*" \
".gdb_index used after symbol reloading"
"(gdb_index|debug_names).*" \
"index used after symbol reloading"

View File

@ -52,3 +52,24 @@ asm ("func_loopfb_end:");
asm (".globl cu_text_end");
asm ("cu_text_end:");
/* The .debug_names-based index support depends on .debug_aranges
generated by GCC. (.gdb_index includes a gdb-generated map
instead.) */
asm (
" .pushsection .debug_aranges,\"\",@progbits \n"
" .4byte .Laranges_end - .Laranges_start \n" // Length of Address Ranges Info
".Laranges_start: \n"
" .2byte 0x2 \n" // DWARF Version
" .4byte 0 \n" // .Ldebug_info0 - Offset of Compilation Unit Info
" .byte 4 \n" // Size of Address
" .byte 0 \n" // Size of Segment Descriptor
" .2byte 0 \n" // Pad to 16 byte boundary
" .2byte 0 \n"
" .4byte cu_text_start \n" // Address
" .4byte cu_text_end - cu_text_start \n" // Length
" .4byte 0 \n"
" .4byte 0 \n"
".Laranges_end: \n"
" .popsection \n"
);

View File

@ -174,6 +174,8 @@ static const struct dwarf2_debug_sections dwarf2_xcoff_names = {
{ ".dwframe", NULL },
{ NULL, NULL }, /* eh_frame */
{ NULL, NULL }, /* gdb_index */
{ NULL, NULL }, /* debug_names */
{ NULL, NULL }, /* debug_aranges */
23
};