Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp11968284rwd; Thu, 22 Jun 2023 22:48:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4xGMPwcmp2vPqIJMuMn2cOEbyUIJapsTIK4HsKVddvJZwcrfWWa+HUVrUcUUvkpjq1e+8f X-Received: by 2002:a05:6a21:3803:b0:123:9582:ea06 with SMTP id yi3-20020a056a21380300b001239582ea06mr4323926pzb.10.1687499289767; Thu, 22 Jun 2023 22:48:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687499289; cv=none; d=google.com; s=arc-20160816; b=i3y0hZKrD68Wy0xMZq2ZVPUe/DEbqHYhzEFbQIAoNARQc7Qvdr2VGVr0z/y5BHGuLZ 34NdVi8O7ODDp7nKphIqLNRtfYq5szANZZRfgnmZug3DrjsTOZK9MKm0X6bwsBrKJ3Yx A8q1th9QaQs+WC3KTDnBNSBIn/ucJBKhAS2MqdlUG0eTnWFyDpOTyEendTb+MM60BAjt AUhsUvc2bE7IiPIQSx35VrNy4PvK56pU3km06y/T/ANdBZvfFyt5djw3oQbZlyNDe/Db RAwg1SW387szgn6UM7ViadVCtrVZRKsViVzyEVAODbyc7/AdUpemUKCKO46h7DkcvIaU 1eUQ== 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; bh=O0LrhnLRbqEUEharnSmOiq1vO/mF0p2PfHnPfcQ/YQg=; b=isIhR1LJxiygwfBASM1AtHwTGAqqU86EN/1CTrS8KpfoWf/o5ebWZGJM1X727Q8Sof AeIoW9n9Qx8O+RylufWYbMbyXyDCVzI2bvUvxad7O5KDmJ5Gyqkc8l9UK8KFE1uXKHGl oGWokS92l/PzNT414+5dzsPbKERwXopxKP6RG2HVrIu9pdQk9W8U8Vw+Yz5VVMUm6249 iizFY3D4EeTE/aINvOmrnix/25/A7k0UdeDWJMtRPVUBZufePWG4sVm6uzeR+V2wZtwe 2sK7GZF5N5CR1BpDvnKplLQIN7v/maN0NHo2aBKrKaFksMM7s8FRB3IgCM5XkpMve+2E jA5Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id le7-20020a170902fb0700b001b035052ec8si4207565plb.81.2023.06.22.22.47.56; Thu, 22 Jun 2023 22:48:09 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231468AbjFWFqy (ORCPT + 99 others); Fri, 23 Jun 2023 01:46:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230010AbjFWFqw (ORCPT ); Fri, 23 Jun 2023 01:46:52 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F15AA26B7; Thu, 22 Jun 2023 22:46:16 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4QnR425MhLztQnS; Fri, 23 Jun 2023 13:43:30 +0800 (CST) Received: from localhost.localdomain (10.67.174.95) by kwepemm600003.china.huawei.com (7.193.23.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Fri, 23 Jun 2023 13:46:09 +0800 From: Yang Jihong To: , , , , , , , , , , , , CC: Subject: [PATCH v5 2/4] perf tools: Extend PRINT_ATTRf to support printing of members with a value of 0 Date: Fri, 23 Jun 2023 05:44:14 +0000 Message-ID: <20230623054416.160858-3-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20230623054416.160858-1-yangjihong1@huawei.com> References: <20230623054416.160858-1-yangjihong1@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.174.95] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600003.china.huawei.com (7.193.23.202) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 When printing attr, members whose value is 0 will not be printed, we want to print the case where attr->type is 0(PERF_TYPE_HARDWARE), add `_a` param to PRINT_ATTRf macro to always print member when it is true No functional change. Signed-off-by: Yang Jihong Acked-by: Adrian Hunter --- tools/perf/util/perf_event_attr_fprintf.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/perf/util/perf_event_attr_fprintf.c b/tools/perf/util/perf_event_attr_fprintf.c index 7e5e7b30510d..433029c6afc5 100644 --- a/tools/perf/util/perf_event_attr_fprintf.c +++ b/tools/perf/util/perf_event_attr_fprintf.c @@ -80,15 +80,15 @@ static void __p_read_format(char *buf, size_t size, u64 value) #define p_branch_sample_type(val) __p_branch_sample_type(buf, BUF_SIZE, val) #define p_read_format(val) __p_read_format(buf, BUF_SIZE, val) -#define PRINT_ATTRn(_n, _f, _p) \ +#define PRINT_ATTRn(_n, _f, _p, _a) \ do { \ - if (attr->_f) { \ + if (_a || attr->_f) { \ _p(attr->_f); \ ret += attr__fprintf(fp, _n, buf, priv);\ } \ } while (0) -#define PRINT_ATTRf(_f, _p) PRINT_ATTRn(#_f, _f, _p) +#define PRINT_ATTRf(_f, _p) PRINT_ATTRn(#_f, _f, _p, false) int perf_event_attr__fprintf(FILE *fp, struct perf_event_attr *attr, attr__fprintf_f attr__fprintf, void *priv) @@ -99,7 +99,7 @@ int perf_event_attr__fprintf(FILE *fp, struct perf_event_attr *attr, PRINT_ATTRf(type, p_unsigned); PRINT_ATTRf(size, p_unsigned); PRINT_ATTRf(config, p_hex); - PRINT_ATTRn("{ sample_period, sample_freq }", sample_period, p_unsigned); + PRINT_ATTRn("{ sample_period, sample_freq }", sample_period, p_unsigned, false); PRINT_ATTRf(sample_type, p_sample_type); PRINT_ATTRf(read_format, p_read_format); @@ -141,10 +141,10 @@ int perf_event_attr__fprintf(FILE *fp, struct perf_event_attr *attr, PRINT_ATTRf(remove_on_exec, p_unsigned); PRINT_ATTRf(sigtrap, p_unsigned); - PRINT_ATTRn("{ wakeup_events, wakeup_watermark }", wakeup_events, p_unsigned); + PRINT_ATTRn("{ wakeup_events, wakeup_watermark }", wakeup_events, p_unsigned, false); PRINT_ATTRf(bp_type, p_unsigned); - PRINT_ATTRn("{ bp_addr, config1 }", bp_addr, p_hex); - PRINT_ATTRn("{ bp_len, config2 }", bp_len, p_hex); + PRINT_ATTRn("{ bp_addr, config1 }", bp_addr, p_hex, false); + PRINT_ATTRn("{ bp_len, config2 }", bp_len, p_hex, false); PRINT_ATTRf(branch_sample_type, p_branch_sample_type); PRINT_ATTRf(sample_regs_user, p_hex); PRINT_ATTRf(sample_stack_user, p_unsigned); -- 2.30.GIT