Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp996987rwb; Tue, 27 Sep 2022 07:12:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4xTLBv9PD5vqRJaPiQ/w2MhH/n/xrtV49iVcpvVj6UEZ34qLK80UuXTFuwEWk87Q3VYM/i X-Received: by 2002:a05:6402:f11:b0:44f:e1ff:801a with SMTP id i17-20020a0564020f1100b0044fe1ff801amr27964357eda.109.1664287958264; Tue, 27 Sep 2022 07:12:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664287958; cv=none; d=google.com; s=arc-20160816; b=W5DK+2ZnH/PNNB596DAN0V75NrmKWnJpCfFmjvEXq8ZElJATqcAI5o2DPr0KW2cpm9 2PwmH5FfIYQHxCEPKHxgfhr4O3vr/Hegxq7sQZCElMWCMf3HKOniKzeZu1oAAc6vgoO+ zJMLwG3vIF+yPSivrsFByTOjXm7Sz6JH/ZhlpIfkBqiuubPi/IS6qkGZKMM19Vdt7ma5 zI1ycpOc9dbwWzMQGIYoehh2OHe/o5Kaf4Od39+8nyd2YTaBdrT1L+WarY3Cwm6J6WZJ oJnpTHPauAmm6vMf2R99TMPporApzQe+xZWzt2rOMlHkqfV8+eLJMjz1P8BfzjT8e8Qb nyUQ== 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=mN6vT74JW0jPtDaV/KCKrl+6LZjFyO1lLqXP11rGt9U=; b=uFnBJH2vtDgHBInUH/S3fex7iuKXqj986R6AYnQKgEPWwT7kwuGNsmf0errvKJYXXH CYhbLNW+nN8dmeciGE3wMWM4NrBLc2Dj5M2iPK1LB1JYLeC6ifSu1BlPBkn1lpO7FOWO KgrWeiqcailgBW5kboflzcaXk3JW/lNl+Ne4D8MCCKPzKJixkadcqVyC+6JRDrJDCGgd cqdsXu779jNjRkyZ9k1cqUHX8hEmuYaErBGzym/4SUZ3Pm758+NZlrziE8CFqj/bakgp cez1+APviRRGmqXhw+A/gsJXI1VqMcs+OTx1cagGv9IiHtnQJdqlFkWl1q+pjkFRZEfD e/Fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nCATbZBE; 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 f14-20020a0564021e8e00b0044e6700024asi1972999edf.116.2022.09.27.07.12.06; Tue, 27 Sep 2022 07:12:38 -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=nCATbZBE; 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 S232790AbiI0NUZ (ORCPT + 99 others); Tue, 27 Sep 2022 09:20:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232626AbiI0NSq (ORCPT ); Tue, 27 Sep 2022 09:18:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCBD415E473; Tue, 27 Sep 2022 06:17:29 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 657F061988; Tue, 27 Sep 2022 13:17:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6AFE2C433D7; Tue, 27 Sep 2022 13:17:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664284630; bh=19EdJ/0y3i1GtpUk5jHOaF/ydgtBPX+gON+rAI0Q9N4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nCATbZBEjSdSSiYvzZKhXv7RNjQRITHtFsU0FYO64bdOCh5fL8RUIUN2gNfvMW4ks FntW28c+YZ5v4tVyVc3F8fEfx6CXFA1Qx/lVdGG3iwkzKuB06DRf4MDktTu/3BvFv8 fS5IOzIiKBEwR9LAZhmtY/YxW9tOyLO4RhZlWuZPCRSyj8/F8pcVlxSdy1ccHkzBv5 JBBtIyAzGlmNOpU6OtXS0w8XA5BBf2WbgKzgEULohK28EZkliI3LdLvStYBLFkkH3X aFpYTsBM8DqB6hKgrEBMXoQ/lAP0/XRsPi4vRoB3AxdAGFqHbbvNCJfI7uFXBnuzKR rQ26jJOAIm/RQ== 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 v10 17/27] scripts: decode_stacktrace: demangle Rust symbols Date: Tue, 27 Sep 2022 15:14:48 +0200 Message-Id: <20220927131518.30000-18-ojeda@kernel.org> In-Reply-To: <20220927131518.30000-1-ojeda@kernel.org> References: <20220927131518.30000-1-ojeda@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 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.3