Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3537054pxb; Mon, 9 Nov 2020 14:00:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJxwt7i1ObwSqbJXQ3UCWJRddd3PuTm23tYdl5Yx68GFHLy864ssEpbNm2K8+gQrK8HJPxLr X-Received: by 2002:a17:906:13d0:: with SMTP id g16mr16874156ejc.327.1604959230244; Mon, 09 Nov 2020 14:00:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604959230; cv=none; d=google.com; s=arc-20160816; b=g4LDlw4fd4O3JpIXZcuVTT1TBV/Qe2Vqdt9f6onEgoIR+SI9ws0rx9lIp8E0rXrpke bNffoPCahNpoSF7G2L94TLalFrtsmBNTL8S/Li7DaGy3/enUDxRdixUezAhDLXfi36zP R5ZkK2noMgDSdyU64q9xlttfw+k0XWCB9qIlfoPe6F/VPu9+kEmtASiBmCrWw727jST+ LtSnJY1rhJ65Our3rXQtyPOlloz/Yu1t1txDio1DuDODsOBErEoKIz8X+hsiSMz24jzd cuW0fniZHhJcSR/7Wtl+lU6ATTAgKjeb6U8zKS06wp4JQjjKY6BkWXNC2XmUmujoP8dH m2jA== 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=lCGJZymHkXO8kvBO6fU+uYpXAN6uL3D1lK7FBPfW7Vc=; b=uPK0vqls/t/yMPTGbNAg+nKfSYjt+z8wYufv8z4XWHPRVsXNKUzRcitYYkNyWEDvX+ gsWaXT/Fu2eASz2WSums9qVtrD/RrWzp90a5aynGUjjSk2wbKMLct4Y3/2fdtr0mQJ+j Exs2YCeCmIgdcMUjW/VI9y5cWVc5i+izhTlmKt2aUOkD3OoEHGyWM96xZPieYxujpekC UMLyBBVZsEpAyH71vjQ5b7719U3FXXMoG06szbFn8Uq8gO38lvp7OuV8uJb//Tz/oEfH kqBcIBRKXiSwYReoZU4bwv+MXBARZ2wfDiwjMiUpu8vJe1Z6ZEvxwJ2zQBY//AOXTQpz SiLQ== 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 d25si1707511eds.401.2020.11.09.14.00.07; Mon, 09 Nov 2020 14:00:30 -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 S1731802AbgKIVzo convert rfc822-to-8bit (ORCPT + 99 others); Mon, 9 Nov 2020 16:55:44 -0500 Received: from us-smtp-delivery-44.mimecast.com ([207.211.30.44]:41929 "EHLO us-smtp-delivery-44.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731865AbgKIVzn (ORCPT ); Mon, 9 Nov 2020 16:55:43 -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-531-hyzNaPwAMniJICckonq7pw-1; Mon, 09 Nov 2020 16:55:36 -0500 X-MC-Unique: hyzNaPwAMniJICckonq7pw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 234CC186DD2B; Mon, 9 Nov 2020 21:55:34 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.192.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 18C016EF46; Mon, 9 Nov 2020 21:55:30 +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 20/24] perf tools: Add build_id_cache__add function Date: Mon, 9 Nov 2020 22:54:11 +0100 Message-Id: <20201109215415.400153-21-jolsa@kernel.org> In-Reply-To: <20201109215415.400153-1-jolsa@kernel.org> References: <20201109215415.400153-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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 sed from another callers in following changes. 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 dc8f864fe15a..0d9a473c46d0 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -670,24 +670,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) @@ -783,8 +774,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); @@ -792,6 +781,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