This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch] objdump/readelf: dump trace itanium VMS sections


Hi,

Itanium VMS (which uses ELF/Dwarf) adds 3 dwarf sections (.trace_abbrevs, .trace_info
and .trace_aranges) to support back-trace symbolization.  Briefly speaking, there are
just a shrunk down version of the standard corresponding .debug_ sections.

This patch allows to easily dump them.  I haven't added single letter option in order to not
pollute the single letter name space.

No regressions on i386 gnu/linux.

Ok to commit ?

Tristan.

binutils/
2010-05-21  Tristan Gingold  <gingold@adacore.com>

	* readelf.c (usage): Add new trace sections for --debug-dump.
	(process_section_headers): Handle dump of trace sections.
	* objdump.c (usage): Add new trace sections for --dwarf.
	* dwarf.h (do_trace_info, do_trace_abbrevs): New variables.
	(do_trace_aranges): Ditto.
	(enum dwarf_section_display_enum): Add trace_info, trace_abbrev
	and trace_aranges literals.
	* dwarf.c (do_trace_info, do_trace_abbrevs): New variables.
	(do_trace_aranges): Ditto.
	(process_debug_info): Add abbrev_sec argument and replace
	abbrev with abbrev_sec.
	(load_debug_info): Adjust call of process_debug_info.
	(display_debug_info): Ditto.
	(display_trace_info): New function.
	(dwarf_select_sections_by_names): Add trace_info, trace_abbrevs
	and trace_aranges sections name.
	(dwarf_select_sections_all): Also select trace sections.
	(debug_displays): Reindent.  Add entries for the trace sections.
	* doc/binutils.texi (readelf): Document new --dwarf parameters.
	(objdump): Ditto.

diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi
index a3c2f99..9f374f8 100644
--- a/binutils/doc/binutils.texi
+++ b/binutils/doc/binutils.texi
@@ -1707,7 +1707,7 @@ objdump [@option{-a}|@option{--archive-headers}]
         [@option{-R}|@option{--dynamic-reloc}]
         [@option{-s}|@option{--full-contents}]
         [@option{-W[lLiaprmfFsoRt]}|
-         @option{--dwarf}[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes]]
+         @option{--dwarf}[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges]]
         [@option{-G}|@option{--stabs}]
         [@option{-t}|@option{--syms}]
         [@option{-T}|@option{--dynamic-syms}]
@@ -2080,13 +2080,16 @@ Display @var{width} bytes on a single line when disassembling
 instructions.
 
 @item -W[lLiaprmfFsoRt]
-@itemx --dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes]
+@itemx --dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges]
 @cindex DWARF
 @cindex debug symbols
 Displays the contents of the debug sections in the file, if any are
 present.  If one of the optional letters or words follows the switch
 then only data found in those specific sections will be dumped.
 
+Note that there is no single letter option to display the content of
+trace sections.
+
 @item -G
 @itemx --stabs
 @cindex stab
@@ -3907,7 +3910,7 @@ readelf [@option{-a}|@option{--all}]
         [@option{-R} <number or name>|@option{--relocated-dump=}<number or name>]
         [@option{-c}|@option{--archive-index}]
         [@option{-w[lLiaprmfFsoRt]}|
-         @option{--debug-dump}[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes]]
+         @option{--debug-dump}[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges]]
         [@option{-I}|@option{--histogram}]
         [@option{-v}|@option{--version}]
         [@option{-W}|@option{--wide}]
@@ -4059,11 +4062,14 @@ of binary archives.  Performs the same function as the @option{t}
 command to @command{ar}, but without using the BFD library.  @xref{ar}.
 
 @item -w[lLiaprmfFsoRt]
-@itemx --debug-dump[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes]
+@itemx --debug-dump[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges]
 Displays the contents of the debug sections in the file, if any are
 present.  If one of the optional letters or words follows the switch
 then only data found in those specific sections will be dumped.
 
+Note that there is no single letter option to display the content of
+trace sections.
+
 Note: the @option{=decodedline} option will display the interpreted
 contents of a .debug_line section whereas the @option{=rawline} option
 dumps the contents in a raw format.
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 57f0cc4..95cabb5 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -53,6 +53,9 @@ int do_debug_frames_interp;
 int do_debug_macinfo;
 int do_debug_str;
 int do_debug_loc;
