diff options
author | nobody <> | 2004-02-29 23:00:22 +0000 |
---|---|---|
committer | nobody <> | 2004-02-29 23:00:22 +0000 |
commit | a0f62e83fcd50712af16ddb555dac32ccf45fb23 (patch) | |
tree | 168849cc2def1bd412ea5e67f421e4da6977a6b2 /libiberty | |
parent | 0f42e75a11cf8bfa4741b4ca2358f568f658005a (diff) | |
download | gdb-a0f62e83fcd50712af16ddb555dac32ccf45fb23.zip gdb-a0f62e83fcd50712af16ddb555dac32ccf45fb23.tar.gz gdb-a0f62e83fcd50712af16ddb555dac32ccf45fb23.tar.bz2 |
This commit was manufactured by cvs2svn to create branch 'gdb_6_1-branch'.gdb_6_1-2004-03-01-gmt-branchpoint
Sprout from drow_intercu-20040221-branch 2004-02-21 19:11:39 UTC nobody 'This commit was manufactured by cvs2svn to create branch'
Cherrypick from master 2004-02-29 23:00:21 UTC Alan Modra <amodra@gmail.com> 'daily update':
ChangeLog
Makefile.in
Makefile.tpl
bfd/ChangeLog
bfd/elf-bfd.h
bfd/elf-eh-frame.c
bfd/elf32-frv.c
bfd/elf32-s390.c
bfd/elf64-s390.c
bfd/elflink.c
bfd/elflink.h
bfd/elfxx-ia64.c
bfd/elfxx-target.h
bfd/libaout.h
bfd/netbsd-core.c
bfd/version.h
cpu/ChangeLog
cpu/m32r.cpu
cpu/m32r.opc
gdb/ChangeLog
gdb/MAINTAINERS
gdb/Makefile.in
gdb/NEWS
gdb/PROBLEMS
gdb/README
gdb/amd64-linux-nat.c
gdb/amd64-linux-tdep.c
gdb/amd64-linux-tdep.h
gdb/amd64-nat.c
gdb/amd64-tdep.c
gdb/amd64-tdep.h
gdb/amd64bsd-nat.c
gdb/amd64fbsd-nat.c
gdb/amd64fbsd-tdep.c
gdb/amd64nbsd-nat.c
gdb/amd64nbsd-tdep.c
gdb/amd64obsd-nat.c
gdb/amd64obsd-tdep.c
gdb/auxv.c
gdb/breakpoint.c
gdb/charset.c
gdb/cli/cli-cmds.c
gdb/cli/cli-dump.c
gdb/cli/cli-script.c
gdb/cli/cli-setshow.c
gdb/coffread.c
gdb/completer.c
gdb/config/djgpp/fnchange.lst
gdb/config/i386/fbsd.mh
gdb/config/i386/fbsd.mt
gdb/config/i386/fbsd64.mh
gdb/config/i386/fbsd64.mt
gdb/config/i386/linux64.mh
gdb/config/i386/linux64.mt
gdb/config/i386/nbsd.mt
gdb/config/i386/nbsd64.mh
gdb/config/i386/nbsd64.mt
gdb/config/i386/nbsdaout.mh
gdb/config/i386/nbsdelf.mh
gdb/config/i386/nm-fbsd.h
gdb/config/i386/nm-fbsd64.h
gdb/config/i386/nm-linux64.h
gdb/config/i386/nm-nbsd.h
gdb/config/i386/nm-nbsdaout.h
gdb/config/i386/nm-obsd.h
gdb/config/i386/obsd.mh
gdb/config/i386/obsd.mt
gdb/config/i386/obsd64.mh
gdb/config/i386/obsd64.mt
gdb/config/i386/obsdaout.mh
gdb/config/i386/tm-fbsd.h
gdb/config/i386/tm-linux64.h
gdb/config/i386/tm-nbsd.h
gdb/config/i386/xm-i386.h
gdb/config/i386/xm-nbsd.h
gdb/config/pa/tm-hppa.h
gdb/configure
gdb/configure.host
gdb/configure.in
gdb/configure.tgt
gdb/corelow.c
gdb/cris-tdep.c
gdb/defs.h
gdb/doc/ChangeLog
gdb/doc/annotate.texinfo
gdb/doc/fdl.texi
gdb/doc/gdb.texinfo
gdb/doc/gdbint.texinfo
gdb/doc/stabs.texinfo
gdb/dwarf2-frame.h
gdb/event-top.c
gdb/exec.c
gdb/frame-unwind.c
gdb/gdbserver/ChangeLog
gdb/gdbserver/linux-arm-low.c
gdb/gdbserver/linux-low.c
gdb/gdbserver/remote-utils.c
gdb/gdbserver/server.c
gdb/gdbserver/server.h
gdb/gdbserver/target.h
gdb/hppa-tdep.c
gdb/i386-nat.c
gdb/i386-tdep.h
gdb/i386bsd-tdep.c
gdb/i386fbsd-nat.c
gdb/i386fbsd-tdep.c
gdb/i386nbsd-tdep.c
gdb/i386obsd-nat.c
gdb/i386obsd-tdep.c
gdb/i387-tdep.c
gdb/i387-tdep.h
gdb/ia64-linux-tdep.c
gdb/ia64-tdep.c
gdb/ia64-tdep.h
gdb/infcall.c
gdb/inflow.c
gdb/printcmd.c
gdb/regcache.c
gdb/remote.c
gdb/s390-tdep.c
gdb/solib.c
gdb/source.c
gdb/symfile.c
gdb/symmisc.c
gdb/testsuite/ChangeLog
gdb/testsuite/config/gdbserver.exp
gdb/testsuite/configure
gdb/testsuite/configure.in
gdb/testsuite/gdb.arch/gdb1431.exp
gdb/testsuite/gdb.arch/gdb1431.s
gdb/testsuite/gdb.base/bigcore.exp
gdb/testsuite/gdb.base/callfuncs.exp
gdb/testsuite/gdb.base/charset.c
gdb/testsuite/gdb.base/charset.exp
gdb/testsuite/gdb.base/chng-syms.exp
gdb/testsuite/gdb.base/corefile.exp
gdb/testsuite/gdb.base/langs.exp
gdb/testsuite/gdb.base/pending.exp
gdb/testsuite/gdb.base/printcmds.exp
gdb/testsuite/gdb.base/relocate.c
gdb/testsuite/gdb.base/setvar.exp
gdb/testsuite/gdb.cp/class2.cc
gdb/testsuite/gdb.cp/class2.exp
gdb/testsuite/gdb.cp/ctti.exp
gdb/testsuite/gdb.cp/cttiadd.cc
gdb/testsuite/gdb.cp/cttiadd1.cc
gdb/testsuite/gdb.cp/cttiadd2.cc
gdb/testsuite/gdb.cp/cttiadd3.cc
gdb/testsuite/gdb.java/jmisc.exp
gdb/testsuite/lib/gdb.exp
gdb/thread-db.c
gdb/top.c
gdb/tracepoint.c
gdb/tui/tui-disasm.c
gdb/tui/tui-hooks.c
gdb/tui/tui-regs.c
gdb/tui/tui-win.c
gdb/tui/tui.c
gdb/utils.c
gdb/valprint.c
gdb/valprint.h
gdb/version.in
include/ChangeLog
include/dyn-string.h
libiberty/ChangeLog
libiberty/cp-demangle.c
libiberty/cp-demangle.h
libiberty/dyn-string.c
libiberty/testsuite/demangle-expected
opcodes/ChangeLog
opcodes/ppc-opc.c
opcodes/sh-dis.c
opcodes/sh-opc.h
src-release
texinfo/texinfo.tex
Delete:
gdb/config/i386/i386bsd.mh
gdb/config/i386/i386bsd.mt
gdb/config/i386/nm-i386bsd.h
gdb/config/i386/nm-x86-64linux.h
gdb/config/i386/tm-i386bsd.h
gdb/config/i386/tm-x86-64linux.h
gdb/config/i386/x86-64linux.mh
gdb/config/i386/x86-64linux.mt
gdb/config/i386/xm-i386bsd.h
gdb/i386b-nat.c
gdb/testsuite/gdb.arch/gdb1431.c
gdb/x86-64-linux-nat.c
gdb/x86-64-linux-tdep.c
gdb/x86-64-linux-tdep.h
gdb/x86-64-tdep.c
gdb/x86-64-tdep.h
sim/testsuite/sim/frv/rst.cgs
sim/testsuite/sim/frv/rstb.cgs
sim/testsuite/sim/frv/rstbf.cgs
sim/testsuite/sim/frv/rstd.cgs
sim/testsuite/sim/frv/rstdf.cgs
sim/testsuite/sim/frv/rstf.cgs
sim/testsuite/sim/frv/rsth.cgs
sim/testsuite/sim/frv/rsthf.cgs
sim/testsuite/sim/frv/rstq.cgs
sim/testsuite/sim/frv/rstqf.cgs
Diffstat (limited to 'libiberty')
-rw-r--r-- | libiberty/ChangeLog | 47 | ||||
-rw-r--r-- | libiberty/cp-demangle.c | 355 | ||||
-rw-r--r-- | libiberty/cp-demangle.h | 12 | ||||
-rw-r--r-- | libiberty/dyn-string.c | 11 | ||||
-rw-r--r-- | libiberty/testsuite/demangle-expected | 26 |
5 files changed, 321 insertions, 130 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 08b7d5b..b9d6e73 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,50 @@ +2004-02-24 Ian Lance Taylor <ian@wasabisystems.com> + + * cp-demangle.h (enum d_builtin_type_print): Add D_PRINT_UNSIGNED, + D_PRINT_UNSIGNED_LONG, D_PRINT_LONG_LONG, + D_PRINT_UNSIGNED_LONG_LONG, D_PRINT_FLOAT. + * cp-demangle.c (cplus_demangle_builtin_types): Change char and + short types to D_PRINT_DEFAULT. Change other integer types to use + new D_PRINT_* values where appropriate. Change float types to + D_PRINT_FLOAT. + (d_print_comp) [LITERAL, LITERAL_NEG]: Handle new D_PRINT_* + values. + * testsuite/demangle-expected: Adjust two test cases. + + * cp-demangle.c (d_print_function_type): Print a space before the + parenthesis around the function type in more cases. + * testsuite/demangle-expected: Adjust one test case. + + * cp-demangle.c (d_print_comp) [UNARY]: Don't emit extra + parentheses around a cast. + * testsuite/demangle-expected: Adjust two test cases to match new + output. + + * cp-demangle.c (__cxa_demangle): Pass DMGL_PARAMS to d_demangle. + + * cp-demangle.c (d_print_comp) [RESTRICT, VOLATILE, CONST]: Don't + push more than one of the same CV-qualifier on the top of the + stack. + (d_print_comp) [ARRAY_TYPE]: If the array itself is CV-qualified, + move the CV-qualifiers to apply to the element type instead. + (d_print_array_type): When checking the modifiers, keep looking + past ones which have been printed already. + * testsuite/demangle-expected: Add three test cases. + +2004-02-23 Ian Lance Taylor <ian@wasabisystems.com> + + * cp-demangle.c (__cxa_demangle): Adjust last patch to handle + empty string correctly. + + * cp-demangle.c (__cxa_demangle): It is not an error if status is + not NULL. It is an error if the mangled name is the same as a + built-in type name. + (main): If IN_GLIBCPP_V3 is defined, test __cxa_demangle rather + than cplus_demangle_v3. + + * dyn-string.c: Remove test of IN_LIBGCC2 and IN_GLIBCPP_V3 and + the associated #define of RETURN_ON_ALLOCATION_FAILURE. + 2004-02-16 Matt Kraai <kraai@alumni.cmu.edu> * regex.c: Include <ansidecl.h>. diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c index 19f191e..fe4b367 100644 --- a/libiberty/cp-demangle.c +++ b/libiberty/cp-demangle.c @@ -1748,31 +1748,33 @@ CP_STATIC_IF_GLIBCPP_V3 const struct demangle_builtin_type_info cplus_demangle_builtin_types[D_BUILTIN_TYPE_COUNT] = { - /* a */ { NL ("signed char"), NL ("signed char"), D_PRINT_INT }, + /* a */ { NL ("signed char"), NL ("signed char"), D_PRINT_DEFAULT }, /* b */ { NL ("bool"), NL ("boolean"), D_PRINT_BOOL }, - /* c */ { NL ("char"), NL ("byte"), D_PRINT_INT }, - /* d */ { NL ("double"), NL ("double"), D_PRINT_DEFAULT }, - /* e */ { NL ("long double"), NL ("long double"), D_PRINT_DEFAULT }, - /* f */ { NL ("float"), NL ("float"), D_PRINT_DEFAULT }, - /* g */ { NL ("__float128"), NL ("__float128"), D_PRINT_DEFAULT }, - /* h */ { NL ("unsigned char"), NL ("unsigned char"), D_PRINT_INT }, + /* c */ { NL ("char"), NL ("byte"), D_PRINT_DEFAULT }, + /* d */ { NL ("double"), NL ("double"), D_PRINT_FLOAT }, + /* e */ { NL ("long double"), NL ("long double"), D_PRINT_FLOAT }, + /* f */ { NL ("float"), NL ("float"), D_PRINT_FLOAT }, + /* g */ { NL ("__float128"), NL ("__float128"), D_PRINT_FLOAT }, + /* h */ { NL ("unsigned char"), NL ("unsigned char"), D_PRINT_DEFAULT }, /* i */ { NL ("int"), NL ("int"), D_PRINT_INT }, - /* j */ { NL ("unsigned int"), NL ("unsigned"), D_PRINT_INT }, + /* j */ { NL ("unsigned int"), NL ("unsigned"), D_PRINT_UNSIGNED }, /* k */ { NULL, 0, NULL, 0, D_PRINT_DEFAULT }, /* l */ { NL ("long"), NL ("long"), D_PRINT_LONG }, - /* m */ { NL ("unsigned long"), NL ("unsigned long"), D_PRINT_LONG }, + /* m */ { NL ("unsigned long"), NL ("unsigned long"), D_PRINT_UNSIGNED_LONG }, /* n */ { NL ("__int128"), NL ("__int128"), D_PRINT_DEFAULT }, - /* o */ { NL ("unsigned __int128"), NL ("unsigned __int128"), D_PRINT_DEFAULT }, + /* o */ { NL ("unsigned __int128"), NL ("unsigned __int128"), + D_PRINT_DEFAULT }, /* p */ { NULL, 0, NULL, 0, D_PRINT_DEFAULT }, /* q */ { NULL, 0, NULL, 0, D_PRINT_DEFAULT }, /* r */ { NULL, 0, NULL, 0, D_PRINT_DEFAULT }, - /* s */ { NL ("short"), NL ("short"), D_PRINT_INT }, - /* t */ { NL ("unsigned short"), NL ("unsigned short"), D_PRINT_INT }, + /* s */ { NL ("short"), NL ("short"), D_PRINT_DEFAULT }, + /* t */ { NL ("unsigned short"), NL ("unsigned short"), D_PRINT_DEFAULT }, /* u */ { NULL, 0, NULL, 0, D_PRINT_DEFAULT }, /* v */ { NL ("void"), NL ("void"), D_PRINT_VOID }, - /* w */ { NL ("wchar_t"), NL ("char"), D_PRINT_INT }, - /* x */ { NL ("long long"), NL ("long"), D_PRINT_DEFAULT }, - /* y */ { NL ("unsigned long long"), NL ("unsigned long long"), D_PRINT_DEFAULT }, + /* w */ { NL ("wchar_t"), NL ("char"), D_PRINT_DEFAULT }, + /* x */ { NL ("long long"), NL ("long"), D_PRINT_LONG_LONG }, + /* y */ { NL ("unsigned long long"), NL ("unsigned long long"), + D_PRINT_UNSIGNED_LONG_LONG }, /* z */ { NL ("..."), NL ("..."), D_PRINT_DEFAULT }, }; @@ -3050,6 +3052,30 @@ d_print_comp (dpi, dc) case DEMANGLE_COMPONENT_RESTRICT: case DEMANGLE_COMPONENT_VOLATILE: case DEMANGLE_COMPONENT_CONST: + { + struct d_print_mod *pdpm; + + /* When printing arrays, it's possible to have cases where the + same CV-qualifier gets pushed on the stack multiple times. + We only need to print it once. */ + + for (pdpm = dpi->modifiers; pdpm != NULL; pdpm = pdpm->next) + { + if (! pdpm->printed) + { + if (pdpm->mod->type != DEMANGLE_COMPONENT_RESTRICT + && pdpm->mod->type != DEMANGLE_COMPONENT_VOLATILE + && pdpm->mod->type != DEMANGLE_COMPONENT_CONST) + break; + if (pdpm->mod->type == dc->type) + { + d_print_comp (dpi, d_left (dc)); + return; + } + } + } + } + /* Fall through. */ case DEMANGLE_COMPONENT_RESTRICT_THIS: case DEMANGLE_COMPONENT_VOLATILE_THIS: case DEMANGLE_COMPONENT_CONST_THIS: @@ -3125,24 +3151,65 @@ d_print_comp (dpi, dc) case DEMANGLE_COMPONENT_ARRAY_TYPE: { - struct d_print_mod dpm; + struct d_print_mod *hold_modifiers; + struct d_print_mod adpm[4]; + unsigned int i; + struct d_print_mod *pdpm; /* We must pass this type down as a modifier in order to print - multi-dimensional arrays correctly. */ + multi-dimensional arrays correctly. If the array itself is + CV-qualified, we act as though the element type were + CV-qualified. We do this by copying the modifiers down + rather than fiddling pointers, so that we don't wind up + with a d_print_mod higher on the stack pointing into our + stack frame after we return. */ - dpm.next = dpi->modifiers; - dpi->modifiers = &dpm; - dpm.mod = dc; - dpm.printed = 0; - dpm.templates = dpi->templates; + hold_modifiers = dpi->modifiers; + + adpm[0].next = hold_modifiers; + dpi->modifiers = &adpm[0]; + adpm[0].mod = dc; + adpm[0].printed = 0; + adpm[0].templates = dpi->templates; + + i = 1; + pdpm = hold_modifiers; + while (pdpm != NULL + && (pdpm->mod->type == DEMANGLE_COMPONENT_RESTRICT + || pdpm->mod->type == DEMANGLE_COMPONENT_VOLATILE + || pdpm->mod->type == DEMANGLE_COMPONENT_CONST)) + { + if (! pdpm->printed) + { + if (i >= sizeof adpm / sizeof adpm[0]) + { + d_print_error (dpi); + return; + } + + adpm[i] = *pdpm; + adpm[i].next = dpi->modifiers; + dpi->modifiers = &adpm[i]; + pdpm->printed = 1; + ++i; + } + + pdpm = pdpm->next; + } d_print_comp (dpi, d_right (dc)); - dpi->modifiers = dpm.next; + dpi->modifiers = hold_modifiers; - if (dpm.printed) + if (adpm[0].printed) return; + while (i > 1) + { + --i; + d_print_mod (dpi, adpm[i].mod); + } + d_print_array_type (dpi, dc, dpi->modifiers); return; @@ -3212,15 +3279,13 @@ d_print_comp (dpi, dc) d_print_expr_op (dpi, d_left (dc)); else { - d_append_string_constant (dpi, "(("); + d_append_char (dpi, '('); d_print_cast (dpi, d_left (dc)); d_append_char (dpi, ')'); } d_append_char (dpi, '('); d_print_comp (dpi, d_right (dc)); d_append_char (dpi, ')'); - if (d_left (dc)->type == DEMANGLE_COMPONENT_CAST) - d_append_char (dpi, ')'); return; case DEMANGLE_COMPONENT_BINARY: @@ -3284,62 +3349,86 @@ d_print_comp (dpi, dc) case DEMANGLE_COMPONENT_LITERAL: case DEMANGLE_COMPONENT_LITERAL_NEG: - /* For some builtin types, produce simpler output. */ - if (d_left (dc)->type == DEMANGLE_COMPONENT_BUILTIN_TYPE) - { - switch (d_left (dc)->u.s_builtin.type->print) - { - case D_PRINT_INT: - if (d_right (dc)->type == DEMANGLE_COMPONENT_NAME) - { - if (dc->type == DEMANGLE_COMPONENT_LITERAL_NEG) - d_append_char (dpi, '-'); - d_print_comp (dpi, d_right (dc)); - return; - } - break; + { + enum d_builtin_type_print tp; - case D_PRINT_LONG: - if (d_right (dc)->type == DEMANGLE_COMPONENT_NAME) - { - if (dc->type == DEMANGLE_COMPONENT_LITERAL_NEG) - d_append_char (dpi, '-'); - d_print_comp (dpi, d_right (dc)); - d_append_char (dpi, 'l'); - return; - } - break; + /* For some builtin types, produce simpler output. */ + tp = D_PRINT_DEFAULT; + if (d_left (dc)->type == DEMANGLE_COMPONENT_BUILTIN_TYPE) + { + tp = d_left (dc)->u.s_builtin.type->print; + switch (tp) + { + case D_PRINT_INT: + case D_PRINT_UNSIGNED: + case D_PRINT_LONG: + case D_PRINT_UNSIGNED_LONG: + case D_PRINT_LONG_LONG: + case D_PRINT_UNSIGNED_LONG_LONG: + if (d_right (dc)->type == DEMANGLE_COMPONENT_NAME) + { + if (dc->type == DEMANGLE_COMPONENT_LITERAL_NEG) + d_append_char (dpi, '-'); + d_print_comp (dpi, d_right (dc)); + switch (tp) + { + default: + break; + case D_PRINT_UNSIGNED: + d_append_char (dpi, 'u'); + break; + case D_PRINT_LONG: + d_append_char (dpi, 'l'); + break; + case D_PRINT_UNSIGNED_LONG: + d_append_string_constant (dpi, "ul"); + break; + case D_PRINT_LONG_LONG: + d_append_string_constant (dpi, "ll"); + break; + case D_PRINT_UNSIGNED_LONG_LONG: + d_append_string_constant (dpi, "ull"); + break; + } + return; + } + break; - case D_PRINT_BOOL: - if (d_right (dc)->type == DEMANGLE_COMPONENT_NAME - && d_right (dc)->u.s_name.len == 1 - && dc->type == DEMANGLE_COMPONENT_LITERAL) - { - switch (d_right (dc)->u.s_name.s[0]) - { - case '0': - d_append_string_constant (dpi, "false"); - return; - case '1': - d_append_string_constant (dpi, "true"); - return; - default: - break; - } - } - break; + case D_PRINT_BOOL: + if (d_right (dc)->type == DEMANGLE_COMPONENT_NAME + && d_right (dc)->u.s_name.len == 1 + && dc->type == DEMANGLE_COMPONENT_LITERAL) + { + switch (d_right (dc)->u.s_name.s[0]) + { + case '0': + d_append_string_constant (dpi, "false"); + return; + case '1': + d_append_string_constant (dpi, "true"); + return; + default: + break; + } + } + break; - default: - break; - } - } + default: + break; + } + } - d_append_char (dpi, '('); - d_print_comp (dpi, d_left (dc)); - d_append_char (dpi, ')'); - if (dc->type == DEMANGLE_COMPONENT_LITERAL_NEG) - d_append_char (dpi, '-'); - d_print_comp (dpi, d_right (dc)); + d_append_char (dpi, '('); + d_print_comp (dpi, d_left (dc)); + d_append_char (dpi, ')'); + if (dc->type == DEMANGLE_COMPONENT_LITERAL_NEG) + d_append_char (dpi, '-'); + if (tp == D_PRINT_FLOAT) + d_append_char (dpi, '['); + d_print_comp (dpi, d_right (dc)); + if (tp == D_PRINT_FLOAT) + d_append_char (dpi, ']'); + } return; default: @@ -3549,11 +3638,13 @@ d_print_function_type (dpi, dc, mods) { int need_paren; int saw_mod; + int need_space; struct d_print_mod *p; struct d_print_mod *hold_modifiers; need_paren = 0; saw_mod = 0; + need_space = 0; for (p = mods; p != NULL; p = p->next) { if (p->printed) @@ -3562,15 +3653,18 @@ d_print_function_type (dpi, dc, mods) saw_mod = 1; switch (p->mod->type) { + case DEMANGLE_COMPONENT_POINTER: + case DEMANGLE_COMPONENT_REFERENCE: + need_paren = 1; + break; case DEMANGLE_COMPONENT_RESTRICT: case DEMANGLE_COMPONENT_VOLATILE: case DEMANGLE_COMPONENT_CONST: case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL: - case DEMANGLE_COMPONENT_POINTER: - case DEMANGLE_COMPONENT_REFERENCE: case DEMANGLE_COMPONENT_COMPLEX: case DEMANGLE_COMPONENT_IMAGINARY: case DEMANGLE_COMPONENT_PTRMEM_TYPE: + need_space = 1; need_paren = 1; break; case DEMANGLE_COMPONENT_RESTRICT_THIS: @@ -3589,18 +3683,14 @@ d_print_function_type (dpi, dc, mods) if (need_paren) { - switch (d_last_char (dpi)) + if (! need_space) { - case ' ': - case '(': - case '*': - break; - - default: - d_append_char (dpi, ' '); - break; + if (d_last_char (dpi) != '(' + && d_last_char (dpi) != '*') + need_space = 1; } - + if (need_space && d_last_char (dpi) != ' ') + d_append_char (dpi, ' '); d_append_char (dpi, '('); } @@ -3643,19 +3733,19 @@ d_print_array_type (dpi, dc, mods) need_paren = 0; for (p = mods; p != NULL; p = p->next) { - if (p->printed) - break; - - if (p->mod->type == DEMANGLE_COMPONENT_ARRAY_TYPE) - { - need_space = 0; - break; - } - else + if (! p->printed) { - need_paren = 1; - need_space = 1; - break; + if (p->mod->type == DEMANGLE_COMPONENT_ARRAY_TYPE) + { + need_space = 0; + break; + } + else + { + need_paren = 1; + need_space = 1; + break; + } } } @@ -3944,29 +4034,46 @@ __cxa_demangle (mangled_name, output_buffer, length, status) char *demangled; size_t alc; - if (status == NULL) - return NULL; - if (mangled_name == NULL) { - *status = -3; + if (status != NULL) + *status = -3; return NULL; } if (output_buffer != NULL && length == NULL) { - *status = -3; + if (status != NULL) + *status = -3; + return NULL; + } + + /* The specification for __cxa_demangle() is that if the mangled + name could be either an extern "C" identifier, or an internal + built-in type name, then we resolve it as the identifier. All + internal built-in type names are a single lower case character. + Frankly, this simplistic disambiguation doesn't make sense to me, + but it is documented, so we implement it here. */ + if (IS_LOWER (mangled_name[0]) + && mangled_name[1] == '\0' + && cplus_demangle_builtin_types[mangled_name[0] - 'a'].name != NULL) + { + if (status != NULL) + *status = -2; return NULL; } - demangled = d_demangle (mangled_name, DMGL_TYPES, &alc); + demangled = d_demangle (mangled_name, DMGL_PARAMS | DMGL_TYPES, &alc); if (demangled == NULL) { - if (alc == 1) - *status = -1; - else - *status = -2; + if (status != NULL) + { + if (alc == 1) + *status = -1; + else + *status = -2; + } return NULL; } @@ -3990,7 +4097,8 @@ __cxa_demangle (mangled_name, output_buffer, length, status) } } - *status = 0; + if (status != NULL) + *status = 0; return demangled; } @@ -4296,7 +4404,11 @@ main (argc, argv) if (dyn_string_length (mangled) > 0) { +#ifdef IN_GLIBCPP_V3 + s = __cxa_demangle (dyn_string_buf (mangled), NULL, NULL, NULL); +#else s = cplus_demangle_v3 (dyn_string_buf (mangled), options); +#endif if (s != NULL) { @@ -4328,9 +4440,16 @@ main (argc, argv) for (i = optind; i < argc; ++i) { char *s; +#ifdef IN_GLIBCPP_V3 + int status; +#endif /* Attempt to demangle. */ +#ifdef IN_GLIBCPP_V3 + s = __cxa_demangle (argv[i], NULL, NULL, &status); +#else s = cplus_demangle_v3 (argv[i], options); +#endif /* If it worked, print the demangled name. */ if (s != NULL) @@ -4339,7 +4458,13 @@ main (argc, argv) free (s); } else - fprintf (stderr, "Failed: %s\n", argv[i]); + { +#ifdef IN_GLIBCPP_V3 + fprintf (stderr, "Failed: %s (status %d)\n", argv[i], status); +#else + fprintf (stderr, "Failed: %s\n", argv[i]); +#endif + } } } diff --git a/libiberty/cp-demangle.h b/libiberty/cp-demangle.h index d3c57ce..eea0868 100644 --- a/libiberty/cp-demangle.h +++ b/libiberty/cp-demangle.h @@ -53,10 +53,20 @@ enum d_builtin_type_print D_PRINT_DEFAULT, /* Print as integer. */ D_PRINT_INT, - /* Print as long, with trailing `l'. */ + /* Print as unsigned integer, with trailing "u". */ + D_PRINT_UNSIGNED, + /* Print as long, with trailing "l". */ D_PRINT_LONG, + /* Print as unsigned long, with trailing "ul". */ + D_PRINT_UNSIGNED_LONG, + /* Print as long long, with trailing "ll". */ + D_PRINT_LONG_LONG, + /* Print as unsigned long long, with trailing "ull". */ + D_PRINT_UNSIGNED_LONG_LONG, /* Print as bool. */ D_PRINT_BOOL, + /* Print as float--put value in square brackets. */ + D_PRINT_FLOAT, /* Print in usual way, but here to detect void. */ D_PRINT_VOID }; diff --git a/libiberty/dyn-string.c b/libiberty/dyn-string.c index 1da76c2..5d48cdc 100644 --- a/libiberty/dyn-string.c +++ b/libiberty/dyn-string.c @@ -1,5 +1,5 @@ /* An abstract string datatype. - Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2000, 2002, 2004 Free Software Foundation, Inc. Contributed by Mark Mitchell (mark@markmitchell.com). This file is part of GNU CC. @@ -45,15 +45,6 @@ Boston, MA 02111-1307, USA. */ #include "libiberty.h" #include "dyn-string.h" -/* If this file is being compiled for inclusion in the C++ runtime - library, as part of the demangler implementation, we don't want to - abort if an allocation fails. Instead, percolate an error code up - through the call chain. */ - -#if defined(IN_LIBGCC2) || defined(IN_GLIBCPP_V3) -#define RETURN_ON_ALLOCATION_FAILURE -#endif - /* Performs in-place initialization of a dyn_string struct. This function can be used with a dyn_string struct on the stack or embedded in another object. The contents of of the string itself diff --git a/libiberty/testsuite/demangle-expected b/libiberty/testsuite/demangle-expected index 25e8830..9a3f0b9 100644 --- a/libiberty/testsuite/demangle-expected +++ b/libiberty/testsuite/demangle-expected @@ -3591,13 +3591,13 @@ hairyfunc5 # This is from gcc PR 8861 --format=gnu-v3 --no-params _Z1fILi1ELc120EEv1AIXplT_cviLd810000000000000000703DAD7A370C5EEE -void f<1, 120>(A<(1) + (((int)((double)810000000000000000703DAD7A370C5)))>) -f<1, 120> +void f<1, (char)120>(A<(1) + ((int)((double)[810000000000000000703DAD7A370C5]))>) +f<1, (char)120> # # This is also from gcc PR 8861 --format=gnu-v3 --no-params _Z1fILi1EEv1AIXplT_cvingLf3f800000EEE -void f<1>(A<(1) + (((int)(-((float)3f800000))))>) +void f<1>(A<(1) + ((int)(-((float)[3f800000])))>) f<1> # # This is from a libstdc++ debug mode patch. @@ -3635,7 +3635,7 @@ std::operator< <file_path, std::string> # More hairy qualifier handling. --format=gnu-v3 --no-params _Z9hairyfuncM1YKFPVPFrPA2_PM1XKFKPA3_ilEPcEiE -hairyfunc(int (* const (X::** (* restrict (* volatile*(Y::*)(int) const)(char*)) [2])(long) const) [3]) +hairyfunc(int (* const (X::** (* restrict (* volatile* (Y::*)(int) const)(char*)) [2])(long) const) [3]) hairyfunc # # Check that negative numbers are handled correctly. @@ -3681,6 +3681,24 @@ _ZNK5boost6spirit5matchI13rcs_deltatextEcvMNS0_4impl5dummyEFvvEEv boost::spirit::match<rcs_deltatext>::operator void (boost::spirit::impl::dummy::*)()() const boost::spirit::match<rcs_deltatext>::operator void (boost::spirit::impl::dummy::*)() # +# Multi-dimensional arrays with qualifiers on the inner dimensions. +--format=gnu-v3 --no-params +_Z3fooIA6_KiEvA9_KT_rVPrS4_ +void foo<int const [6]>(int const [9][6], int restrict const (* volatile restrict) [9][6]) +foo<int const [6]> +# +# From PR libstdc++/12736 +--format=gnu-v3 --no-params +_Z3fooIA3_iEvRKT_ +void foo<int [3]>(int const (&) [3]) +foo<int [3]> +# +# Related to PR libstdc++/12736 +--format=gnu-v3 --no-params +_Z3fooIPA3_iEvRKT_ +void foo<int (*) [3]>(int (* const&) [3]) +foo<int (*) [3]> +# # Test GNU V3 constructor and destructor identification. # 0 means it is not a constructor/destructor. # Other integers correspond to enum gnu_v3_{c,d}tor_kinds in demangle.h. |