From patchwork Mon Dec 12 17:56:01 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: 32466 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2381184wrr; Mon, 12 Dec 2022 09:56:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf51f90eONRBS/s+CslnbTrlE2p3iPNYJP2m/94Y2PPKI3yV+M5APc21MXVrfAUhi28gC6BA X-Received: by 2002:a05:6402:4147:b0:45c:835c:3686 with SMTP id x7-20020a056402414700b0045c835c3686mr15100067eda.15.1670867818168; Mon, 12 Dec 2022 09:56:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670867818; cv=none; d=google.com; s=arc-20160816; b=ozeC68bcg+r2bf8wHC80Qo0Jc4ex4WcXMk0Jx2aDGrzzZghId/I30MXWifrBWigFAX q5Ap7u5BsdDtzB5Fw9yteXGL0ig8zrfvNYLfPKbBYukL4UNLMrQ01S2K5tS42QMEW/5F EOOpKP74s7BRz8bEFq2m+Gbf1aJVCio/FI3eLg3wTNPSGy+5TQetUI2W87HJF7wjERIO nzHNfToGYpiU9boJDJYXrwa8bi9aydlh77VMVEY6mutqE9mDzuuO+RMVap7UieaKVuA3 0CpIoiRnyT6Z+QvZKkV6TQVRmmIzV8h3bixnmcEEe2kZMny8QjmJWB/kxyITSvcemh6l TE9g== 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=QOyNtRIbrrJCJEPxejeYtMDUtDUszKNA/BXFwjSm/OE8jCcK8b81yOlRvU6H72UcAZ +ID/xD5UoVjC+bfUgNMU+/XJAM64mPEJ24lg6Rn4ZFoI+YTWr3PablF5thFaNfZDsCpj bPJaZJ/Va4Vn/WX51B9X9Sz75fnuKitmQ89Im6BSV3sespzRTEWil8erU6gNC0z2HFPw CNTjme/fwxmRMPz0UVZKzjcV+cHoQfHNp37wab1Gg/+1/UGuAsnRrsFTQp2lM+WdE7zN 1CaCwhDOSZfoNYDiNrDyjNWWG60d+5jO7EFqR6BFV7sQS9jGlrFfe1+rPvEJj/CprxnF NwqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id n9-20020aa7c449000000b004645d47d9e1si6934213edr.345.2022.12.12.09.56.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 09:56:58 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 44A1E384EF7A for ; Mon, 12 Dec 2022 17:56:31 +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 0D9943853D7B; Mon, 12 Dec 2022 17:56:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0D9943853D7B 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 1315C7002BD; Mon, 12 Dec 2022 18:56:04 +0100 (CET) From: =?utf-8?q?Bj=C3=B6rn_Sch=C3=A4pers?= To: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Subject: [PATCH] libstdc++: Deliver names of C functions in Date: Mon, 12 Dec 2022 18:56:01 +0100 Message-Id: <20221212175601.50166-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?1752031893405565629?= 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; }