[RFC] readelf -w/-debug-dump= association

Message ID 20210527031504.GD2732960@bubble.grove.modra.org
State New
Headers show
Series
  • [RFC] readelf -w/-debug-dump= association
Related show

Commit Message

Libor Bukata via Binutils May 27, 2021, 3:15 a.m.
I'm soliciting opinions on this change to readelf --help, which I
think is good but I might be a little too familiar with readelf to
judge well.

The idea is to make it a little easier to learn, for example, that -wo
is shorthand for --debug-dump=loc.  Also to ensure that people adding
new --debug-dump= options put the associated -w option in the correct
place.

	* readelf.c (usage): Associate -w and --debug-dump options closely.


-- 
Alan Modra
Australia Development Lab, IBM

Comments

Fangrui Song May 27, 2021, 6:02 a.m. | #1
On 2021-05-27, Alan Modra via Binutils wrote:
>I'm soliciting opinions on this change to readelf --help, which I

>think is good but I might be a little too familiar with readelf to

>judge well.

>

>The idea is to make it a little easier to learn, for example, that -wo

>is shorthand for --debug-dump=loc.  Also to ensure that people adding

>new --debug-dump= options put the associated -w option in the correct

>place.

>

>	* readelf.c (usage): Associate -w and --debug-dump options closely.

>

>diff --git a/binutils/readelf.c b/binutils/readelf.c

>index a6ed24c03bd..9844a9229c3 100644

>--- a/binutils/readelf.c

>+++ b/binutils/readelf.c

>@@ -4653,10 +4653,10 @@ usage (FILE * stream)

>   -R --relocated-dump=<number|name>\n\

>                          Dump the contents of section <number|name> as relocated bytes\n\

>   -z --decompress        Decompress section before dumping it\n\

>-  -w[lLiaprmfFsOoRtgUuTAc] or\n\

>-  --debug-dump=[rawline,decodedline,info,abbrev,pubnames,aranges,macro,frames,\n\

>-                frames-interp,str,str-offsets,loc,Ranges,pubtypes,gdb_index,\n\

>-                trace_info,trace_abbrev,trace_aranges,addr,cu_index]\n\

>+  -w/--debug-dump=[a/abbrev, A/addr, r/aranges, c/cu_index, L/decodedline,\n\

>+                   f/frames, F/frames-interp, g/gdb_index, i/info, o/loc,\n\

>+                   m/macro, p/pubnames, t/pubtypes, R/Ranges, l/rawline, s/str\n\

>+                   O/str-offsets, u/trace_abbrev, T/trace_aranges, U/trace_info]\n\

>                          Display the contents of DWARF debug sections\n\

>   -wk,--debug-dump=links Display the contents of sections that link to separate debuginfo files\n\

>   -P,--process-links     Display the contents of non-debug sections in separate debuginfo files.  (Implies -wK)\n"));


This is a great idea.

Previously it was difficult to associate the shortcuts to the long
names.
Andreas Schwab May 27, 2021, 8:14 a.m. | #2
On Mai 27 2021, Alan Modra via Binutils wrote:

> diff --git a/binutils/readelf.c b/binutils/readelf.c

> index a6ed24c03bd..9844a9229c3 100644

> --- a/binutils/readelf.c

> +++ b/binutils/readelf.c

> @@ -4653,10 +4653,10 @@ usage (FILE * stream)

>    -R --relocated-dump=<number|name>\n\

>                           Dump the contents of section <number|name> as relocated bytes\n\

>    -z --decompress        Decompress section before dumping it\n\

> -  -w[lLiaprmfFsOoRtgUuTAc] or\n\

> -  --debug-dump=[rawline,decodedline,info,abbrev,pubnames,aranges,macro,frames,\n\

> -                frames-interp,str,str-offsets,loc,Ranges,pubtypes,gdb_index,\n\

> -                trace_info,trace_abbrev,trace_aranges,addr,cu_index]\n\

> +  -w/--debug-dump=[a/abbrev, A/addr, r/aranges, c/cu_index, L/decodedline,\n\

> +                   f/frames, F/frames-interp, g/gdb_index, i/info, o/loc,\n\

> +                   m/macro, p/pubnames, t/pubtypes, R/Ranges, l/rawline, s/str\n\

> +                   O/str-offsets, u/trace_abbrev, T/trace_aranges, U/trace_info]\n\


Note that the argument to -w/--debug-dump is optional.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."
Libor Bukata via Binutils May 27, 2021, 8:51 a.m. | #3
On Thu, May 27, 2021 at 10:14:03AM +0200, Andreas Schwab wrote:
> Note that the argument to -w/--debug-dump is optional.


