From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E26A8ECAAA1 for ; Tue, 1 Nov 2022 13:48:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230008AbiKANsa (ORCPT ); Tue, 1 Nov 2022 09:48:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbiKANs1 (ORCPT ); Tue, 1 Nov 2022 09:48:27 -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 B667C1162; Tue, 1 Nov 2022 06:48:26 -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 16730611E7; Tue, 1 Nov 2022 13:48:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0F14C433D6; Tue, 1 Nov 2022 13:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667310505; bh=2r6RMNudw65t+LrmOPtjGBPzbGcSI8my0xvyNFh7v7c=; h=From:To:Cc:Subject:Date:From; b=u5+TP2f9XGevZNTdAqt4Z6sTDENHb1y8A2EB/sZeIJBNN5gNKhdu7VRPYYjTRbjoR rN+rfjLGrVZv6sOSAAMzo/gVxb9HhjrMCeJYQzhO0fRuZXQzGvHEWmPzfeQ4D68lur UmGTrEWmKkGaTh4fclViL4/nVhGi7GqeSzFPbkKC60Yo5gJXxt8E33slKoN+ePtv1E EsbpwrIlXzxari5SEvfTDmcVq1fKlCRCG8/DNDp9YfhLVSGQ8+AeeIl4fGw1xBZVsr v1cNvJDF9KowiwjFdIOFnb6lF3MLCL/n8DYnURo64OmDJsz9Qd7hHbeOPlrnq9DEJy KEpr1Lh8PEnCg== From: "Masami Hiramatsu (Google)" To: Arnaldo Carvalho de Melo Cc: Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Masami Hiramatsu , Steven Rostedt Subject: [PATCH v2 0/3] tools/perf: Fix perf probe crash by clang DWARF5 file Date: Tue, 1 Nov 2022 22:48:21 +0900 Message-Id: <166731050151.2100653.8202870942871353491.stgit@devnote3> X-Mailer: git-send-email 2.38.1.273.g43a17bfeac-goog User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-perf-users@vger.kernel.org Hi, Here is the 2nd version of the patches for perf probe which improves the robustness against clang DWARF5 file. Since the Clang generates a bit different DWARF5 file, the perf probe crashes or failes to analyze it. There are actually fragile code against it, so I fixed it ([1/3]) to avoid crash by SEGV. And make it accepts Clang's DWARF5 file ([2/3],[3/3]). Without this series, the perf probe crashes with the DWARF5 file which generated by clang as below; $ ./perf probe -k $BIN_PATH/vmlinux -s $SRC_PATH -L vfs_read:10 Segmentation fault This series fixes it to handle such file correctly; $ ./perf probe -k $BIN_PATH/vmlinux -s $SRC_PATH -L vfs_read:10 11 ret = rw_verify_area(READ, file, pos, count); 12 if (ret) return ret; On the DWARF5 specification, Sec 2.14, there is "The value 0 indicates that no source file has been specified." for DW_AT_decl_file, but clang generated DWARF5 will use the value 0. This issue is discussed on DWARF std ML; https://www.mail-archive.com/dwarf-discuss@lists.dwarfstd.org/msg00884.html And suggested that removing this part from the specification. http://wiki.dwarfstd.org/index.php?title=DWARF5_Line_Table_File_Numbers So as far as I understand, this is out of standard at this moment, but the standard itself has a discussion on this part. And maybe updated as currently clang does in the next release/revision. Thank you, --- Masami Hiramatsu (Google) (3): tools/perf: Fix to avoid crashing if DW_AT_decl_file is NULL tools/perf: Fix to use dwarf_attr_integrate for generic attr accessor tools/perf: Fix to get declared file name from clang DWARF5 tools/perf/util/dwarf-aux.c | 58 ++++++++++++++++++++++++++++------------ tools/perf/util/dwarf-aux.h | 3 ++ tools/perf/util/probe-finder.c | 37 +++++++++++++++++--------- 3 files changed, 68 insertions(+), 30 deletions(-) -- Masami Hiramatsu (Google)