Re: [PATCH perf/core v5 02/15] perf-buildid-cache: Use path/to/bin/buildid/elf instead of path/to/bin/buildid

From: Masami Hiramatsu
Date: Thu Apr 28 2016 - 18:50:35 EST


On Thu, 28 Apr 2016 10:22:23 +0900
Namhyung Kim <namhyung@xxxxxxxxxx> wrote:

> Hi Masami,
>
> On Thu, Apr 28, 2016 at 03:37:23AM +0900, Masami Hiramatsu wrote:
> > From: Masami Hiramatsu <masami.hiramatsu.pt@xxxxxxxxxxx>
> >
> > Use path/to/bin/buildid/elf instead of path/to/bin/buildid
> > to store corresponding elf binary.
> > This also stores vdso in buildid/vdso, kallsyms in buildid/kallsyms.
> >
> > Note that the existing caches are not updated until user adds
> > or updates the cache. Anyway, if there is the old style build-id
> > cache it falls back to use it. (IOW, it is backward compatible)
> >
> > Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@xxxxxxxxxxx>
> > Signed-off-by: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
> > ---
> > Changes in v5:
> > - Support old style buildid caches.
> > ---
> > tools/perf/util/build-id.c | 80 ++++++++++++++++++++++++++++++++++----------
> > tools/perf/util/dso.h | 5 +++
> > tools/perf/util/symbol.c | 15 ++++++--
> > 3 files changed, 76 insertions(+), 24 deletions(-)
> >
> > diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
> > index b6ecf87..b035483 100644
> > --- a/tools/perf/util/build-id.c
> > +++ b/tools/perf/util/build-id.c
> > @@ -144,7 +144,8 @@ static int asnprintf(char **strp, size_t size, const char *fmt, ...)
> > return ret;
> > }
> >
> > -static char *build_id__filename(const char *sbuild_id, char *bf, size_t size)
> > +static char *build_id_cache__linkname(const char *sbuild_id, char *bf,
> > + size_t size)
> > {
> > char *tmp = bf;
> > int ret = asnprintf(&bf, size, "%s/.build-id/%.2s/%s", buildid_dir,
> > @@ -154,15 +155,45 @@ static char *build_id__filename(const char *sbuild_id, char *bf, size_t size)
> > return bf;
> > }
> >
> > +static bool __is_regular_file(const char *pathname)
> > +{
> > + struct stat sb;
> > + return stat(pathname, &sb) == 0 && S_ISREG(sb.st_mode);
> > +}
>
> It looks like that the is_regular_file() is already in the
> util/util.c

Nice catch!!
OK, it should be used.

Thanks!

--
Masami Hiramatsu <mhiramat@xxxxxxxxxx>