Thanks.  That means I can't really move the '=' out of the brackets.

-- 
Alan Modra
Australia Development Lab, IBM
Libor Bukata via Binutils May 27, 2021, 10:58 a.m. | #4
Hi Alan,

> +  -w/--debug-dump=[a/abbrev, A/addr, r/aranges, c/cu_index, L/decodedline,\n\

> +                   f/frames, F/frames-interp, g/gdb_index, i/info, o/loc,\n\

> +                   m/macro, p/pubnames, t/pubtypes, R/Ranges, l/rawline, s/str\n\

> +                   O/str-offsets, u/trace_abbrev, T/trace_aranges, U/trace_info]\n\


I like the idea, but reading the text above it implies that, for example "--debug-dump=a"
could be a valid option.

As an alternative we could list out the options long hand:

   -w/--debug-dump          Dump all relevant debug info
   -wa/--debug-dump=abbrev  Dump the contents of the .debug_abbrev sections
   -wA/--debug-dump=addr    Dump the contents of the .debug_addr sections
   [...]
   -wU/--debug-dump=trace_info  Dump the contents of the umm, whichever section this is
   Note: -w[letter] options can be combined, eg -wai
   Note: --debug-dump options can be combined, eg --debug-dump=abbrev,info

A lot more verbose, but probably more helpful to those unfamiliar with readelf.
Just a suggestion.  Go with your idea if you prefer it.

Cheers
   Nick
Libor Bukata via Binutils May 29, 2021, 11:30 a.m. | #5
On Thu, May 27, 2021 at 11:58:20AM +0100, Nick Clifton wrote:
> Hi Alan,

> 

> > +  -w/--debug-dump=[a/abbrev, A/addr, r/aranges, c/cu_index, L/decodedline,\n\

> > +                   f/frames, F/frames-interp, g/gdb_index, i/info, o/loc,\n\

> > +                   m/macro, p/pubnames, t/pubtypes, R/Ranges, l/rawline, s/str\n\

> > +                   O/str-offsets, u/trace_abbrev, T/trace_aranges, U/trace_info]\n\

> 

> I like the idea, but reading the text above it implies that, for example "--debug-dump=a"

> could be a valid option.

> 

> As an alternative we could list out the options long hand:

> 

>   -w/--debug-dump          Dump all relevant debug info

>   -wa/--debug-dump=abbrev  Dump the contents of the .debug_abbrev sections

>   -wA/--debug-dump=addr    Dump the contents of the .debug_addr sections

>   [...]

>   -wU/--debug-dump=trace_info  Dump the contents of the umm, whichever section this is

>   Note: -w[letter] options can be combined, eg -wai

>   Note: --debug-dump options can be combined, eg --debug-dump=abbrev,info

> 

> A lot more verbose, but probably more helpful to those unfamiliar with readelf.

> Just a suggestion.  Go with your idea if you prefer it.


I think we have enough examples of how the options work that a more 
concise help message is actually more useful.

Splitting up help strings makes it more likely that at least some of
the help translation survives adding new options.

	* readelf.c (parse_args): Call dwarf_select_sections_all on
	--debug-dump without optarg.
	(usage): Associate -w and --debug-dump options closely.
	Split up help message.  Remove extraneous blank lines around
	ctf help.
	* objdump.c (usage): Similarly.

