This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Refactor rust-demangle to be independent of C++ demangling.
- From: "Ian Lance Taylor via gcc-patches" <gcc-patches at gcc dot gnu dot org>
- To: Eduard-Mihai Burtescu <eddyb at lyken dot rs>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>, Ian Lance Taylor <ian at airs dot com>
- Date: Tue, 22 Oct 2019 11:39:00 -0700
- Subject: Re: [PATCH] Refactor rust-demangle to be independent of C++ demangling.
- References: <fd31aba1-d21e-4a3e-99b6-84f4aaa033c4@www.fastmail.com>
- Reply-to: Ian Lance Taylor <iant at google dot com>
On Tue, Oct 22, 2019 at 11:08 AM Eduard-Mihai Burtescu <eddyb@lyken.rs> wrote:
>
> @@ -160,27 +159,20 @@ cplus_demangle (const char *mangled, int options)
> if ((options & DMGL_STYLE_MASK) == 0)
> options |= (int) current_demangling_style & DMGL_STYLE_MASK;
>
> + /* The Rust demangling is implemented elsewhere.
> + Legacy Rust symbols overlap with GNU_V3, so try Rust first. */
> + if (RUST_DEMANGLING || AUTO_DEMANGLING)
> + {
> + ret = rust_demangle (mangled, options);
> + if (ret || RUST_DEMANGLING)
> + return ret;
> + }
> +
> /* The V3 ABI demangling is implemented elsewhere. */
> - if (GNU_V3_DEMANGLING || RUST_DEMANGLING || AUTO_DEMANGLING)
> + if (GNU_V3_DEMANGLING || AUTO_DEMANGLING)
> {
> ret = cplus_demangle_v3 (mangled, options);
> - if (GNU_V3_DEMANGLING)
> - return ret;
> -
> - if (ret)
> - {
> - /* Rust symbols are GNU_V3 mangled plus some extra subtitutions.
> - The subtitutions are always smaller, so do in place changes. */
> - if (rust_is_mangled (ret))
> - rust_demangle_sym (ret);
> - else if (RUST_DEMANGLING)
> - {
> - free (ret);
> - ret = NULL;
> - }
> - }
> -
> - if (ret || RUST_DEMANGLING)
> + if (ret || GNU_V3_DEMANGLING)
> return ret;
> }
I have to assume that C++ demangling is still quite a bit more common
than Rust demangling, so it's troubling that it looks like we're going
to do extra work for each symbol that starts with _ZN, which is not a
particularly uncommon prefix for a C++ mangled name. Is there some
way we can quickly separate out Rust symbols? Or should we try C++
demangling first?
Ian