Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp1895418rwb; Fri, 5 Aug 2022 09:28:54 -0700 (PDT) X-Google-Smtp-Source: AA6agR68xElDfE6b48ruKc2P2VxxklhRNq8rcWjK5/+i/FBpGWj0Alwe0u92FNwoT9HnsL/DZoBW X-Received: by 2002:a05:6a00:bc5:b0:52b:49c9:d26c with SMTP id x5-20020a056a000bc500b0052b49c9d26cmr7389950pfu.73.1659716933845; Fri, 05 Aug 2022 09:28:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659716933; cv=none; d=google.com; s=arc-20160816; b=gBMpI9beX2DkODyijx/+i+/xQNNbbUsABQLxX+tZwacqNR4IeS3/r8PzqjVf1kiG52 d8I4TnDfBpqGNymR6r8iS4HmbKqFz/5R8+CgCWdheg+fQp71/tRYpUr4ibGvE9zvQjk2 /OXVxpzBxcrrImFKKj1QgD9dfE9g/tWvJuPoaauz0QM9X45TIBdGu4+ZoUg+BORonEvX VHbHjJTD48EYstCa2D4564WlO+OqUuZUTqPBvI3M4j7M/WuJTwJj6V5o4oWpuzHYmaSn IrVhMCjYup+guLsRYYgCwDhKnhfjw1gYoIk02FOyyPhecdPULjFeYZCvd7JhE2k+RW7G 5scQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=49OaeXnWk6cMwp+kh4OvJx/YTDNQxj6+ac8Ivp8gcQE=; b=HDuTXOg/4K9iHcgH32qnt7nY9ZWtHEh5nptTpdhOHJELvqYslmPysX46ZMN/wXoZaw p4gYQBuIDs+2GDFTR8ex0u/OZBrpdkk5Hp+QPh9AsPcPnKl2q4YXlPNKrG7vk8FEN7IX hVemh7YCxlRHeYSWtUA5Z0z8Aa53mVThOxZKK1is/oDHhGKeiclzUqcZ5oE9DPE2t4hu Pg5Pj/p3r+sAaphmvpUyI9fBhxx2pCM3SiyF5jAQlzm7EewZUN9gnofPXjErEkeltK+9 WMoM4LP7HKuRe6cAoArPs7VSPTh48N4xbaUbWv0KVcnqeboWGawUc4aYSe1GTf4e1Qlz jshQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bLUNXDsz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o26-20020a634e5a000000b0041ccc0ff2b8si3184665pgl.95.2022.08.05.09.28.40; Fri, 05 Aug 2022 09:28:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bLUNXDsz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241267AbiHEPqO (ORCPT + 99 others); Fri, 5 Aug 2022 11:46:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241076AbiHEPph (ORCPT ); Fri, 5 Aug 2022 11:45:37 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0008867CB6; Fri, 5 Aug 2022 08:44:11 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id AAC40B82985; Fri, 5 Aug 2022 15:44:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E11BFC433C1; Fri, 5 Aug 2022 15:44:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659714249; bh=NuOpRdMsihtMLYOwhaS3C4UEtVr+be11RVn2cwjc27A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bLUNXDszz/zBqQ3brx1rD/r7bdkpSyhZXciDVIvfIarmxR1WnGSa74LxDuUcI33XI dGcJxGZQj2taqZRKpOZhVCWP0WQT76D10FmmwH/4mX3Kwy6HPk7Gy8jjZdPj1963j2 F5mh9r/0rLOdO5fmZb+qPv2WE3IxKqQUTUPEZkg6x5Gv0E6zto0I2bHcDR1ReL6vSf bcWE/gq0lY7tzsVSnrZ3DFs+ey6RrhDGOC9Ox2ZQn+p73D+pmuefTTJHL2g8vxZ6Vg cmn09dJMAemfoRXhr8M34QoqyyQWAVFAENaDrV5aUuNedV/eMEXSTzomRUzCmfX1G3 +wMAopQNkWbOA== From: Miguel Ojeda To: Linus Torvalds , Greg Kroah-Hartman Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, patches@lists.linux.dev, Jarkko Sakkinen , Miguel Ojeda , Kees Cook , Alex Gaynor , Wedson Almeida Filho Subject: [PATCH v9 17/27] scripts: decode_stacktrace: demangle Rust symbols Date: Fri, 5 Aug 2022 17:42:02 +0200 Message-Id: <20220805154231.31257-18-ojeda@kernel.org> In-Reply-To: <20220805154231.31257-1-ojeda@kernel.org> References: <20220805154231.31257-1-ojeda@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Recent versions of both Binutils (`c++filt`) and LLVM (`llvm-cxxfilt`) provide Rust v0 mangling support. Reviewed-by: Kees Cook Co-developed-by: Alex Gaynor Signed-off-by: Alex Gaynor Co-developed-by: Wedson Almeida Filho Signed-off-by: Wedson Almeida Filho Signed-off-by: Miguel Ojeda --- scripts/decode_stacktrace.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh index 7075e26ab2c4..564c5632e1a2 100755 --- a/scripts/decode_stacktrace.sh +++ b/scripts/decode_stacktrace.sh @@ -8,6 +8,14 @@ usage() { echo " $0 -r | [|auto] []" } +# Try to find a Rust demangler +if type llvm-cxxfilt >/dev/null 2>&1 ; then + cppfilt=llvm-cxxfilt +elif type c++filt >/dev/null 2>&1 ; then + cppfilt=c++filt + cppfilt_opts=-i +fi + if [[ $1 == "-r" ]] ; then vmlinux="" basepath="auto" @@ -180,6 +188,12 @@ parse_symbol() { # In the case of inlines, move everything to same line code=${code//$'\n'/' '} + # Demangle if the name looks like a Rust symbol and if + # we got a Rust demangler + if [[ $name =~ ^_R && $cppfilt != "" ]] ; then + name=$("$cppfilt" "$cppfilt_opts" "$name") + fi + # Replace old address with pretty line numbers symbol="$segment$name ($code)" } -- 2.37.1