Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1225358pxu; Mon, 23 Nov 2020 15:12:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJwKloVO5CEkHdkrH9u+feftW3zQky6SQo6pUv6ElzvtrR+zD3Kl9Kw+AR8FY5tXNXqUceEm X-Received: by 2002:a50:fb13:: with SMTP id d19mr1452775edq.133.1606173165356; Mon, 23 Nov 2020 15:12:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606173165; cv=none; d=google.com; s=arc-20160816; b=IyAqrzKMY1v9HUcnL7PiyfKOhuQy3swjeb6BSUr90ZdsVT6UQSsSJnkZe7mpKGSfeb jHrR0E+w0mUj4T3To59/kgMt5S6UvJ2KQ9Fs9rM4JflrE1kcxyAZNKW1RNbnQhAg2POt 2a4QM+u4POaU4a2D13ccPn9ujpPeOBjGIVqPiJhOG/mqo4vadPkPwH0g+bD8e8FEwl3+ HmUie0PndBsB/b6BIMLhnAdQtW8/li0kVQxqg7LASJAzqZpS/xQ21TOaAj17HiF2E9VZ rfLzDFoULvb1QKYIWfxar1LtCfB4zrzS58pq5gKfpjNgmIPXfQG1w2YQz3B2kXbo/d44 h+tg== 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=vb3zNyr5ZgtIVLFJT5icmpUiDV/KA7hWHgQalFzcPcA=; b=0cawRtZdDPOadfm6U04ERCRNBg5iz1BWHfy67CpJTrfoZatbaJBcl+MzBS+udiX8O8 6/yoIp3y5JY9w02xzygdM/Th3byk2BpuxypHZlYruHnZ+waRJGnhof+5RdXgOmC416KT YPYRfXyhb3ikkuA244XDcO/M8fkOOQvv2d/P6c8Thi2M9K/ByG/Kkp2rhQoDxiN8bJyZ 0cL8C93F8fk/fwbzOi0AFvPGePAMfkcPxiK8GIPiJQUuPOSBslJe2hEM0z4SFQUgXedN 1QfgLu/h55qc87PuKbnkWzny+YYxyxmP/cPrkSoLuBVbcDQVQ2lVm9Ju88YEnEwjLLZq 0L9g== 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 b27si7451458eje.466.2020.11.23.15.12.22; Mon, 23 Nov 2020 15:12:45 -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 S2388306AbgKWXGs convert rfc822-to-8bit (ORCPT + 99 others); Mon, 23 Nov 2020 18:06:48 -0500 Received: from us-smtp-delivery-44.mimecast.com ([205.139.111.44]:41142 "EHLO us-smtp-delivery-44.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388268AbgKWXGp (ORCPT ); Mon, 23 Nov 2020 18:06:45 -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-308-ZAmwqwsPNtil_dr7LyrCng-1; Mon, 23 Nov 2020 18:06:40 -0500 X-MC-Unique: ZAmwqwsPNtil_dr7LyrCng-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 32EDE100A241; Mon, 23 Nov 2020 23:06:38 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.195.242]) by smtp.corp.redhat.com (Postfix) with ESMTP id 30DBC5D9CA; Mon, 23 Nov 2020 23:06:35 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: Ian Rogers , lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Namhyung Kim , Alexander Shishkin , Michael Petlan , Song Liu , Stephane Eranian , Alexey Budankov , Andi Kleen , Adrian Hunter Subject: [PATCH 21/25] perf tools: Add build_id_cache__add function Date: Tue, 24 Nov 2020 00:05:08 +0100 Message-Id: <20201123230512.2097312-22-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_cache__add function as core function that adds file into build id database. It will be set from another callers in following changes. Acked-by: Ian Rogers Signed-off-by: Jiri Olsa --- tools/perf/util/build-id.c | 42 ++++++++++++++++++++++++-------------- tools/perf/util/build-id.h | 2 ++ 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index 6bf3cc79c5d5..02df36b30ac5 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -671,24 +671,15 @@ static char *build_id_cache__find_debug(const char *sbuild_id, return realname; } -int build_id_cache__add_s(const char *sbuild_id, const char *name, - struct nsinfo *nsi, bool is_kallsyms, bool is_vdso) +int +build_id_cache__add(const char *sbuild_id, const char *name, const char *realname, + struct nsinfo *nsi, bool is_kallsyms, bool is_vdso) { const size_t size = PATH_MAX; - char *realname = NULL, *filename = NULL, *dir_name = NULL, - *linkname = zalloc(size), *tmp; + char *filename = NULL, *dir_name = NULL, *linkname = zalloc(size), *tmp; char *debugfile = NULL; int err = -1; - if (!is_kallsyms) { - if (!is_vdso) - realname = nsinfo__realpath(name, nsi); - else - realname = realpath(name, NULL); - if (!realname) - goto out_free; - } - dir_name = build_id_cache__cachedir(sbuild_id, name, nsi, is_kallsyms, is_vdso); if (!dir_name) @@ -788,8 +779,6 @@ int build_id_cache__add_s(const char *sbuild_id, const char *name, pr_debug4("Failed to update/scan SDT cache for %s\n", realname); out_free: - if (!is_kallsyms) - free(realname); free(filename); free(debugfile); free(dir_name); @@ -797,6 +786,29 @@ int build_id_cache__add_s(const char *sbuild_id, const char *name, return err; } +int build_id_cache__add_s(const char *sbuild_id, const char *name, + struct nsinfo *nsi, bool is_kallsyms, bool is_vdso) +{ + char *realname = NULL; + int err = -1; + + if (!is_kallsyms) { + if (!is_vdso) + realname = nsinfo__realpath(name, nsi); + else + realname = realpath(name, NULL); + if (!realname) + goto out_free; + } + + err = build_id_cache__add(sbuild_id, name, realname, nsi, is_kallsyms, is_vdso); + +out_free: + if (!is_kallsyms) + free(realname); + return err; +} + static int build_id_cache__add_b(const struct build_id *bid, const char *name, struct nsinfo *nsi, bool is_kallsyms, bool is_vdso) diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h index c6f10e3d2152..02613f4b2c29 100644 --- a/tools/perf/util/build-id.h +++ b/tools/perf/util/build-id.h @@ -63,6 +63,8 @@ char *build_id_cache__complement(const char *incomplete_sbuild_id); int build_id_cache__list_build_ids(const char *pathname, struct nsinfo *nsi, struct strlist **result); bool build_id_cache__cached(const char *sbuild_id); +int build_id_cache__add(const char *sbuild_id, const char *name, const char *realname, + struct nsinfo *nsi, bool is_kallsyms, bool is_vdso); int build_id_cache__add_s(const char *sbuild_id, const char *name, struct nsinfo *nsi, bool is_kallsyms, bool is_vdso); -- 2.26.2