diff --git a/binutils/objdump.c b/binutils/objdump.c
index 39b5793bc2e..977f8172092 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -213,105 +213,164 @@ usage (FILE *stream, int status)
   fprintf (stream, _(" Display information from object <file(s)>.\n"));
   fprintf (stream, _(" At least one of the following switches must be given:\n"));
   fprintf (stream, _("\
-  -a, --archive-headers    Display archive header information\n\
-  -f, --file-headers       Display the contents of the overall file header\n\
-  -p, --private-headers    Display object format specific file header contents\n\
-  -P, --private=OPT,OPT... Display object format specific contents\n\
-  -h, --[section-]headers  Display the contents of the section headers\n\
-  -x, --all-headers        Display the contents of all headers\n\
-  -d, --disassemble        Display assembler contents of executable sections\n\
-  -D, --disassemble-all    Display assembler contents of all sections\n\
-      --disassemble=<sym>  Display assembler contents from <sym>\n\
-  -S, --source             Intermix source code with disassembly\n\
-      --source-comment[=<txt>] Prefix lines of source code with <txt>\n\
-  -s, --full-contents      Display the full contents of all sections requested\n\
-  -g, --debugging          Display debug information in object file\n\
-  -e, --debugging-tags     Display debug information using ctags style\n\
-  -G, --stabs              Display (in raw form) any STABS info in the file\n\
-  -W[lLiaprmfFsoORtUuTgAck] or\n\
-  --dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,\n\
-          =frames-interp,=str,=str-offsets,=loc,=Ranges,=pubtypes,\n\
-          =gdb_index,=trace_info,=trace_abbrev,=trace_aranges,\n\
-          =addr,=cu_index,=links]\n\
-                           Display DWARF info in the file\n\
-"));
+  -a, --archive-headers    Display archive header information\n"));
+  fprintf (stream, _("\
+  -f, --file-headers       Display the contents of the overall file header\n"));
+  fprintf (stream, _("\
+  -p, --private-headers    Display object format specific file header contents\n"));
+  fprintf (stream, _("\
+  -P, --private=OPT,OPT... Display object format specific contents\n"));
+  fprintf (stream, _("\
+  -h, --[section-]headers  Display the contents of the section headers\n"));
+  fprintf (stream, _("\
+  -x, --all-headers        Display the contents of all headers\n"));
+  fprintf (stream, _("\
+  -d, --disassemble        Display assembler contents of executable sections\n"));
+  fprintf (stream, _("\
+  -D, --disassemble-all    Display assembler contents of all sections\n"));
+  fprintf (stream, _("\
+      --disassemble=<sym>  Display assembler contents from <sym>\n"));
+  fprintf (stream, _("\
+  -S, --source             Intermix source code with disassembly\n"));
+  fprintf (stream, _("\
+      --source-comment[=<txt>] Prefix lines of source code with <txt>\n"));
+  fprintf (stream, _("\
+  -s, --full-contents      Display the full contents of all sections requested\n"));
+  fprintf (stream, _("\
+  -g, --debugging          Display debug information in object file\n"));
+  fprintf (stream, _("\
+  -e, --debugging-tags     Display debug information using ctags style\n"));
+  fprintf (stream, _("\
+  -G, --stabs              Display (in raw form) any STABS info in the file\n"));
+  fprintf (stream, _("\
+  -W, --dwarf[a/=abbrev, A/=addr, r/=aranges, c/=cu_index, L/=decodedline,\n\
+              f/=frames, F/=frames-interp, g/=gdb_index, i/=info, o/=loc,\n\
+              m/=macro, p/=pubnames, t/=pubtypes, R/=Ranges, l/=rawline,\n\
+              s/=str, O/=str-offsets, u/=trace_abbrev, T/=trace_aranges,\n\
+              U/=trace_info]\n\
+                           Display the contents of DWARF debug sections\n"));
+  fprintf (stream, _("\
+  -Wk,--dwarf=links        Display the contents of sections that link to\n\
+                            separate debuginfo files\n"));
 #if DEFAULT_FOR_FOLLOW_LINKS
   fprintf (stream, _("\
-  -WK,--dwarf=follow-links     Follow links to separate debug info files (default)\n\
-  -WN,--dwarf=no-follow-links  Do not follow links to separate debug info files\n\
-"));
+  -WK,--dwarf=follow-links\
+                           Follow links to separate debug info files (default)\n"));
+  fprintf (stream, _("\
+  -WN,--dwarf=no-follow-links\
+                           Do not follow links to separate debug info files\n"));
 #else
   fprintf (stream, _("\
-  -WK,--dwarf=follow-links     Follow links to separate debug info files\n\
-  -WN,--dwarf=no-follow-links  Do not follow links to separate debug info files (default)\n\
-"));
+  -WK,--dwarf=follow-links\
+                           Follow links to separate debug info files\n"));
+  fprintf (stream, _("\
+  -WN,--dwarf=no-follow-links\
+                           Do not follow links to separate debug info files\n\
+                            (default)\n"));
 #endif
   fprintf (stream, _("\
-  -L, --process-links          Display the contents of non-debug sections in separate debuginfo files.\n\
-"));
+  -L, --process-links      Display the contents of non-debug sections in\n\
+                            separate debuginfo files.  (Implies -WK)\n"));
 #ifdef ENABLE_LIBCTF
   fprintf (stream, _("\
-  --ctf=SECTION            Display CTF info from SECTION\n\
-"));
+      --ctf=SECTION        Display CTF info from SECTION\n"));
 #endif
   fprintf (stream, _("\
-  -t, --syms               Display the contents of the symbol table(s)\n\
-  -T, --dynamic-syms       Display the contents of the dynamic symbol table\n\
-  -r, --reloc              Display the relocation entries in the file\n\
-  -R, --dynamic-reloc      Display the dynamic relocation entries in the file\n\
-  @<file>                  Read options from <file>\n\
-  -v, --version            Display this program's version number\n\
-  -i, --info               List object formats and architectures supported\n\
-  -H, --help               Display this information\n\
-"));
+  -t, --syms               Display the contents of the symbol table(s)\n"));
+  fprintf (stream, _("\
+  -T, --dynamic-syms       Display the contents of the dynamic symbol table\n"));
+  fprintf (stream, _("\
+  -r, --reloc              Display the relocation entries in the file\n"));
+  fprintf (stream, _("\
+  -R, --dynamic-reloc      Display the dynamic relocation entries in the file\n"));
+  fprintf (stream, _("\
+  @<file>                  Read options from <file>\n"));
+  fprintf (stream, _("\
+  -v, --version            Display this program's version number\n"));
+  fprintf (stream, _("\
+  -i, --info               List object formats and architectures supported\n"));
+  fprintf (stream, _("\
+  -H, --help               Display this information\n"));
+
   if (status != 2)
     {
       const struct objdump_private_desc * const *desc;
 
       fprintf (stream, _("\n The following switches are optional:\n"));
       fprintf (stream, _("\
-  -b, --target=BFDNAME           Specify the target object format as BFDNAME\n\
-  -m, --architecture=MACHINE     Specify the target architecture as MACHINE\n\
-  -j, --section=NAME             Only display information for section NAME\n\
-  -M, --disassembler-options=OPT Pass text OPT on to the disassembler\n\
-  -EB --endian=big               Assume big endian format when disassembling\n\
-  -EL --endian=little            Assume little endian format when disassembling\n\
-      --file-start-context       Include context from start of file (with -S)\n\
-  -I, --include=DIR              Add DIR to search list for source files\n\
-  -l, --line-numbers             Include line numbers and filenames in output\n\
-  -F, --file-offsets             Include file offsets when displaying information\n\
+  -b, --target=BFDNAME           Specify the target object format as BFDNAME\n"));
+      fprintf (stream, _("\
+  -m, --architecture=MACHINE     Specify the target architecture as MACHINE\n"));
+      fprintf (stream, _("\
+  -j, --section=NAME             Only display information for section NAME\n"));
+      fprintf (stream, _("\
+  -M, --disassembler-options=OPT Pass text OPT on to the disassembler\n"));
+      fprintf (stream, _("\
+  -EB --endian=big               Assume big endian format when disassembling\n"));
+      fprintf (stream, _("\
+  -EL --endian=little            Assume little endian format when disassembling\n"));
+      fprintf (stream, _("\
+      --file-start-context       Include context from start of file (with -S)\n"));
+      fprintf (stream, _("\
+  -I, --include=DIR              Add DIR to search list for source files\n"));
+      fprintf (stream, _("\
+  -l, --line-numbers             Include line numbers and filenames in output\n"));
+      fprintf (stream, _("\
+  -F, --file-offsets             Include file offsets when displaying information\n"));
+      fprintf (stream, _("\
   -C, --demangle[=STYLE]         Decode mangled/processed symbol names\n\
                                   The STYLE, if specified, can be `auto', `gnu',\n\
                                   `lucid', `arm', `hp', `edg', `gnu-v3', `java'\n\
-                                  or `gnat'\n\
-      --recurse-limit            Enable a limit on recursion whilst demangling.  [Default]\n\
-      --no-recurse-limit         Disable a limit on recursion whilst demangling\n\
-  -w, --wide                     Format output for more than 80 columns\n\
-  -z, --disassemble-zeroes       Do not skip blocks of zeroes when disassembling\n\
-      --start-address=ADDR       Only process data whose address is >= ADDR\n\
-      --stop-address=ADDR        Only process data whose address is < ADDR\n\
-      --no-addresses             Do not print address alongside disassembly\n\
-      --prefix-addresses         Print complete address alongside disassembly\n\
-      --[no-]show-raw-insn       Display hex alongside symbolic disassembly\n\
-      --insn-width=WIDTH         Display WIDTH bytes on a single line for -d\n\
-      --adjust-vma=OFFSET        Add OFFSET to all displayed section addresses\n\
-      --special-syms             Include special symbols in symbol dumps\n\
-      --inlines                  Print all inlines for source line (with -l)\n\
-      --prefix=PREFIX            Add PREFIX to absolute paths for -S\n\
+                                  or `gnat'\n"));
+      fprintf (stream, _("\
+      --recurse-limit            Enable a limit on recursion whilst demangling\n\
+                                  (default)\n"));
+      fprintf (stream, _("\
+      --no-recurse-limit         Disable a limit on recursion whilst demangling\n"));
+      fprintf (stream, _("\
+  -w, --wide                     Format output for more than 80 columns\n"));
+      fprintf (stream, _("\
+  -z, --disassemble-zeroes       Do not skip blocks of zeroes when disassembling\n"));
+      fprintf (stream, _("\
+      --start-address=ADDR       Only process data whose address is >= ADDR\n"));
+      fprintf (stream, _("\
+      --stop-address=ADDR        Only process data whose address is < ADDR\n"));
+      fprintf (stream, _("\
+      --no-addresses             Do not print address alongside disassembly\n"));
+      fprintf (stream, _("\
+      --prefix-addresses         Print complete address alongside disassembly\n"));
+      fprintf (stream, _("\
+      --[no-]show-raw-insn       Display hex alongside symbolic disassembly\n"));
+      fprintf (stream, _("\
+      --insn-width=WIDTH         Display WIDTH bytes on a single line for -d\n"));
+      fprintf (stream, _("\
+      --adjust-vma=OFFSET        Add OFFSET to all displayed section addresses\n"));
+      fprintf (stream, _("\
+      --special-syms             Include special symbols in symbol dumps\n"));
+      fprintf (stream, _("\
+      --inlines                  Print all inlines for source line (with -l)\n"));
+      fprintf (stream, _("\
+      --prefix=PREFIX            Add PREFIX to absolute paths for -S\n"));
+      fprintf (stream, _("\
       --prefix-strip=LEVEL       Strip initial directory names for -S\n"));
       fprintf (stream, _("\
-      --dwarf-depth=N        Do not display DIEs at depth N or greater\n\
-      --dwarf-start=N        Display DIEs starting with N, at the same depth\n\
-                             or deeper\n\
-      --dwarf-check          Make additional dwarf internal consistency checks.\n"));
+      --dwarf-depth=N            Do not display DIEs at depth N or greater\n"));
+      fprintf (stream, _("\
+      --dwarf-start=N            Display DIEs starting at offset N\n"));
+      fprintf (stream, _("\
+      --dwarf-check              Make additional dwarf consistency checks.\n"));
 #ifdef ENABLE_LIBCTF
       fprintf (stream, _("\
-      --ctf-parent=SECTION     Use SECTION as the CTF parent\n"));
+      --ctf-parent=SECTION       Use SECTION as the CTF parent\n"));
 #endif
       fprintf (stream, _("\
-      --visualize-jumps          Visualize jumps by drawing ASCII art lines\n\
-      --visualize-jumps=color    Use colors in the ASCII art\n\
-      --visualize-jumps=extended-color   Use extended 8-bit color codes\n\
+      --visualize-jumps          Visualize jumps by drawing ASCII art lines\n"));
+      fprintf (stream, _("\
+      --visualize-jumps=color    Use colors in the ASCII art\n"));
+      fprintf (stream, _("\
+      --visualize-jumps=extended-color\n\
+                                 Use extended 8-bit color codes\n"));
+      fprintf (stream, _("\
       --visualize-jumps=off      Disable jump visualization\n\n"));
 
       list_supported_targets (program_name, stream);
diff --git a/binutils/readelf.c b/binutils/readelf.c
index d773b9a4931..ebb93b7dc1a 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -4613,77 +4613,123 @@ usage (FILE * stream)
 {
   fprintf (stream, _("Usage: readelf <option(s)> elf-file(s)\n"));
   fprintf (stream, _(" Display information about the contents of ELF format files\n"));
-  fprintf (stream, _(" Options are:\n\
-  -a --all               Equivalent to: -h -l -S -s -r -d -V -A -I\n\
-  -h --file-header       Display the ELF file header\n\
-  -l --program-headers   Display the program headers\n\
-     --segments          An alias for --program-headers\n\
-  -S --section-headers   Display the sections' header\n\
-     --sections          An alias for --section-headers\n\
-  -g --section-groups    Display the section groups\n\
-  -t --section-details   Display the section details\n\
-  -e --headers           Equivalent to: -h -l -S\n\
-  -s --syms              Display the symbol table\n\
-     --symbols           An alias for --syms\n\
-     --dyn-syms          Display the dynamic symbol table\n\
-     --lto-syms          Display LTO symbol tables\n\
+  fprintf (stream, _(" Options are:\n"));
+  fprintf (stream, _("\
+  -a --all               Equivalent to: -h -l -S -s -r -d -V -A -I\n"));
+  fprintf (stream, _("\
+  -h --file-header       Display the ELF file header\n"));
+  fprintf (stream, _("\
+  -l --program-headers   Display the program headers\n"));
+  fprintf (stream, _("\
+     --segments          An alias for --program-headers\n"));
+  fprintf (stream, _("\
+  -S --section-headers   Display the sections' header\n"));
+  fprintf (stream, _("\
+     --sections          An alias for --section-headers\n"));
+  fprintf (stream, _("\
+  -g --section-groups    Display the section groups\n"));
+  fprintf (stream, _("\
+  -t --section-details   Display the section details\n"));
+  fprintf (stream, _("\
+  -e --headers           Equivalent to: -h -l -S\n"));
+  fprintf (stream, _("\
+  -s --syms              Display the symbol table\n"));
+  fprintf (stream, _("\
+     --symbols           An alias for --syms\n"));
+  fprintf (stream, _("\
+     --dyn-syms          Display the dynamic symbol table\n"));
+  fprintf (stream, _("\
+     --lto-syms          Display LTO symbol tables\n"));
+  fprintf (stream, _("\
      --sym-base=[0|8|10|16] \n\
                          Force base for symbol sizes.  The options are \n\
-                         mixed (the default), octal, decimal, hexadecimal.\n\
+                         mixed (the default), octal, decimal, hexadecimal.\n"));
+  fprintf (stream, _("\
   -C --demangle[=STYLE]  Decode low-level symbol names into user-level names\n\
                           The STYLE, if specified, can be `auto' (the default),\n\
                           `gnu', `lucid', `arm', `hp', `edg', `gnu-v3', `java'\n\
-                          or `gnat'\n\
-     --no-demangle       Do not demangle low-level symbol names.  (This is the default)\n\
-     --recurse-limit     Enable a demangling recursion limit.  (This is the default)\n\
-     --no-recurse-limit  Disable a demangling recursion limit\n\
-  -n --notes             Display the core notes (if present)\n\
-  -r --relocs            Display the relocations (if present)\n\
-  -u --unwind            Display the unwind info (if present)\n\
-  -d --dynamic           Display the dynamic section (if present)\n\
-  -V --version-info      Display the version sections (if present)\n\
-  -A --arch-specific     Display architecture specific information (if any)\n\
-  -c --archive-index     Display the symbol/file index in an archive\n\
-  -D --use-dynamic       Use the dynamic section info when displaying symbols\n\
-  -L --lint|--enable-checks  Display warning messages for possible problems\n\
+                          or `gnat'\n"));
+  fprintf (stream, _("\
+     --no-demangle       Do not demangle low-level symbol names.  (default)\n"));
+  fprintf (stream, _("\
+     --recurse-limit     Enable a demangling recursion limit.  (default)\n"));
+  fprintf (stream, _("\
+     --no-recurse-limit  Disable a demangling recursion limit\n"));
+  fprintf (stream, _("\
+  -n --notes             Display the core notes (if present)\n"));
+  fprintf (stream, _("\
+  -r --relocs            Display the relocations (if present)\n"));
+  fprintf (stream, _("\
+  -u --unwind            Display the unwind info (if present)\n"));
+  fprintf (stream, _("\
+  -d --dynamic           Display the dynamic section (if present)\n"));
+  fprintf (stream, _("\
+  -V --version-info      Display the version sections (if present)\n"));
+  fprintf (stream, _("\
+  -A --arch-specific     Display architecture specific information (if any)\n"));
+  fprintf (stream, _("\
+  -c --archive-index     Display the symbol/file index in an archive\n"));
+  fprintf (stream, _("\
+  -D --use-dynamic       Use the dynamic section info when displaying symbols\n"));
+  fprintf (stream, _("\
+  -L --lint|--enable-checks\n\
+                         Display warning messages for possible problems\n"));
+  fprintf (stream, _("\
   -x --hex-dump=<number|name>\n\
-                         Dump the contents of section <number|name> as bytes\n\
+                         Dump the contents of section <number|name> as bytes\n"));
+  fprintf (stream, _("\
   -p --string-dump=<number|name>\n\
-                         Dump the contents of section <number|name> as strings\n\
+                         Dump the contents of section <number|name> as strings\n"));
+  fprintf (stream, _("\
   -R --relocated-dump=<number|name>\n\
-                         Dump the contents of section <number|name> as relocated bytes\n\
-  -z --decompress        Decompress section before dumping it\n\
-  -w[lLiaprmfFsOoRtgUuTAc] or\n\
-  --debug-dump=[rawline,decodedline,info,abbrev,pubnames,aranges,macro,frames,\n\
-                frames-interp,str,str-offsets,loc,Ranges,pubtypes,gdb_index,\n\
-                trace_info,trace_abbrev,trace_aranges,addr,cu_index]\n\
-                         Display the contents of DWARF debug sections\n\
-  -wk,--debug-dump=links Display the contents of sections that link to separate debuginfo files\n\
-  -P,--process-links     Display the contents of non-debug sections in separate debuginfo files.  (Implies -wK)\n"));
+                         Dump the relocated contents of section <number|name>\n"));
+  fprintf (stream, _("\
+  -z --decompress        Decompress section before dumping it\n"));
+  fprintf (stream, _("\
+  -w --debug-dump[a/=abbrev, A/=addr, r/=aranges, c/=cu_index, L/=decodedline,\n\
+                  f/=frames, F/=frames-interp, g/=gdb_index, i/=info, o/=loc,\n\
+                  m/=macro, p/=pubnames, t/=pubtypes, R/=Ranges, l/=rawline,\n\
+                  s/=str, O/=str-offsets, u/=trace_abbrev, T/=trace_aranges,\n\
+                  U/=trace_info]\n\
+                         Display the contents of DWARF debug sections\n"));
+  fprintf (stream, _("\
+  -wk --debug-dump=links Display the contents of sections that link to separate\n\
+                          debuginfo files\n"));
+  fprintf (stream, _("\
+  -P --process-links     Display the contents of non-debug sections in separate\n\
+                          debuginfo files.  (Implies -wK)\n"));
 #if DEFAULT_FOR_FOLLOW_LINKS
   fprintf (stream, _("\
-  -wK,--debug-dump=follow-links     Follow links to separate debug info files (default)\n\
-  -wN,--debug-dump=no-follow-links  Do not follow links to separate debug info files\n\
-"));
+  -wK --debug-dump=follow-links\n\
+                         Follow links to separate debug info files (default)\n"));
+  fprintf (stream, _("\
+  -wN --debug-dump=no-follow-links\n\
+                         Do not follow links to separate debug info files\n"));
 #else
   fprintf (stream, _("\
-  -wK,--debug-dump=follow-links     Follow links to separate debug info files\n\
-  -wN,--debug-dump=no-follow-links  Do not follow links to separate debug info files (default)\n\
-"));
+  -wK --debug-dump=follow-links\n\
+                         Follow links to separate debug info files\n"));
+  fprintf (stream, _("\
+  -wN --debug-dump=no-follow-links\n\
+                         Do not follow links to separate debug info files\n\
+                          (default)\n"));
 #endif
   fprintf (stream, _("\
-  --dwarf-depth=N        Do not display DIEs at depth N or greater\n\
-  --dwarf-start=N        Display DIEs starting with N, at the same depth\n\
-                         or deeper\n"));
+  --dwarf-depth=N        Do not display DIEs at depth N or greater\n"));
+  fprintf (stream, _("\
+  --dwarf-start=N        Display DIEs starting at offset N\n"));
 #ifdef ENABLE_LIBCTF
   fprintf (stream, _("\
-  --ctf=<number|name>    Display CTF info from section <number|name>\n\
+  --ctf=<number|name>    Display CTF info from section <number|name>\n"));
+  fprintf (stream, _("\
   --ctf-parent=<number|name>\n\
-                         Use section <number|name> as the CTF parent\n\n\
+                         Use section <number|name> as the CTF parent\n"));
+  fprintf (stream, _("\
   --ctf-symbols=<number|name>\n\
-                         Use section <number|name> as the CTF external symtab\n\n\
+                         Use section <number|name> as the CTF external symtab\n"));
+  fprintf (stream, _("\
   --ctf-strings=<number|name>\n\
-                         Use section <number|name> as the CTF external strtab\n\n"));
+                         Use section <number|name> as the CTF external strtab\n"));
 #endif
 
 #ifdef SUPPORT_DISASSEMBLY
@@ -4692,11 +4738,16 @@ usage (FILE * stream)
                          Disassemble the contents of section <number|name>\n"));
 #endif
   fprintf (stream, _("\
-  -I --histogram         Display histogram of bucket list lengths\n\
-  -W --wide              Allow output width to exceed 80 characters\n\
-  -T --silent-truncation If a symbol name is truncated, do not add a suffix [...]\n\
-  @<file>                Read options from <file>\n\
-  -H --help              Display this information\n\
+  -I --histogram         Display histogram of bucket list lengths\n"));
+  fprintf (stream, _("\
+  -W --wide              Allow output width to exceed 80 characters\n"));
+  fprintf (stream, _("\
+  -T --silent-truncation If a symbol name is truncated, do not add [...] suffix\n"));
+  fprintf (stream, _("\
+  @<file>                Read options from <file>\n"));
+  fprintf (stream, _("\
+  -H --help              Display this information\n"));
+  fprintf (stream, _("\
   -v --version           Display the version number of readelf\n"));
 
   if (REPORT_BUGS_TO[0] && stream == stdout)
@@ -4899,7 +4950,10 @@ parse_args (struct dump_data *dumpdata, int argc, char ** argv)
 	case OPTION_DEBUG_DUMP:
 	  do_dump = true;
 	  if (optarg == NULL)
-	    do_debugging = true;
+	    {
+	      do_debugging = true;
+	      dwarf_select_sections_all ();
+	    }
 	  else
 	    {
 	      do_debugging = false;


-- 
Alan Modra
Australia Development Lab, IBM
Libor Bukata via Binutils May 29, 2021, noon | #6
Hi Alan,

> I think we have enough examples of how the options work that a more

> concise help message is actually more useful.

> 

> Splitting up help strings makes it more likely that at least some of

> the help translation survives adding new options.

> 

> 	* readelf.c (parse_args): Call dwarf_select_sections_all on

> 	--debug-dump without optarg.

> 	(usage): Associate -w and --debug-dump options closely.

> 	Split up help message.  Remove extraneous blank lines around

> 	ctf help.

> 	* objdump.c (usage): Similarly.

  Looks good to me. :-)

Cheers
   Nick
Libor Bukata via Binutils May 29, 2021, 1:21 p.m. | #7
On Sat, May 29, 2021 at 09:00:13PM +0930, Alan Modra wrote:
> 	* readelf.c (parse_args): Call dwarf_select_sections_all on

> 	--debug-dump without optarg.

> 	(usage): Associate -w and --debug-dump options closely.

> 	Split up help message.  Remove extraneous blank lines around

> 	ctf help.

> 	* objdump.c (usage): Similarly.


Fix a last-minute change..

	* objdump (usage): Add missing \n.

diff --git a/binutils/objdump.c b/binutils/objdump.c
index 977f8172092..a7b8303b992 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -254,17 +254,17 @@ usage (FILE *stream, int status)
                             separate debuginfo files\n"));
 #if DEFAULT_FOR_FOLLOW_LINKS
   fprintf (stream, _("\
-  -WK,--dwarf=follow-links\
+  -WK,--dwarf=follow-links\n\
                            Follow links to separate debug info files (default)\n"));
   fprintf (stream, _("\
-  -WN,--dwarf=no-follow-links\
+  -WN,--dwarf=no-follow-links\n\
                            Do not follow links to separate debug info files\n"));
 #else
   fprintf (stream, _("\
-  -WK,--dwarf=follow-links\
+  -WK,--dwarf=follow-links\n\
                            Follow links to separate debug info files\n"));
   fprintf (stream, _("\
-  -WN,--dwarf=no-follow-links\
+  -WN,--dwarf=no-follow-links\n\
                            Do not follow links to separate debug info files\n\
                             (default)\n"));
 #endif


-- 
Alan Modra
Australia Development Lab, IBM

Patch

diff --git a/binutils/readelf.c b/binutils/readelf.c
index a6ed24c03bd..9844a9229c3 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -4653,10 +4653,10 @@  usage (FILE * stream)
   -R --relocated-dump=<number|name>\n\
                          Dump the contents of section <number|name> as relocated bytes\n\
   -z --decompress        Decompress section before dumping it\n\
-  -w[lLiaprmfFsOoRtgUuTAc] or\n\
-  --debug-dump=[rawline,decodedline,info,abbrev,pubnames,aranges,macro,frames,\n\
-                frames-interp,str,str-offsets,loc,Ranges,pubtypes,gdb_index,\n\
-                trace_info,trace_abbrev,trace_aranges,addr,cu_index]\n\
+  -w/--debug-dump=[a/abbrev, A/addr, r/aranges, c/cu_index, L/decodedline,\n\
+                   f/frames, F/frames-interp, g/gdb_index, i/info, o/loc,\n\
+                   m/macro, p/pubnames, t/pubtypes, R/Ranges, l/rawline, s/str\n\
+                   O/str-offsets, u/trace_abbrev, T/trace_aranges, U/trace_info]\n\
                          Display the contents of DWARF debug sections\n\
   -wk,--debug-dump=links Display the contents of sections that link to separate debuginfo files\n\
   -P,--process-links     Display the contents of non-debug sections in separate debuginfo files.  (Implies -wK)\n"));