From patchwork Thu Nov 9 23:59:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 163640 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp786161vqs; Thu, 9 Nov 2023 16:02:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IHze9NH7kH6RIDY2BnIH9/c/Ae9Qbynd6ZFNGVZugpeRUGJGrzQ8zWPsGA2lJ12QZyqzgGa X-Received: by 2002:a4a:e74e:0:b0:586:b79f:b0ee with SMTP id n14-20020a4ae74e000000b00586b79fb0eemr6897622oov.5.1699574539554; Thu, 09 Nov 2023 16:02:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699574539; cv=none; d=google.com; s=arc-20160816; b=hJrd0t1wGG1fB0nw7ZosIJwRGJIuVidxB+4ckVukCN73tqCZe0kDU0lMKjNtJ6XxTZ GbBvYdtGZ908E7xO0NufPwwAjGlYO7kHjvcQQVsXBcJAIvCbYOnXnVfThPJtA23LJjsl QkRE9vQ/fGFuB/ZnO+9l4St9nQADHFFk8qoF2xWBqaQgNChuz/SLsh3fkn8sE4c99kTU k15J6gZcQEKfT8MvEWS0ScsF31h4kdkf0WHDmqdZyc9AjlYFpEUwg94yyqUSn2djTpWQ DqPVwza0Lsj/5Z5RsST17XX0tl+u28FmGGpFXIc+hRoRJIBana3p/XKTF+cdFQMqZC+1 c0Pw== 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:sender :dkim-signature; bh=+X4K8d8Dew6reLn4C0dstRYrhu2d/Re9BWl7Yzp4hOo=; fh=K//si1Hi/RYC7s39rVvmvh0YbZGmBrdWWHQg3cPF7Xc=; b=N16c/zDN9mxMC5dYyLCyjcW7DgN2G6RsIgr3HQZCFjwWr1F3sLS1Roo0Puwet3WPfJ Hq86aOxKhUoD7KgEjPrzd//oHpYLiY9sb6YQ8US7G9bgS2yS36LrqbE03XwCBtyz+lzC p6ASzjrLNz1GdK966bXDMiXbOhjhRY2706VMnOjKyjx602jNVbFaZ28RFABeWCPx6KIb gews8tJGlq3ptkdiVORIJOCRI6WeZpVNkfbYTtlmLfNU/IXmD/NeYuH1T/AnNL9orY/S Pxn5/BEYCF5m5IP85gAEkqNhu3eYyU8j4BK4YDnamFS4NNS9WgEQM2TE4+CZRcpd7/a3 rg5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fc+0U4Gy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id l17-20020a05683016d100b006d32010ed43si6828279otr.35.2023.11.09.16.02.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 16:02:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fc+0U4Gy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 1F68481A1BFF; Thu, 9 Nov 2023 16:01:55 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345605AbjKJAA7 (ORCPT + 30 others); Thu, 9 Nov 2023 19:00:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345502AbjKJAAj (ORCPT ); Thu, 9 Nov 2023 19:00:39 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E23246B2; Thu, 9 Nov 2023 16:00:30 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-28023eadc70so1291767a91.2; Thu, 09 Nov 2023 16:00:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699574430; x=1700179230; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=+X4K8d8Dew6reLn4C0dstRYrhu2d/Re9BWl7Yzp4hOo=; b=fc+0U4Gy18sRK/DkuJub7OLhE5u9XNZ9Y+wievEjZg8ShRmRC50Rpw3/o0YO/SuLK8 WHm4i7vw2FEkCQDnDx3LxTdnp4yS10p2GuFycCK8kwMKJcpdrNXqKsbvOaGfORLjwrN7 uU4JNfPpuKTeP+5fy6Mo/p9n8JA2zC8e2OAN6ERwl4+Ij7B3vWNGOC0XrbJVqNYntrDp bY0hRK2aJBi2wRSNkN0ixByHQgq3UvZ48uuzyglHZ/CMOWYDbzJbSYG59wSMkMqo4Eqr Z35a/FTmuvcMejv5w1FCJrD+4qNBAAYve7keLNNTstJZ4dp8x4PvQAssJAweIheY/1So qF9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699574430; x=1700179230; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=+X4K8d8Dew6reLn4C0dstRYrhu2d/Re9BWl7Yzp4hOo=; b=Xb55HhLdCEexIoXSXF7phdpjvy9tfXkxrJybItYVH8ULWrNGiRYiNq0kUfFav04aPv awLVRZqKLgZFCsLyJ0MUoL4H32Vq7tJ8FKKBL4lLzsg2DiMTL2/ebqtJk32umwY91+dd pCMU/xAK0Xni4SO/vyKxholVUBA71OptPXsvJNOoB25kJfxMObptc0kIjWSP3XVj3kdp 3db2seZ+944CT+VNMEtWc+FzhVzTQuufL6DYU/2v28tjljVMRTikRvPh2ZqcFHVNzkz9 1gqlO8jx1SMnijeVstPgkWqrJAnqP84VfY4sbsQUCP+VVIdx841rv1xOrW9zbtO9C8BI vAZA== X-Gm-Message-State: AOJu0YyjBzOFKoOIEGN2e3H8GwEBW3FkynBZ4L+8ESGF0YOaY80Zfjz+ BUEN26SGd9m3JbrThGsIFVc= X-Received: by 2002:a17:90b:33c3:b0:27d:839:52ae with SMTP id lk3-20020a17090b33c300b0027d083952aemr3235984pjb.32.1699574429713; Thu, 09 Nov 2023 16:00:29 -0800 (PST) Received: from bangji.corp.google.com ([2620:15c:2c0:5:d45c:ae16:d959:a5f1]) by smtp.gmail.com with ESMTPSA id k32-20020a17090a4ca300b002635db431a0sm371312pjh.45.2023.11.09.16.00.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 16:00:29 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa , Peter Zijlstra Cc: Ian Rogers , Adrian Hunter , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, Linus Torvalds , Stephane Eranian , Masami Hiramatsu , Andi Kleen , linux-trace-devel@vger.kernel.org, linux-toolchains@vger.kernel.org Subject: [PATCH 09/52] perf probe: Convert to check dwarf_getcfi feature Date: Thu, 9 Nov 2023 15:59:28 -0800 Message-ID: <20231110000012.3538610-10-namhyung@kernel.org> X-Mailer: git-send-email 2.42.0.869.gea05f2083d-goog In-Reply-To: <20231110000012.3538610-1-namhyung@kernel.org> References: <20231110000012.3538610-1-namhyung@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 09 Nov 2023 16:01:55 -0800 (PST) X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782133072297709132 X-GMAIL-MSGID: 1782133072297709132 Now it has a feature check for the dwarf_getcfi(), use it and convert the code to check HAVE_DWARF_CFI_SUPPORT definition. Suggested-by: Masami Hiramatsu (Google) Signed-off-by: Namhyung Kim Acked-by: Masami Hiramatsu (Google) --- tools/perf/Makefile.config | 5 +++++ tools/perf/util/probe-finder.c | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index 8b6cffbc4858..aa55850fbc21 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -476,6 +476,11 @@ else else CFLAGS += -DHAVE_DWARF_GETLOCATIONS_SUPPORT endif # dwarf_getlocations + ifneq ($(feature-dwarf_getcfi), 1) + msg := $(warning Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.142); + else + CFLAGS += -DHAVE_DWARF_CFI_SUPPORT + endif # dwarf_getcfi endif # Dwarf support endif # libelf support endif # NO_LIBELF diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index 8d3dd85f9ff4..c8923375e30d 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c @@ -604,7 +604,7 @@ static int call_probe_finder(Dwarf_Die *sc_die, struct probe_finder *pf) ret = dwarf_getlocation_addr(&fb_attr, pf->addr, &pf->fb_ops, &nops, 1); if (ret <= 0 || nops == 0) { pf->fb_ops = NULL; -#if _ELFUTILS_PREREQ(0, 142) +#ifdef HAVE_DWARF_CFI_SUPPORT } else if (nops == 1 && pf->fb_ops[0].atom == DW_OP_call_frame_cfa && (pf->cfi_eh != NULL || pf->cfi_dbg != NULL)) { if ((dwarf_cfi_addrframe(pf->cfi_eh, pf->addr, &frame) != 0 && @@ -615,7 +615,7 @@ static int call_probe_finder(Dwarf_Die *sc_die, struct probe_finder *pf) free(frame); return -ENOENT; } -#endif +#endif /* HAVE_DWARF_CFI_SUPPORT */ } /* Call finder's callback handler */ @@ -1140,7 +1140,7 @@ static int debuginfo__find_probes(struct debuginfo *dbg, pf->machine = ehdr.e_machine; -#if _ELFUTILS_PREREQ(0, 142) +#ifdef HAVE_DWARF_CFI_SUPPORT do { GElf_Shdr shdr; @@ -1150,7 +1150,7 @@ static int debuginfo__find_probes(struct debuginfo *dbg, pf->cfi_dbg = dwarf_getcfi(dbg->dbg); } while (0); -#endif +#endif /* HAVE_DWARF_CFI_SUPPORT */ ret = debuginfo__find_probe_location(dbg, pf); return ret;