From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id BB3693861806; Tue, 2 Apr 2024 20:06:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BB3693861806 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1712088415; bh=JjXCXPX3p0rL4H2pM9CkdqAz0jMyR+1w6zhWB3eUzHU=; h=From:To:Subject:Date:From; b=xKLWtrvyhSGDq86GcPwdQDTbDSTv2h9PSfa4xoCH7CtBJK94CVwXS77ML+rTHeJfy 0VMMsDITbCmeUDJIGrJvvMLrVQo4t4HTPwwxLj9cqP8DZjrI7HNB1VPwfurTOdAnzV pcOqY5Wtm8AMMC2K25Jm2gNsrak03Du78Mey9wpQ= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: binutils-cvs@sourceware.org, gdb-cvs@sourceware.org Subject: [binutils-gdb] libiberty: Invoke D demangler when --format=auto X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 251cedaeb57fe1e0fd28798f476fbee75373bbf4 X-Git-Newrev: b1741ab0dafd899889faab6e862094a325a6b83c Message-Id: <20240402200655.BB3693861806@sourceware.org> Date: Tue, 2 Apr 2024 20:06:55 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Db1741ab0dafd= 899889faab6e862094a325a6b83c commit b1741ab0dafd899889faab6e862094a325a6b83c Author: Tom Tromey Date: Sat Mar 30 13:48:30 2024 -0600 libiberty: Invoke D demangler when --format=3Dauto =20 Investigating GDB PR d/31580 showed that the libiberty demangler doesn't automatically demangle D mangled names. However, I think it should -- like C++ and Rust (new-style), D mangled names are readily distinguished by the leading "_D", and so the likelihood of confusion is low. The other non-"auto" cases in this code are Ada (where the encoded form could more easily be confused by ordinary programs) and Java (which is long gone, but which also shared the C++ mangling and thus was just an output style preference). =20 This patch also fixed another GDB bug, though of course that part won't apply to the GCC repository. =20 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31580 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30276 =20 libiberty * cplus-dem.c (cplus_demangle): Try the D demangler with "auto" format. * testsuite/d-demangle-expected: Add --format=3Dauto test. Diff: --- gdb/testsuite/gdb.dlang/dlang-start-2.exp | 4 +--- libiberty/cplus-dem.c | 2 +- libiberty/testsuite/d-demangle-expected | 5 +++++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/gdb/testsuite/gdb.dlang/dlang-start-2.exp b/gdb/testsuite/gdb.= dlang/dlang-start-2.exp index 4b3163ec97d..284f841b54a 100644 --- a/gdb/testsuite/gdb.dlang/dlang-start-2.exp +++ b/gdb/testsuite/gdb.dlang/dlang-start-2.exp @@ -79,10 +79,8 @@ if {[gdb_start_cmd] < 0} { return -1 } =20 -# We should probably have "D main" instead of "_Dmain" here, filed PR30276 -# '[gdb/symtab] function name is _Dmain instead of "D main"' about that. gdb_test "" \ - "in _Dmain \\(\\)" \ + "in D main \\(\\)" \ "start" =20 gdb_test "show language" {"auto; currently d".} diff --git a/libiberty/cplus-dem.c b/libiberty/cplus-dem.c index 8b92946981f..ee9e84f5d6b 100644 --- a/libiberty/cplus-dem.c +++ b/libiberty/cplus-dem.c @@ -186,7 +186,7 @@ cplus_demangle (const char *mangled, int options) if (GNAT_DEMANGLING) return ada_demangle (mangled, options); =20 - if (DLANG_DEMANGLING) + if (DLANG_DEMANGLING || AUTO_DEMANGLING) { ret =3D dlang_demangle (mangled, options); if (ret) diff --git a/libiberty/testsuite/d-demangle-expected b/libiberty/testsuite/= d-demangle-expected index 47b059c4298..cfbdf2a52cb 100644 --- a/libiberty/testsuite/d-demangle-expected +++ b/libiberty/testsuite/d-demangle-expected @@ -1470,3 +1470,8 @@ demangle.anonymous --format=3Ddlang _D8demangle9anonymous03fooZ demangle.anonymous.foo +# +# Test that 'auto' works. +--format=3Dauto +_D8demangle9anonymous03fooZ +demangle.anonymous.foo