PATCH: binutils/1437: c++filt no longer works with stdin
H. J. Lu
hjl@lucon.org
Mon Oct 10 17:12:00 GMT 2005
This patch restores the old behavior for stdin.
H.J.
---
2005-10-10 H.J. Lu <hongjiu.lu@intel.com>
PR binutils/1437
* cxxfilt.c (flags): Remove DMGL_TYPES.
(demangle_it): Removed.
(main): Updated to add DMGL_TYPES to flags for command line
args and restore the old behavior for stdin.
--- binutils/cxxfilt.c.stdin 2005-10-04 09:28:27.000000000 -0700
+++ binutils/cxxfilt.c 2005-10-10 09:56:55.000000000 -0700
@@ -30,7 +30,7 @@
#include "getopt.h"
#include "safe-ctype.h"
-static int flags = DMGL_PARAMS | DMGL_ANSI | DMGL_VERBOSE | DMGL_TYPES;
+static int flags = DMGL_PARAMS | DMGL_ANSI | DMGL_VERBOSE;
static int strip_underscore = TARGET_PREPENDS_UNDERSCORE;
static const struct option long_options[] =
@@ -47,30 +47,6 @@ static const struct option long_options[
};
static void
-demangle_it (char *mangled_name)
-{
- char *result;
- unsigned int skip_first = 0;
-
- if (mangled_name[0] == '.' || mangled_name[0] == '$')
- ++skip_first;
- if (strip_underscore && mangled_name[skip_first] == '_')
- ++skip_first;
-
- result = cplus_demangle (mangled_name + skip_first, flags);
-
- if (result == NULL)
- puts (mangled_name);
- else
- {
- if (mangled_name[0] == '.')
- putchar ('.');
- puts (result);
- free (result);
- }
-}
-
-static void
print_demangler_list (FILE *stream)
{
const struct demangler_engine *demangler;
@@ -217,8 +193,24 @@ main (int argc, char **argv)
if (optind < argc)
{
+ /* For command line args, also try to demangle type encodings.
+ We don't want to do it for stdin since it won't work with
+
+ .ident "GCC: (GNU) 4.0.2"
+
+ in assembly output. */
+ flags |= DMGL_TYPES;
for ( ; optind < argc; optind++)
- demangle_it (argv[optind]);
+ {
+ char *result = cplus_demangle (argv[optind], flags);
+ if (result == NULL)
+ puts (argv[optind]);
+ else
+ {
+ puts (result);
+ free (result);
+ }
+ }
return 0;
}
@@ -262,12 +254,35 @@ main (int argc, char **argv)
if (i > 0)
{
+ unsigned skip_first = 0;
+ char *result;
+
mbuffer[i] = 0;
- demangle_it (mbuffer);
+ if (mbuffer[0] == '.' || mbuffer[0] == '$')
+ ++skip_first;
+ if (strip_underscore && mbuffer[skip_first] == '_')
+ ++skip_first;
+
+ if (skip_first > i)
+ skip_first = i;
+
+ result = cplus_demangle (mbuffer + skip_first, flags);
+ if (result)
+ {
+ if (mbuffer[0] == '.')
+ putc ('.', stdout);
+ fputs (result, stdout);
+ free (result);
+ }
+ else
+ fputs (mbuffer, stdout);
+
fflush (stdout);
}
if (c == EOF)
break;
+ putchar (c);
+ fflush (stdout);
}
return 0;
More information about the Binutils
mailing list