* [PATCH] configure: check for perf_event.h version
@ 2015-08-06 13:06 Markus Metzger
2015-08-06 14:03 ` Pedro Alves
0 siblings, 1 reply; 6+ messages in thread
From: Markus Metzger @ 2015-08-06 13:06 UTC (permalink / raw)
To: palves; +Cc: gdb-patches
Intel(R) Processor Trace support requires a recent linux/perf_event.h header.
When GDB is built on an older system, Intel(R) Processor Trace will not be
available and there is no indication in the configure and build log as to
what went wrong.
Check for a compatible linux/perf_event.h at configure-time.
2015-08-06 Markus Metzger <markus.t.metzger@intel.com>
gdb/
* configure.ac: Check for PERF_ATTR_SIZE_VER5 in linux/perf_event.h
* configure: Regenerate.
---
gdb/configure | 27 ++++++++++++++++++++++++++-
gdb/configure.ac | 14 ++++++++++++++
2 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/gdb/configure b/gdb/configure
index e1b778b..ddff555 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -1558,7 +1558,8 @@ Optional Packages:
(auto/yes/no/<python-program>)
--with-guile[=GUILE] include guile support
(auto/yes/no/<guile-version>/<pkg-config-program>)
- --with-intel-pt include Intel(R) Processor Trace support (auto/yes/no)
+ --with-intel-pt include Intel(R) Processor Trace support
+ (auto/yes/no)
--with-libipt-prefix[=DIR] search for libipt in DIR/include and DIR/lib
--without-libipt-prefix don't search for libipt in includedir and libdir
--without-included-regex
@@ -9732,6 +9733,30 @@ if test "${with_intel_pt}" = no; then
$as_echo "$as_me: WARNING: Intel(R) Processor Trace support disabled; some features may be unavailable." >&2;}
HAVE_LIBIPT=no
else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+#include <linux/perf_event.h>
+#ifdef PERF_ATTR_SIZE_VER5
+# error
+#endif
+
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+ perf_event=no
+else
+ perf_event=yes
+fi
+rm -f conftest.err conftest.$ac_ext
+ if test "$perf_event" != yes; then
+ if test "$with_intel_pt" = yes; then
+ as_fn_error "linux/perf_event.h missing or too old" "$LINENO" 5
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: linux/perf_event.h missing or too old; some features may be unavailable." >&5
+$as_echo "$as_me: WARNING: linux/perf_event.h missing or too old; some features may be unavailable." >&2;}
+ fi
+ fi
+
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 905c27b..d867e85 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -1252,6 +1252,20 @@ if test "${with_intel_pt}" = no; then
AC_MSG_WARN([Intel(R) Processor Trace support disabled; some features may be unavailable.])
HAVE_LIBIPT=no
else
+ AC_PREPROC_IFELSE(AC_LANG_SOURCE([[
+#include <linux/perf_event.h>
+#ifdef PERF_ATTR_SIZE_VER5
+# error
+#endif
+ ]]), [perf_event=no], [perf_event=yes])
+ if test "$perf_event" != yes; then
+ if test "$with_intel_pt" = yes; then
+ AC_MSG_ERROR([linux/perf_event.h missing or too old])
+ else
+ AC_MSG_WARN([linux/perf_event.h missing or too old; some features may be unavailable.])
+ fi
+ fi
+
AC_LIB_HAVE_LINKFLAGS([ipt], [], [#include "intel-pt.h"], [pt_insn_alloc_decoder (0);])
if test "$HAVE_LIBIPT" != yes; then
if test "$with_intel_pt" = yes; then
--
1.8.3.1
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] configure: check for perf_event.h version
2015-08-06 13:06 [PATCH] configure: check for perf_event.h version Markus Metzger
@ 2015-08-06 14:03 ` Pedro Alves
2015-08-06 14:14 ` Metzger, Markus T
0 siblings, 1 reply; 6+ messages in thread
From: Pedro Alves @ 2015-08-06 14:03 UTC (permalink / raw)
To: Markus Metzger; +Cc: gdb-patches
On 08/06/2015 02:06 PM, Markus Metzger wrote:
> Intel(R) Processor Trace support requires a recent linux/perf_event.h header.
>
> When GDB is built on an older system, Intel(R) Processor Trace will not be
> available and there is no indication in the configure and build log as to
> what went wrong.
>
> Check for a compatible linux/perf_event.h at configure-time.
> diff --git a/gdb/configure.ac b/gdb/configure.ac
> index 905c27b..d867e85 100644
> --- a/gdb/configure.ac
> +++ b/gdb/configure.ac
> @@ -1252,6 +1252,20 @@ if test "${with_intel_pt}" = no; then
> AC_MSG_WARN([Intel(R) Processor Trace support disabled; some features may be unavailable.])
> HAVE_LIBIPT=no
> else
> + AC_PREPROC_IFELSE(AC_LANG_SOURCE([[
> +#include <linux/perf_event.h>
> +#ifdef PERF_ATTR_SIZE_VER5
> +# error
> +#endif
Can you explain what kind of symbol PERF_ATTR_SIZE_VER5 is?
From the patch, I understand that that is something that is _not_
defined in the perf versions that are supposedly supported?
(otherwise, I'd expect an #ifndef instead.)
What about these? :
nat/linux-btrace.c:722:#if defined (PERF_ATTR_SIZE_VER5)
nat/linux-btrace.c:739:#endif /* defined (PERF_ATTR_SIZE_VER5) */
nat/linux-btrace.c:759:#if defined (PERF_ATTR_SIZE_VER5)
nat/linux-btrace.c:872:#else /* !defined (PERF_ATTR_SIZE_VER5) */
nat/linux-btrace.c:881:#endif /* !defined (PERF_ATTR_SIZE_VER5) */
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 6+ messages in thread* RE: [PATCH] configure: check for perf_event.h version
2015-08-06 14:03 ` Pedro Alves
@ 2015-08-06 14:14 ` Metzger, Markus T
2015-08-06 14:54 ` Pedro Alves
0 siblings, 1 reply; 6+ messages in thread
From: Metzger, Markus T @ 2015-08-06 14:14 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
> -----Original Message-----
> From: Pedro Alves [mailto:palves@redhat.com]
> Sent: Thursday, August 6, 2015 3:49 PM
> To: Metzger, Markus T
> Cc: gdb-patches@sourceware.org
> Subject: Re: [PATCH] configure: check for perf_event.h version
>
> On 08/06/2015 02:06 PM, Markus Metzger wrote:
> > Intel(R) Processor Trace support requires a recent linux/perf_event.h
> header.
> >
> > When GDB is built on an older system, Intel(R) Processor Trace will not be
> > available and there is no indication in the configure and build log as to
> > what went wrong.
> >
> > Check for a compatible linux/perf_event.h at configure-time.
>
>
> > diff --git a/gdb/configure.ac b/gdb/configure.ac
> > index 905c27b..d867e85 100644
> > --- a/gdb/configure.ac
> > +++ b/gdb/configure.ac
> > @@ -1252,6 +1252,20 @@ if test "${with_intel_pt}" = no; then
> > AC_MSG_WARN([Intel(R) Processor Trace support disabled; some
> features may be unavailable.])
> > HAVE_LIBIPT=no
> > else
> > + AC_PREPROC_IFELSE(AC_LANG_SOURCE([[
> > +#include <linux/perf_event.h>
> > +#ifdef PERF_ATTR_SIZE_VER5
> > +# error
> > +#endif
>
> Can you explain what kind of symbol PERF_ATTR_SIZE_VER5 is?
> From the patch, I understand that that is something that is _not_
> defined in the perf versions that are supposedly supported?
> (otherwise, I'd expect an #ifndef instead.)
It's a macro. I took the double-negation approach from a similar
check for python_has_threads. Maybe this wasn't such a good
idea.
We need the macro defined for Intel PT support.
> What about these? :
>
> nat/linux-btrace.c:722:#if defined (PERF_ATTR_SIZE_VER5)
> nat/linux-btrace.c:739:#endif /* defined (PERF_ATTR_SIZE_VER5) */
> nat/linux-btrace.c:759:#if defined (PERF_ATTR_SIZE_VER5)
> nat/linux-btrace.c:872:#else /* !defined (PERF_ATTR_SIZE_VER5) */
> nat/linux-btrace.c:881:#endif /* !defined (PERF_ATTR_SIZE_VER5) */
Those are uses of this macro to make GDB build with Intel PT
support on systems that support it and without on systems that
don't.
The additional check in configure shall give a warning/error if the
System on which GDB is built does not support Intel PT - unless it
is disabled via --intel-pt=no.
Regards,
Markus.
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Prof. Dr. Hermann Eul
Chairperson of the Supervisory Board: Tiffany Doon Silva
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] configure: check for perf_event.h version
2015-08-06 14:14 ` Metzger, Markus T
@ 2015-08-06 14:54 ` Pedro Alves
2015-08-06 15:00 ` Metzger, Markus T
0 siblings, 1 reply; 6+ messages in thread
From: Pedro Alves @ 2015-08-06 14:54 UTC (permalink / raw)
To: Metzger, Markus T; +Cc: gdb-patches
On 08/06/2015 03:14 PM, Metzger, Markus T wrote:
>> -----Original Message-----
>> From: Pedro Alves [mailto:palves@redhat.com]
>> Sent: Thursday, August 6, 2015 3:49 PM
>> To: Metzger, Markus T
>> Cc: gdb-patches@sourceware.org
>> Subject: Re: [PATCH] configure: check for perf_event.h version
>>
>> On 08/06/2015 02:06 PM, Markus Metzger wrote:
>>> Intel(R) Processor Trace support requires a recent linux/perf_event.h
>> header.
>>>
>>> When GDB is built on an older system, Intel(R) Processor Trace will not be
>>> available and there is no indication in the configure and build log as to
>>> what went wrong.
>>>
>>> Check for a compatible linux/perf_event.h at configure-time.
>>
>>
>>> diff --git a/gdb/configure.ac b/gdb/configure.ac
>>> index 905c27b..d867e85 100644
>>> --- a/gdb/configure.ac
>>> +++ b/gdb/configure.ac
>>> @@ -1252,6 +1252,20 @@ if test "${with_intel_pt}" = no; then
>>> AC_MSG_WARN([Intel(R) Processor Trace support disabled; some
>> features may be unavailable.])
>>> HAVE_LIBIPT=no
>>> else
>>> + AC_PREPROC_IFELSE(AC_LANG_SOURCE([[
>>> +#include <linux/perf_event.h>
>>> +#ifdef PERF_ATTR_SIZE_VER5
>>> +# error
>>> +#endif
>>
>> Can you explain what kind of symbol PERF_ATTR_SIZE_VER5 is?
>> From the patch, I understand that that is something that is _not_
>> defined in the perf versions that are supposedly supported?
>> (otherwise, I'd expect an #ifndef instead.)
>
> It's a macro.
Was there ever a PERF_ATTR_SIZE_VER4 symbol? What if
PERF_ATTR_SIZE_VER6 is ever created? Do we want to have to
check for it explicitly then?
> I took the double-negation approach from a similar
> check for python_has_threads.
In the python case, we've already checked earlier that python.h
is available.
In your case, it seems that if <linux/perf_event.h> isn't
available, you end up with perf_event=yes? Is that what we want?
> Maybe this wasn't such a good idea.
Note also that the Python code has an explicit comment
to help people not get confused with the negation:
# Note that the test is reversed so that python_has_threads=yes on
# unexpected failures.
If this goes with the double-negation approach, a similar
comment would be very nice to have.
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 6+ messages in thread* RE: [PATCH] configure: check for perf_event.h version
2015-08-06 14:54 ` Pedro Alves
@ 2015-08-06 15:00 ` Metzger, Markus T
2015-08-06 15:17 ` Pedro Alves
0 siblings, 1 reply; 6+ messages in thread
From: Metzger, Markus T @ 2015-08-06 15:00 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
> -----Original Message-----
> From: Pedro Alves [mailto:palves@redhat.com]
> Sent: Thursday, August 6, 2015 4:29 PM
> To: Metzger, Markus T
> Cc: gdb-patches@sourceware.org
> Subject: Re: [PATCH] configure: check for perf_event.h version
>
> On 08/06/2015 03:14 PM, Metzger, Markus T wrote:
> >> -----Original Message-----
> >> From: Pedro Alves [mailto:palves@redhat.com]
> >> Sent: Thursday, August 6, 2015 3:49 PM
> >> To: Metzger, Markus T
> >> Cc: gdb-patches@sourceware.org
> >> Subject: Re: [PATCH] configure: check for perf_event.h version
> >>
> >> On 08/06/2015 02:06 PM, Markus Metzger wrote:
> >>> Intel(R) Processor Trace support requires a recent linux/perf_event.h
> >> header.
> >>>
> >>> When GDB is built on an older system, Intel(R) Processor Trace will not
> be
> >>> available and there is no indication in the configure and build log as to
> >>> what went wrong.
> >>>
> >>> Check for a compatible linux/perf_event.h at configure-time.
> >>
> >>
> >>> diff --git a/gdb/configure.ac b/gdb/configure.ac
> >>> index 905c27b..d867e85 100644
> >>> --- a/gdb/configure.ac
> >>> +++ b/gdb/configure.ac
> >>> @@ -1252,6 +1252,20 @@ if test "${with_intel_pt}" = no; then
> >>> AC_MSG_WARN([Intel(R) Processor Trace support disabled; some
> >> features may be unavailable.])
> >>> HAVE_LIBIPT=no
> >>> else
> >>> + AC_PREPROC_IFELSE(AC_LANG_SOURCE([[
> >>> +#include <linux/perf_event.h>
> >>> +#ifdef PERF_ATTR_SIZE_VER5
> >>> +# error
> >>> +#endif
> >>
> >> Can you explain what kind of symbol PERF_ATTR_SIZE_VER5 is?
> >> From the patch, I understand that that is something that is _not_
> >> defined in the perf versions that are supposedly supported?
> >> (otherwise, I'd expect an #ifndef instead.)
> >
> > It's a macro.
>
> Was there ever a PERF_ATTR_SIZE_VER4 symbol? What if
> PERF_ATTR_SIZE_VER6 is ever created? Do we want to have to
> check for it explicitly then?
The linux/perf_event.h header defines the macros for all previous
versions. The current version thus defines
#define PERF_ATTR_SIZE_VER0 64 /* sizeof first published struct */
#define PERF_ATTR_SIZE_VER1 72 /* add: config2 */
#define PERF_ATTR_SIZE_VER2 80 /* add: branch_sample_type */
#define PERF_ATTR_SIZE_VER3 96 /* add: sample_regs_user */
/* add: sample_stack_user */
#define PERF_ATTR_SIZE_VER4 104 /* add: sample_regs_intr */
#define PERF_ATTR_SIZE_VER5 112 /* add: aux_watermark */
> > I took the double-negation approach from a similar
> > check for python_has_threads.
>
> In the python case, we've already checked earlier that python.h
> is available.
>
> In your case, it seems that if <linux/perf_event.h> isn't
> available, you end up with perf_event=yes? Is that what we want?
No. I'll change it and send an update.
Thanks,
Markus.
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Prof. Dr. Hermann Eul
Chairperson of the Supervisory Board: Tiffany Doon Silva
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] configure: check for perf_event.h version
2015-08-06 15:00 ` Metzger, Markus T
@ 2015-08-06 15:17 ` Pedro Alves
0 siblings, 0 replies; 6+ messages in thread
From: Pedro Alves @ 2015-08-06 15:17 UTC (permalink / raw)
To: Metzger, Markus T; +Cc: gdb-patches
On 08/06/2015 04:00 PM, Metzger, Markus T wrote:
>> -----Original Message-----
>> From: Pedro Alves [mailto:palves@redhat.com]
>> Sent: Thursday, August 6, 2015 4:29 PM
>> To: Metzger, Markus T
>> Cc: gdb-patches@sourceware.org
>> Subject: Re: [PATCH] configure: check for perf_event.h version
>>
>> On 08/06/2015 03:14 PM, Metzger, Markus T wrote:
>>>> -----Original Message-----
>>>> From: Pedro Alves [mailto:palves@redhat.com]
>>>> Sent: Thursday, August 6, 2015 3:49 PM
>>>> To: Metzger, Markus T
>>>> Cc: gdb-patches@sourceware.org
>>>> Subject: Re: [PATCH] configure: check for perf_event.h version
>>>>
>>>> On 08/06/2015 02:06 PM, Markus Metzger wrote:
>>>>> Intel(R) Processor Trace support requires a recent linux/perf_event.h
>>>> header.
>>>>>
>>>>> When GDB is built on an older system, Intel(R) Processor Trace will not
>> be
>>>>> available and there is no indication in the configure and build log as to
>>>>> what went wrong.
>>>>>
>>>>> Check for a compatible linux/perf_event.h at configure-time.
>>>>
>>>>
>>>>> diff --git a/gdb/configure.ac b/gdb/configure.ac
>>>>> index 905c27b..d867e85 100644
>>>>> --- a/gdb/configure.ac
>>>>> +++ b/gdb/configure.ac
>>>>> @@ -1252,6 +1252,20 @@ if test "${with_intel_pt}" = no; then
>>>>> AC_MSG_WARN([Intel(R) Processor Trace support disabled; some
>>>> features may be unavailable.])
>>>>> HAVE_LIBIPT=no
>>>>> else
>>>>> + AC_PREPROC_IFELSE(AC_LANG_SOURCE([[
>>>>> +#include <linux/perf_event.h>
>>>>> +#ifdef PERF_ATTR_SIZE_VER5
>>>>> +# error
>>>>> +#endif
>>>>
>>>> Can you explain what kind of symbol PERF_ATTR_SIZE_VER5 is?
>>>> From the patch, I understand that that is something that is _not_
>>>> defined in the perf versions that are supposedly supported?
>>>> (otherwise, I'd expect an #ifndef instead.)
>>>
>>> It's a macro.
>>
>> Was there ever a PERF_ATTR_SIZE_VER4 symbol? What if
>> PERF_ATTR_SIZE_VER6 is ever created? Do we want to have to
>> check for it explicitly then?
>
> The linux/perf_event.h header defines the macros for all previous
> versions. The current version thus defines
>
> #define PERF_ATTR_SIZE_VER0 64 /* sizeof first published struct */
> #define PERF_ATTR_SIZE_VER1 72 /* add: config2 */
> #define PERF_ATTR_SIZE_VER2 80 /* add: branch_sample_type */
> #define PERF_ATTR_SIZE_VER3 96 /* add: sample_regs_user */
> /* add: sample_stack_user */
> #define PERF_ATTR_SIZE_VER4 104 /* add: sample_regs_intr */
> #define PERF_ATTR_SIZE_VER5 112 /* add: aux_watermark */
Ah. Thanks.
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-08-06 15:17 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-06 13:06 [PATCH] configure: check for perf_event.h version Markus Metzger
2015-08-06 14:03 ` Pedro Alves
2015-08-06 14:14 ` Metzger, Markus T
2015-08-06 14:54 ` Pedro Alves
2015-08-06 15:00 ` Metzger, Markus T
2015-08-06 15:17 ` Pedro Alves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox