From patchwork Mon Dec 12 17:55:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Bj=C3=B6rn_Sch=C3=A4pers?= X-Patchwork-Id: 32465 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2380682wrr; Mon, 12 Dec 2022 09:55:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf5FazPQOjMo4LA39LrSs70F6VmSzhLi8MWWptmuHkhvoOJs0JRGJPLROlzcZgiH5wVDvopd X-Received: by 2002:a17:906:480b:b0:7c0:aabd:fef0 with SMTP id w11-20020a170906480b00b007c0aabdfef0mr14776166ejq.17.1670867742766; Mon, 12 Dec 2022 09:55:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670867742; cv=none; d=google.com; s=arc-20160816; b=qrslUruzObtrEqqw3mNbgyNhTRUup89iUTW85LqrNJ/c8PpjMyAxK2JJ0ZJPul/tkZ ZrirZXoydKta0zCYy7cwB4uCltrQAHod0yehrhF2+wm9oRZtZs1AvgVhR7BanGXiUk+J 0OI9ey1wExWp7LZFp7kvPRLzLwTM/jHZTZMGmSx0chEGtmgDN+0YBFYa4VWdXGbQRdLf 3Hrb0QOHW2WCOVPZOtyR92kImsVgvFxztYeT2xUp+2UHBpbGe1r4vF1Wd7XWH09IcAAz 0fznmgWKDgJXmG/hr4K/3oRK67wG/9nLNF2KAihI61pa6irO2aSVZkGhlpQUtiTNP1lg L78g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dmarc-filter :delivered-to; bh=s9bEGnmw/IiL/6OmyoiBV3SOk/94G337GVieYjyzzuM=; b=eGXzWetGuY70c8vItZoEq9bOcSk6U5p7kmTCMBVf+Uu6IIVK54oseHeBPVSe0UguuE QYdqmpicLsIzonbRM69kl3arnmLLm9VcQbD2/CpwQu8VXHqx0My7seec/PLnRFEBoaFw dbc0DkrUhQO8tNbxhJoWGkevi5N+jVVGSHLmrBtktmdIj+4zEqXdjUT27cvrHKmijT/m 6GB1klYOMuK2LoQ7qGJ6LaMXqwZgv5+JrJeDLKM9bRoqLT16Twhku6k3N/ynimiy9v4H f1dpgHF87KYRKedXsSJSs2NPeOvSx9EGwhh3sB8tuxf8B60sqrpQoEMy/G9BATtYcY8n JZeA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id ho36-20020a1709070ea400b007ad9c8201e7si6440426ejc.93.2022.12.12.09.55.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 09:55:42 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 159743851357 for ; Mon, 12 Dec 2022 17:55:38 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail.hazardy.de (mail.hazardy.de [78.94.181.132]) by sourceware.org (Postfix) with ESMTPS id 532B7385558F for ; Mon, 12 Dec 2022 17:55:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 532B7385558F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=hazardy.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=hazardy.de Received: from NB-372.intranet.mimot.com (unknown [78.94.181.132]) by mail.hazardy.de (Postfix) with ESMTPSA id ACFF97002BD; Mon, 12 Dec 2022 18:55:11 +0100 (CET) From: =?utf-8?q?Bj=C3=B6rn_Sch=C3=A4pers?= To: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.or Subject: [PATCH] libstdc++: Deliver names of C functions in Date: Mon, 12 Dec 2022 18:55:08 +0100 Message-Id: <20221212175508.50143-1-gcc@hazardy.de> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-Spam-Status: No, score=-13.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752031814564275778?= X-GMAIL-MSGID: =?utf-8?q?1752031814564275778?= From: Björn Schäpers One could add (), these are not part of __name. One could also try to check upfront if __cxa_demangle should be called at all. -- >8 -- Tested on i686-w64-mingw32. __cxa_demangle is only to demangle C++ names, for all C functions, extern "C" functions, and including main it returns -2, in that case just adapt the given name. Otherwise it's kept empty, which doesn't look nice in the stacktrace. libstdc++-v3/ChangeLog: * include/std/stacktrace (stacktrace_entry::_S_demangle): Use raw __name if __cxa_demangle could not demangle it. Signed-off-by: Björn Schäpers --- libstdc++-v3/include/std/stacktrace | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/include/std/stacktrace b/libstdc++-v3/include/std/stacktrace index 83c6463b0d8..6d4051b9f5b 100644 --- a/libstdc++-v3/include/std/stacktrace +++ b/libstdc++-v3/include/std/stacktrace @@ -217,8 +217,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION int __status; char* __str = __cxxabiv1::__cxa_demangle(__name, nullptr, nullptr, &__status); - if (__status == 0) + switch (__status) + { + case 0: __s = __str; + break; + case -2: + __s = __name; + break; + } __builtin_free(__str); return __s; }