lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 14 Sep 2020 13:13:31 -0300
From:   Arnaldo Carvalho de Melo <acme@...nel.org>
To:     Jiri Olsa <jolsa@...nel.org>
Cc:     lkml <linux-kernel@...r.kernel.org>,
        Peter Zijlstra <a.p.zijlstra@...llo.nl>,
        Ingo Molnar <mingo@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Namhyung Kim <namhyung@...nel.org>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Michael Petlan <mpetlan@...hat.com>,
        Song Liu <songliubraving@...com>,
        "Frank Ch. Eigler" <fche@...hat.com>,
        Ian Rogers <irogers@...gle.com>,
        Stephane Eranian <eranian@...gle.com>,
        Alexey Budankov <alexey.budankov@...ux.intel.com>,
        Andi Kleen <ak@...ux.intel.com>,
        Adrian Hunter <adrian.hunter@...el.com>
Subject: Re: [PATCH 20/26] perf tools: Add build_id_cache__add function

Em Sun, Sep 13, 2020 at 11:03:07PM +0200, Jiri Olsa escreveu:
> 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.

More prep work generally useful, applying now.

- Arnaldo
 
> Signed-off-by: Jiri Olsa <jolsa@...nel.org>
> ---
>  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
> 

-- 

- Arnaldo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