Debian Codegraph @

external/linker/eng/common/cross/arm/trusty-lttng-2.4.patch

raw
1 From e72c9d7ead60e3317bd6d1fade995c07021c947b Mon Sep 17 00:00:00 2001
2 From: Mathieu Desnoyers <[email protected]>
3 Date: Thu, 7 May 2015 13:25:04 -0400
4 Subject: [PATCH] Fix: building probe providers with C++ compiler
5
6 Robert Daniels wrote:
7 > > I'm attempting to use lttng userspace tracing with a C++ application
8 > > on an ARM platform. I'm using GCC 4.8.4 on Linux 3.14 with the 2.6
9 > > release of lttng. I've compiled lttng-modules, lttng-ust, and
10 > > lttng-tools and have been able to get a simple test working with C
11 > > code. When I attempt to run the hello.cxx test on my target it will
12 > > segfault.
13 >
14 >
15 > I spent a little time digging into this issue and finally discovered the
16 > cause of my segfault with ARM C++ tracepoints.
17 >
18 > There is a struct called 'lttng_event' in ust-events.h which contains an
19 > empty union 'u'. This was the cause of my issue. Under C, this empty union
20 > compiles to a zero byte member while under C++ it compiles to a one byte
21 > member, and in my case was four-byte aligned which caused my C++ code to
22 > have the 'cds_list_head node' offset incorrectly by four bytes. This lead
23 > to an incorrect linked list structure which caused my issue.
24 >
25 > Since this union is empty, I simply removed it from the struct and everything
26 > worked correctly.
27 >
28 > I don't know the history or purpose behind this empty union so I'd like to
29 > know if this is a safe fix. If it is I can submit a patch with the union
30 > removed.
31
32 That's a very nice catch!
33
34 We do not support building tracepoint probe provider with
35 g++ yet, as stated in lttng-ust(3):
36
37 "- Note for C++ support: although an application instrumented with
38 tracepoints can be compiled with g++, tracepoint probes should be
39 compiled with gcc (only tested with gcc so far)."
40
41 However, if it works fine with this fix, then I'm tempted to take it,
42 especially because removing the empty union does not appear to affect
43 the layout of struct lttng_event as seen from liblttng-ust, which must
44 be compiled with a C compiler, and from probe providers compiled with
45 a C compiler. So all we are changing is the layout of a probe provider
46 compiled with a C++ compiler, which is anyway buggy at the moment,
47 because it is not compatible with the layout expected by liblttng-ust
48 compiled with a C compiler.
49
50 Reported-by: Robert Daniels <[email protected]>
51 Signed-off-by: Mathieu Desnoyers <[email protected]>
52 ---
53 include/lttng/ust-events.h | 2 --
54 1 file changed, 2 deletions(-)
55
56 diff --git a/usr/include/lttng/ust-events.h b/usr/include/lttng/ust-events.h
57 index 328a875..3d7a274 100644
58 --- a/usr/include/lttng/ust-events.h
59 +++ b/usr/include/lttng/ust-events.h
60 @@ -407,8 +407,6 @@ struct lttng_event {
61 void *_deprecated1;
62 struct lttng_ctx *ctx;
63 enum lttng_ust_instrumentation instrumentation;
64 - union {
65 - } u;
66 struct cds_list_head node; /* Event list in session */
67 struct cds_list_head _deprecated2;
68 void *_deprecated3;
69 --
70 2.7.4
71