From patchwork Thu Nov 9 23:59:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 163639 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp786105vqs; Thu, 9 Nov 2023 16:02:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IFHTQJ9rFl3Ai7Lg4UHxnEAl6+3CGBhFJSh9Dr5qQQI6Yisc/xbAMN60VqnvjIt84GLPXl8 X-Received: by 2002:a05:6808:ec2:b0:3a7:2598:ab2c with SMTP id q2-20020a0568080ec200b003a72598ab2cmr3721172oiv.7.1699574535856; Thu, 09 Nov 2023 16:02:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699574535; cv=none; d=google.com; s=arc-20160816; b=dIw31IRFp7gvgVCm6LLNLJmxwz9TI6hRm5GLgi+ziUpxdbcPUvw54sn86naN2ckDsF N6/rKGU2L2P9L1tQnTKw6VJXImopci+sVMGOJLxu9Zxr2FcTYfP/tQArT86FCBOY47oI M5W4Twy4pxxuefAeprAEgADy/cNKx80R1ybncaKN66KpbgOjvwQUGdc4uwdXayge0oFn svxTYn0fKuxLiD0xW9Mte2KGI7pPUhlW09F29Tu1j48a81eqUHidTZp0O/pGR19auTHd MO/qf4OndN2LdCx3yquaaXQJ8o6BPWuK6owrAh56IffIbL5pdWqqkz7wzqJ9FLwCQzMi jUMQ== 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=gBFPY4pW04M2sgJecsy3kFli8IglhnnPsjX6xiP+Dlg=; fh=K//si1Hi/RYC7s39rVvmvh0YbZGmBrdWWHQg3cPF7Xc=; b=DHI6NQK47AX/Y9mfOV8oURCWML80SSuDDXtIrd4+DMjBfXo5hxtCm9xxTqVJSCiw21 SjGNIEjDOALWaFfeBgEr6Mxe7fDH2DdnJG724st5PcKwDHFnmk/GHd6g4NTScK+5tVt2 ZKh9h6IOaFFT059+234uI7pqbpjoQPWXhjIcDqFUY2kAvw6hGOW5fR002jvJqa5kNdch utoAwhoWlF4aRs2w181ii9h6ATpJ3DDSQp6udIv0Um5SrUVgE/A95LVonpV/qqreW+Tz JqFNNAn8G52qEe+f9Y5t+NTgeju7JNbTWd50lBhdO0Jbiiuex9fZiy4uFPq6pR/7UG+w I0Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=AjF20uFK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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. [23.128.96.32]) by mx.google.com with ESMTPS id a14-20020a056808128e00b003b6cc849d7fsi243313oiw.31.2023.11.09.16.02.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 16:02:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=AjF20uFK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 12804807F4A0; Thu, 9 Nov 2023 16:01:17 -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 S1345435AbjKJAAj (ORCPT + 30 others); Thu, 9 Nov 2023 19:00:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345450AbjKJAAg (ORCPT ); Thu, 9 Nov 2023 19:00:36 -0500 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7E1B4689; Thu, 9 Nov 2023 16:00:24 -0800 (PST) Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6bb4abb8100so1390619b3a.2; Thu, 09 Nov 2023 16:00:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699574424; x=1700179224; 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=gBFPY4pW04M2sgJecsy3kFli8IglhnnPsjX6xiP+Dlg=; b=AjF20uFKQi1cHWGqvw1DKTEmQ5rTmfFuJjUR2OWT2Y+2IYSFbXwkA2pWIbrknqOemL 1caI36D22RZr2TCDWojbPe61NtCz764bLpxXBNaD5TyQH5qPft66jbBXZgmXNBerdrn4 xX1AlHUeUygAfK9CLJdKNCOGfu9Ba1QWc1WmqF3+Si8XUBztGk9EQXdjsZFjYauRetea v5fGo+r6EUQtJPYZcHQN71ayLPwJd/K6N3EUaiWHo6koNzkyDVAUtmpVQJPnO4diD1/1 PAQ0yrATm2jGBMhm8g23ryWDrjWcmCSW6XbMhwLrYE7/UGq7B/LlWNKHJ6P6kegDKbft J8CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699574424; x=1700179224; 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=gBFPY4pW04M2sgJecsy3kFli8IglhnnPsjX6xiP+Dlg=; b=IDxo4JQgeh4f56EzBWYKBVB2p0eMxc6VqfYRPhInmeXLhSBlYMWqPggtQLAqJ6Wbid dfBgb1bBiXK4I2prFsYP3wb2ptl8JzcOprHY1rJRynuAfb6oH9jqbwOht4mLyQjd0S9f MxrQooEPpbqm5+Z4mf/rjD/yCe0VEASvDSlJb94pMYvuzpPN1BeXBbRWHkVhQQPN3lgO qXdRm4fJN+BNfvXTGyLjJxq9rwakg/9lF4382fC1CJ/4CizXDhTeMCyIEVx5i8FzYiwq SV2Vf4kZio/CNnIirQLB+Os1Fy2J0UbDBrCCdyIdhAsRG1+7zBjlr6QBwytwBkBx+wFK L2SQ== X-Gm-Message-State: AOJu0Yylx352mBaN86SZq/h2M3jcgn7meIUdGQNiztNyH+xD/Euq31Jp rWYjKtPnK+TPK9HvntRaMvY= X-Received: by 2002:a05:6a20:9143:b0:182:11b2:b982 with SMTP id x3-20020a056a20914300b0018211b2b982mr6536454pzc.27.1699574424018; Thu, 09 Nov 2023 16:00:24 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 16:00:23 -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 05/52] perf dwarf-aux: Move #ifdef code to the header file Date: Thu, 9 Nov 2023 15:59:24 -0800 Message-ID: <20231110000012.3538610-6-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:17 -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: 1782133068437030660 X-GMAIL-MSGID: 1782133068437030660 It's a usual convention that the conditional code is handled in a header file. As I'm planning to add some more of them, let's move the current code to the header first. Acked-by: Masami Hiramatsu (Google) Signed-off-by: Namhyung Kim --- tools/perf/util/dwarf-aux.c | 7 ------- tools/perf/util/dwarf-aux.h | 19 +++++++++++++++++-- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c index 4849c3bbfd95..adef2635587d 100644 --- a/tools/perf/util/dwarf-aux.c +++ b/tools/perf/util/dwarf-aux.c @@ -1245,13 +1245,6 @@ int die_get_var_range(Dwarf_Die *sp_die, Dwarf_Die *vr_die, struct strbuf *buf) out: return ret; } -#else -int die_get_var_range(Dwarf_Die *sp_die __maybe_unused, - Dwarf_Die *vr_die __maybe_unused, - struct strbuf *buf __maybe_unused) -{ - return -ENOTSUP; -} #endif /* diff --git a/tools/perf/util/dwarf-aux.h b/tools/perf/util/dwarf-aux.h index 7ec8bc1083bb..4f5d0211ee4f 100644 --- a/tools/perf/util/dwarf-aux.h +++ b/tools/perf/util/dwarf-aux.h @@ -121,7 +121,6 @@ int die_get_typename(Dwarf_Die *vr_die, struct strbuf *buf); /* Get the name and type of given variable DIE, stored as "type\tname" */ int die_get_varname(Dwarf_Die *vr_die, struct strbuf *buf); -int die_get_var_range(Dwarf_Die *sp_die, Dwarf_Die *vr_die, struct strbuf *buf); /* Check if target program is compiled with optimization */ bool die_is_optimized_target(Dwarf_Die *cu_die); @@ -130,4 +129,20 @@ bool die_is_optimized_target(Dwarf_Die *cu_die); void die_skip_prologue(Dwarf_Die *sp_die, Dwarf_Die *cu_die, Dwarf_Addr *entrypc); -#endif +#ifdef HAVE_DWARF_GETLOCATIONS_SUPPORT + +/* Get byte offset range of given variable DIE */ +int die_get_var_range(Dwarf_Die *sp_die, Dwarf_Die *vr_die, struct strbuf *buf); + +#else /* HAVE_DWARF_GETLOCATIONS_SUPPORT */ + +static inline int die_get_var_range(Dwarf_Die *sp_die __maybe_unused, + Dwarf_Die *vr_die __maybe_unused, + struct strbuf *buf __maybe_unused) +{ + return -ENOTSUP; +} + +#endif /* HAVE_DWARF_GETLOCATIONS_SUPPORT */ + +#endif /* _DWARF_AUX_H */