Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp2290193imn; Mon, 1 Aug 2022 19:17:10 -0700 (PDT) X-Google-Smtp-Source: AA6agR5h0wtPF+zvULQkntdlauxv+lJ62zFI9nyqI9KIr5MZWMcn2LYFnBG46+a1x/t4Ogo36ZxF X-Received: by 2002:a05:6402:280f:b0:43d:f946:a895 with SMTP id h15-20020a056402280f00b0043df946a895mr558628ede.229.1659406630705; Mon, 01 Aug 2022 19:17:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659406630; cv=none; d=google.com; s=arc-20160816; b=OYvVSXnw1lh6Utd/ra84AA64WsBZdJs45WVIvGA6AjwvTv8mrDqwM084bBAV0tQ6jY Od9ljgyr0hx8enHE7h/1hGBYEQgLdPI0RWPZEmiRLbdHgb8POZ/WGT6VjuRZBCzlnQ0t 1rPc/IQWN+A7eAhviJN25+8OCIf+qdTRybftA5LZ6u6hg+3UHEeVa7zQQtFOdaMkVXdZ PKXvSBP50robP9F73H1KvB8A/CFnVF+9wciZ3G1fjb16ilKhVH+zUgb9hEZ+xkjIdzsU Wkv/XYoYV57vlmr1NRTe5VQbjvxbNlb9nyQafRmN3ax/ulfQTB5djkMIZQ0YEAt3cCNY lL8A== 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=CPls5McYGs01s172180Yx+Cx5gYhIDxIIf46473YfB7HJLJWjzdan3Vv8M24XduzH0 /6iS441hTMLftqabm4zwj5Uw0aUC8o6Sk7nk6fBLCXLzgxSUm0dQnw5tabKBMAsxSaI2 18lEgn1ns1MWsp3n2tZtwaOkptfcErKgR9Q9r0Ic+A+un7dIy3RhcLcdfxdjWp476Yz4 Tg7DbWirEQVAFM7TtgOs05YHf/QP9PQuOLlcQDFkAgSXuaTQIorYtUhobIS/0+hL3FiF XUjcTY9IxltgeMR7UOcQKLhLjsZ6sJju7Ml91YoaoHp3yUkyphpLVVe40WSIcIrvZ2LG SOjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=X8B0Rnx5; 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 l20-20020a170906795400b00730462ddd4fsi7040283ejo.542.2022.08.01.19.16.45; Mon, 01 Aug 2022 19:17:10 -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=X8B0Rnx5; 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 S235807AbiHBBzi (ORCPT + 99 others); Mon, 1 Aug 2022 21:55:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235735AbiHBByy (ORCPT ); Mon, 1 Aug 2022 21:54:54 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55C2A48CA4; Mon, 1 Aug 2022 18:53:25 -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 sin.source.kernel.org (Postfix) with ESMTPS id C2BD7CE19F4; Tue, 2 Aug 2022 01:53:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7F69C433D7; Tue, 2 Aug 2022 01:53:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659405202; bh=NuOpRdMsihtMLYOwhaS3C4UEtVr+be11RVn2cwjc27A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X8B0Rnx5hiPLbSQoil8jKzXGRaRTnT8LMR36JCM47QXX1Ycf4AmUmgZdAiE+oV1D3 o4p5tpjKvbuIxvWblx+XLusOwnoMU6JVRIQeGkHMDX7LDIKgYgCp8SdvuisfDOAcHI /K2RzIhggO2YLXfENgxZqpouWFDB5+RNR1Tf24TW6np5BTFSNusinvIZd8My4lONp9 SWViyeJwWFo86tWZWFMvYJrTd05pVn+TFyzn7AVIYFadgj9MKTzf+yRbEiYyc9O3IT dOQ5kkp0mkxS32epGd7W7pL6UdRODLdr8vuOSssLVHbsHfujhuZmldPwtkSpgM4U97 zQVwM3n+zstIw== From: Miguel Ojeda To: Linus Torvalds , Greg Kroah-Hartman Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Jarkko Sakkinen , Miguel Ojeda , Kees Cook , Alex Gaynor , Wedson Almeida Filho Subject: [PATCH v8 24/31] scripts: decode_stacktrace: demangle Rust symbols Date: Tue, 2 Aug 2022 03:50:11 +0200 Message-Id: <20220802015052.10452-25-ojeda@kernel.org> In-Reply-To: <20220802015052.10452-1-ojeda@kernel.org> References: <20220802015052.10452-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 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