Add optional style argument to --demangle switch.

This commit is contained in:
Nick Clifton 2000-07-20 18:02:56 +00:00
parent 483f05e373
commit 28c309a287
11 changed files with 132 additions and 32 deletions

View File

@ -1,3 +1,11 @@
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: Document optional style to demangle
switch.
2000-07-20 Hans-Peter Nilsson <hp@axis.com> 2000-07-20 Hans-Peter Nilsson <hp@axis.com>
* MAINTAINERS: Add self as CRIS port maintainer. * MAINTAINERS: Add self as CRIS port maintainer.

View File

@ -51,7 +51,7 @@ static asymbol **syms; /* Symbol table. */
static struct option long_options[] = static struct option long_options[] =
{ {
{"basenames", no_argument, NULL, 's'}, {"basenames", no_argument, NULL, 's'},
{"demangle", no_argument, NULL, 'C'}, {"demangle", optional_argument, NULL, 'C'},
{"exe", required_argument, NULL, 'e'}, {"exe", required_argument, NULL, 'e'},
{"functions", no_argument, NULL, 'f'}, {"functions", no_argument, NULL, 'f'},
{"target", required_argument, NULL, 'b'}, {"target", required_argument, NULL, 'b'},
@ -75,7 +75,7 @@ usage (stream, status)
{ {
fprintf (stream, _("\ fprintf (stream, _("\
Usage: %s [-CfsHV] [-b bfdname] [--target=bfdname]\n\ Usage: %s [-CfsHV] [-b bfdname] [--target=bfdname]\n\
[-e executable] [--exe=executable] [--demangle]\n\ [-e executable] [--exe=executable] [--demangle[=style]]\n\
[--basenames] [--functions] [addr addr ...]\n"), [--basenames] [--functions] [addr addr ...]\n"),
program_name); program_name);
list_supported_targets (program_name, stream); list_supported_targets (program_name, stream);
@ -301,6 +301,17 @@ main (argc, argv)
break; break;
case 'C': case 'C':
do_demangle = true; do_demangle = true;
if (optarg != NULL)
{
enum demangling_styles style;
style = cplus_demangle_name_to_style (optarg);
if (style == unknown_demangling)
fatal (_("unknown demangling style `%s'"),
optarg);
cplus_demangle_set_style (style);
}
break; break;
case 'e': case 'e':
filename = optarg; filename = optarg;

View File

@ -630,7 +630,7 @@ The @sc{gnu} linker @code{ld} is now described in a separate manual.
@smallexample @smallexample
nm [ -a | --debug-syms ] [ -g | --extern-only ] nm [ -a | --debug-syms ] [ -g | --extern-only ]
[ -B ] [ -C | --demangle ] [ -D | --dynamic ] [ -B ] [ -C | --demangle[=@var{style}] ] [ -D | --dynamic ]
[ -s | --print-armap ] [ -A | -o | --print-file-name ] [ -s | --print-armap ] [ -A | -o | --print-file-name ]
[ -n | -v | --numeric-sort ] [ -p | --no-sort ] [ -n | -v | --numeric-sort ] [ -p | --no-sort ]
[ -r | --reverse-sort ] [ --size-sort ] [ -u | --undefined-only ] [ -r | --reverse-sort ] [ --size-sort ] [ -u | --undefined-only ]
@ -754,12 +754,14 @@ listed.
The same as @samp{--format=bsd} (for compatibility with the MIPS @code{nm}). The same as @samp{--format=bsd} (for compatibility with the MIPS @code{nm}).
@item -C @item -C
@itemx --demangle @itemx --demangle[=@var{style}]
@cindex demangling in nm @cindex demangling in nm
Decode (@dfn{demangle}) low-level symbol names into user-level names. Decode (@dfn{demangle}) low-level symbol names into user-level names.
Besides removing any initial underscore prepended by the system, this Besides removing any initial underscore prepended by the system, this
makes C++ function names readable. @xref{c++filt}, for more information makes C++ function names readable. Different compilers have different
on demangling. 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 @item --no-demangle
Do not demangle low-level symbol names. This is the default. Do not demangle low-level symbol names. This is the default.
@ -1173,7 +1175,7 @@ Show a summary of the options to @code{objcopy}.
@smallexample @smallexample
objdump [ -a | --archive-headers ] objdump [ -a | --archive-headers ]
[ -b @var{bfdname} | --target=@var{bfdname} ] [ -b @var{bfdname} | --target=@var{bfdname} ]
[ -C | --demangle ] [ -C | --demangle[=@var{style}] ]
[ -d | --disassemble ] [ -d | --disassemble ]
[ -D | --disassemble-all ] [ -D | --disassemble-all ]
[ -z | --disassemble-zeroes ] [ -z | --disassemble-zeroes ]
@ -1258,12 +1260,14 @@ formats available with the @samp{-i} option.
@xref{Target Selection}, for more information. @xref{Target Selection}, for more information.
@item -C @item -C
@itemx --demangle @itemx --demangle[=@var{style}]
@cindex demangling in objdump @cindex demangling in objdump
Decode (@dfn{demangle}) low-level symbol names into user-level names. Decode (@dfn{demangle}) low-level symbol names into user-level names.
Besides removing any initial underscore prepended by the system, this Besides removing any initial underscore prepended by the system, this
makes C++ function names readable. @xref{c++filt}, for more information makes C++ function names readable. Different compilers have different
on demangling. 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 -G
@item --debugging @item --debugging
@ -1859,6 +1863,8 @@ the one specified by the C++ Annotated Reference Manual
the one used by the HP compiler the one used by the HP compiler
@item edg @item edg
the one used by the EDG compiler 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 @end table
@item --help @item --help
@ -1894,7 +1900,7 @@ c++filt @var{option} @var{symbol}
@smallexample @smallexample
addr2line [ -b @var{bfdname} | --target=@var{bfdname} ] addr2line [ -b @var{bfdname} | --target=@var{bfdname} ]
[ -C | --demangle ] [ -C | --demangle[=@var{style} ]
[ -e @var{filename} | --exe=@var{filename} ] [ -e @var{filename} | --exe=@var{filename} ]
[ -f | --functions ] [ -s | --basename ] [ -f | --functions ] [ -s | --basename ]
[ -H | --help ] [ -V | --version ] [ -H | --help ] [ -V | --version ]
@ -1941,12 +1947,14 @@ Specify that the object-code format for the object files is
@var{bfdname}. @var{bfdname}.
@item -C @item -C
@itemx --demangle @itemx --demangle[=@var{style}]
@cindex demangling in objdump @cindex demangling in objdump
Decode (@dfn{demangle}) low-level symbol names into user-level names. Decode (@dfn{demangle}) low-level symbol names into user-level names.
Besides removing any initial underscore prepended by the system, this Besides removing any initial underscore prepended by the system, this
makes C++ function names readable. @xref{c++filt}, for more information makes C++ function names readable. Different compilers have different
on demangling. 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} @item -e @var{filename}
@itemx --exe=@var{filename} @itemx --exe=@var{filename}
@ -1960,7 +1968,6 @@ Display function names as well as file and line number information.
@item -s @item -s
@itemx --basenames @itemx --basenames
Display only the base of each file name. Display only the base of each file name.
@end table
@node nlmconv @node nlmconv
@chapter nlmconv @chapter nlmconv

View File

@ -260,7 +260,7 @@ static bfd *lineno_cache_rel_bfd;
static struct option long_options[] = static struct option long_options[] =
{ {
{"debug-syms", no_argument, &print_debug_syms, 1}, {"debug-syms", no_argument, &print_debug_syms, 1},
{"demangle", no_argument, &do_demangle, 1}, {"demangle", optional_argument, 0, 'C'},
{"dynamic", no_argument, &dynamic, 1}, {"dynamic", no_argument, &dynamic, 1},
{"extern-only", no_argument, &external_only, 1}, {"extern-only", no_argument, &external_only, 1},
{"format", required_argument, 0, 'f'}, {"format", required_argument, 0, 'f'},
@ -297,7 +297,9 @@ usage (stream, status)
-a, --debug-syms Display debugger-only symbols\n\ -a, --debug-syms Display debugger-only symbols\n\
-A, --print-file-name Print name of the input file before every symbol\n\ -A, --print-file-name Print name of the input file before every symbol\n\
-B Same as --format=bsd\n\ -B Same as --format=bsd\n\
-C, --demangle Decode low-level symbol names into user-level names\n\ -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' or 'gnu-new-abi'\n\
--no-demangle Do not demangle low-level symbol names\n\ --no-demangle Do not demangle low-level symbol names\n\
-D, --dynamic Display dynamic symbols instead of normal symbols\n\ -D, --dynamic Display dynamic symbols instead of normal symbols\n\
--defined-only Display only defined symbols\n\ --defined-only Display only defined symbols\n\
@ -407,7 +409,8 @@ main (argc, argv)
bfd_init (); bfd_init ();
set_default_bfd_target (); set_default_bfd_target ();
while ((c = getopt_long (argc, argv, "aABCDef:glnopPrst:uvV", long_options, (int *) 0)) != EOF) while ((c = getopt_long (argc, argv, "aABCDef:glnopPrst:uvV",
long_options, (int *) 0)) != EOF)
{ {
switch (c) switch (c)
{ {
@ -423,6 +426,17 @@ main (argc, argv)
break; break;
case 'C': case 'C':
do_demangle = 1; do_demangle = 1;
if (optarg != NULL)
{
enum demangling_styles style;
style = cplus_demangle_name_to_style (optarg);
if (style == unknown_demangling)
fatal (_("unknown demangling style `%s'"),
optarg);
cplus_demangle_set_style (style);
}
break; break;
case 'D': case 'D':
dynamic = 1; dynamic = 1;

View File

@ -255,7 +255,9 @@ usage (stream, status)
-EL --endian=little Assume little 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\ --file-start-context Include context from start of file (with -S)\n\
-l, --line-numbers Include line numbers and filenames in output\n\ -l, --line-numbers Include line numbers and filenames in output\n\
-C, --demangle Decode mangled/processed symbol names\n\ -C, --demangle[=STYLE] Decode mangled/processed symbol names\n\
The STYLE, if specified, can be `auto', 'gnu',\n\
'lucid', 'arm', 'hp', 'edg', or 'gnu-new-abi'\n\
-w, --wide Format output for more than 80 columns\n\ -w, --wide Format output for more than 80 columns\n\
-z, --disassemble-zeroes Do not skip blocks of zeroes when disassembling\n\ -z, --disassemble-zeroes Do not skip blocks of zeroes when disassembling\n\
--start-address=ADDR Only process data whoes address is >= ADDR\n\ --start-address=ADDR Only process data whoes address is >= ADDR\n\
@ -288,7 +290,7 @@ static struct option long_options[]=
{"architecture", required_argument, NULL, 'm'}, {"architecture", required_argument, NULL, 'm'},
{"archive-headers", no_argument, NULL, 'a'}, {"archive-headers", no_argument, NULL, 'a'},
{"debugging", no_argument, NULL, 'g'}, {"debugging", no_argument, NULL, 'g'},
{"demangle", no_argument, NULL, 'C'}, {"demangle", optional_argument, NULL, 'C'},
{"disassemble", no_argument, NULL, 'd'}, {"disassemble", no_argument, NULL, 'd'},
{"disassemble-all", no_argument, NULL, 'D'}, {"disassemble-all", no_argument, NULL, 'D'},
{"disassembler-options", required_argument, NULL, 'M'}, {"disassembler-options", required_argument, NULL, 'M'},
@ -2833,6 +2835,17 @@ main (argc, argv)
break; break;
case 'C': case 'C':
do_demangle = true; do_demangle = true;
if (optarg != NULL)
{
enum demangling_styles style;
style = cplus_demangle_name_to_style (optarg);
if (style == unknown_demangling)
fatal (_("unknown demangling style `%s'"),
optarg);
cplus_demangle_set_style (style);
}
break; break;
case 'w': case 'w':
wide_output = true; wide_output = true;

View File

@ -1,3 +1,8 @@
2000-07-05 Kenneth Block <krblock@computer.org>
* gprof/gprof.c: Add optional style to demangle switch
* gprof/gprof.texi: Document optional style to demangle switch.
2000-06-05 DJ Delorie <dj@redhat.com> 2000-06-05 DJ Delorie <dj@redhat.com>
* MAINTAINERS: new * MAINTAINERS: new

View File

@ -29,6 +29,7 @@
#include "hist.h" #include "hist.h"
#include "source.h" #include "source.h"
#include "sym_ids.h" #include "sym_ids.h"
#include "demangle.h"
const char *whoami; const char *whoami;
const char *function_mapping_file; const char *function_mapping_file;
@ -104,7 +105,7 @@ static struct option long_options[] =
/* various options to affect output: */ /* various options to affect output: */
{"all-lines", no_argument, 0, 'x'}, {"all-lines", no_argument, 0, 'x'},
{"demangle", no_argument, 0, OPTION_DEMANGLE}, {"demangle", optional_argument, 0, OPTION_DEMANGLE},
{"no-demangle", no_argument, 0, OPTION_NO_DEMANGLE}, {"no-demangle", no_argument, 0, OPTION_NO_DEMANGLE},
{"directory-path", required_argument, 0, 'I'}, {"directory-path", required_argument, 0, 'I'},
{"display-unused-functions", no_argument, 0, 'z'}, {"display-unused-functions", no_argument, 0, 'z'},
@ -153,7 +154,7 @@ Usage: %s [-[abcDhilLsTvwxyz]] [-[ACeEfFJnNOpPqQZ][name]] [-I dirs]\n\
[--no-static] [--print-path] [--separate-files]\n\ [--no-static] [--print-path] [--separate-files]\n\
[--static-call-graph] [--sum] [--table-length=len] [--traditional]\n\ [--static-call-graph] [--sum] [--table-length=len] [--traditional]\n\
[--version] [--width=n] [--ignore-non-functions]\n\ [--version] [--width=n] [--ignore-non-functions]\n\
[--demangle] [--no-demangle]\n\ [--demangle[=STYLE]] [--no-demangle]\n\
[image-file] [profile-file...]\n"), [image-file] [profile-file...]\n"),
whoami); whoami);
if (status == 0) if (status == 0)
@ -425,6 +426,21 @@ This program is free software. This program has absolutely no warranty.\n"));
break; break;
case OPTION_DEMANGLE: case OPTION_DEMANGLE:
demangle = TRUE; 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; break;
case OPTION_NO_DEMANGLE: case OPTION_NO_DEMANGLE:
demangle = FALSE; demangle = FALSE;

View File

@ -478,12 +478,14 @@ are annotated. If this option is specified, every line in
a basic-block is annotated by repeating the annotation for the a basic-block is annotated by repeating the annotation for the
first line. This behavior is similar to @code{tcov}'s @samp{-a}. first line. This behavior is similar to @code{tcov}'s @samp{-a}.
@item --demangle @item --demangle[=@var{style}]
@itemx --no-demangle @itemx --no-demangle
These options control whether C++ symbol names should be demangled when These options control whether C++ symbol names should be demangled when
printing output. The default is to demangle symbols. The printing output. The default is to demangle symbols. The
@code{--no-demangle} option may be used to turn off demangling. @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 @end table
@node Analysis Options,Miscellaneous Options,Output Options,Invoking @node Analysis Options,Miscellaneous Options,Output Options,Invoking

View File

@ -1,3 +1,8 @@
2000-07-05 Kenneth Block <krblock@computer.org>
* ld/lexsup.c: Add optional style to demangle switch
* ld/ld.texinfo: Document optional style to demangle switch.
2000-07-20 Hans-Peter Nilsson <hp@axis.com> 2000-07-20 Hans-Peter Nilsson <hp@axis.com>
* Makefile.am (ALL_EMULATIONS): Add ecrisaout.o, ecriself.o, * Makefile.am (ALL_EMULATIONS): Add ecrisaout.o, ecriself.o,

View File

@ -852,17 +852,19 @@ space between @var{symbol}, the equals sign (``@key{=}''), and
@var{expression}. @var{expression}.
@cindex demangling, from command line @cindex demangling, from command line
@kindex --demangle @kindex --demangle[=@var{style}]
@kindex --no-demangle @kindex --no-demangle
@item --demangle @item --demangle[=@var{style}]
@itemx --no-demangle @itemx --no-demangle
These options control whether to demangle symbol names in error messages These options control whether to demangle symbol names in error messages
and other output. When the linker is told to demangle, it tries to and other output. When the linker is told to demangle, it tries to
present symbol names in a readable fashion: it strips leading present symbol names in a readable fashion: it strips leading
underscores if they are used by the object file format, and converts C++ underscores if they are used by the object file format, and converts C++
mangled symbol names into user readable names. The linker will demangle mangled symbol names into user readable names. Different compilers have
by default unless the environment variable @samp{COLLECT_NO_DEMANGLE} is different mangling styles. The optional demangling style argument can be used
set. These options may be used to override the default. 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 @cindex dynamic linker, from command line
@kindex --dynamic-linker @var{file} @kindex --dynamic-linker @var{file}
@ -1072,6 +1074,11 @@ specifies the first set of directories to search. The
either by specifying a list of names separated by colons, or by either by specifying a list of names separated by colons, or by
appearing multiple times. appearing multiple times.
This option should be used with caution as it overrides the search path
that may have been hard compiled into a shared library. In such a case it
is possible to use unintentionally a different search path than the
runtime linker would do.
The linker uses the following search paths to locate required shared The linker uses the following search paths to locate required shared
libraries. libraries.
@enumerate @enumerate

View File

@ -37,6 +37,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "ldfile.h" #include "ldfile.h"
#include "ldver.h" #include "ldver.h"
#include "ldemul.h" #include "ldemul.h"
#include "demangle.h"
#ifndef PATH_SEPARATOR #ifndef PATH_SEPARATOR
#if defined (__MSDOS__) || (defined (_WIN32) && ! defined (__CYGWIN32__)) #if defined (__MSDOS__) || (defined (_WIN32) && ! defined (__CYGWIN32__))
@ -272,8 +273,8 @@ static const struct ld_option ld_options[] =
'\0', NULL, N_("Output cross reference table"), TWO_DASHES }, '\0', NULL, N_("Output cross reference table"), TWO_DASHES },
{ {"defsym", required_argument, NULL, OPTION_DEFSYM}, { {"defsym", required_argument, NULL, OPTION_DEFSYM},
'\0', N_("SYMBOL=EXPRESSION"), N_("Define a symbol"), TWO_DASHES }, '\0', N_("SYMBOL=EXPRESSION"), N_("Define a symbol"), TWO_DASHES },
{ {"demangle", no_argument, NULL, OPTION_DEMANGLE}, { {"demangle", optional_argument, NULL, OPTION_DEMANGLE},
'\0', NULL, N_("Demangle symbol names"), TWO_DASHES }, '\0', N_("[=STYLE]"), N_("Demangle symbol names [using STYLE]"), TWO_DASHES },
{ {"dynamic-linker", required_argument, NULL, OPTION_DYNAMIC_LINKER}, { {"dynamic-linker", required_argument, NULL, OPTION_DYNAMIC_LINKER},
'\0', N_("PROGRAM"), N_("Set the dynamic linker to use"), TWO_DASHES }, '\0', N_("PROGRAM"), N_("Set the dynamic linker to use"), TWO_DASHES },
{ {"embedded-relocs", no_argument, NULL, OPTION_EMBEDDED_RELOCS}, { {"embedded-relocs", no_argument, NULL, OPTION_EMBEDDED_RELOCS},
@ -594,6 +595,17 @@ parse_args (argc, argv)
break; break;
case OPTION_DEMANGLE: case OPTION_DEMANGLE:
demangling = true; demangling = true;
if (optarg != NULL)
{
enum demangling_styles style;
style = cplus_demangle_name_to_style (optarg);
if (style == unknown_demangling)
einfo (_("%F%P: unknown demangling style `%s'"),
optarg);
cplus_demangle_set_style (style);
}
break; break;
case OPTION_DYNAMIC_LINKER: case OPTION_DYNAMIC_LINKER:
command_line.interpreter = optarg; command_line.interpreter = optarg;