linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>,
	linux-kernel@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	David Ahern <dsahern@gmail.com>, Jiri Olsa <jolsa@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Vinson Lee <vlee@freedesktop.org>, Wang Nan <wangnan0@huawei.com>
Subject: Re: [PATCH 06/10] perf probe: Check if dwarf_getlocations() is available
Date: Fri, 13 May 2016 08:47:23 -0300	[thread overview]
Message-ID: <20160513114723.GC11346@kernel.org> (raw)
In-Reply-To: <20160513113852.0431958d40979b8cb5f53397@kernel.org>

Em Fri, May 13, 2016 at 11:38:52AM +0900, Masami Hiramatsu escreveu:
> On Thu, 12 May 2016 17:03:51 -0300
> Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> 
> > From: Arnaldo Carvalho de Melo <acme@redhat.com>
> > 
> > If not, tell the user that:
> > 
> >   config/Makefile:273: Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.157
> > 
> > And return -ENOTSUPP in die_get_var_range(), failing features that
> > need it, like the one pointed out above.
> > 
> > This fixes the build on older systems, such as Ubuntu 12.04.5.
> > 
> 
> Hmm, would we better to use similar technique for dwarf_cfi_addrframe?
> the commit 7752f1b096e1
> ("perf probe: Don't compile CFI related code if elfutils is old")
> uses _ELFUTILS_PREREQ() macro for checking the elfutils version directly.

I'll take a look at this.
 
> Anyway, this looks good to me.
> 
> Acked-by: Masami Hiramatsu <mhiramat@kernel.org>

Thanks for verifying this and the other one!

- Arnaldo
 
