Extend the DWARF decoder to display FORM names when operating in wide mode.

PR 26847
	* dwarf.c (read_and_display_attr_value): In wide mode, display the
	name of the form.
This commit is contained in:
Nick Clifton
2020-11-09 10:37:51 +00:00
parent a4e91c4630
commit 521d4b194f
2 changed files with 109 additions and 47 deletions

View File

@ -1,3 +1,9 @@
2020-11-09 Nick Clifton <nickc@redhat.com>
PR 26847
* dwarf.c (read_and_display_attr_value): In wide mode, display the
name of the form.
2020-11-09 Alan Modra <amodra@gmail.com> 2020-11-09 Alan Modra <amodra@gmail.com>
* elfedit (usage): Avoid false positive "may be used uninitialised". * elfedit (usage): Avoid false positive "may be used uninitialised".

View File

@ -2411,6 +2411,17 @@ read_and_display_attr_value (unsigned long attribute,
return data; return data;
} }
if (do_wide && ! do_loc)
{
/* PR 26847: Display the name of the form. */
const char * name = get_FORM_name (form);
/* For convenience we skip the DW_FORM_ prefix to the name. */
if (name[0] == 'D')
name += 8; /* strlen ("DW_FORM_") */
printf ("%c(%s)", delimiter, name);
}
switch (form) switch (form)
{ {
default: default:
@ -2492,7 +2503,13 @@ read_and_display_attr_value (unsigned long attribute,
case DW_FORM_GNU_ref_alt: case DW_FORM_GNU_ref_alt:
if (!do_loc) if (!do_loc)
printf ("%c<alt 0x%s>", delimiter, dwarf_vmatoa ("x", uvalue)); {
if (do_wide)
/* We have already printed the form name. */
printf ("%c<0x%s>", delimiter, dwarf_vmatoa ("x", uvalue));
else
printf ("%c<alt 0x%s>", delimiter, dwarf_vmatoa ("x", uvalue));
}
/* FIXME: Follow the reference... */ /* FIXME: Follow the reference... */
break; break;
@ -2620,16 +2637,32 @@ read_and_display_attr_value (unsigned long attribute,
case DW_FORM_strp: case DW_FORM_strp:
if (!do_loc) if (!do_loc)
printf (_("%c(indirect string, offset: 0x%s): %s"), delimiter, {
dwarf_vmatoa ("x", uvalue), if (do_wide)
fetch_indirect_string (uvalue)); /* We have already displayed the form name. */
printf (_("%c(offset: 0x%s): %s"), delimiter,
dwarf_vmatoa ("x", uvalue),
fetch_indirect_string (uvalue));
else
printf (_("%c(indirect string, offset: 0x%s): %s"), delimiter,
dwarf_vmatoa ("x", uvalue),
fetch_indirect_string (uvalue));
}
break; break;
case DW_FORM_line_strp: case DW_FORM_line_strp:
if (!do_loc) if (!do_loc)
printf (_("%c(indirect line string, offset: 0x%s): %s"), delimiter, {
dwarf_vmatoa ("x", uvalue), if (do_wide)
fetch_indirect_line_string (uvalue)); /* We have already displayed the form name. */
printf (_("%c(offset: 0x%s): %s"), delimiter,
dwarf_vmatoa ("x", uvalue),
fetch_indirect_line_string (uvalue));
else
printf (_("%c(indirect line string, offset: 0x%s): %s"), delimiter,
dwarf_vmatoa ("x", uvalue),
fetch_indirect_line_string (uvalue));
}
break; break;
case DW_FORM_GNU_str_index: case DW_FORM_GNU_str_index:
@ -2638,18 +2671,30 @@ read_and_display_attr_value (unsigned long attribute,
const char * suffix = strrchr (section->name, '.'); const char * suffix = strrchr (section->name, '.');
bfd_boolean dwo = (suffix && strcmp (suffix, ".dwo") == 0) ? TRUE : FALSE; bfd_boolean dwo = (suffix && strcmp (suffix, ".dwo") == 0) ? TRUE : FALSE;
printf (_("%c(indexed string: 0x%s): %s"), delimiter, if (do_wide)
dwarf_vmatoa ("x", uvalue), /* We have already displayed the form name. */
fetch_indexed_string (uvalue, this_set, offset_size, dwo)); printf (_("%c(offset: 0x%s): %s"), delimiter,
dwarf_vmatoa ("x", uvalue),
fetch_indexed_string (uvalue, this_set, offset_size, dwo));
else
printf (_("%c(indexed string: 0x%s): %s"), delimiter,
dwarf_vmatoa ("x", uvalue),
fetch_indexed_string (uvalue, this_set, offset_size, dwo));
} }
break; break;
case DW_FORM_GNU_strp_alt: case DW_FORM_GNU_strp_alt:
if (!do_loc) if (!do_loc)
{ {
printf (_("%c(alt indirect string, offset: 0x%s) %s"), delimiter, if (do_wide)
dwarf_vmatoa ("x", uvalue), /* We have already displayed the form name. */
fetch_alt_indirect_string (uvalue)); printf (_("%c(offset: 0x%s) %s"), delimiter,
dwarf_vmatoa ("x", uvalue),
fetch_alt_indirect_string (uvalue));
else
printf (_("%c(alt indirect string, offset: 0x%s) %s"), delimiter,
dwarf_vmatoa ("x", uvalue),
fetch_alt_indirect_string (uvalue));
} }
break; break;
@ -2664,17 +2709,30 @@ read_and_display_attr_value (unsigned long attribute,
char buf[64]; char buf[64];
SAFE_BYTE_GET64 (data, &high_bits, &uvalue, end); SAFE_BYTE_GET64 (data, &high_bits, &uvalue, end);
printf ("%csignature: 0x%s", delimiter, if (do_wide)
dwarf_vmatoa64 (high_bits, uvalue, buf, sizeof (buf))); /* We have already displayed the form name. */
printf ("%c: 0x%s", delimiter,
dwarf_vmatoa64 (high_bits, uvalue, buf, sizeof (buf)));
else
printf ("%csignature: 0x%s", delimiter,
dwarf_vmatoa64 (high_bits, uvalue, buf, sizeof (buf)));
} }
data += 8; data += 8;
break; break;
case DW_FORM_GNU_addr_index: case DW_FORM_GNU_addr_index:
if (!do_loc) if (!do_loc)
printf (_("%c(addr_index: 0x%s): %s"), delimiter, {
dwarf_vmatoa ("x", uvalue), if (do_wide)
fetch_indexed_value (uvalue * pointer_size, pointer_size)); /* We have already displayed the form name. */
printf (_("%c(index: 0x%s): %s"), delimiter,
dwarf_vmatoa ("x", uvalue),
fetch_indexed_value (uvalue * pointer_size, pointer_size));
else
printf (_("%c(addr_index: 0x%s): %s"), delimiter,
dwarf_vmatoa ("x", uvalue),
fetch_indexed_value (uvalue * pointer_size, pointer_size));
}
break; break;
default: default:
@ -7369,7 +7427,6 @@ display_debug_ranges_list (unsigned char *start, unsigned char *finish,
break; break;
SAFE_SIGNED_BYTE_GET_AND_INC (end, start, pointer_size, finish); SAFE_SIGNED_BYTE_GET_AND_INC (end, start, pointer_size, finish);
printf (" %8.8lx ", offset); printf (" %8.8lx ", offset);
if (begin == 0 && end == 0) if (begin == 0 && end == 0)
@ -10643,7 +10700,6 @@ parse_gnu_debuglink (struct dwarf_section * section, void * data)
The CRC value is stored after the filename, aligned up to 4 bytes. */ The CRC value is stored after the filename, aligned up to 4 bytes. */
name = (const char *) section->start; name = (const char *) section->start;
crc_offset = strnlen (name, section->size) + 1; crc_offset = strnlen (name, section->size) + 1;
crc_offset = (crc_offset + 3) & ~3; crc_offset = (crc_offset + 3) & ~3;
if (crc_offset + 4 > section->size) if (crc_offset + 4 > section->size)