This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] libiberty: support demangling of rvalue reference typenames
- From: Artemiy Volkov <artemiyv at acm dot org>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: Ian Lance Taylor <ian at airs dot com>, gcc-patches <gcc-patches at gcc dot gnu dot org>, DJ Delorie <dj at redhat dot com>
- Date: Tue, 5 Jan 2016 23:38:40 +0300
- Subject: Re: [PATCH] libiberty: support demangling of rvalue reference typenames
- Authentication-results: sourceware.org; auth=none
- References: <1451958209-29170-1-git-send-email-artemiyv at acm dot org> <m3y4c45zm3 dot fsf at pepe dot airs dot com> <20160105075727 dot GA2876 at gmail dot com> <m3twms5f97 dot fsf at pepe dot airs dot com> <20160105135903 dot GA32467 at gmail dot com> <CAKOQZ8yP4oR4PbJz51Ri0q0UU7us+LFPJj-zVYTOLFDavq0DsA at mail dot gmail dot com>
On Tue, Jan 05, 2016 at 07:26:36AM -0800, Ian Lance Taylor wrote:
> On Tue, Jan 5, 2016 at 5:59 AM, Artemiy Volkov <artemiyv@acm.org> wrote:
> > On Tue, Jan 05, 2016 at 05:26:28AM -0800, Ian Lance Taylor wrote:
> >> Artemiy Volkov <artemiyv@acm.org> writes:
> >>
> >> > On Mon, Jan 04, 2016 at 10:06:44PM -0800, Ian Lance Taylor wrote:
> >> >> Artemiy Volkov <artemiyv@acm.org> writes:
> >> >>
> >> >> > This patch adds handling of 'O' (rvalue ref) type codes in the C++
> >> >> > demangling
> >> >> > code which is done similarly to the 'R' (regular references)
> >> >> > case. It also adds
> >> >> > a few testcases for various demangling styles which are just
> >> >> > mirrored versions
> >> >> > of the corresponding regular references demangling tests.
> >> >> >
> >> >> > libiberty/ChangeLog:
> >> >> >
> >> >> > 2016-01-04 Artemiy Volkov <artemiyv@acm.org>
> >> >> >
> >> >> > * cplus-dem.c (enum type_kind_t): Add tk_rvalue_reference
> >> >> > constant.
> >> >> > (demangle_template_value_parm): Handle tk_rvalue_reference
> >> >> > type kind.
> >> >> > (do_type): Support 'O' type id (rvalue references).
> >> >>
> >> >> Is there a compiler that actually generate these symbols?
> >> >
> >> > Sure, at least gcc and clang generate this. E.g. when compiling:
> >> >
> >> > void f(int&& b) { }
> >> >
> >> > you then have:
> >> >
> >> > â nm 1.o
> >> > 0000000000000000 T _Z1fOi
> >>
> >> That symbol name is handled by code in cp-demangle.c, not cplus-dem.c.
> >> It already works today. Try it. cplus-dem is the old (very old)
> >> demangler. cp-demangle is the current demangler.
> >
> > Sorry, I believe I should have mentioned that this patch is for the
> > needs of gdb, whose demangle command still pretty much uses the old
> > demangler in cplus-dem.c. I was working on rvalue references support in
> > gdb (https://sourceware.org/ml/gdb-patches/2015-12/msg00407.html) and
> > AIUI all the patches for libiberty should go through this mailing list,
> > that's why I sent the libiberty part here to later merge it to gdb.
>
> If gdb is using the code in cplus-dem.c in any way for a program
> compiled in the last 15 years, then gdb is doing something horribly
> wrong. What function is gdb calling that makes your patch make a
> difference?
This is what I'm doing, just the ordinary use of the demangle command...
â gdb gdb/gdb
GNU gdb (GDB) 7.10.1
Copyright (C) 2015 Free Software Foundation, Inc.
[snip]
(top-gdb) b cplus-dem.c:3636
Breakpoint 3 at 0x8cf598: file ../../binutils-gdb/libiberty/cplus-dem.c,
line 3636.
(top-gdb) r
Starting program: /home/w41/gdb-build/gdb/gdb
[snip]
(gdb) demangle -l c++ -- __20DisplayList_IteratorO11DisplayList
Breakpoint 3, do_type (work=0x7fffffffdf40, mangled=0x7fffffffded0,
result=0x11622b0) at ../../binutils-gdb/libiberty/cplus-dem.c:3636
3636 type_quals = TYPE_UNQUALIFIED;
(top-gdb) bt
#0 do_type (work=0x7fffffffdf40, mangled=0x7fffffffded0,
result=0x11622b0) at ../../binutils-gdb/libiberty/cplus-dem.c:3636
#1 0x00000000008d0b5c in do_arg (work=0x7fffffffdf40,
mangled=0x7fffffffded0, result=0x7fffffffdde0)
at ../../binutils-gdb/libiberty/cplus-dem.c:4231
#2 0x00000000008d1350 in demangle_args (work=0x7fffffffdf40,
mangled=0x7fffffffded0, declp=0x7fffffffdee0)
at ../../binutils-gdb/libiberty/cplus-dem.c:4514
#3 0x00000000008cb79a in demangle_signature (work=0x7fffffffdf40,
mangled=0x7fffffffded0, declp=0x7fffffffdee0)
at ../../binutils-gdb/libiberty/cplus-dem.c:1665
#4 0x00000000008ca778 in internal_cplus_demangle (work=0x7fffffffdf40,
mangled=0xdf5132 "O11DisplayList")
at ../../binutils-gdb/libiberty/cplus-dem.c:1203
#5 0x00000000008c9e0c in cplus_demangle (mangled=0xdf511a
"__20DisplayList_IteratorO11DisplayList", options=3)
at ../../binutils-gdb/libiberty/cplus-dem.c:886
#6 0x00000000007f2af0 in bfd_demangle (abfd=0x0, name=0xdf511a
"__20DisplayList_IteratorO11DisplayList", options=3)
at ../../binutils-gdb/bfd/bfd.c:1917
#7 0x0000000000781795 in gdb_demangle (name=0xdf511a
"__20DisplayList_IteratorO11DisplayList", options=3)
at ../../binutils-gdb/gdb/cp-support.c:1571
#8 0x0000000000695474 in language_demangle (current_language=0x9c0180
<cplus_language_defn>,
mangled=0xdf511a "__20DisplayList_IteratorO11DisplayList",
options=3) at ../../binutils-gdb/gdb/language.c:651
#9 0x00000000006a9189 in demangle_command (args=0xdf61a9 "-l c++ --
__20DisplayList_IteratorO11DisplayList", from_tty=1)
at ../../binutils-gdb/gdb/demangle.c:218
#10 0x0000000000507d64 in do_cfunc (c=0xeb1710, args=0xdf61a9 "-l c++ --
__20DisplayList_IteratorO11DisplayList", from_tty=1)
at ../../binutils-gdb/gdb/cli/cli-decode.c:105
#11 0x000000000050ad01 in cmd_func (cmd=0xeb1710, args=0xdf61a9 "-l c++
-- __20DisplayList_IteratorO11DisplayList", from_tty=1)
at ../../binutils-gdb/gdb/cli/cli-decode.c:1885
#12 0x0000000000769272 in execute_command (p=0xdf61d8 "t", from_tty=1)
at ../../binutils-gdb/gdb/top.c:475
#13 0x00000000006558c7 in command_handler (command=0xdf61a0 "demangle -l
c++ -- __20DisplayList_IteratorO11DisplayList")
at ../../binutils-gdb/gdb/event-top.c:491
#14 0x0000000000655e80 in command_line_handler (rl=0x1161910 "demangle
-l c++ -- __20DisplayList_IteratorO11DisplayList")
at ../../binutils-gdb/gdb/event-top.c:690
#15 0x00000000007d73fb in rl_callback_read_char () at
../../binutils-gdb/readline/callback.c:220
#16 0x000000000065538f in rl_callback_read_char_wrapper
(client_data=0x0) at ../../binutils-gdb/gdb/event-top.c:171
#17 0x00000000006557f4 in stdin_event_handler (error=0, client_data=0x0)
at ../../binutils-gdb/gdb/event-top.c:430
#18 0x000000000065441f in handle_file_event (file_ptr=0x11602c0,
ready_mask=1) at ../../binutils-gdb/gdb/event-loop.c:708
#19 0x00000000006549c2 in gdb_wait_for_event (block=1) at
../../binutils-gdb/gdb/event-loop.c:834
#20 0x000000000065391c in gdb_do_one_event () at
../../binutils-gdb/gdb/event-loop.c:323
#21 0x000000000065395e in start_event_loop () at
../../binutils-gdb/gdb/event-loop.c:347
#22 0x00000000006553c2 in cli_command_loop (data=0x0) at
../../binutils-gdb/gdb/event-top.c:186
---Type <return> to continue, or q <return> to quit---
#23 0x000000000064bd26 in current_interp_command_loop () at
../../binutils-gdb/gdb/interps.c:317
#24 0x000000000064cf0a in captured_command_loop (data=0x0) at
../../binutils-gdb/gdb/main.c:318
#25 0x0000000000648b31 in catch_errors (func=0x64ceef
<captured_command_loop>, func_args=0x0, errstring=0x9863d5 "",
mask=RETURN_MASK_ALL)
at ../../binutils-gdb/gdb/exceptions.c:240
#26 0x000000000064e3f9 in captured_main (data=0x7fffffffe7e0) at
../../binutils-gdb/gdb/main.c:1157
#27 0x0000000000648b31 in catch_errors (func=0x64d321 <captured_main>,
func_args=0x7fffffffe7e0, errstring=0x9863d5 "", mask=RETURN_MASK_ALL)
at ../../binutils-gdb/gdb/exceptions.c:240
#28 0x000000000064e422 in gdb_main (args=0x7fffffffe7e0) at
../../binutils-gdb/gdb/main.c:1165
#29 0x0000000000468c0d in main (argc=1, argv=0x7fffffffe8e8) at
../../binutils-gdb/gdb/gdb.c:32
>
> Ian
Thanks,
Artemiy