binutils/

* dwarf.c (do_debug_addr, do_debug_cu_index): New global flags.
	(load_debug_info): Fix typo.
	(cu_tu_indexes_read, shndx_pool, shndx_pool_size, shndx_pool_used):
	New global variables.
	(prealloc_cu_tu_list, add_shndx_to_cu_tu_entry, end_cu_tu_entry)
	(process_cu_tu_index, load_cu_tu_indexes, find_cu_tu_set)
	(display_cu_index): New functions.
	(dwarf_select_sections_by_names): Add "debug_addr", "cu_index".
	Sort entries alphabetically.
	(dwarf_select_sections_all): Set do_debug_addr, do_debug_cu_index.
	(debug_displays): Add .debug_cu_index, .debug_tu_index.
	Clean up formatting.
	* dwarf.h (dwarf_section_display_enum): Add dwp_cu_index,
	dwp_tu_index.
	(do_debug_addr, do_debug_cu_index): New global flags.
	(find_cu_tu_set): New function declaration.
	* objdump.c (usage): Add --dwarf=addr, --dwarf=cu_index.
	* readelf.c (find_section_in_set): New function.
	(usage): Add --debug-dump=addr, --debug_dump=cu_index.
	(process_section_headers): Check do_debug_addr and do_debug_cu_index.
	(section_subset): New global variable.
	(load_debug_section): Restrict search to section subset.
	(display_debug_section): Add section index as paramter.  Select subset
	of sections when dumping a .dwp file.  Update caller.
This commit is contained in:
Cary Coutant 2012-10-24 01:59:39 +00:00
parent c886f0b40c
commit 657d0d47ba
5 changed files with 326 additions and 50 deletions

View file

@ -505,6 +505,24 @@ find_section_by_address (bfd_vma addr)
return NULL;
}
/* Return a pointer to section NAME, or NULL if no such section exists,
restricted to the list of sections given in SET. */
static Elf_Internal_Shdr *
find_section_in_set (const char * name, unsigned int * set)
{
unsigned int i;
if (set != NULL)
{
while ((i = *set++) > 0)
if (streq (SECTION_NAME (section_headers + i), name))
return section_headers + i;
}
return find_section (name);
}
/* Read an unsigned LEB128 encoded value from p. Set *PLEN to the number of
bytes read. */
@ -3244,7 +3262,8 @@ usage (FILE * stream)
-w[lLiaprmfFsoRt] or\n\
--debug-dump[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,\n\
=frames-interp,=str,=loc,=Ranges,=pubtypes,\n\
=gdb_index,=trace_info,=trace_abbrev,=trace_aranges]\n\
=gdb_index,=trace_info,=trace_abbrev,=trace_aranges,\n\
=addr,=cu_index]\n\
Display the contents of DWARF2 debug sections\n"));
fprintf (stream, _("\
--dwarf-depth=N Do not display DIEs at depth N or greater\n\
@ -4671,7 +4690,8 @@ process_section_headers (FILE * file)
else if ((do_debugging || do_debug_info || do_debug_abbrevs
|| do_debug_lines || do_debug_pubnames || do_debug_pubtypes
|| do_debug_aranges || do_debug_frames || do_debug_macinfo
|| do_debug_str || do_debug_loc || do_debug_ranges)
|| do_debug_str || do_debug_loc || do_debug_ranges
|| do_debug_addr || do_debug_cu_index)
&& (const_strneq (name, ".debug_")
|| const_strneq (name, ".zdebug_")))
{
@ -4694,6 +4714,9 @@ process_section_headers (FILE * file)
|| (do_debug_macinfo && const_strneq (name, "macro"))
|| (do_debug_str && const_strneq (name, "str"))
|| (do_debug_loc && const_strneq (name, "loc"))
|| (do_debug_addr && const_strneq (name, "addr"))
|| (do_debug_cu_index && const_strneq (name, "cu_index"))
|| (do_debug_cu_index && const_strneq (name, "tu_index"))
)
request_dump_bynumber (i, DEBUG_DUMP);
}
@ -10673,6 +10696,10 @@ load_specific_debug_section (enum dwarf_section_display_enum debug,
return 1;
}
/* If this is not NULL, load_debug_section will only look for sections
within the list of sections given here. */
unsigned int *section_subset = NULL;
int
load_debug_section (enum dwarf_section_display_enum debug, void * file)
{
@ -10680,18 +10707,24 @@ load_debug_section (enum dwarf_section_display_enum debug, void * file)
Elf_Internal_Shdr * sec;
/* Locate the debug section. */
sec = find_section (section->uncompressed_name);
sec = find_section_in_set (section->uncompressed_name, section_subset);
if (sec != NULL)
section->name = section->uncompressed_name;
else
{
sec = find_section (section->compressed_name);
sec = find_section_in_set (section->compressed_name, section_subset);
if (sec != NULL)
section->name = section->compressed_name;
}
if (sec == NULL)
return 0;
/* If we're loading from a subset of sections, and we've loaded
a section matching this name before, it's likely that it's a
different one. */
if (section_subset != NULL)
free_debug_section (debug);
return load_specific_debug_section (debug, sec, (FILE *) file);
}
@ -10710,7 +10743,7 @@ free_debug_section (enum dwarf_section_display_enum debug)
}
static int
display_debug_section (Elf_Internal_Shdr * section, FILE * file)
display_debug_section (int shndx, Elf_Internal_Shdr * section, FILE * file)
{
char * name = SECTION_NAME (section);
bfd_size_type length;
@ -10754,8 +10787,14 @@ display_debug_section (Elf_Internal_Shdr * section, FILE * file)
if (load_specific_debug_section ((enum dwarf_section_display_enum) i,
section, file))
{
/* If this debug section is part of a CU/TU set in a .dwp file,
restrict load_debug_section to the sections in that set. */
section_subset = find_cu_tu_set (file, shndx);
result &= debug_displays[i].display (sec, file);
section_subset = NULL;
if (secondary || (i != info && i != abbrev))
free_debug_section ((enum dwarf_section_display_enum) i);
}
@ -10827,7 +10866,7 @@ process_section_contents (FILE * file)
dump_section_as_strings (section, file);
if (dump_sects[i] & DEBUG_DUMP)
display_debug_section (section, file);
display_debug_section (i, section, file);
}
/* Check to see if the user requested a