+int do_trace_info;
+int do_trace_abbrevs;
+int do_trace_aranges;
 int do_wide;
 
 /* Values for do_debug_lines.  */
@@ -1874,6 +1877,7 @@ read_and_display_attr (unsigned long attribute,
 static int
 process_debug_info (struct dwarf_section *section,
 		    void *file,
+                    enum dwarf_section_display_enum abbrev_sec,
 		    int do_loc,
 		    int do_types)
 {
@@ -1945,11 +1949,11 @@ process_debug_info (struct dwarf_section *section,
       load_debug_section (str, file);
     }
 
-  load_debug_section (abbrev, file);
-  if (debug_displays [abbrev].section.start == NULL)
+  load_debug_section (abbrev_sec, file);
+  if (debug_displays [abbrev_sec].section.start == NULL)
     {
       warn (_("Unable to locate %s section!\n"),
-	    debug_displays [abbrev].section.name);
+	    debug_displays [abbrev_sec].section.name);
       return 0;
     }
 
@@ -2067,16 +2071,17 @@ process_debug_info (struct dwarf_section *section,
 
       /* Process the abbrevs used by this compilation unit. DWARF
 	 sections under Mach-O have non-zero addresses.  */
-      if (compunit.cu_abbrev_offset >= debug_displays [abbrev].section.size)
+      if (compunit.cu_abbrev_offset >= debug_displays [abbrev_sec].section.size)
 	warn (_("Debug info is corrupted, abbrev offset (%lx) is larger than abbrev section size (%lx)\n"),
 	      (unsigned long) compunit.cu_abbrev_offset,
-	      (unsigned long) debug_displays [abbrev].section.size);
+	      (unsigned long) debug_displays [abbrev_sec].section.size);
       else
 	process_abbrev_section
-	  ((unsigned char *) debug_displays [abbrev].section.start
-	   + compunit.cu_abbrev_offset - debug_displays [abbrev].section.address,
-	   (unsigned char *) debug_displays [abbrev].section.start
-	   + debug_displays [abbrev].section.size);
+	  ((unsigned char *) debug_displays [abbrev_sec].section.start
+	   + compunit.cu_abbrev_offset
+           - debug_displays [abbrev_sec].section.address,
+	   (unsigned char *) debug_displays [abbrev_sec].section.start
+	   + debug_displays [abbrev_sec].section.size);
 
       level = 0;
       while (tags < start)
@@ -2227,7 +2232,7 @@ load_debug_info (void * file)
     return num_debug_info_entries;
 
   if (load_debug_section (info, file)
-      && process_debug_info (&debug_displays [info].section, file, 1, 0))
+      && process_debug_info (&debug_displays [info].section, file, abbrev, 1, 0))
     return num_debug_info_entries;
 
   num_debug_info_entries = DEBUG_INFO_UNAVAILABLE;
@@ -3589,13 +3594,19 @@ display_debug_str (struct dwarf_section *section,
 static int
 display_debug_info (struct dwarf_section *section, void *file)
 {
-  return process_debug_info (section, file, 0, 0);
+  return process_debug_info (section, file, abbrev, 0, 0);
 }
 
 static int
 display_debug_types (struct dwarf_section *section, void *file)
 {
-  return process_debug_info (section, file, 0, 1);
+  return process_debug_info (section, file, abbrev, 0, 1);
+}
+
+static int
+display_trace_info (struct dwarf_section *section, void *file)
+{
+  return process_debug_info (section, file, trace_abbrev, 0, 0);
 }
 
 static int
@@ -5036,6 +5047,10 @@ dwarf_select_sections_by_names (const char *names)
 	 with earlier versions of readelf.  */
       { "ranges", & do_debug_aranges, 1 },
       { "str", & do_debug_str, 1 },
+      /* These trace_* sections are used by Itanium VMS.  */
+      { "trace_abbrev", & do_trace_abbrevs, 1 },
+      { "trace_aranges", & do_trace_aranges, 1 },
+      { "trace_info", & do_trace_info, 1 },
       { NULL, NULL, 0 }
     };
 
