Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1223510pxu; Mon, 23 Nov 2020 15:09:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJxYGUUr8UwYaJHGZELZvCh2Ktpvn2xkR+gcWC9y/DjZRYXOXf7ekMpkJ64+Q+EhQlGZFGQR X-Received: by 2002:a50:99c3:: with SMTP id n3mr1425995edb.213.1606172973497; Mon, 23 Nov 2020 15:09:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606172973; cv=none; d=google.com; s=arc-20160816; b=pwLMd1yXiHQykr+7WpcvoVO/a0BT5uQA9UGFnBk3K5peMKyaayFffWMRAxqbN425KB LLvOac1LC10oRdh4g4BapK7oc2206/HoqxlhMyyas1yktth6lB1aSkzMUAaRNKOg8iPJ bTVg6b0llULVOqX926SSo6ESk6Sg2jQWHkbRFbdshzHTqhXDuo8E1ouLDThsTU0pvOcG LpgtNYDWm8hGBWY1+ioUQbcpP0VvOkO0AWRQPoDa7OeoyHG/CBNXFtiKVrvOJWFS5T+p pc56+drFU7TBkpgZBctfrLZ8wGjJt5DL81cePU8R6KIZPrTA/9eUc4y3F44/elGXi8is r+3Q== 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=GgHjpxrDKALEvUGHzTkissvECrrZPGSscvMrJyN5fxo=; b=gNFdXbRJq+QZ/qNC4Fe40L68ilrrQCGhys1mFRBvPCL0irL27bn3uAcJxXSe04XpcB C8fvYeUwQaFCQrST23FCZHjpyYrmMCS+ZvhqxuU5xaYg1NPZ4d/+qwU0b9BjJV7XqQmo KVRcFZIiF387qc3DUpAzAZq5UpDmWdjy+LiKE6SF7BuKeytEDgboWFyHwCuTX9oby2mb CiZxIJsk05fTaR9yG3vIKETnEcjvbJBgFiEl75zwebG4SLJanB7CxK/PGtlLsunX+QAq 6qInk939UIsm1PXyflVkk6Y/GKy1RILHRjhLELDWzjUkxfq4Xm/ZeGwLCjwg6NhqXrcL lPGw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bz2si7402497ejc.558.2020.11.23.15.09.11; Mon, 23 Nov 2020 15:09:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S2387615AbgKWXF6 convert rfc822-to-8bit (ORCPT + 99 others); Mon, 23 Nov 2020 18:05:58 -0500 Received: from us-smtp-delivery-44.mimecast.com ([207.211.30.44]:49882 "EHLO us-smtp-delivery-44.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733150AbgKWXF5 (ORCPT ); Mon, 23 Nov 2020 18:05:57 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-61-ouafUnhDNF-RAxCdRrCiqg-1; Mon, 23 Nov 2020 18:05:49 -0500 X-MC-Unique: ouafUnhDNF-RAxCdRrCiqg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A281681CBDB; Mon, 23 Nov 2020 23:05:47 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.195.242]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9CEC85D9CA; Mon, 23 Nov 2020 23:05:43 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Namhyung Kim , Alexander Shishkin , Michael Petlan , Song Liu , Ian Rogers , Stephane Eranian , Alexey Budankov , Andi Kleen , Adrian Hunter Subject: [PATCH 07/25] perf tools: Add build_id__is_defined function Date: Tue, 24 Nov 2020 00:04:54 +0100 Message-Id: <20201123230512.2097312-8-jolsa@kernel.org> In-Reply-To: <20201123230512.2097312-1-jolsa@kernel.org> References: <20201123230512.2097312-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jolsa@kernel.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kernel.org Content-Transfer-Encoding: 8BIT Content-Type: text/plain; charset=WINDOWS-1252 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding build_id__is_defined helper to check build id is defined and is != zero build id. Signed-off-by: Jiri Olsa --- tools/perf/util/build-id.c | 6 ++++++ tools/perf/util/build-id.h | 1 + 2 files changed, 7 insertions(+) diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index 6b410c3d52dc..2aacc8b29f7e 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -37,6 +37,7 @@ #include #include +#include #include static bool no_buildid_cache; @@ -912,3 +913,8 @@ void build_id__init(struct build_id *bid, const u8 *data, size_t size) memcpy(bid->data, data, size); bid->size = size; } + +bool build_id__is_defined(const struct build_id *bid) +{ + return bid && bid->size ? !!memchr_inv(bid->data, 0, bid->size) : false; +} diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h index f293f99d5dba..d53415feaf69 100644 --- a/tools/perf/util/build-id.h +++ b/tools/perf/util/build-id.h @@ -21,6 +21,7 @@ struct feat_fd; void build_id__init(struct build_id *bid, const u8 *data, size_t size); int build_id__sprintf(const struct build_id *build_id, char *bf); +bool build_id__is_defined(const struct build_id *bid); int sysfs__sprintf_build_id(const char *root_dir, char *sbuild_id); int filename__sprintf_build_id(const char *pathname, char *sbuild_id); char *build_id_cache__kallsyms_path(const char *sbuild_id, char *bf, -- 2.26.2