public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: binutils@sourceware.org
Subject: Restore readelf -wF
Date: Thu, 16 Jun 2022 10:00:38 +0930	[thread overview]
Message-ID: <Yqp5rjD0tvQ8T1gO@squeak.grove.modra.org> (raw)

Commit 94585d6d4495 resulted in readelf -wF failing with
Unrecognized debug letter option 'F'

binutils/
	* dwarf.c (debug_dump_long_opts): Add letter.
	(debug_option_table): New, replacing..
	(opts_table, letter_table): ..these.
	(dwarf_select_sections_by_names): Adjust to suit.  Set
	do_debug_frames outside of loop.
	(dwarf_select_sections_by_letters): Similarly.
gas/
	* testsuite/gas/i386/ehinterp.d: Use readelf -wF.

diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index f11eeaa24ce..cb2523af1f3 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -12034,6 +12034,50 @@ free_debug_memory (void)
   free_dwo_info ();
 }
 
+typedef struct
+{
+  const char letter;
+  const char *option;
+  int *variable;
+  int val;
+} debug_dump_long_opts;
+
+static const debug_dump_long_opts debug_option_table[] =
+{
+  { 'A', "addr", &do_debug_addr, 1 },
+  { 'a', "abbrev", &do_debug_abbrevs, 1 },
+  { 'c', "cu_index", &do_debug_cu_index, 1 },
+#ifdef HAVE_LIBDEBUGINFOD
+  { 'D', "use-debuginfod", &use_debuginfod, 1 },
+  { 'E', "do-not-use-debuginfod", &use_debuginfod, 0 },
+#endif
+  { 'F', "frames-interp", &do_debug_frames_interp, 1 },
+  { 'f', "frames", &do_debug_frames, 1 },
+  { 'g', "gdb_index", &do_gdb_index, 1 },
+  { 'i', "info", &do_debug_info, 1 },
+  { 'K', "follow-links", &do_follow_links, 1 },
+  { 'k', "links", &do_debug_links, 1 },
+  { 'L', "decodedline", &do_debug_lines, FLAG_DEBUG_LINES_DECODED },
+  { 'l', "rawline", &do_debug_lines, FLAG_DEBUG_LINES_RAW },
+  /* For compatibility with earlier versions of readelf.  */
+  { 'l', "line", &do_debug_lines, FLAG_DEBUG_LINES_RAW },
+  { 'm', "macro", &do_debug_macinfo, 1 },
+  { 'N', "no-follow-links", &do_follow_links, 0 },
+  { 'O', "str-offsets", &do_debug_str_offsets, 1 },
+  { 'o', "loc", &do_debug_loc, 1 },
+  { 'p', "pubnames", &do_debug_pubnames, 1 },
+  { 'R', "Ranges", &do_debug_ranges, 1 },
+  { 'r', "aranges", &do_debug_aranges, 1 },
+  /* For compatibility with earlier versions of readelf.  */
+  { 'r', "ranges", &do_debug_aranges, 1 },
+  { 's', "str", &do_debug_str, 1 },
+  { 'T', "trace_aranges", &do_trace_aranges, 1 },
+  { 't', "pubtypes", &do_debug_pubtypes, 1 },
+  { 'U', "trace_info", &do_trace_info, 1 },
+  { 'u', "trace_abbrev", &do_trace_abbrevs, 1 },
+  { 0, NULL, NULL, 0 }
+};
+
 /* Enable display of specific DWARF sections as determined by the comma
    separated strings in NAMES.  Returns non-zero if any displaying was
    enabled.  */
@@ -12041,64 +12085,15 @@ free_debug_memory (void)
 int
 dwarf_select_sections_by_names (const char *names)
 {
-  typedef struct
-  {
-    const char * option;
-    int *        variable;
-    int          val;
-  }
-  debug_dump_long_opts;
-
-  static const debug_dump_long_opts opts_table [] =
-    {
-      /* Please keep this table alpha- sorted.  */
-      { "Ranges", & do_debug_ranges, 1 },
-      { "abbrev", & do_debug_abbrevs, 1 },
-      { "addr", & do_debug_addr, 1 },
-      { "aranges", & do_debug_aranges, 1 },
-      { "cu_index", & do_debug_cu_index, 1 },
-      { "decodedline", & do_debug_lines, FLAG_DEBUG_LINES_DECODED },
-#ifdef HAVE_LIBDEBUGINFOD
-      { "do-not-use-debuginfod", & use_debuginfod, 0 },
-#endif
-      { "follow-links", & do_follow_links, 1 },
-      { "frames", & do_debug_frames, 1 },
-      { "frames-interp", & do_debug_frames_interp, 1 },
-      /* The special .gdb_index section.  */
-      { "gdb_index", & do_gdb_index, 1 },
-      { "info", & do_debug_info, 1 },
-      { "line", & do_debug_lines, FLAG_DEBUG_LINES_RAW }, /* For backwards compatibility.  */
-      { "links", & do_debug_links, 1 },
-      { "loc",  & do_debug_loc, 1 },
-      { "macro", & do_debug_macinfo, 1 },
-      { "no-follow-links", & do_follow_links, 0 },
-      { "pubnames", & do_debug_pubnames, 1 },
-      { "pubtypes", & do_debug_pubtypes, 1 },
-      /* This entry is for compatibility
-	 with earlier versions of readelf.  */
-      { "ranges", & do_debug_aranges, 1 },
-      { "rawline", & do_debug_lines, FLAG_DEBUG_LINES_RAW },
-      { "str", & do_debug_str, 1 },
-      { "str-offsets", & do_debug_str_offsets, 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 },
-#ifdef HAVE_LIBDEBUGINFOD
-      { "use-debuginfod", & use_debuginfod, 1 },
-#endif
-      { NULL, NULL, 0 }
-    };
-
   const char *p;
   int result = 0;
 
   p = names;
   while (*p)
     {
-      const debug_dump_long_opts * entry;
+      const debug_dump_long_opts *entry;
 
-      for (entry = opts_table; entry->option; entry++)
+      for (entry = debug_option_table; entry->option; entry++)
 	{
 	  size_t len = strlen (entry->option);
 
@@ -12108,11 +12103,6 @@ dwarf_select_sections_by_names (const char *names)
 	      * entry->variable = entry->val;
 	      result |= entry->val;
 
-	      /* The --debug-dump=frames-interp option also
-		 enables the --debug-dump=frames option.  */
-	      if (do_debug_frames_interp)
-		do_debug_frames = 1;
-
 	      p += len;
 	      break;
 	    }
@@ -12130,6 +12120,11 @@ dwarf_select_sections_by_names (const char *names)
 	p++;
     }
 
+  /* The --debug-dump=frames-interp option also enables the
+     --debug-dump=frames option.  */
+  if (do_debug_frames_interp)
+    do_debug_frames = 1;
+
   return result;
 }
 
