This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
[PATCH]Add option style argument to --demangle
- To: binutils at sourceware dot cygnus dot com
- Subject: [PATCH]Add option style argument to --demangle
- From: Ken Block <block at zk3 dot dec dot com>
- Date: Wed, 05 Jul 2000 10:53:03 -0400
- Cc: "H. J. Lu" <hjl at lucon dot org>, dj at delorie dot com, phdm at macqel dot be,dje at transmeta dot com
A couple people did not like the --style switch. They felt the name was
too generic. So instead of adding a --style switch, I've added an
optional argument to "--demangle" and updated the documentation. I
posted this change as a suggestion before and nobody objected and one
person commented that they liked it, so I'd assume this is acceptable
and would appreciate if somebody could check this into CVS.
2000-07-05 Kenneth Block <krblock@computer.org>
* binutils/nm.c: Add optional style to demangle switch
* binutils/objdump.c: Add optional style to demangle switch
* binutils/addr2line.c: Add optional style to demangle switch
* binutils/binutils.texi: Add optional style to demangle switch
* ld/lexsup.c: Add optional style to demangle switch
* ld/ld.texinfo: Add optional style to demangle switch
* gprof/gprof.c: Add optional style to demangle switch
* gprof/gprof.texi: Add optional style to demangle switch
*** ./binutils/nm.c.orig Fri Apr 7 00:39:24 2000
--- ./binutils/nm.c Wed Jul 5 10:23:16 2000
***************
*** 260,266 ****
static struct option long_options[] =
{
{"debug-syms", no_argument, &print_debug_syms, 1},
! {"demangle", no_argument, &do_demangle, 1},
{"dynamic", no_argument, &dynamic, 1},
{"extern-only", no_argument, &external_only, 1},
{"format", required_argument, 0, 'f'},
--- 260,266 ----
static struct option long_options[] =
{
{"debug-syms", no_argument, &print_debug_syms, 1},
! {"demangle", optional_argument, 0, 'C'},
{"dynamic", no_argument, &dynamic, 1},
{"extern-only", no_argument, &external_only, 1},
{"format", required_argument, 0, 'f'},
***************
*** 296,303 ****
[--debug-syms] [--extern-only] [--print-armap] [--print-file-name]\n\
[--numeric-sort] [--no-sort] [--reverse-sort] [--size-sort]\n\
[--undefined-only] [--portability] [-f {bsd,sysv,posix}]\n\
! [--format={bsd,sysv,posix}] [--demangle] [--no-demangle] [--dynamic]\n\
! [--defined-only] [--line-numbers]\n\
[--version] [--help]\n\
[file...]\n"),
program_name);
--- 296,303 ----
[--debug-syms] [--extern-only] [--print-armap] [--print-file-name]\n\
[--numeric-sort] [--no-sort] [--reverse-sort] [--size-sort]\n\
[--undefined-only] [--portability] [-f {bsd,sysv,posix}]\n\
! [--format={bsd,sysv,posix}] [--demangle[=style]] [--no-demangle]\n\
! [--dynamic] [--defined-only] [--line-numbers]\n\
[--version] [--help]\n\
[file...]\n"),
program_name);
***************
*** 404,409 ****
--- 404,422 ----
break;
case 'C':
do_demangle = 1;
+ if (optarg!=NULL)
+ {
+ enum demangling_styles style;
+ style = cplus_demangle_name_to_style (optarg);
+ if (style == unknown_demangling)
+ {
+ fprintf (stderr,
+ _("%s: unknown demangling style `%s'\n"),
+ program_name,optarg);
+ xexit (1);
+ }
+ cplus_demangle_set_style (style);
+ }
break;
case 'D':
dynamic = 1;
*** ./binutils/objdump.c.orig Thu Jun 15 17:51:53 2000
--- ./binutils/objdump.c Wed Jul 5 10:18:34 2000
***************
*** 254,260 ****
-EL --endian=little Assume little endian format when disassembling\n\
--file-start-context Include context from start of file (with -S)\n\
-l --line-numbers Include line numbers and filenames in output\n\
! -C --demangle Decode mangled/processed symbol names\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 whoes address is >= <addr>\n\
--- 254,260 ----
-EL --endian=little Assume little endian format when disassembling\n\
--file-start-context Include context from start of file (with -S)\n\
-l --line-numbers Include line numbers and filenames in output\n\
! -C --demangle[=style] Decode mangled/processed symbol names\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 whoes address is >= <addr>\n\
***************
*** 287,293 ****
{"architecture", required_argument, NULL, 'm'},
{"archive-headers", no_argument, NULL, 'a'},
{"debugging", no_argument, NULL, 'g'},
! {"demangle", no_argument, NULL, 'C'},
{"disassemble", no_argument, NULL, 'd'},
{"disassemble-all", no_argument, NULL, 'D'},
{"disassembler-options", required_argument, NULL, 'M'},
--- 287,293 ----
{"architecture", required_argument, NULL, 'm'},
{"archive-headers", no_argument, NULL, 'a'},
{"debugging", no_argument, NULL, 'g'},
! {"demangle", optional_argument, NULL, 'C'},
{"disassemble", no_argument, NULL, 'd'},
{"disassemble-all", no_argument, NULL, 'D'},
{"disassembler-options", required_argument, NULL, 'M'},
***************
*** 2830,2835 ****
--- 2830,2848 ----
break;
case 'C':
do_demangle = true;
+ if (optarg!=NULL)
+ {
+ enum demangling_styles style;
+ style = cplus_demangle_name_to_style (optarg);
+ if (style == unknown_demangling)
+ {
+ fprintf (stderr,
+ _("%s: unknown demangling style `%s'\n"),
+ program_name,optarg);
+ xexit (1);
+ }
+ cplus_demangle_set_style (style);
+ }
break;
case 'w':
wide_output = true;
*** ./binutils/addr2line.c.orig Thu Jun 15 17:59:14 2000
--- ./binutils/addr2line.c Wed Jul 5 10:18:47 2000
***************
*** 51,57 ****
static struct option long_options[] =
{
{"basenames", no_argument, NULL, 's'},
! {"demangle", no_argument, NULL, 'C'},
{"exe", required_argument, NULL, 'e'},
{"functions", no_argument, NULL, 'f'},
{"target", required_argument, NULL, 'b'},
--- 51,57 ----
static struct option long_options[] =
{
{"basenames", no_argument, NULL, 's'},
! {"demangle", optional_argument, NULL, 'C'},
{"exe", required_argument, NULL, 'e'},
{"functions", no_argument, NULL, 'f'},
{"target", required_argument, NULL, 'b'},
***************
*** 75,81 ****
{
fprintf (stream, _("\
Usage: %s [-CfsHV] [-b bfdname] [--target=bfdname]\n\
! [-e executable] [--exe=executable] [--demangle]\n\
[--basenames] [--functions] [addr addr ...]\n"),
program_name);
list_supported_targets (program_name, stream);
--- 75,81 ----
{
fprintf (stream, _("\
Usage: %s [-CfsHV] [-b bfdname] [--target=bfdname]\n\
! [-e executable] [--exe=executable] [--demangle[=style]]\n\
[--basenames] [--functions] [addr addr ...]\n"),
program_name);
list_supported_targets (program_name, stream);
***************
*** 301,306 ****
--- 301,319 ----
break;
case 'C':
do_demangle = true;
+ if (optarg!=NULL)
+ {
+ enum demangling_styles style;
+ style = cplus_demangle_name_to_style (optarg);
+ if (style == unknown_demangling)
+ {
+ fprintf (stderr,
+ _("%s: unknown demangling style `%s'\n"),
+ program_name,optarg);
+ xexit (1);
+ }
+ cplus_demangle_set_style (style);
+ }
break;
case 'e':
filename = optarg;
*** ./binutils/binutils.texi.orig Tue Jun 20 13:50:30 2000
--- ./binutils/binutils.texi Wed Jul 5 10:06:02 2000
***************
*** 630,636 ****
@smallexample
nm [ -a | --debug-syms ] [ -g | --extern-only ]
! [ -B ] [ -C | --demangle ] [ -D | --dynamic ]
[ -s | --print-armap ] [ -A | -o | --print-file-name ]
[ -n | -v | --numeric-sort ] [ -p | --no-sort ]
[ -r | --reverse-sort ] [ --size-sort ] [ -u | --undefined-only ]
--- 630,636 ----
@smallexample
nm [ -a | --debug-syms ] [ -g | --extern-only ]
! [ -B ] [ -C | --demangle[=@var{style}] ] [ -D | --dynamic ]
[ -s | --print-armap ] [ -A | -o | --print-file-name ]
[ -n | -v | --numeric-sort ] [ -p | --no-sort ]
[ -r | --reverse-sort ] [ --size-sort ] [ -u | --undefined-only ]
***************
*** 754,765 ****
The same as @samp{--format=bsd} (for compatibility with the MIPS @code{nm}).
@item -C
! @itemx --demangle
@cindex demangling in nm
Decode (@dfn{demangle}) low-level symbol names into user-level names.
Besides removing any initial underscore prepended by the system, this
! makes C++ function names readable. @xref{c++filt}, for more information
! on demangling.
@item --no-demangle
Do not demangle low-level symbol names. This is the default.
--- 754,767 ----
The same as @samp{--format=bsd} (for compatibility with the MIPS @code{nm}).
@item -C
! @itemx --demangle[=@var{style}]
@cindex demangling in nm
Decode (@dfn{demangle}) low-level symbol names into user-level names.
Besides removing any initial underscore prepended by the system, this
! makes C++ function names readable. Different compilers have different
! mangling styles. The optional demangling style argument can be used to
! choose an appropriate demangling style for your compiler. @xref{c++filt},
! for more information on demangling.
@item --no-demangle
Do not demangle low-level symbol names. This is the default.
***************
*** 1170,1176 ****
@smallexample
objdump [ -a | --archive-headers ]
[ -b @var{bfdname} | --target=@var{bfdname} ]
! [ -C | --demangle ]
[ -d | --disassemble ]
[ -D | --disassemble-all ]
[ -z | --disassemble-zeroes ]
--- 1172,1178 ----
@smallexample
objdump [ -a | --archive-headers ]
[ -b @var{bfdname} | --target=@var{bfdname} ]
! [ -C | --demangle[=@var{style}] ]
[ -d | --disassemble ]
[ -D | --disassemble-all ]
[ -z | --disassemble-zeroes ]
***************
*** 1255,1266 ****
@xref{Target Selection}, for more information.
@item -C
! @itemx --demangle
@cindex demangling in objdump
Decode (@dfn{demangle}) low-level symbol names into user-level names.
Besides removing any initial underscore prepended by the system, this
! makes C++ function names readable. @xref{c++filt}, for more information
! on demangling.
@item -G
@item --debugging
--- 1257,1270 ----
@xref{Target Selection}, for more information.
@item -C
! @itemx --demangle[=@var{style}]
@cindex demangling in objdump
Decode (@dfn{demangle}) low-level symbol names into user-level names.
Besides removing any initial underscore prepended by the system, this
! makes C++ function names readable. Different compilers have different
! mangling styles. The optional demangling style argument can be used to
! choose an appropriate demangling style for your compiler. @xref{c++filt},
! for more information on demangling.
@item -G
@item --debugging
***************
*** 1856,1861 ****
--- 1860,1867 ----
the one used by the HP compiler
@item edg
the one used by the EDG compiler
+ @item gnu-new-abi
+ the one used by the @sc{gnu} compiler with the new ABI.
@end table
@item --help
***************
*** 1891,1897 ****
@smallexample
addr2line [ -b @var{bfdname} | --target=@var{bfdname} ]
! [ -C | --demangle ]
[ -e @var{filename} | --exe=@var{filename} ]
[ -f | --functions ] [ -s | --basename ]
[ -H | --help ] [ -V | --version ]
--- 1897,1903 ----
@smallexample
addr2line [ -b @var{bfdname} | --target=@var{bfdname} ]
! [ -C | --demangle[=@var{style} ]
[ -e @var{filename} | --exe=@var{filename} ]
[ -f | --functions ] [ -s | --basename ]
[ -H | --help ] [ -V | --version ]
***************
*** 1938,1949 ****
@var{bfdname}.
@item -C
! @itemx --demangle
@cindex demangling in objdump
Decode (@dfn{demangle}) low-level symbol names into user-level names.
Besides removing any initial underscore prepended by the system, this
! makes C++ function names readable. @xref{c++filt}, for more information
! on demangling.
@item -e @var{filename}
@itemx --exe=@var{filename}
--- 1944,1957 ----
@var{bfdname}.
@item -C
! @itemx --demangle[=@var{style}]
@cindex demangling in objdump
Decode (@dfn{demangle}) low-level symbol names into user-level names.
Besides removing any initial underscore prepended by the system, this
! makes C++ function names readable. Different compilers have different
! mangling styles. The optional demangling style argument can be used to
! choose an appropriate demangling style for your compiler. @xref{c++filt},
! for more information on demangling.
@item -e @var{filename}
@itemx --exe=@var{filename}
***************
*** 1957,1963 ****
@item -s
@itemx --basenames
Display only the base of each file name.
- @end table
@node nlmconv
@chapter nlmconv
--- 1965,1970 ----
*** ./ld/lexsup.c.orig Sun May 14 22:21:03 2000
--- ./ld/lexsup.c Wed Jul 5 10:19:00 2000
***************
*** 37,42 ****
--- 37,43 ----
#include "ldfile.h"
#include "ldver.h"
#include "ldemul.h"
+ #include "demangle.h"
#ifndef PATH_SEPARATOR
#if defined (__MSDOS__) || (defined (_WIN32) && ! defined (__CYGWIN32__))
***************
*** 267,273 ****
'\0', NULL, N_("Output cross reference table"), TWO_DASHES },
{ {"defsym", required_argument, NULL, OPTION_DEFSYM},
'\0', N_("SYMBOL=EXPRESSION"), N_("Define a symbol"), TWO_DASHES },
! { {"demangle", no_argument, NULL, OPTION_DEMANGLE},
'\0', NULL, N_("Demangle symbol names"), TWO_DASHES },
{ {"dynamic-linker", required_argument, NULL, OPTION_DYNAMIC_LINKER},
'\0', N_("PROGRAM"), N_("Set the dynamic linker to use"), TWO_DASHES },
--- 268,274 ----
'\0', NULL, N_("Output cross reference table"), TWO_DASHES },
{ {"defsym", required_argument, NULL, OPTION_DEFSYM},
'\0', N_("SYMBOL=EXPRESSION"), N_("Define a symbol"), TWO_DASHES },
! { {"demangle", optional_argument, NULL, OPTION_DEMANGLE},
'\0', NULL, N_("Demangle symbol names"), TWO_DASHES },
{ {"dynamic-linker", required_argument, NULL, OPTION_DYNAMIC_LINKER},
'\0', N_("PROGRAM"), N_("Set the dynamic linker to use"), TWO_DASHES },
***************
*** 587,592 ****
--- 588,606 ----
break;
case OPTION_DEMANGLE:
demangling = true;
+ if (optarg!=NULL)
+ {
+ enum demangling_styles style;
+ style = cplus_demangle_name_to_style (optarg);
+ if (style == unknown_demangling)
+ {
+ fprintf (stderr,
+ _("%s: unknown demangling style `%s'\n"),
+ program_name,optarg);
+ xexit (1);
+ }
+ cplus_demangle_set_style (style);
+ }
break;
case OPTION_DYNAMIC_LINKER:
command_line.interpreter = optarg;
*** ./ld/ld.texinfo.orig Mon Jun 19 12:28:43 2000
--- ./ld/ld.texinfo Wed Jul 5 10:06:00 2000
***************
*** 825,841 ****
@var{expression}.
@cindex demangling, from command line
! @kindex --demangle
@kindex --no-demangle
! @item --demangle
@itemx --no-demangle
These options control whether to demangle symbol names in error messages
and other output. When the linker is told to demangle, it tries to
present symbol names in a readable fashion: it strips leading
underscores if they are used by the object file format, and converts C++
! mangled symbol names into user readable names. The linker will demangle
! by default unless the environment variable @samp{COLLECT_NO_DEMANGLE} is
! set. These options may be used to override the default.
@cindex dynamic linker, from command line
@kindex --dynamic-linker @var{file}
--- 825,843 ----
@var{expression}.
@cindex demangling, from command line
! @kindex --demangle[=@var{style}]
@kindex --no-demangle
! @item --demangle[=@var{style}]
@itemx --no-demangle
These options control whether to demangle symbol names in error messages
and other output. When the linker is told to demangle, it tries to
present symbol names in a readable fashion: it strips leading
underscores if they are used by the object file format, and converts C++
! mangled symbol names into user readable names. Different compilers have
! different mangling styles. The optional demangling style argument can be used
! to choose an appropriate demangling style for your compiler. The linker will
! demangle by default unless the environment variable @samp{COLLECT_NO_DEMANGLE}
! is set. These options may be used to override the default.
@cindex dynamic linker, from command line
@kindex --dynamic-linker @var{file}
*** ./gprof/gprof.c.orig Tue Jun 20 14:07:47 2000
--- ./gprof/gprof.c Wed Jul 5 10:31:19 2000
***************
*** 29,34 ****
--- 29,35 ----
#include "hist.h"
#include "source.h"
#include "sym_ids.h"
+ #include "demangle.h"
const char *whoami;
const char *function_mapping_file;
***************
*** 104,110 ****
/* various options to affect output: */
{"all-lines", no_argument, 0, 'x'},
! {"demangle", no_argument, 0, OPTION_DEMANGLE},
{"no-demangle", no_argument, 0, OPTION_NO_DEMANGLE},
{"directory-path", required_argument, 0, 'I'},
{"display-unused-functions", no_argument, 0, 'z'},
--- 105,111 ----
/* various options to affect output: */
{"all-lines", no_argument, 0, 'x'},
! {"demangle", optional_argument, 0, OPTION_DEMANGLE},
{"no-demangle", no_argument, 0, OPTION_NO_DEMANGLE},
{"directory-path", required_argument, 0, 'I'},
{"display-unused-functions", no_argument, 0, 'z'},
***************
*** 153,159 ****
[--no-static] [--print-path] [--separate-files]\n\
[--static-call-graph] [--sum] [--table-length=len] [--traditional]\n\
[--version] [--width=n] [--ignore-non-functions]\n\
! [--demangle] [--no-demangle]\n\
[image-file] [profile-file...]\n"),
whoami);
if (status == 0)
--- 154,160 ----
[--no-static] [--print-path] [--separate-files]\n\
[--static-call-graph] [--sum] [--table-length=len] [--traditional]\n\
[--version] [--width=n] [--ignore-non-functions]\n\
! [--demangle[=style]] [--no-demangle]\n\
[image-file] [profile-file...]\n"),
whoami);
if (status == 0)
***************
*** 425,430 ****
--- 426,444 ----
break;
case OPTION_DEMANGLE:
demangle = TRUE;
+ if (optarg!=NULL)
+ {
+ enum demangling_styles style;
+ style = cplus_demangle_name_to_style (optarg);
+ if (style == unknown_demangling)
+ {
+ fprintf (stderr,
+ _("%s: unknown demangling style `%s'\n"),
+ whoami,optarg);
+ xexit (1);
+ }
+ cplus_demangle_set_style (style);
+ }
break;
case OPTION_NO_DEMANGLE:
demangle = FALSE;
*** ./gprof/gprof.texi.orig Tue Jun 20 14:08:36 2000
--- ./gprof/gprof.texi Wed Jul 5 10:10:59 2000
***************
*** 478,489 ****
a basic-block is annotated by repeating the annotation for the
first line. This behavior is similar to @code{tcov}'s @samp{-a}.
! @item --demangle
@itemx --no-demangle
These options control whether C++ symbol names should be demangled when
printing output. The default is to demangle symbols. The
! @code{--no-demangle} option may be used to turn off demangling.
!
@end table
@node Analysis Options,Miscellaneous Options,Output Options,Invoking
--- 478,491 ----
a basic-block is annotated by repeating the annotation for the
first line. This behavior is similar to @code{tcov}'s @samp{-a}.
! @item --demangle[=@var{style}]
@itemx --no-demangle
These options control whether C++ symbol names should be demangled when
printing output. The default is to demangle symbols. The
! @code{--no-demangle} option may be used to turn off demangling. Different
! compilers have different mangling styles. The optional demangling style
! argument can be used to choose an appropriate demangling style for your
! compiler.
@end table
@node Analysis Options,Miscellaneous Options,Output Options,Invoking