Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp688393pxu; Thu, 26 Nov 2020 09:06:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJy6zNV+v2waqZw/lG04hlJRapLKU8L3KgVZl9WG6Os+JqDfSwbR5lmRXy8Gbbo8QToyTOSA X-Received: by 2002:aa7:c448:: with SMTP id n8mr3514978edr.10.1606410391498; Thu, 26 Nov 2020 09:06:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606410391; cv=none; d=google.com; s=arc-20160816; b=tVVOmLKbwLnUuncZTzgBVgAluDKUQQ8x41bUoX6JaaBUY42Ax4Nsu3Z8fRMDhsG/m4 /s0I8EbL0SO/RSN6PcXl88c76ymIh7WOXUuOUaq4PYIRxySF3uE5SZEIJ9vjjPy0lvzn 9xCXSd86qLYqXU4DkW2bETVwIN8MB2FiHa0Wez+fdPrAoa4WDfAcmJbBe+oFwXq4qc65 DjxEY3rK4j4002ALAanFlXI2teSIeD1qnxtFg3szxEyblTFC2XgIxcptr8QlejWJp9Af lXyg7QN3eEKcgs3BfCYIWHagnhSj7PaAgbu2JolstbjQwZ+ayK6K5DeVoq9FO6Jg4eVD m/AQ== 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=FEwc7vYVPao3/CM0BQwdUkw8BLdMYEjzEszCmnfRUtwaZ4Z6v2dVRM1/Uvl4xOEqmF HTDADbIlYuUxFzQZJvtI1y0wVcFbJLUH+muxePpCaImOH/7IiVAX+T+N4aWJsZvkyVtt f6O4jtQySAcfxbApW8ejRDJqeI/SeLJBEZiNDndZSjfvkGB6LahalpuvI3xXc3b8n8cp xRheQSrQtBaa9V7TV02V38huccItQLD6bqa7US90CGHtpx7Hf0m8IEfW42FsjbdyIvx0 rdycDHNSNIya4rpKj2xWIWZ5xdUY/BdHPpu+nYXPBtPlL+4Ful628RUYV6HadUDy5P7J Fm/w== 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 y14si3483383edq.407.2020.11.26.09.06.08; Thu, 26 Nov 2020 09:06: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 S2404212AbgKZRCE convert rfc822-to-8bit (ORCPT + 99 others); Thu, 26 Nov 2020 12:02:04 -0500 Received: from us-smtp-delivery-44.mimecast.com ([207.211.30.44]:40624 "EHLO us-smtp-delivery-44.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404206AbgKZRCC (ORCPT ); Thu, 26 Nov 2020 12:02:02 -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-523-yipx1AvHN8mqGqHyS6SZZQ-1; Thu, 26 Nov 2020 12:01:55 -0500 X-MC-Unique: yipx1AvHN8mqGqHyS6SZZQ-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 E0434100E321; Thu, 26 Nov 2020 17:01:52 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.192.133]) by smtp.corp.redhat.com (Postfix) with ESMTP id CDB3460BFA; Thu, 26 Nov 2020 17:01:49 +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: Thu, 26 Nov 2020 18:00:22 +0100 Message-Id: <20201126170026.2619053-22-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_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