This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[RFA] Add support for pretty-printing .debug_gnu_pubnames, pubtypes
- From: Doug Evans <dje at google dot com>
- To: binutils at sourceware dot org
- Cc: ccoutant at google dot com, saugustine at google dot com
- Date: Wed, 09 Oct 2013 14:15:23 -0700
- Subject: [RFA] Add support for pretty-printing .debug_gnu_pubnames, pubtypes
- Authentication-results: sourceware.org; auth=none
Hi.
This is patch adds support for pretty-printing .debug_gnu_pubnames
and .debug_gnu_pubtypes.
To keep things simple, I changed how symbol kinds are printed
in display_gdb_index. I realize i18n strings are best handled
as complete phrases, but splitting it up into static/global and
function/variable/type/etc. doesn't seem onerous, and I'd
rather keep the code simple.
Ok to check in?
2013-10-09 Doug Evans <dje@google.com>
Add pretty-printing of .debug_gnu_pubnames, .debug_gnu_pubtypes.
* dwarf.c (get_gdb_index_symbol_kind_name): New function.
(display_debug_pubnames_worker): Renamed from display_debug_pubnames.
Add support for .debug_gnu_pubnames, .debug_gnu_pubtypes.
(display_debug_pubnames, display_debug_pubnames_gnu): New functions.
(display_gdb_index): Redo printing of symbol kind.
(debug_displays): Add .debug_gnu_pubnames, .debug_gnu_pubtypes.
* dwarf.h (dwarf_section_display_enum): Add gnu_pubnames, gnu_pubtypes.
* readelf.c (process_section_headers): Add gnu_pubnames, gnu_pubtypes.
Index: dwarf.c
===================================================================
RCS file: /cvs/src/src/binutils/dwarf.c,v
retrieving revision 1.140
diff -u -p -r1.140 dwarf.c
--- dwarf.c 1 Oct 2013 10:32:54 -0000 1.140
+++ dwarf.c 9 Oct 2013 21:04:39 -0000
@@ -3476,9 +3476,29 @@ find_debug_info_for_offset (unsigned lon
return NULL;
}
+static const char *
+get_gdb_index_symbol_kind_name (gdb_index_symbol_kind kind)
+{
+ /* See gdb/gdb-index.h. */
+ static const char * const kinds[] =
+ {
+ N_ ("no info"),
+ N_ ("type"),
+ N_ ("variable"),
+ N_ ("function"),
+ N_ ("other"),
+ N_ ("unused5"),
+ N_ ("unused6"),
+ N_ ("unused7")
+ };
+
+ return kinds[kind];
+}
+
static int
-display_debug_pubnames (struct dwarf_section *section,
- void *file ATTRIBUTE_UNUSED)
+display_debug_pubnames_worker (struct dwarf_section *section,
+ void *file ATTRIBUTE_UNUSED,
+ int is_gnu)
{
DWARF2_Internal_PubNames names;
unsigned char *start = section->start;
@@ -3546,7 +3566,10 @@ display_debug_pubnames (struct dwarf_sec
printf (_(" Size of area in .debug_info section: %ld\n"),
(long) names.pn_size);
- printf (_("\n Offset\tName\n"));
+ if (is_gnu)
+ printf (_("\n Offset Kind Name\n"));
+ else
+ printf (_("\n Offset\tName\n"));
do
{
@@ -3555,7 +3578,28 @@ display_debug_pubnames (struct dwarf_sec
if (offset != 0)
{
data += offset_size;
- printf (" %-6lx\t%s\n", offset, data);
+ if (is_gnu)
+ {
+ unsigned int kind_data;
+ gdb_index_symbol_kind kind;
+ const char *kind_name;
+ int is_static;
+
+ SAFE_BYTE_GET (kind_data, data, 1, end);
+ data++;
+ /* GCC computes the kind as the upper byte in the CU index
+ word, and then right shifts it by the CU index size.
+ Left shift KIND to where the gdb-index.h accessor macros
+ can use it. */
+ kind_data <<= GDB_INDEX_CU_BITSIZE;
+ kind = GDB_INDEX_SYMBOL_KIND_VALUE (kind_data);
+ kind_name = get_gdb_index_symbol_kind_name (kind);
+ is_static = GDB_INDEX_SYMBOL_STATIC_VALUE (kind_data);
+ printf (" %-6lx %s,%-10s %s\n",
+ offset, is_static ? "s" : "g", kind_name, data);
+ }
+ else
+ printf (" %-6lx\t%s\n", offset, data);
data += strnlen ((char *) data, end - data) + 1;
}
}
@@ -3567,6 +3611,18 @@ display_debug_pubnames (struct dwarf_sec
}
static int
+display_debug_pubnames (struct dwarf_section *section, void *file)
+{
+ return display_debug_pubnames_worker (section, file, 0);
+}
+
+static int
+display_debug_gnu_pubnames (struct dwarf_section *section, void *file)
+{
+ return display_debug_pubnames_worker (section, file, 1);
+}
+
+static int
display_debug_macinfo (struct dwarf_section *section,
void *file ATTRIBUTE_UNUSED)
{
@@ -6110,38 +6166,9 @@ display_gdb_index (struct dwarf_section
else
printf ("%c%lu", num_cus > 1 ? '\t' : ' ', (unsigned long) cu);
- switch (kind)
- {
- case GDB_INDEX_SYMBOL_KIND_NONE:
- printf (_(" [no symbol information]"));
- break;
- case GDB_INDEX_SYMBOL_KIND_TYPE:
- printf (is_static
- ? _(" [static type]")
- : _(" [global type]"));
- break;
- case GDB_INDEX_SYMBOL_KIND_VARIABLE:
- printf (is_static
- ? _(" [static variable]")
- : _(" [global variable]"));
- break;
- case GDB_INDEX_SYMBOL_KIND_FUNCTION:
- printf (is_static
- ? _(" [static function]")
- : _(" [global function]"));
- break;
- case GDB_INDEX_SYMBOL_KIND_OTHER:
- printf (is_static
- ? _(" [static other]")
- : _(" [global other]"));
- break;
- default:
- printf (is_static
- ? _(" [static unknown: %d]")
- : _(" [global unknown: %d]"),
- kind);
- break;
- }
+ printf (" [%s, %s]",
+ is_static ? _("static") : _("global"),
+ get_gdb_index_symbol_kind_name (kind));
if (num_cus > 1)
printf ("\n");
}
@@ -6765,6 +6792,8 @@ struct dwarf_section_display debug_displ
display_debug_lines, &do_debug_lines, 1 },
{ { ".debug_pubnames", ".zdebug_pubnames", NULL, NULL, 0, 0, 0 },
display_debug_pubnames, &do_debug_pubnames, 0 },
+ { { ".debug_gnu_pubnames", ".zdebug_gnu_pubnames", NULL, NULL, 0, 0, 0 },
+ display_debug_gnu_pubnames, &do_debug_pubnames, 0 },
{ { ".eh_frame", "", NULL, NULL, 0, 0, 0 },
display_debug_frames, &do_debug_frames, 1 },
{ { ".debug_macinfo", ".zdebug_macinfo", NULL, NULL, 0, 0, 0 },
@@ -6777,6 +6806,8 @@ struct dwarf_section_display debug_displ
display_debug_loc, &do_debug_loc, 1 },
{ { ".debug_pubtypes", ".zdebug_pubtypes", NULL, NULL, 0, 0, 0 },
display_debug_pubnames, &do_debug_pubtypes, 0 },
+ { { ".debug_gnu_pubtypes", ".zdebug_gnu_pubtypes", NULL, NULL, 0, 0, 0 },
+ display_debug_gnu_pubnames, &do_debug_pubtypes, 0 },
{ { ".debug_ranges", ".zdebug_ranges", NULL, NULL, 0, 0, 0 },
display_debug_ranges, &do_debug_ranges, 1 },
{ { ".debug_static_func", ".zdebug_static_func", NULL, NULL, 0, 0, 0 },
Index: dwarf.h
===================================================================
RCS file: /cvs/src/src/binutils/dwarf.h,v
retrieving revision 1.28
diff -u -p -r1.28 dwarf.h
--- dwarf.h 25 Mar 2013 13:16:41 -0000 1.28
+++ dwarf.h 9 Oct 2013 21:04:39 -0000
@@ -108,6 +108,8 @@ typedef struct
}
DWARF2_Internal_ARange;
+/* N.B. The order here must match the order in debug_displays. */
+
enum dwarf_section_display_enum
{
abbrev = 0,
@@ -116,12 +118,14 @@ enum dwarf_section_display_enum
info,
line,
pubnames,
+ gnu_pubnames,
eh_frame,
macinfo,
macro,
str,
loc,
pubtypes,
+ gnu_pubtypes,
ranges,
static_func,
static_vars,
Index: readelf.c
===================================================================
RCS file: /cvs/src/src/binutils/readelf.c,v
retrieving revision 1.608
diff -u -p -r1.608 readelf.c
--- readelf.c 17 Sep 2013 21:09:27 -0000 1.608
+++ readelf.c 9 Oct 2013 21:04:39 -0000
@@ -4909,6 +4909,8 @@ process_section_headers (FILE * file)
|| (do_debug_lines && const_strneq (name, "line."))
|| (do_debug_pubnames && const_strneq (name, "pubnames"))
|| (do_debug_pubtypes && const_strneq (name, "pubtypes"))
+ || (do_debug_pubnames && const_strneq (name, "gnu_pubnames"))
+ || (do_debug_pubtypes && const_strneq (name, "gnu_pubtypes"))
|| (do_debug_aranges && const_strneq (name, "aranges"))
|| (do_debug_ranges && const_strneq (name, "ranges"))
|| (do_debug_frames && const_strneq (name, "frame"))