Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1731390pxk; Sun, 13 Sep 2020 14:09:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNc0ZxgNCM35fTqyupt0mpoNEPcAbI9ulbSTt2I3B79LjQuEv53pHLdGTwQAKsRAfLYSS1 X-Received: by 2002:a50:bf47:: with SMTP id g7mr14369179edk.26.1600031381888; Sun, 13 Sep 2020 14:09:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600031381; cv=none; d=google.com; s=arc-20160816; b=YxikkyYAy0q2HouR5ecZBat0TJMiLKIjsr3m8iOVj8vIw2rtIWbmh/f5SaSw/mKni7 8f3xYfAL0d583vCyhzbl2rpohKPp6wBZmiQkfXmxZd314zs4jpJHrgbNWz0xqAXORem2 Ne2lEzMs5m8UMZYTvP5ZfI5WbntXYctql+hM++Whi2vIow7jULZfnbf7jOJzYsOSFWTp CsISi9uBOgkXfhiFBsugz+W9qGGB8y0L7DprK/dAvQOp34Vr9WtoaHYtub169WuaXxYb tvHUurwlx1Mn/v/EJQxFYRULmTYjankXCpO71IzKIqrjHZJNfyyAZYcasqhIYdf70teQ iFIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Ka/XZSeytIVENjk5qOh7h27jqvC41BdZn7gJ5RYc4eo=; b=L2gmAtUoC2gd4m62yRTmk66eyUBE3kqDkZiaVHeBte7l/im0oB//yf2jr9L6ocr5lK /SEu4Ap/O+lVTtgQAgeLAMi7Dtqny6QdS3cwIhT8P4evi59awjPrM1tOz3Qlg3OxRhPD sa3GM+Mw6Wr7Qa9wbbZ+DxsKSAD9r4JhKGw547PZ9nyupAcAHn96D97fkSQTgd6lB167 VuEhkRVHfGzmjiH4XvsWSt0H1a1qBcRrVj2aCraMgGuHzeIKrqRCZdso48apbfsL5g36 j9h6ypCxsQ6xs5PX+TxQgh140ITNpX6/viSW1vylyMwHC8zJWkCui2cEwz+I710XAzze igjQ== 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 yj16si6335287ejb.751.2020.09.13.14.09.20; Sun, 13 Sep 2020 14:09:41 -0700 (PDT) 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 S1726089AbgIMVFh convert rfc822-to-8bit (ORCPT + 99 others); Sun, 13 Sep 2020 17:05:37 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:36950 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726003AbgIMVFB (ORCPT ); Sun, 13 Sep 2020 17:05:01 -0400 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-4-qETf2qFUPxe894uLK0xPGQ-1; Sun, 13 Sep 2020 17:04:54 -0400 X-MC-Unique: qETf2qFUPxe894uLK0xPGQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 27FE7801AAE; Sun, 13 Sep 2020 21:04:52 +0000 (UTC) Received: from krava.redhat.com (ovpn-112-4.ams2.redhat.com [10.36.112.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 831BD1002388; Sun, 13 Sep 2020 21:04:47 +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 , "Frank Ch. Eigler" , Ian Rogers , Stephane Eranian , Alexey Budankov , Andi Kleen , Adrian Hunter Subject: [PATCH 20/26] perf tools: Add build_id_cache__add function Date: Sun, 13 Sep 2020 23:03:07 +0200 Message-Id: <20200913210313.1985612-21-jolsa@kernel.org> In-Reply-To: <20200913210313.1985612-1-jolsa@kernel.org> References: <20200913210313.1985612-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jolsa@kernel.org X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: kernel.org Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org 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 b281c97894e0..bf044e52ad1f 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -668,24 +668,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) @@ -786,8 +777,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); @@ -795,6 +784,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 u8 *build_id, size_t build_id_size, 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 2cf87b7304e2..6d1c7180047b 100644 --- a/tools/perf/util/build-id.h +++ b/tools/perf/util/build-id.h @@ -50,6 +50,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