@@ -12139,62 +12134,19 @@ dwarf_select_sections_by_names (const char *names)
 int
 dwarf_select_sections_by_letters (const char *letters)
 {
-  typedef struct
-  {
-    const char   letter;
-    int *        variable;
-    int          val;
-    bool         cont;
-  }
-  debug_dump_letter_opts;
-
-  static const debug_dump_letter_opts letter_table [] =
-    {
-      { 'A', & do_debug_addr, 1, false},
-      { 'a', & do_debug_abbrevs, 1, false },
-      { 'c', & do_debug_cu_index, 1, false },
-#ifdef HAVE_LIBDEBUGINFOD
-      { 'D', & use_debuginfod, 1, false },
-      { 'E', & use_debuginfod, 0, false },
-#endif
-      { 'F', & do_debug_frames_interp, 1, true }, /* Note the fall through.  */
-      { 'f', & do_debug_frames, 1, false },
-      { 'g', & do_gdb_index, 1, false },
-      { 'i', & do_debug_info, 1, false },
-      { 'K', & do_follow_links, 1, false },
-      { 'k', & do_debug_links, 1, false },
-      { 'L', & do_debug_lines, FLAG_DEBUG_LINES_DECODED, false },
-      { 'l', & do_debug_lines, FLAG_DEBUG_LINES_RAW, false },
-      { 'm', & do_debug_macinfo, 1, false },
-      { 'N', & do_follow_links, 0, false },
-      { 'O', & do_debug_str_offsets, 1, false },
-      { 'o', & do_debug_loc, 1, false },
-      { 'p', & do_debug_pubnames, 1, false },
-      { 'R', & do_debug_ranges, 1, false },
-      { 'r', & do_debug_aranges, 1, false },
-      { 's', & do_debug_str, 1, false },
-      { 'T', & do_trace_aranges, 1, false },
-      { 't', & do_debug_pubtypes, 1, false },
-      { 'U', & do_trace_info, 1, false },
-      { 'u', & do_trace_abbrevs, 1, false },
-      { 0, NULL, 0, false }
-    };
-
   int result = 0;
 
   while (* letters)
     {
-      const debug_dump_letter_opts * entry;
+      const debug_dump_long_opts *entry;
 
-      for (entry = letter_table; entry->letter; entry++)
+      for (entry = debug_option_table; entry->letter; entry++)
 	{
 	  if (entry->letter == * letters)
 	    {
 	      * entry->variable |= entry->val;
 	      result |= entry->val;
-
-	      if (! entry->cont)
-		break;
+	      break;
 	    }
 	}
 
@@ -12204,6 +12156,11 @@ dwarf_select_sections_by_letters (const char *letters)
       letters ++;
     }
 
+  /* The --debug-dump=frames-interp option also enables the
+     --debug-dump=frames option.  */
+  if (do_debug_frames_interp)
+    do_debug_frames = 1;
+
   return result;
 }
 
diff --git a/gas/testsuite/gas/i386/ehinterp.d b/gas/testsuite/gas/i386/ehinterp.d
index 5b6ac858709..d4988261195 100644
--- a/gas/testsuite/gas/i386/ehinterp.d
+++ b/gas/testsuite/gas/i386/ehinterp.d
@@ -1,4 +1,4 @@
-#readelf: --debug-dump=frames-interp
+#readelf: -wF
 
 Contents of the \.eh_frame section:
 

-- 
Alan Modra
Australia Development Lab, IBM

                 reply	other threads:[~2022-06-16  0:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yqp5rjD0tvQ8T1gO@squeak.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).