From patchwork Sat Mar 30 20:10:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 87850 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 744B2385C6E8 for ; Sat, 30 Mar 2024 20:10:58 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta36.uswest2.a.cloudfilter.net (omta36.uswest2.a.cloudfilter.net [35.89.44.35]) by sourceware.org (Postfix) with ESMTPS id 387843858D28 for ; Sat, 30 Mar 2024 20:10:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 387843858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 387843858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711829432; cv=none; b=eW2BS/hcad/XYmFILCGe555yhpKRiweTDrdSdhm0f0ZuDSoFAXRxx9/8fFLKr6G5nOMsxs2ZmF1QWlSr1xUStN/P6QCwl4zG+fwvI5ia0YCW1a91gZBG5r18LSF7C8Jl/zlQTq9WnYS5F4RsFZGnPcitFsf2ZJAjr46ndbGX7Mw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711829432; c=relaxed/simple; bh=11lZEXl+j7eUrMeJfOobgOvUudqbA47WMldt3lZO5dk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=f7kjgvYaHGXTSk4FRQ7w/xVELulZkXjsgwDj8ly7Mg/J/QKyFLW5IO4N/2LsAgIZEagoosTpQBPcjxMSfs2jsadPCF59zgcp/1U7MgZ7HbhWca/Pyyy7LSeHuc/CB/UUfGX/eFHs8JNIAUHxElngzkCqDlEQ0PePNQseAqc12G0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5009a.ext.cloudfilter.net ([10.0.29.176]) by cmsmtp with ESMTPS id qc7QreTzjtf2Qqf25rWU7D; Sat, 30 Mar 2024 20:10:29 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id qf23rfj6uELAWqf24rpq0B; Sat, 30 Mar 2024 20:10:28 +0000 X-Authority-Analysis: v=2.4 cv=EfzOQumC c=1 sm=1 tr=0 ts=660871b4 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=K6JAEmCyrfEA:10 a=Qbun_eYptAEA:10 a=CCpqsmhAAAAA:8 a=oWXG3-jZ40e-WZOujaIA:9 a=ul9cdbp4aOFLsgKbc677:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=9W/2PyOxJLEt6C4TyjvhovApQ9PKqUKnjvlfWwG+fOU=; b=l3fVCr6AOEps/2sVw09bSNOjel MwX480COe8DkCc8E5/tlNrpJjjGB2oko5Rbuqcp2XiCgSs1B3gp9kaf3Z4vSTOQ2ILGXozTbjCMQw u0B3NxM52jg+1DEXa8IaaRnmS; Received: from 97-122-82-115.hlrn.qwest.net ([97.122.82.115]:33432 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rqf23-002dOi-1b; Sat, 30 Mar 2024 14:10:27 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: gcc-patches@gcc.gnu.org, Tom Tromey Subject: [PATCH] libiberty: Invoke D demangler when --format=auto Date: Sat, 30 Mar 2024 14:10:13 -0600 Message-ID: <20240330201013.1755786-1-tom@tromey.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.82.115 X-Source-L: No X-Exim-ID: 1rqf23-002dOi-1b X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-82-115.hlrn.qwest.net (localhost.localdomain) [97.122.82.115]:33432 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfNu0kmwNNwdPb9jXX+iL6FtN7Ddu7gN2LTRz2rePn2QtZAAj/DY/PshgNcYYJySOL+vTmIc6THMSDLX7QaRB7Bm4n2zLE0V++7Nsp2rirg8AXVNYFOyD eKK+PT1R75cpbAnqTlKSerTILX5VxOZP08H6xXC4NrMU4f48TKIrSk/yRQkUgYfHh5o7KZgUkRS+QfO/iwFXUKmmbp4Zn6mCpjQ= X-Spam-Status: No, score=-3021.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org 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). This patch also fixed another GDB bug, though of course that part won't apply to the GCC repository. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31580 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30276 libiberty * cplus-dem.c (cplus_demangle): Try the D demangler with "auto" format. * testsuite/d-demangle-expected: Add --format=auto test. --- 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 } -# 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" 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); - if (DLANG_DEMANGLING) + if (DLANG_DEMANGLING || AUTO_DEMANGLING) { ret = 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=dlang _D8demangle9anonymous03fooZ demangle.anonymous.foo +# +# Test that 'auto' works. +--format=auto +_D8demangle9anonymous03fooZ +demangle.anonymous.foo