Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp686728pxu; Thu, 26 Nov 2020 09:04:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJw/ltOvNHVmU9xu1V0ABY8fTwiS6lXMfM4sVwpHsSZp7vVlVhFFjiudBcPgvUxYicHrEmRJ X-Received: by 2002:a05:6402:21c7:: with SMTP id bi7mr3621122edb.54.1606410271048; Thu, 26 Nov 2020 09:04:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606410271; cv=none; d=google.com; s=arc-20160816; b=MGRZYHV0qoiem/82/NBqL5mq6TVC5gtp4WZf7mUzeAlMtl/uRIbNglBPxIKoywk0+8 m14U5oEDwswtXPI778/htUuZyCcuuhki4OlybWgS4r77FnkENWnZe9Ac25d6Cj3NmFA/ eHy/N8+uJDNN9XVYpZ076WN53pZ+sLA4+UcObvGsmduCY5W7NimIOWt7Xp4QaX5aBKjP x+Vv6FqaYwSMXQhmPJ3miBWjeTITu8cgIhzEriUN5+qSd/9aFG9O1SSa6f3F0Ess+hp+ vAgeFXGfZwEYJnHINEOY+zmd4axnASDIxGsrxp82NQ7A0V2i7gBIp79Q95YUBS3/c/xy snaQ== 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=QXu1ug0pZ3OBoGD00ky3t7I2sfCfySBTvP2e1vTVUsH7OyWqIxQbwRxwYFS0oXQJSS qbyyBrYMIAd4SJlVg+hzULiFpd1qskzrgPn4qKjrPv2s5/KReJ0OsF0jVSLv94Kunbqr H6J0lg168PIQ4rBcsovjTPEXimjbb87bLPVL7PnPz+9rKtvzAhZDiVi8AZrS/wcT674i yKG6+F81QKUqeBEOSStNI5Cz/9oXAprTT1IAN+F9yo/Cty0+Sk+HWqJw3RIyGQ6JLw36 sL4svBaEVxL20ebbO9E4HdxPoG4/bykON4TSyccqXhAp54uKlllFw0+heBWchVVNNo4k 6waQ== 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 pw16si3295811ejb.430.2020.11.26.09.04.03; Thu, 26 Nov 2020 09:04:31 -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 S2404046AbgKZRBK convert rfc822-to-8bit (ORCPT + 99 others); Thu, 26 Nov 2020 12:01:10 -0500 Received: from us-smtp-delivery-44.mimecast.com ([207.211.30.44]:30619 "EHLO us-smtp-delivery-44.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403995AbgKZRBJ (ORCPT ); Thu, 26 Nov 2020 12:01:09 -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-381-jeSIGMKFNKi3DbvkwCxjuw-1; Thu, 26 Nov 2020 12:01:04 -0500 X-MC-Unique: jeSIGMKFNKi3DbvkwCxjuw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A683680EDAC; Thu, 26 Nov 2020 17:01:02 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.192.133]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9977260C05; Thu, 26 Nov 2020 17:00:59 +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: Thu, 26 Nov 2020 18:00:08 +0100 Message-Id: <20201126170026.2619053-8-jolsa@kernel.org> In-Reply-To: <20201126170026.2619053-1-jolsa@kernel.org> References: <20201126170026.2619053-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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