> > Cc: Adrian Hunter <adrian.hunter@intel.com>
> > Cc: David Ahern <dsahern@gmail.com>
> > Cc: Jiri Olsa <jolsa@kernel.org>
> > Cc: Namhyung Kim <namhyung@kernel.org>
> > Cc: Vinson Lee <vlee@freedesktop.org>
> > Cc: Wang Nan <wangnan0@huawei.com>
> > Link: http://lkml.kernel.org/n/tip-9l7luqkq4gfnx7vrklkq4obs@git.kernel.org
> > Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> > ---
> >  tools/build/Makefile.feature                  |  2 ++
> >  tools/build/feature/Makefile                  |  4 ++++
> >  tools/build/feature/test-all.c                |  5 +++++
> >  tools/build/feature/test-dwarf_getlocations.c | 12 ++++++++++++
> >  tools/perf/config/Makefile                    |  6 ++++++
> >  tools/perf/util/dwarf-aux.c                   |  9 +++++++++
> >  6 files changed, 38 insertions(+)
> >  create mode 100644 tools/build/feature/test-dwarf_getlocations.c
> > 
> > diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
> > index 6b7707270aa3..9f878619077a 100644
> > --- a/tools/build/Makefile.feature
> > +++ b/tools/build/Makefile.feature
> > @@ -30,6 +30,7 @@ endef
> >  FEATURE_TESTS_BASIC :=			\
> >  	backtrace			\
> >  	dwarf				\
> > +	dwarf_getlocations		\
> >  	fortify-source			\
> >  	sync-compare-and-swap		\
> >  	glibc				\
> > @@ -78,6 +79,7 @@ endif
> >  
> >  FEATURE_DISPLAY ?=			\
> >  	dwarf				\
> > +	dwarf_getlocations		\
> >  	glibc				\
> >  	gtk2				\
> >  	libaudit			\
> > diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
> > index c5f4c417428d..4ae94dbfdab9 100644
> > --- a/tools/build/feature/Makefile
> > +++ b/tools/build/feature/Makefile
> > @@ -3,6 +3,7 @@ FILES=					\
> >  	test-backtrace.bin		\
> >  	test-bionic.bin			\
> >  	test-dwarf.bin			\
> > +	test-dwarf_getlocations.bin	\
> >  	test-fortify-source.bin		\
> >  	test-sync-compare-and-swap.bin	\
> >  	test-glibc.bin			\
> > @@ -82,6 +83,9 @@ endif
> >  $(OUTPUT)test-dwarf.bin:
> >  	$(BUILD) $(DWARFLIBS)
> >  
> > +$(OUTPUT)test-dwarf_getlocations.bin:
> > +	$(BUILD) $(DWARFLIBS)
> > +
> >  $(OUTPUT)test-libelf-mmap.bin:
> >  	$(BUILD) -lelf
> >  
> > diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c
> > index e499a36c1e4a..a282e8cb84f3 100644
> > --- a/tools/build/feature/test-all.c
> > +++ b/tools/build/feature/test-all.c
> > @@ -41,6 +41,10 @@
> >  # include "test-dwarf.c"
> >  #undef main
> >  
> > +#define main main_test_dwarf_getlocations
> > +# include "test-dwarf_getlocations.c"
> > +#undef main
> > +
> >  #define main main_test_libelf_getphdrnum
> >  # include "test-libelf-getphdrnum.c"
> >  #undef main
> > @@ -143,6 +147,7 @@ int main(int argc, char *argv[])
> >  	main_test_libelf_mmap();
> >  	main_test_glibc();
> >  	main_test_dwarf();
> > +	main_test_dwarf_getlocations();
> >  	main_test_libelf_getphdrnum();
> >  	main_test_libunwind();
> >  	main_test_libaudit();
> > diff --git a/tools/build/feature/test-dwarf_getlocations.c b/tools/build/feature/test-dwarf_getlocations.c
> > new file mode 100644
> > index 000000000000..70162699dd43
> > --- /dev/null
> > +++ b/tools/build/feature/test-dwarf_getlocations.c
> > @@ -0,0 +1,12 @@
> > +#include <stdlib.h>
> > +#include <elfutils/libdw.h>
> > +
> > +int main(void)
> > +{
> > +	Dwarf_Addr base, start, end;
> > +	Dwarf_Attribute attr;
> > +	Dwarf_Op *op;
> > +        size_t nops;
> > +	ptrdiff_t offset = 0;
> > +        return (int)dwarf_getlocations(&attr, offset, &base, &start, &end, &op, &nops);
> > +}
> > diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
> > index f7d7f5a1cad5..6f8f6430f2bf 100644
> > --- a/tools/perf/config/Makefile
> > +++ b/tools/perf/config/Makefile
> > @@ -268,6 +268,12 @@ else
> >      ifneq ($(feature-dwarf), 1)
> >        msg := $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev);
> >        NO_DWARF := 1
> > +    else
> > +      ifneq ($(feature-dwarf_getlocations), 1)
> > +        msg := $(warning Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.157);
> > +      else
> > +        CFLAGS += -DHAVE_DWARF_GETLOCATIONS
> > +      endif # dwarf_getlocations
> >      endif # Dwarf support
> >    endif # libelf support
> >  endif # NO_LIBELF
> > diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
> > index 577e600c8eb1..aea189b41cc8 100644
> > --- a/tools/perf/util/dwarf-aux.c
> > +++ b/tools/perf/util/dwarf-aux.c
> > @@ -959,6 +959,7 @@ int die_get_varname(Dwarf_Die *vr_die, struct strbuf *buf)
> >  	return 0;
> >  }
> >  
> > +#ifdef HAVE_DWARF_GETLOCATIONS
> >  /**
> >   * die_get_var_innermost_scope - Get innermost scope range of given variable DIE
> >   * @sp_die: a subprogram DIE
> > @@ -1080,3 +1081,11 @@ int die_get_var_range(Dwarf_Die *sp_die, Dwarf_Die *vr_die, struct strbuf *buf)
> >  
> >  	return ret;
> >  }
> > +#else
> > +int die_get_var_range(Dwarf_Die *sp_die __maybe_unused,
> > +		      Dwarf_Die *vr_die __maybe_unused,
> > +		      struct strbuf *buf __maybe_unused)
> > +{
> > +	return -ENOTSUP;
> > +}
> > +#endif
> > -- 
> > 2.5.5
> > 
> 
> 
> -- 
> Masami Hiramatsu <mhiramat@kernel.org>

  reply	other threads:[~2016-05-13 11:47 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-12 20:03 [GIT PULL 00/10] perf/urgent fixes Arnaldo Carvalho de Melo
2016-05-12 20:03 ` [PATCH 01/10] perf tools: Use readdir() instead of deprecated readdir_r() Arnaldo Carvalho de Melo
2016-05-12 20:03 ` [PATCH 02/10] perf script: " Arnaldo Carvalho de Melo
2016-05-12 20:03 ` [PATCH 03/10] perf thread_map: " Arnaldo Carvalho de Melo
2016-05-12 20:03 ` [PATCH 04/10] perf tools: " Arnaldo Carvalho de Melo
2016-05-12 20:03 ` [PATCH 05/10] perf dwarf: Guard !x86_64 definitions under #ifdef else clause Arnaldo Carvalho de Melo
2016-05-13  2:14   ` Masami Hiramatsu
2016-05-12 20:03 ` [PATCH 06/10] perf probe: Check if dwarf_getlocations() is available Arnaldo Carvalho de Melo
2016-05-13  2:38   ` Masami Hiramatsu
2016-05-13 11:47     ` Arnaldo Carvalho de Melo [this message]
2016-05-12 20:03 ` [PATCH 07/10] tools lib traceevent: Do not reassign parg after collapse_tree() Arnaldo Carvalho de Melo
2016-05-12 20:03 ` [PATCH 08/10] perf evsel: Improve EPERM error handling in open_strerror() Arnaldo Carvalho de Melo
2016-05-12 20:03 ` [PATCH 09/10] perf evsel: Handle EACCESS + perf_event_paranoid=2 in fallback() Arnaldo Carvalho de Melo
2016-05-12 20:03 ` [PATCH 10/10] perf stat: Fallback to user only counters when perf_event_paranoid > 1 Arnaldo Carvalho de Melo
2016-05-13  5:36 ` [GIT PULL 00/10] perf/urgent fixes Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160513114723.GC11346@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=dsahern@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=vlee@freedesktop.org \
    --cc=wangnan0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).