qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tracetool: work around ust <sys/sdt.h> include conflict
@ 2020-06-25 14:07 Stefan Hajnoczi
  2020-06-29 12:53 ` Stefan Hajnoczi
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Hajnoczi @ 2020-06-25 14:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, Stefan Hajnoczi

Both the dtrace and ust backends may include <sys/sdt.h> but LTTng
Userspace Tracer 2.11 and later requires SDT_USE_VARIADIC to be defined
before including the header file.

This is a classic problem with C header files included from different
parts of a program. If the same header is included twice within the same
compilation unit then the first inclusion determines the macro
environment.

Work around this by defining SDT_USE_VARIADIC in the dtrace backend too.
It doesn't hurt and fixes a missing STAP_PROBEV() compiler error when
the ust backend is enabled together with the dtrace backend.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
I am also sending a fix to the LTTng Userspace Tracer project to add
-DSDT_USE_VARIADIC to the pkg-config CFLAGS so that applications define
the macro consistently. But this patch is still needed as a workaround
for lttng-ust 2.11.
---
 scripts/tracetool/backend/dtrace.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/scripts/tracetool/backend/dtrace.py b/scripts/tracetool/backend/dtrace.py
index 638990db79..79dbc2fa27 100644
--- a/scripts/tracetool/backend/dtrace.py
+++ b/scripts/tracetool/backend/dtrace.py
@@ -40,6 +40,12 @@ def generate_h_begin(events, group):
     else:
         header = "trace-dtrace.h"
 
+    # Workaround for ust backend, which also includes <sys/sdt.h> and may
+    # require SDT_USE_VARIADIC to be defined. If dtrace includes <sys/sdt.h>
+    # first without defining SDT_USE_VARIADIC then ust breaks because the
+    # STAP_PROBEV() macro is not defined.
+    out('#define SDT_USE_VARIADIC 1')
+
     out('#include "%s"' % header,
         '')
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] tracetool: work around ust <sys/sdt.h> include conflict
  2020-06-25 14:07 [PATCH] tracetool: work around ust <sys/sdt.h> include conflict Stefan Hajnoczi
@ 2020-06-29 12:53 ` Stefan Hajnoczi
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Hajnoczi @ 2020-06-29 12:53 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: qemu-devel, armbru

[-- Attachment #1: Type: text/plain, Size: 1204 bytes --]

On Thu, Jun 25, 2020 at 03:07:57PM +0100, Stefan Hajnoczi wrote:
> Both the dtrace and ust backends may include <sys/sdt.h> but LTTng
> Userspace Tracer 2.11 and later requires SDT_USE_VARIADIC to be defined
> before including the header file.
> 
> This is a classic problem with C header files included from different
> parts of a program. If the same header is included twice within the same
> compilation unit then the first inclusion determines the macro
> environment.
> 
> Work around this by defining SDT_USE_VARIADIC in the dtrace backend too.
> It doesn't hurt and fixes a missing STAP_PROBEV() compiler error when
> the ust backend is enabled together with the dtrace backend.
> 
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
> I am also sending a fix to the LTTng Userspace Tracer project to add
> -DSDT_USE_VARIADIC to the pkg-config CFLAGS so that applications define
> the macro consistently. But this patch is still needed as a workaround
> for lttng-ust 2.11.
> ---
>  scripts/tracetool/backend/dtrace.py | 6 ++++++
>  1 file changed, 6 insertions(+)

Thanks, applied to my tracing tree:
https://github.com/stefanha/qemu/commits/tracing

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-29 12:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-25 14:07 [PATCH] tracetool: work around ust <sys/sdt.h> include conflict Stefan Hajnoczi
2020-06-29 12:53 ` Stefan Hajnoczi

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).