@@ -5156,40 +5171,49 @@ dwarf_select_sections_all (void)
   do_debug_macinfo = 1;
   do_debug_str = 1;
   do_debug_loc = 1;
+  do_trace_info = 1;
+  do_trace_abbrevs = 1;
+  do_trace_aranges = 1;
 }
 
 struct dwarf_section_display debug_displays[] =
 {
-  { { ".debug_abbrev",		".zdebug_abbrev",	NULL,	NULL,	0,	0 },
+  { { ".debug_abbrev",		".zdebug_abbrev",	NULL, NULL, 0, 0 },
     display_debug_abbrev,		&do_debug_abbrevs,	0 },
-  { { ".debug_aranges",		".zdebug_aranges",	NULL,	NULL,	0,	0 },
+  { { ".debug_aranges",		".zdebug_aranges",	NULL, NULL, 0, 0 },
     display_debug_aranges,		&do_debug_aranges,	1 },
-  { { ".debug_frame",		".zdebug_frame",	NULL,	NULL,	0,	0 },
+  { { ".debug_frame",		".zdebug_frame",	NULL, NULL, 0, 0 },
     display_debug_frames,		&do_debug_frames,	1 },
-  { { ".debug_info",		".zdebug_info",		NULL,	NULL,	0,	0 },
+  { { ".debug_info",		".zdebug_info",		NULL, NULL, 0, 0 },
     display_debug_info,			&do_debug_info,		1 },
-  { { ".debug_line",		".zdebug_line",		NULL,	NULL,	0,	0 },
+  { { ".debug_line",		".zdebug_line",		NULL, NULL, 0, 0 },
     display_debug_lines,		&do_debug_lines,	1 },
-  { { ".debug_pubnames",	".zdebug_pubnames",	NULL,	NULL,	0,	0 },
+  { { ".debug_pubnames",	".zdebug_pubnames",	NULL, NULL, 0, 0 },
     display_debug_pubnames,		&do_debug_pubnames,	0 },
-  { { ".eh_frame",		"",			NULL,	NULL,	0,	0 },
+  { { ".eh_frame",		"",			NULL, NULL, 0, 0 },
     display_debug_frames,		&do_debug_frames,	1 },
-  { { ".debug_macinfo",		".zdebug_macinfo",	NULL,	NULL,	0,	0 },
+  { { ".debug_macinfo",		".zdebug_macinfo",	NULL, NULL, 0, 0 },
     display_debug_macinfo,		&do_debug_macinfo,	0 },
-  { { ".debug_str",		".zdebug_str",		NULL,	NULL,	0,	0 },
+  { { ".debug_str",		".zdebug_str",		NULL, NULL, 0, 0 },
     display_debug_str,			&do_debug_str,		0 },
-  { { ".debug_loc",		".zdebug_loc",		NULL,	NULL,	0,	0 },
+  { { ".debug_loc",		".zdebug_loc",		NULL, NULL, 0, 0 },
     display_debug_loc,			&do_debug_loc,		1 },
-  { { ".debug_pubtypes",	".zdebug_pubtypes",	NULL,	NULL,	0,	0 },
+  { { ".debug_pubtypes",	".zdebug_pubtypes",	NULL, NULL, 0, 0 },
     display_debug_pubnames,		&do_debug_pubtypes,	0 },
-  { { ".debug_ranges",		".zdebug_ranges",	NULL,	NULL,	0,	0 },
+  { { ".debug_ranges",		".zdebug_ranges",	NULL, NULL, 0, 0 },
     display_debug_ranges,		&do_debug_ranges,	1 },
-  { { ".debug_static_func",	".zdebug_static_func",	NULL,	NULL,	0,	0 },
+  { { ".debug_static_func",	".zdebug_static_func",	NULL, NULL, 0, 0 },
     display_debug_not_supported,	NULL,			0 },
-  { { ".debug_static_vars",	".zdebug_static_vars",	NULL,	NULL,	0,	0 },
+  { { ".debug_static_vars",	".zdebug_static_vars",	NULL, NULL, 0, 0 },
     display_debug_not_supported,	NULL,			0 },
-  { { ".debug_types",		".zdebug_types",	NULL,	NULL,	0,	0 },
+  { { ".debug_types",		".zdebug_types",	NULL, NULL, 0, 0 },
     display_debug_types,		&do_debug_info,		1 },
-  { { ".debug_weaknames",	".zdebug_weaknames",	NULL,	NULL,	0,	0 },
-    display_debug_not_supported,	NULL,			0 }
+  { { ".debug_weaknames",	".zdebug_weaknames",	NULL, NULL, 0, 0 },
+    display_debug_not_supported,	NULL,			0 },
+  { { ".trace_info",		"",			NULL, NULL, 0, 0 },
+    display_trace_info,			&do_trace_info,		1 },
+  { { ".trace_abbrev",		"",			NULL, NULL, 0, 0 },
+    display_debug_abbrev,		&do_trace_abbrevs,	0 },
+  { { ".trace_aranges",		"",			NULL, NULL, 0, 0 },
+    display_debug_aranges,		&do_trace_aranges,	0 }
 };
diff --git a/binutils/dwarf.h b/binutils/dwarf.h
index 1ad96ab..58ecc67 100644
--- a/binutils/dwarf.h
+++ b/binutils/dwarf.h
@@ -71,6 +71,9 @@ enum dwarf_section_display_enum
   static_vars,
   types,
   weaknames,
+  trace_info,
+  trace_abbrev,
+  trace_aranges,
   max
 };
 
@@ -113,6 +116,9 @@ extern int do_debug_frames_interp;
 extern int do_debug_macinfo;
 extern int do_debug_str;
 extern int do_debug_loc;
+extern int do_trace_info;
+extern int do_trace_abbrevs;
+extern int do_trace_aranges;
 extern int do_wide;
 
 extern void init_dwarf_regnames (unsigned int);
diff --git a/binutils/objdump.c b/binutils/objdump.c
index 44d363b..2a419b7 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -205,7 +205,8 @@ usage (FILE *stream, int status)
   -G, --stabs              Display (in raw form) any STABS info in the file\n\
   -W[lLiaprmfFsoRt] or\n\
   --dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,\n\
-          =frames-interp,=str,=loc,=Ranges,=pubtypes]\n\
+          =frames-interp,=str,=loc,=Ranges,=pubtypes,\n\
+          =trace_info,=trace_abbrev,=trace_aranges]\n\
                            Display DWARF info in the file\n\
   -t, --syms               Display the contents of the symbol table(s)\n\
   -T, --dynamic-syms       Display the contents of the dynamic symbol table\n\
diff --git a/binutils/readelf.c b/binutils/readelf.c
index bcb24c2..9c3e2dc 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -3141,7 +3141,8 @@ usage (FILE * stream)
                          Dump the contents of section <number|name> as relocated bytes\n\
   -w[lLiaprmfFsoRt] or\n\
   --debug-dump[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,\n\
-               =frames-interp,=str,=loc,=Ranges,=pubtypes]\n\
 #ifdef SUPPORT_DISASSEMBLY
   fprintf (stream, _("\
@@ -4539,6 +4540,21 @@ process_section_headers (FILE * file)
 	request_dump_bynumber (i, DEBUG_DUMP);
       else if (do_debug_frames && streq (name, ".eh_frame"))
 	request_dump_bynumber (i, DEBUG_DUMP);
+      /* Trace sections for Itanium VMS.  */
+      else if ((do_debugging || do_trace_info || do_trace_abbrevs
+                || do_trace_aranges)
+	       && const_strneq (name, ".trace_"))
+	{
+          name += sizeof (".trace_") - 1;
+
+	  if (do_debugging
+	      || (do_trace_info     && streq (name, "info"))
+	      || (do_trace_abbrevs  && streq (name, "abbrev"))
+	      || (do_trace_aranges  && streq (name, "aranges"))
+	      )
+	    request_dump_bynumber (i, DEBUG_DUMP);
+	}
+
     }
 
   if (! do_sections)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]