Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1154189pxu; Fri, 27 Nov 2020 00:38:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJytLesWjDvywwB+u7lzai9mRPyuZax/T0SFRNv0B7K643iF1W+II+uM66wUrJ2yu6mJ/QcX X-Received: by 2002:a17:906:85cf:: with SMTP id i15mr6671176ejy.373.1606466283717; Fri, 27 Nov 2020 00:38:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606466283; cv=none; d=google.com; s=arc-20160816; b=Kr9T03yH34N8+LSVfE7XzCi8m0nyopZNKKCm/zjgf2dn/3axn2xCJUvQhbIL9lUcTJ hM2jyKbehCYoyBy5u6N5x0AEP7zy4LRcgVTtUYAFAJpLJW8H/8jmRC21+vY2XMctuQIR KsUD5YKzwXu9wLBukSi9rlDFzM4nWxKMSvo9U694qh/lkMQ1AGNF988FLzfiuYt8vONH /b5KjnSUn6Dhv1KAVAsKHN1qSC7MHuVOTDlym8EK7/xE81obQoPq1YbTVik/43wGXrhm QGVltts86sUw/bzW0V/9Xlh9HByc6HjuFoiddZL5QEfYVNvmfim43z2EfEW+N7sw9iEp HuNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=b1YpxH/DPwQ1rfUxJADQQxFowXoFm/ET1oldafcc+78=; b=1GK4+0xtIYZBqf/+K+vGatgQllJFNd9+dzbhrbB9NfBMzgKvvs9fH0ikGMoGR7fx1m Xgc2Lw+mn8DZs8k1NkiyVAUT/cGlH4ueiiRgQo2w29fgXY2li+DPMSkWlO4wGdrlikNb Ly+19j6hJyVcD2yzDZFtIcSIsnQfHrYcH/uKblnFzAOLLcFfcOt+pOiQR/aZpGNvySuz r6FY0FF6BkkQBjuQkxdLyC4i0Qc6cGt471Q1or9qdhCCNJ0BnZ6Y+5W+mbktB8W1d3us wYZY3kqAgapG9joa7+ARQ4CbsY7M9KzMwNQsbxtvf++0KypkEzsyAPc/7sk8z49URROJ VbYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nswZc2KW; 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 y23si4582795eju.563.2020.11.27.00.37.41; Fri, 27 Nov 2020 00:38:03 -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; dkim=pass header.i=@kernel.org header.s=default header.b=nswZc2KW; 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 S2404492AbgKZRxu (ORCPT + 99 others); Thu, 26 Nov 2020 12:53:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:46572 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404262AbgKZRxu (ORCPT ); Thu, 26 Nov 2020 12:53:50 -0500 Received: from quaco.ghostprotocols.net (unknown [179.97.37.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 20BF720665; Thu, 26 Nov 2020 17:53:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606413229; bh=7QGAk4QZEWRnKfTDBVWHoD4S6Vq06F+m5SKvJ3EDZ6Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nswZc2KWkg9MZUcrSeOGKyYax4HnjeTQZxov2s9NqZS6gs8kFoTOjidwSRK4EQlRV 976s/PCx4y+Xc2xEKdU289iTvsaB+LAoA3zV+FlUCeec0qqHekGqz5/m+FtPSIiy8f dcEaJt9WPP0x4s4RIGwcSHfqEwDIK8bIXP5Slzq4= Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 183C340E29; Thu, 26 Nov 2020 14:53:47 -0300 (-03) Date: Thu, 26 Nov 2020 14:53:47 -0300 From: Arnaldo Carvalho de Melo To: Jiri Olsa 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: Re: [PATCH 21/25] perf tools: Add build_id_cache__add function Message-ID: <20201126175347.GH70905@kernel.org> References: <20201126170026.2619053-1-jolsa@kernel.org> <20201126170026.2619053-22-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201126170026.2619053-22-jolsa@kernel.org> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Thu, Nov 26, 2020 at 06:00:22PM +0100, Jiri Olsa escreveu: > 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. Thanks, applied. - Arnaldo > 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 > -- - Arnaldo