[lttng-dev] [RFC-PATCH] Adding trap tracepoints definitions

2013-03-14 Thread Francis Deslauriers
Hi,

I am currently working on adding trap tracepoints in the kernel. As of now,
i
have an implementation of the tracepoints trap_entry and trap_exit. I have
created a LTTng probe for those events as well.

It would really be appreciated that you, LTTng guys, can give me your
comments
about my work already done. It would also be great if some of you could
test it
during a not so short amount of time, so we could perhaps propose the
patches
to add these tracepoints in the mainline kernel after having tested them
properly.

I will first send a patch concerning the implementation of the tracepoints.
This will be followed by a lttng-modules patch adding the LTTng trap probe.
Finally, i will send a patch about the locations of the tracepoints in the
kernel
itself.

Feel free to give general comments and critics in reply of this email, and
specific
comments in reply to the patches they apply to.

Thanks,

Francis Deslauriers
___
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [RFC-PATCH] Adding trap tracepoints definitions

2013-03-20 Thread Francis Deslauriers
This patch adds new trap tracepoint definitions. Both trap entry and trap exit
tracepoints can be added.

Signed-off-by: Francis Deslauriers fdesl...@gmail.com
---
 include/trace/events/trap.h |   45 +++
 1 file changed, 45 insertions(+)
 create mode 100644 include/trace/events/trap.h

diff --git a/include/trace/events/trap.h b/include/trace/events/trap.h
new file mode 100644
index 000..e79e8c0
--- /dev/null
+++ b/include/trace/events/trap.h
@@ -0,0 +1,45 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM trap
+
+#if !defined(_TRACE_TRAP_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_TRAP_H
+
+#include linux/tracepoint.h
+
+TRACE_EVENT(trap_entry,
+
+   TP_PROTO(struct pt_regs *regs, long trap),
+
+   TP_ARGS(regs, trap),
+   
+   TP_STRUCT__entry(
+   __field(long,trap )
+   __field(  unsigned long,ip)
+   ),
+   TP_fast_assign(
+   __entry-trap = trap;
+   __entry-ip = regs ? instruction_pointer(regs) : 0UL;
+   ),
+
+   TP_printk(number=%ld, ip = %lu, __entry-trap, __entry-ip)
+);
+
+TRACE_EVENT(trap_exit,
+
+   TP_PROTO(long trap),
+
+   TP_ARGS(trap),
+   
+   TP_STRUCT__entry(
+   __field(long,trap )
+   ),
+   TP_fast_assign(
+   __entry-trap = trap;
+   ),
+
+   TP_printk(number=%ld, __entry-trap)
+);
+
+#endif /* _TRACE_TRAP_H */
+/* This part must be outside protection */
+#include trace/define_trace.h
-- 
1.7.10.4


___
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


Re: [lttng-dev] [RFC-PATCH] Adding trap tracepoints definitions

2013-03-20 Thread Francis Deslauriers
Here is reworked version on the trap tracepoints.

If it looks good, i will go on by sending a lttng-modules patch adding the
trap-probe.

Comments are welcome.

Francis


On Wed, Mar 20, 2013 at 3:55 PM, Francis Deslauriers fdesl...@gmail.comwrote:

 This patch adds new trap tracepoint definitions. Both trap entry and trap
 exit
 tracepoints can be added.

 Signed-off-by: Francis Deslauriers fdesl...@gmail.com
 ---
  include/trace/events/trap.h |   45
 +++
  1 file changed, 45 insertions(+)
  create mode 100644 include/trace/events/trap.h

 diff --git a/include/trace/events/trap.h b/include/trace/events/trap.h
 new file mode 100644
 index 000..e79e8c0
 --- /dev/null
 +++ b/include/trace/events/trap.h
 @@ -0,0 +1,45 @@
 +#undef TRACE_SYSTEM
 +#define TRACE_SYSTEM trap
 +
 +#if !defined(_TRACE_TRAP_H) || defined(TRACE_HEADER_MULTI_READ)
 +#define _TRACE_TRAP_H
 +
 +#include linux/tracepoint.h
 +
 +TRACE_EVENT(trap_entry,
 +
 +   TP_PROTO(struct pt_regs *regs, long trap),
 +
 +   TP_ARGS(regs, trap),
 +
 +   TP_STRUCT__entry(
 +   __field(long,trap )
 +   __field(  unsigned long,ip)
 +   ),
 +   TP_fast_assign(
 +   __entry-trap = trap;
 +   __entry-ip = regs ? instruction_pointer(regs) : 0UL;
 +   ),
 +
 +   TP_printk(number=%ld, ip = %lu, __entry-trap, __entry-ip)
 +);
 +
 +TRACE_EVENT(trap_exit,
 +
 +   TP_PROTO(long trap),
 +
 +   TP_ARGS(trap),
 +
 +   TP_STRUCT__entry(
 +   __field(long,trap )
 +   ),
 +   TP_fast_assign(
 +   __entry-trap = trap;
 +   ),
 +
 +   TP_printk(number=%ld, __entry-trap)
 +);
 +
 +#endif /* _TRACE_TRAP_H */
 +/* This part must be outside protection */
 +#include trace/define_trace.h
 --
 1.7.10.4


___
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [RFC-PATCH] Adding trap tracepoints definitions

2013-03-20 Thread Francis Deslauriers
This patch adds new trap tracepoint definitions. Both trap entry and trap exit
tracepoints can be added.

Signed-off-by: Francis Deslauriers fdesl...@gmail.com
---
 include/trace/events/trap.h |   45 +++
 1 file changed, 45 insertions(+)
 create mode 100644 include/trace/events/trap.h

diff --git a/include/trace/events/trap.h b/include/trace/events/trap.h
new file mode 100644
index 000..e1847a3
--- /dev/null
+++ b/include/trace/events/trap.h
@@ -0,0 +1,45 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM trap
+
+#if !defined(_TRACE_TRAP_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_TRAP_H
+
+#include linux/tracepoint.h
+
+TRACE_EVENT(trap_entry,
+
+   TP_PROTO(struct pt_regs *regs, long trap),
+
+   TP_ARGS(regs, trap),
+
+   TP_STRUCT__entry(
+   __field(long,   trap)
+   __field(unsigned long,  ip)
+   ),
+   TP_fast_assign(
+   __entry-trap = trap;
+   __entry-ip = regs ? instruction_pointer(regs) : 0UL;
+   ),
+
+   TP_printk(number=%ld, ip = %lu, __entry-trap, __entry-ip)
+);
+
+TRACE_EVENT(trap_exit,
+
+   TP_PROTO(long trap),
+
+   TP_ARGS(trap),
+
+   TP_STRUCT__entry(
+   __field(long,   trap)
+   ),
+   TP_fast_assign(
+   __entry-trap = trap;
+   ),
+
+   TP_printk(number=%ld, __entry-trap)
+);
+
+#endif /* _TRACE_TRAP_H */
+/* This part must be outside protection */
+#include trace/define_trace.h
-- 
1.7.10.4


___
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [RFC-PATCH] Adding trap tracepoints definitions

2013-03-20 Thread Francis Deslauriers
This patch adds new trap tracepoint definitions. It enables each
architecture to add trap instrumentation.

Signed-off-by: Francis Deslauriers fdesl...@gmail.com
---
 include/trace/events/trap.h |   47 +++
 1 file changed, 47 insertions(+)
 create mode 100644 include/trace/events/trap.h

diff --git a/include/trace/events/trap.h b/include/trace/events/trap.h
new file mode 100644
index 000..171b9cf
--- /dev/null
+++ b/include/trace/events/trap.h
@@ -0,0 +1,47 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM trap
+
+#if !defined(_TRACE_TRAP_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_TRAP_H
+
+#include linux/tracepoint.h
+
+TRACE_EVENT(trap_entry,
+
+   TP_PROTO(struct pt_regs *regs, long trap),
+
+   TP_ARGS(regs, trap),
+
+   TP_STRUCT__entry(
+   __field(long,   trap)
+   __field(unsigned long,  ip  )
+   ),
+
+   TP_fast_assign(
+   __entry-trap   = trap;
+   __entry-ip = regs ? instruction_pointer(regs) : 0UL;
+   ),
+
+   TP_printk(number=%ld ip=%lu, __entry-trap, __entry-ip)
+);
+
+TRACE_EVENT(trap_exit,
+
+   TP_PROTO(long trap),
+
+   TP_ARGS(trap),
+
+   TP_STRUCT__entry(
+   __field(long,   trap)
+   ),
+
+   TP_fast_assign(
+   __entry-trap   = trap;
+   ),
+
+   TP_printk(number=%ld, __entry-trap)
+);
+
+#endif /* _TRACE_TRAP_H */
+/* This part must be outside protection */
+#include trace/define_trace.h
-- 
1.7.10.4


___
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


Re: [lttng-dev] [RFC-PATCH] Adding trap tracepoints definitions

2013-03-20 Thread Francis Deslauriers
On Wed, Mar 20, 2013 at 10:51 PM, Mathieu Desnoyers
mathieu.desnoy...@efficios.com wrote:
 Subject change:

 Adding trap tracepoints definitions

 - Add trap trace event definitions

 -

 Add trace trace event definitions. It will allow each architecture to
 instrument their traps.

How about this?
Add trap trace event definitions

Add trap entry and trap exit trace event definitions. It will allow each
architecture to instrument their traps.


This way we dont repeat the subject and it is more specific.


 I'm being even more strict than usual as you notice given that this
 patch is targeting lkml.

 Thanks,

 Mathieu


 Signed-off-by: Francis Deslauriers fdesl...@gmail.com
 ---
  include/trace/events/trap.h |   47 
 +++
  1 file changed, 47 insertions(+)
  create mode 100644 include/trace/events/trap.h

 diff --git a/include/trace/events/trap.h b/include/trace/events/trap.h
 new file mode 100644
 index 000..171b9cf
 --- /dev/null
 +++ b/include/trace/events/trap.h
 @@ -0,0 +1,47 @@
 +#undef TRACE_SYSTEM
 +#define TRACE_SYSTEM trap
 +
 +#if !defined(_TRACE_TRAP_H) || defined(TRACE_HEADER_MULTI_READ)
 +#define _TRACE_TRAP_H
 +
 +#include linux/tracepoint.h
 +
 +TRACE_EVENT(trap_entry,
 +
 + TP_PROTO(struct pt_regs *regs, long trap),
 +
 + TP_ARGS(regs, trap),
 +
 + TP_STRUCT__entry(
 + __field(long,   trap)
 + __field(unsigned long,  ip  )
 + ),
 +
 + TP_fast_assign(
 + __entry-trap   = trap;
 + __entry-ip = regs ? instruction_pointer(regs) : 0UL;
 + ),
 +
 + TP_printk(number=%ld ip=%lu, __entry-trap, __entry-ip)
 +);
 +
 +TRACE_EVENT(trap_exit,
 +
 + TP_PROTO(long trap),
 +
 + TP_ARGS(trap),
 +
 + TP_STRUCT__entry(
 + __field(long,   trap)
 + ),
 +
 + TP_fast_assign(
 + __entry-trap   = trap;
 + ),
 +
 + TP_printk(number=%ld, __entry-trap)
 +);
 +
 +#endif /* _TRACE_TRAP_H */
 +/* This part must be outside protection */
 +#include trace/define_trace.h
 --
 1.7.10.4


 ___
 lttng-dev mailing list
 lttng-dev@lists.lttng.org
 http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

 --
 Mathieu Desnoyers
 EfficiOS Inc.
 http://www.efficios.com

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [trap-probe] Add lttng-probe-trap

2013-03-21 Thread Francis Deslauriers
This probe monitors trap entry and trap exit trace event.

Signed-off-by: Francis Deslauriers fdesl...@gmail.com
---
 instrumentation/events/lttng-module/trap.h |   46 +++
 instrumentation/events/mainline/trap.h |   47 
 probes/Makefile|1 +
 probes/lttng-probe-trap.c  |   43 +
 4 files changed, 137 insertions(+)
 create mode 100644 instrumentation/events/lttng-module/trap.h
 create mode 100644 instrumentation/events/mainline/trap.h
 create mode 100644 probes/lttng-probe-trap.c

diff --git a/instrumentation/events/lttng-module/trap.h 
b/instrumentation/events/lttng-module/trap.h
new file mode 100644
index 000..124bbba
--- /dev/null
+++ b/instrumentation/events/lttng-module/trap.h
@@ -0,0 +1,46 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM trap
+
+#if !defined(_TRACE_TRAP_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_TRAP_H
+
+#include linux/tracepoint.h
+
+TRACE_EVENT(trap_entry,
+
+   TP_PROTO(struct pt_regs *regs, long trap),
+
+   TP_ARGS(regs, trap),
+
+   TP_STRUCT__entry(
+   __field(long,   trap)
+   __field(unsigned long,  ip  )
+
+   ),
+   TP_fast_assign(
+   tp_assign(trap, trap)
+   tp_assign(ip, regs ? instruction_pointer(regs) : 0UL)
+   ),
+
+   TP_printk(number=%ld ip=%lu, __entry-trap, __entry-ip)
+)
+
+TRACE_EVENT(trap_exit,
+
+   TP_PROTO(long trap),
+
+   TP_ARGS(trap),
+
+   TP_STRUCT__entry(
+   __field(long,   trap)
+   ),
+   TP_fast_assign(
+   tp_assign(trap, trap)
+   ),
+
+   TP_printk(number=%ld, __entry-trap)
+)
+
+#endif /* _TRACE_TRAP_H */
+/* This part must be outside protection */
+#include ../../../probes/define_trace.h
diff --git a/instrumentation/events/mainline/trap.h 
b/instrumentation/events/mainline/trap.h
new file mode 100644
index 000..171b9cf
--- /dev/null
+++ b/instrumentation/events/mainline/trap.h
@@ -0,0 +1,47 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM trap
+
+#if !defined(_TRACE_TRAP_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_TRAP_H
+
+#include linux/tracepoint.h
+
+TRACE_EVENT(trap_entry,
+
+   TP_PROTO(struct pt_regs *regs, long trap),
+
+   TP_ARGS(regs, trap),
+
+   TP_STRUCT__entry(
+   __field(long,   trap)
+   __field(unsigned long,  ip  )
+   ),
+
+   TP_fast_assign(
+   __entry-trap   = trap;
+   __entry-ip = regs ? instruction_pointer(regs) : 0UL;
+   ),
+
+   TP_printk(number=%ld ip=%lu, __entry-trap, __entry-ip)
+);
+
+TRACE_EVENT(trap_exit,
+
+   TP_PROTO(long trap),
+
+   TP_ARGS(trap),
+
+   TP_STRUCT__entry(
+   __field(long,   trap)
+   ),
+
+   TP_fast_assign(
+   __entry-trap   = trap;
+   ),
+
+   TP_printk(number=%ld, __entry-trap)
+);
+
+#endif /* _TRACE_TRAP_H */
+/* This part must be outside protection */
+#include trace/define_trace.h
diff --git a/probes/Makefile b/probes/Makefile
index 088cd5f..c8d0085 100644
--- a/probes/Makefile
+++ b/probes/Makefile
@@ -15,6 +15,7 @@ obj-m += lttng-probe-timer.o
 obj-m += lttng-probe-kmem.o
 obj-m += lttng-probe-module.o
 obj-m += lttng-probe-power.o
+obj-m += lttng-probe-trap.o
 
 obj-m += lttng-probe-statedump.o
 
diff --git a/probes/lttng-probe-trap.c b/probes/lttng-probe-trap.c
new file mode 100644
index 000..17c1526
--- /dev/null
+++ b/probes/lttng-probe-trap.c
@@ -0,0 +1,43 @@
+/*
+ * probes/lttng-probe-trap.c
+ *
+ * LTTng trap probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers mathieu.desnoy...@efficios.com
+ * Copyright (C) 2013 Francis Deslauriers fdesl...@gmail.com.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include linux/module.h
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include trace/events/trap.h
+#include ../wrapper/tracepoint.h
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include

[lttng-dev] [RFC-Patch 1/2] Add page fault trace event definitions

2013-04-07 Thread Francis Deslauriers
Add page_fault_entry and page_fault_exit event definitions. It will
allow each architecture to instrument their page faults.

Signed-off-by: Francis Deslauriers fdesl...@gmail.com
Reviewed-by: Raphaël Beamonte raphael.beamo...@polymtl.ca
---
 include/trace/events/fault.h |   51 ++
 1 file changed, 51 insertions(+)
 create mode 100644 include/trace/events/fault.h

diff --git a/include/trace/events/fault.h b/include/trace/events/fault.h
new file mode 100644
index 000..7256b40
--- /dev/null
+++ b/include/trace/events/fault.h
@@ -0,0 +1,51 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM fault
+
+#if !defined(_TRACE_FAULT_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_FAULT_H
+
+#include linux/tracepoint.h
+
+TRACE_EVENT(page_fault_entry,
+
+   TP_PROTO(struct pt_regs *regs, unsigned long address,
+   int write_access),
+
+   TP_ARGS(regs, address, write_access),
+
+   TP_STRUCT__entry(
+   __field(unsigned long,  ip  )
+   __field(unsigned long,  addr)
+   __field(int,write   )
+   ),
+
+   TP_fast_assign(
+   __entry-ip = regs ? instruction_pointer(regs) : 0UL;
+   __entry-addr   = address;
+   __entry-write  = write_access;
+   ),
+
+   TP_printk(ip=%lu addr=%lu write_access=%d,
+   __entry-ip, __entry-addr, __entry-write)
+);
+
+TRACE_EVENT(page_fault_exit,
+
+   TP_PROTO(int result),
+
+   TP_ARGS(result),
+
+   TP_STRUCT__entry(
+   __field(int,res )
+   ),
+
+   TP_fast_assign(
+   __entry-res= result;
+   ),
+
+   TP_printk(result=%d, __entry-res)
+);
+
+#endif /* _TRACE_FAULT_H */
+/* This part must be outside protection */
+#include trace/define_trace.h
-- 
1.7.10.4


___
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [RFC-Patch 2/2] x86:Instruments page fault trace event

2013-04-07 Thread Francis Deslauriers
Signed-off-by: Francis Deslauriers fdesl...@gmail.com
Reviewed-by: Raphaël Beamonte raphael.beamo...@polymtl.ca
---
 arch/x86/mm/fault.c |5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 2b97525..f41a5a0 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -20,6 +20,9 @@
 #include asm/fixmap.h/* VSYSCALL_START   
*/
 #include asm/context_tracking.h  /* exception_enter(), ...   */
 
+#define CREATE_TRACE_POINTS
+#include trace/events/fault.h/* trace_page_fault_*(), ...
*/
+
 /*
  * Page fault error code bits:
  *
@@ -1183,7 +1186,9 @@ good_area:
 * make sure we exit gracefully rather than endlessly redo
 * the fault:
 */
+   trace_page_fault_entry(regs, address, write);
fault = handle_mm_fault(mm, vma, address, flags);
+   trace_page_fault_exit(fault);
 
if (unlikely(fault  (VM_FAULT_RETRY|VM_FAULT_ERROR))) {
if (mm_fault_error(regs, error_code, address, fault))
-- 
1.7.10.4


___
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [RFC-Patch 1/2] Add page fault trace event definitions

2013-04-09 Thread Francis Deslauriers
Add page_fault_entry and page_fault_exit event definitions. It will
allow each architecture to instrument their page faults.

Signed-off-by: Francis Deslauriers fdesl...@gmail.com
Reviewed-by: Raphaël Beamonte raphael.beamo...@gmail.com
---
 include/trace/events/fault.h |   51 ++
 1 file changed, 51 insertions(+)
 create mode 100644 include/trace/events/fault.h

diff --git a/include/trace/events/fault.h b/include/trace/events/fault.h
new file mode 100644
index 000..522ddee
--- /dev/null
+++ b/include/trace/events/fault.h
@@ -0,0 +1,51 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM fault
+
+#if !defined(_TRACE_FAULT_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_FAULT_H
+
+#include linux/tracepoint.h
+
+TRACE_EVENT(page_fault_entry,
+
+   TP_PROTO(struct pt_regs *regs, unsigned long address,
+   int write_access),
+
+   TP_ARGS(regs, address, write_access),
+
+   TP_STRUCT__entry(
+   __field(unsigned long,  ip  )
+   __field(unsigned long,  addr)
+   __field(uint8_t,write   )
+   ),
+
+   TP_fast_assign(
+   __entry-ip = regs ? instruction_pointer(regs) : 0UL;
+   __entry-addr   = address;
+   __entry-write  = !!write_access;
+   ),
+
+   TP_printk(ip=%lu addr=%lu write_access=%d,
+   __entry-ip, __entry-addr, __entry-write)
+);
+
+TRACE_EVENT(page_fault_exit,
+
+   TP_PROTO(int result),
+
+   TP_ARGS(result),
+
+   TP_STRUCT__entry(
+   __field(int,res )
+   ),
+
+   TP_fast_assign(
+   __entry-res= result;
+   ),
+
+   TP_printk(result=%d, __entry-res)
+);
+
+#endif /* _TRACE_FAULT_H */
+/* This part must be outside protection */
+#include trace/define_trace.h
-- 
1.7.10.4


___
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-tools] Add vpid, vppid and vtid explanation in add-context help menu

2014-06-18 Thread francis . deslauriers
From: Francis Deslauriers francis.deslauri...@efficios.com

Signed-off-by: Francis Deslauriers francis.deslauri...@efficios.com
---
 src/bin/lttng/commands/add_context.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/bin/lttng/commands/add_context.c 
b/src/bin/lttng/commands/add_context.c
index 405b782..52d0db4 100644
--- a/src/bin/lttng/commands/add_context.c
+++ b/src/bin/lttng/commands/add_context.c
@@ -514,6 +514,9 @@ static void usage(FILE *ofp)
fprintf(ofp,TYPE can be one of the strings 
below:\n);
print_ctx_type(ofp);
fprintf(ofp, \n);
+   fprintf(ofp, Note that the vpid, vppid and vtid context types 
represent the virtual process id,\n
+   virtual parent process id and virtual thread id as 
seen from the current execution context\n
+   as oppose to the pid, ppid and tid that are kernel 
internal data structures.\n\n);
fprintf(ofp, Example:\n);
fprintf(ofp, This command will add the context information 'prio' and 
two per-cpu\n
perf counters (hardware branch misses and cache 
misses), to all channels\n
-- 
1.8.3.2


___
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


Re: [lttng-dev] [PATCH lttng-tools] Add vpid, vppid and vtid explanation in add-context help menu

2014-06-19 Thread Francis Deslauriers
On Thu, Jun 19, 2014 at 2:21 PM, David Goulet dgou...@efficios.com wrote:
 On 18 Jun (22:19:40), francis.deslauri...@efficios.com wrote:
 From: Francis Deslauriers francis.deslauri...@efficios.com

 Signed-off-by: Francis Deslauriers francis.deslauri...@efficios.com
 ---
  src/bin/lttng/commands/add_context.c | 3 +++
  1 file changed, 3 insertions(+)

 diff --git a/src/bin/lttng/commands/add_context.c 
 b/src/bin/lttng/commands/add_context.c
 index 405b782..52d0db4 100644
 --- a/src/bin/lttng/commands/add_context.c
 +++ b/src/bin/lttng/commands/add_context.c
 @@ -514,6 +514,9 @@ static void usage(FILE *ofp)
   fprintf(ofp,TYPE can be one of the 
 strings below:\n);
   print_ctx_type(ofp);
   fprintf(ofp, \n);
 + fprintf(ofp, Note that the vpid, vppid and vtid context types 
 represent the virtual process id,\n
 + virtual parent process id and virtual thread id as 
 seen from the current execution context\n
 + as oppose to the pid, ppid and tid that are kernel 
 internal data structures.\n\n);

 That would be kind of neat if you could also add this to the man page.
 Usually, I try to keep both the --help and man page in sync :).

I didn't add it to the man page because there is no mention of the
available context types in the man page.
The user is asked to run the lttng add-context -h command to get more
information on the available types.
Should I add a note to the man page anyway?

Thanks,
Francis


 Cheers!
 David

   fprintf(ofp, Example:\n);
   fprintf(ofp, This command will add the context information 'prio' and 
 two per-cpu\n
   perf counters (hardware branch misses and cache 
 misses), to all channels\n
 --
 1.8.3.2


 ___
 lttng-dev mailing list
 lttng-dev@lists.lttng.org
 http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-ust] Move enablers syncing after the channel registration

2014-07-10 Thread francis . deslauriers
From: Francis Deslauriers francis.deslauri...@efficios.com

Fixes possible race condition where an event registration is received
 before its channel registration by the consumer.

Signed-off-by: Francis Deslauriers francis.deslauri...@efficios.com
---
 liblttng-ust/lttng-events.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/liblttng-ust/lttng-events.c b/liblttng-ust/lttng-events.c
index e44628d..285b98e 100644
--- a/liblttng-ust/lttng-events.c
+++ b/liblttng-ust/lttng-events.c
@@ -248,8 +248,6 @@ int lttng_session_enable(struct lttng_session *session)
 
/* Set transient enabler state to enabled */
session-tstate = 1;
-   /* We need to sync enablers with session before activation. */
-   lttng_session_sync_enablers(session);
 
/*
 * Snapshot the number of events per channel to know the type of header
@@ -287,6 +285,9 @@ int lttng_session_enable(struct lttng_session *session)
}
}
 
+   /* We need to sync enablers with session before activation. */
+   lttng_session_sync_enablers(session);
+
/* Set atomically the state to active */
CMM_ACCESS_ONCE(session-active) = 1;
CMM_ACCESS_ONCE(session-been_active) = 1;
-- 
1.8.3.2


___
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


Re: [lttng-dev] babeltrace-python bindings

2014-11-04 Thread Francis Deslauriers
Hi,

Do you get any errors at configure or compile time?

Cheers,

Francis

On Tue, Nov 4, 2014 at 5:37 PM, Bin YE yebinia...@gmail.com wrote:
 Hi there

 i have installed Lttng and babeltrace
 my system:Ubuntu 14.04LTS
 I have made following steps

 sudo apt-add-repository ppa:lttng/ppa
 sudo apt-get update
 sudo apt-get install lttng-tools
 sudo apt-get install lttng-modules-dkms
 sudo apt-get install liblttng-ust-dev

 export PYTHON=python3
 export PYTHON_CONFIG=/usr/bin/python3-config

 ./configure --enable-python-bindings
  make
  make install
  ldconfig

 but i still can not use babeltrace python bindings
 when i run import babeltrace it output error with no module

 I really need you help about it
 Thank you very much in advance

 Bin Ye

 ___
 lttng-dev mailing list
 lttng-dev@lists.lttng.org
 http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


___
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


Re: [lttng-dev] lttng for android

2014-12-05 Thread Francis Deslauriers
Hi Chao,

There has been some work going on to port LTTng to Android but I don't
think it's upstream yet.
You can try to apply the patchset that Charles Brière has submitted earlier
this fall[1] but since
those are big changes it takes more time the review and test them.
Don't hesitate to share you experience with us.

Have a look at the archives of the mailing list.

[1] http://lists.lttng.org/pipermail/lttng-dev/2014-October/023678.html


Cheers,

Francis

On Fri, Dec 5, 2014 at 5:23 AM, Chao Xie xiechao_m...@163.com wrote:



 Hi
 If i want to collect the trace data from the target system which is the
 android platform with ARM chip, how can i compile the lttng and collect the
 trace data?

 ___
 lttng-dev mailing list
 lttng-dev@lists.lttng.org
 http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


Re: [lttng-dev] Can lttng support kernel function tracer

2015-02-16 Thread Francis Deslauriers
Hi Zhenyu,

If I understandd your question correctly, I can think of two ways to
trace an arbitrary kernel function. First, you can hook the tracer on
a dynamic probe[1] using something like this:
lttng enable-event customEventName -k --probe kernelFunctionName.
You can also hook the tracer on both entry and exit of a function
using --function instead of --probe.
To list your kernel symbols use cat /proc/kallsyms
Second, you can create custom kernel tracepoints and compile them in
you kernel. Have a look at the online documentation [2].

Don't hesitate to explain further if this doesn't answer your question.

Cheers!
Francis

[1] 
http://git.lttng.org/?p=lttng-tools.git;a=blob;f=doc/quickstart.txt;h=018c27b2b939ef7cd075255fd01bcfd8b2b21b1e;hb=HEAD#l93
[2] http://lttng.org/docs/#doc-instrumenting-linux-kernel-itself

On Thu, Feb 12, 2015 at 7:49 PM, zhenyu.ren zhenyu@aliyun.com wrote:
 Hi,

It's well known that lttng can make use of kernel tracepoints to do block 
 tracing ,system call tracing etc.Is it possible that  lttng can produce 
 anything like kernel function tracer does?

 Thanks
 zhenyu.ren

 ___
 lttng-dev mailing list
 lttng-dev@lists.lttng.org
 http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


Re: [lttng-dev] 答复: Can lttng support kernel function tracer

2015-02-17 Thread Francis Deslauriers
CCing lttng-dev back in the thread.

I might be wrong but I think that might be a usecase for a profiler
rather than a usecase for a tracer. Can someone else confirm?
To do that kind of work, you could compile your kernel with gprof support.

Thanks,
Francis


On Tue, Feb 17, 2015 at 3:38 AM, zhenyu.ren zhenyu@aliyun.com wrote:
 Hi,Francis
In fact, I want to trace all kernel functions related to some
 behavior.For example,I write()  and it returns 100ms later ,so  I want to
 know which kernel  function is too slow. In this case,I can use function
 tracer to trace all kernel function in the write() time window.However,I
 want to know is it possible that lttng can be useful in this case.

 Thanks
 zhenyu.ren


 --
 发件人:Francis Deslauriers francis.deslauri...@mail.utoronto.ca
 发送时间:2015年2月17日(星期二) 00:53
 收件人:zhenyu.ren zhenyu@aliyun.com
 抄 送:lttng-dev lttng-dev@lists.lttng.org
 主 题:Re: [lttng-dev] Can lttng support kernel function tracer

 Hi Zhenyu,

 If I understandd your question correctly, I can think of two ways to
 trace an arbitrary kernel function. First, you can hook the tracer on
 a dynamic probe[1] using something like this:
 lttng enable-event customEventName -k --probe kernelFunctionName.
 You can also hook the tracer on both entry and exit of a function
 using --function instead of --probe.
 To list your kernel symbols use cat /proc/kallsyms
 Second, you can create custom kernel tracepoints and compile them in
 you kernel. Have a look at the online documentation [2].

 Don't hesitate to explain further if this doesn't answer your question.

 Cheers!
 Francis

 [1]
 http://git.lttng.org/?p=lttng-tools.git;a=blob;f=doc/quickstart.txt;h=018c27b2b939ef7cd075255fd01bcfd8b2b21b1e;hb=HEAD#l93
 [2] http://lttng.org/docs/#doc-instrumenting-linux-kernel-itself

 On Thu, Feb 12, 2015 at 7:49 PM, zhenyu.ren zhenyu@aliyun.com wrote:
 Hi,

 It's well known that lttng can make use of kernel tracepoints to do block
 tracing ,system call tracing etc.Is it possible that lttng can produce
 anything like kernel function tracer does?

 Thanks
 zhenyu.ren

 ___
 lttng-dev mailing list
 lttng-dev@lists.lttng.org
 http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


Re: [lttng-dev] 答复:答复: Can lttng support kernel function tracer

2015-02-19 Thread Francis Deslauriers
You can use the snapshot feature to start recording whenever you
witness a significant latency[1].
You can use the system() function to trigger a record from your app.
e.g. system(lttng snapshot record);

[1] http://lttng.org/docs/#doc-taking-a-snapshot

I hope it helps.

Francis

On Wed, Feb 18, 2015 at 1:29 AM, zhenyu.ren zhenyu@aliyun.com wrote:
 I think that might be a usecase for a profiler rather than a usecase for a 
 tracer

 I am sorry that I have misled you.Not all write instances(a chance in a 
 million) take 100ms+ to complete.So I have to trace all write instances to 
 capture the deviant ones.

 Thanks
 zhenyu.ren






 --
 发件人:Francis Deslauriers francis.deslauri...@mail.utoronto.ca


 发送时间:2015年2月17日(星期二) 23:09
 收件人:zhenyu.ren zhenyu@aliyun.com
 抄 送:lttng-dev@lists.lttng.org lttng-dev@lists.lttng.org
 主 题:Re: 答复:[lttng-dev] Can lttng support kernel function tracer


 CCing lttng-dev back in the thread.

 I might be wrong but I think that might be a usecase for a profiler
 rather than a usecase for a tracer. Can someone else confirm?
 To do that kind of work, you could compile your kernel with gprof support.

 Thanks,
 Francis


 On Tue, Feb 17, 2015 at 3:38 AM, zhenyu.ren zhenyu@aliyun.com wrote:
 Hi,Francis
In fact, I want to trace all kernel functions related to some
 behavior.For example,I write()  and it returns 100ms later ,so  I want to
 know which kernel  function is too slow. In this case,I can use function
 tracer to trace all kernel function in the write() time window.However,I
 want to know is it possible that lttng can be useful in this case.

 Thanks
 zhenyu.ren


 --
 发件人:Francis Deslauriers francis.deslauri...@mail.utoronto.ca
 发送时间:2015年2月17日(星期二) 00:53
 收件人:zhenyu.ren zhenyu@aliyun.com
 抄 送:lttng-dev lttng-dev@lists.lttng.org
 主 题:Re: [lttng-dev] Can lttng support kernel function tracer

 Hi Zhenyu,

 If I understandd your question correctly, I can think of two ways to
 trace an arbitrary kernel function. First, you can hook the tracer on
 a dynamic probe[1] using something like this:
 lttng enable-event customEventName -k --probe kernelFunctionName.
 You can also hook the tracer on both entry and exit of a function
 using --function instead of --probe.
 To list your kernel symbols use cat /proc/kallsyms
 Second, you can create custom kernel tracepoints and compile them in
 you kernel. Have a look at the online documentation [2].

 Don't hesitate to explain further if this doesn't answer your question.

 Cheers!
 Francis

 [1]
 http://git.lttng.org/?p=lttng-tools.git;a=blob;f=doc/quickstart.txt;h=018c27b2b939ef7cd075255fd01bcfd8b2b21b1e;hb=HEAD#l93
 [2] http://lttng.org/docs/#doc-instrumenting-linux-kernel-itself

 On Thu, Feb 12, 2015 at 7:49 PM, zhenyu.ren zhenyu@aliyun.com wrote:
 Hi,

 It's well known that lttng can make use of kernel tracepoints to do block
 tracing ,system call tracing etc.Is it possible that lttng can produce
 anything like kernel function tracer does?

 Thanks
 zhenyu.ren

 ___
 lttng-dev mailing list
 lttng-dev@lists.lttng.org
 http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH babeltrace] Set the minimum Python version to 3.0

2017-02-21 Thread Francis Deslauriers
To be applied on Babeltrace v1.5

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index fd80fd9..7d9b66e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -239,7 +239,7 @@ AM_CONDITIONAL([USE_PYTHON], [test "x${enable_python:-yes}" 
= xyes])
 
 if test "x${enable_python:-yes}" = xyes; then
   AX_PKG_SWIG($swig_version, [], [ AC_MSG_ERROR([SWIG $swig_version or newer 
is needed]) ])
-  AM_PATH_PYTHON
+  AM_PATH_PYTHON([3.0], [], [ AC_MSG_ERROR([Python 3.0 or newer is needed]) ])
 
   AC_ARG_VAR([PYTHON_INCLUDE], [Include flags for python, bypassing 
python-config])
   AC_ARG_VAR([PYTHON_CONFIG], [Path to python-config])
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH babeltrace v2] Build Python bindings with distutils for consistent installs

2017-02-21 Thread Francis Deslauriers
This patch changes the build system used to compile and install the
Python Bindings. Distutils is used to find the right install directory.
When the install directory generated from the install prefix is not in
the Python search path (PYTHON_PATH), we print a warning explaining what
can be done to include it.
It uses Distutils which is part of the Python standard library.

To be applied on Babeltrace v1.5

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 .gitignore| 10 +++-
 bindings/python/Makefile.am   | 58 +-
 bindings/python/babeltrace/Makefile.am| 30 ++
 bindings/python/babeltrace/__init__.py.in | 25 
 bindings/python/setup.py.in   | 85 +++
 configure.ac  | 13 ++--
 m4/python_modules.m4  | 23 
 tests/bin/intersection/bt_python_helper.py.in |  8 +--
 8 files changed, 187 insertions(+), 65 deletions(-)
 create mode 100644 bindings/python/babeltrace/__init__.py.in
 create mode 100644 bindings/python/setup.py.in
 delete mode 100644 m4/python_modules.m4

diff --git a/.gitignore b/.gitignore
index a7c9e3c..9259b6f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -47,8 +47,12 @@ converter/babeltrace-log
 core
 formats/ctf/metadata/ctf-parser.output
 stamp-h1
-bindings/python/babeltrace.i
-bindings/python/babeltrace.py
-bindings/python/babeltrace_wrap.c
+bindings/python/setup.py
+bindings/python/installed_files.txt
+bindings/python/build
+bindings/python/babeltrace/__init__.py
+bindings/python/babeltrace/babeltrace.i
+bindings/python/babeltrace/babeltrace.py
+bindings/python/babeltrace/babeltrace_wrap.c
 babeltrace.pc
 babeltrace-ctf.pc
diff --git a/bindings/python/Makefile.am b/bindings/python/Makefile.am
index d6b3648..37ae14e 100644
--- a/bindings/python/Makefile.am
+++ b/bindings/python/Makefile.am
@@ -1,3 +1,59 @@
 if USE_PYTHON
-SUBDIRS = babeltrace
+SUBDIRS = babeltrace .
+
+AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include -I$(srcdir)/babeltrace/
+
+# Since the shared object used by the python bindings is not built with libtool
+# we need to manually set the `rpath` during linkage
+AM_LDFLAGS=-L$(top_builddir)/formats/ctf/.libs -L$(top_builddir)/lib/.libs 
-Wl,-rpath,$(prefix)/lib
+
+INSTALLED_FILES=installed_files.txt
+
+all-local: build-python-bindings.stamp
+
+$(builddir)/babeltrace/__init__.py: $(srcdir)/babeltrace/__init__.py.in
+   cd babeltrace && $(MAKE) __init__.py
+
+$(builddir)/babeltrace/babeltrace.i: $(srcdir)/babeltrace/babeltrace.i.in
+   cd babeltrace && $(MAKE) babeltrace.i
+
+BINDINGS_DEPS=setup.py \
+   babeltrace/__init__.py \
+   babeltrace/babeltrace.i \
+   babeltrace/python-complements.c \
+   babeltrace/python-complements.h
+
+BUILD_FLAGS=CC="$(CC)" \
+   CFLAGS="$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(GLIB_CFLAGS) 
$(AM_CFLAGS)" \
+   CPPFLAGS="$(AM_CPPFLAGS) $(CPPFLAGS)" \
+   LDFLAGS="$(AM_LDFLAGS) $(LDFLAGS)"
+
+build-python-bindings.stamp: $(BINDINGS_DEPS)
+   $(BUILD_FLAGS) $(PYTHON) $(builddir)/setup.py build_ext
+   $(BUILD_FLAGS) $(PYTHON) $(builddir)/setup.py build
+   touch $@
+
+# This target installs the Python package and saves the path of all the
+# installed files in the INSTALLED_FILES text file to be used during this
+# uninstallation
+install-exec-local:
+   @opts="--prefix=$(prefix) --verbose --record $(INSTALLED_FILES) 
--no-compile $(DISTSETUPOPTS)"; \
+   if [ "$(DESTDIR)" != "" ]; then \
+   opts="$$opts --root=$(DESTDIR)"; \
+   fi; \
+   $(PYTHON) $(builddir)/setup.py install $$opts;
+
+clean-local:
+   rm -rf $(builddir)/build
+
+# Distutils' setup.py does not include an uninstall target, we thus need to do 
it
+# manually. We use the INSTALLED_FILES file produced during the install to
+# clean up the install folder and delete the folder it self.
+uninstall-local:
+   cat $(builddir)/$(INSTALLED_FILES) | xargs rm -rf
+   cat $(builddir)/$(INSTALLED_FILES) | $(GREP) "__init__.py" | xargs 
dirname | xargs rmdir
+   rm -f $(builddir)/$(INSTALLED_FILES)
+
+CLEANFILES = babeltrace/babeltrace_wrap.c babeltrace/babeltrace.py 
build-python-bindings.stamp
+DISTCLEANFILES = setup.py
 endif
diff --git a/bindings/python/babeltrace/Makefile.am 
b/bindings/python/babeltrace/Makefile.am
index 11dcdf0..f612aa6 100644
--- a/bindings/python/babeltrace/Makefile.am
+++ b/bindings/python/babeltrace/Makefile.am
@@ -1,31 +1,9 @@
+if USE_PYTHON
 babeltrace.i: babeltrace.i.in
sed "s/BABELTRACE_VERSION_STR/Babeltrace $(PACKAGE_VERSION)/g" < \
$(top_srcdir)/bindings/python/babeltrace/babeltrace.i.in > \
$(top_builddir)/bindings/python/bab

Re: [lttng-dev] [PATCH babeltrace] Build Python bindings with distutils for consistent installs

2017-02-20 Thread Francis Deslauriers
I noticed some shortcomings for this patch. I will send an updated
version shortly.

Francis

2017-02-17 15:59 GMT-05:00 Francis Deslauriers
<francis.deslauri...@efficios.com>:
> This patch changes the build system used to compile and install the
> Python Bindings. Distutils is used to find the right install directory.
> When the install directory generated from the install prefix is not in
> the Python search path (PYTHON_PATH), we print a warning explaining what
> can be done to include it.
> It uses Distutils which is part of the Python standard library.
>
> To be applied on top of 1.5.
>
> Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
> ---
>  .gitignore| 10 +++--
>  bindings/python/Makefile.am   | 39 +++-
>  bindings/python/babeltrace/Makefile.am| 31 -
>  bindings/python/babeltrace/__init__.py.in | 25 +++
>  bindings/python/setup.py.in   | 75 
> +++
>  configure.ac  | 14 +++---
>  m4/python_modules.m4  | 23 --
>  7 files changed, 153 insertions(+), 64 deletions(-)
>  delete mode 100644 bindings/python/babeltrace/Makefile.am
>  create mode 100644 bindings/python/babeltrace/__init__.py.in
>  create mode 100644 bindings/python/setup.py.in
>  delete mode 100644 m4/python_modules.m4
>
> diff --git a/.gitignore b/.gitignore
> index a7c9e3c..9259b6f 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -47,8 +47,12 @@ converter/babeltrace-log
>  core
>  formats/ctf/metadata/ctf-parser.output
>  stamp-h1
> -bindings/python/babeltrace.i
> -bindings/python/babeltrace.py
> -bindings/python/babeltrace_wrap.c
> +bindings/python/setup.py
> +bindings/python/installed_files.txt
> +bindings/python/build
> +bindings/python/babeltrace/__init__.py
> +bindings/python/babeltrace/babeltrace.i
> +bindings/python/babeltrace/babeltrace.py
> +bindings/python/babeltrace/babeltrace_wrap.c
>  babeltrace.pc
>  babeltrace-ctf.pc
> diff --git a/bindings/python/Makefile.am b/bindings/python/Makefile.am
> index d6b3648..ab75a3a 100644
> --- a/bindings/python/Makefile.am
> +++ b/bindings/python/Makefile.am
> @@ -1,3 +1,40 @@
>  if USE_PYTHON
> -SUBDIRS = babeltrace
> +
> +SUBDIRS = .
> +
> +AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include -I$(srcdir)/babeltrace/
> +
> +# Since the shared object used by the python bindings is not built with 
> libtool
> +# we need to manually set the `rpath` during linkage
> +AM_LDFLAGS=-L$(top_builddir)/formats/ctf/.libs -L$(top_builddir)/lib/.libs 
> -Wl,-rpath,$(prefix)/lib
> +
> +INSTALLED_FILES=installed_files.txt
> +
> +all-local:
> +   CC="$(CC)" CFLAGS="$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) 
> $(GLIB_CFLAGS) $(AM_CFLAGS)" CPPFLAGS="$(AM_CPPFLAGS) $(CPPFLAGS)" 
> LDFLAGS="$(AM_LDFLAGS) $(LDFLAGS)" $(PYTHON) $(builddir)/setup.py build_ext 
> --swig-opts="-Wall -I$(top_srcdir)"
> +   $(PYTHON) $(builddir)/setup.py build
> +
> +# This target installs the Python package and saves the path of all the
> +# installed files in the INSTALLED_FILES text file to be used during this
> +# uninstallation
> +install-exec-local:
> +   @opts="--prefix=$(prefix) --verbose --record $(INSTALLED_FILES) 
> --no-compile $(DISTSETUPOPTS)"; \
> +   if [ "$(DESTDIR)" != "" ]; then \
> +   opts="$$opts --root=$(DESTDIR)"; \
> +   fi; \
> +   $(PYTHON) $(builddir)/setup.py install $$opts;
> +
> +clean-local:
> +   rm -rf $(builddir)/build
> +
> +# Distutils' setup.py does not include an uninstall target, we thus need to 
> do it
> +# manually. We use the INSTALLED_FILES file produced during the install to
> +# clean up the install folder and delete the folder it self.
> +uninstall-local:
> +   cat $(INSTALLED_FILES) | xargs rm -rf
> +   cat $(INSTALLED_FILES) | $(GREP) "__init__.py" | xargs dirname | 
> xargs rmdir
> +   rm -f $(INSTALLED_FILES)
> +
> +CLEANFILES = babeltrace/babeltrace_wrap.c babeltrace/babeltrace.py
> +DISTCLEANFILES = babeltrace/__init__.py babeltrace/babeltrace.i
>  endif
> diff --git a/bindings/python/babeltrace/Makefile.am 
> b/bindings/python/babeltrace/Makefile.am
> deleted file mode 100644
> index 11dcdf0..000
> --- a/bindings/python/babeltrace/Makefile.am
> +++ /dev/null
> @@ -1,31 +0,0 @@
> -babeltrace.i: babeltrace.i.in
> -   sed "s/BABELTRACE_VERSION_STR/Babeltrace $(PACKAGE_VERSION)/g" < \
> -   $(top_srcdir)/bindings/python/babeltrace/babeltrace.i.in > \
> -  

[lttng-dev] [PATCH babeltrace] Build Python bindings with distutils for consistent installs

2017-02-17 Thread Francis Deslauriers
This patch changes the build system used to compile and install the
Python Bindings. Distutils is used to find the right install directory.
When the install directory generated from the install prefix is not in
the Python search path (PYTHON_PATH), we print a warning explaining what
can be done to include it.
It uses Distutils which is part of the Python standard library.

To be applied on top of 1.5.

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 .gitignore| 10 +++--
 bindings/python/Makefile.am   | 39 +++-
 bindings/python/babeltrace/Makefile.am| 31 -
 bindings/python/babeltrace/__init__.py.in | 25 +++
 bindings/python/setup.py.in   | 75 +++
 configure.ac  | 14 +++---
 m4/python_modules.m4  | 23 --
 7 files changed, 153 insertions(+), 64 deletions(-)
 delete mode 100644 bindings/python/babeltrace/Makefile.am
 create mode 100644 bindings/python/babeltrace/__init__.py.in
 create mode 100644 bindings/python/setup.py.in
 delete mode 100644 m4/python_modules.m4

diff --git a/.gitignore b/.gitignore
index a7c9e3c..9259b6f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -47,8 +47,12 @@ converter/babeltrace-log
 core
 formats/ctf/metadata/ctf-parser.output
 stamp-h1
-bindings/python/babeltrace.i
-bindings/python/babeltrace.py
-bindings/python/babeltrace_wrap.c
+bindings/python/setup.py
+bindings/python/installed_files.txt
+bindings/python/build
+bindings/python/babeltrace/__init__.py
+bindings/python/babeltrace/babeltrace.i
+bindings/python/babeltrace/babeltrace.py
+bindings/python/babeltrace/babeltrace_wrap.c
 babeltrace.pc
 babeltrace-ctf.pc
diff --git a/bindings/python/Makefile.am b/bindings/python/Makefile.am
index d6b3648..ab75a3a 100644
--- a/bindings/python/Makefile.am
+++ b/bindings/python/Makefile.am
@@ -1,3 +1,40 @@
 if USE_PYTHON
-SUBDIRS = babeltrace
+
+SUBDIRS = .
+
+AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include -I$(srcdir)/babeltrace/
+
+# Since the shared object used by the python bindings is not built with libtool
+# we need to manually set the `rpath` during linkage
+AM_LDFLAGS=-L$(top_builddir)/formats/ctf/.libs -L$(top_builddir)/lib/.libs 
-Wl,-rpath,$(prefix)/lib
+
+INSTALLED_FILES=installed_files.txt
+
+all-local:
+   CC="$(CC)" CFLAGS="$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) 
$(GLIB_CFLAGS) $(AM_CFLAGS)" CPPFLAGS="$(AM_CPPFLAGS) $(CPPFLAGS)" 
LDFLAGS="$(AM_LDFLAGS) $(LDFLAGS)" $(PYTHON) $(builddir)/setup.py build_ext 
--swig-opts="-Wall -I$(top_srcdir)"
+   $(PYTHON) $(builddir)/setup.py build
+
+# This target installs the Python package and saves the path of all the
+# installed files in the INSTALLED_FILES text file to be used during this
+# uninstallation
+install-exec-local:
+   @opts="--prefix=$(prefix) --verbose --record $(INSTALLED_FILES) 
--no-compile $(DISTSETUPOPTS)"; \
+   if [ "$(DESTDIR)" != "" ]; then \
+   opts="$$opts --root=$(DESTDIR)"; \
+   fi; \
+   $(PYTHON) $(builddir)/setup.py install $$opts;
+
+clean-local:
+   rm -rf $(builddir)/build
+
+# Distutils' setup.py does not include an uninstall target, we thus need to do 
it
+# manually. We use the INSTALLED_FILES file produced during the install to
+# clean up the install folder and delete the folder it self.
+uninstall-local:
+   cat $(INSTALLED_FILES) | xargs rm -rf
+   cat $(INSTALLED_FILES) | $(GREP) "__init__.py" | xargs dirname | xargs 
rmdir
+   rm -f $(INSTALLED_FILES)
+
+CLEANFILES = babeltrace/babeltrace_wrap.c babeltrace/babeltrace.py
+DISTCLEANFILES = babeltrace/__init__.py babeltrace/babeltrace.i
 endif
diff --git a/bindings/python/babeltrace/Makefile.am 
b/bindings/python/babeltrace/Makefile.am
deleted file mode 100644
index 11dcdf0..000
--- a/bindings/python/babeltrace/Makefile.am
+++ /dev/null
@@ -1,31 +0,0 @@
-babeltrace.i: babeltrace.i.in
-   sed "s/BABELTRACE_VERSION_STR/Babeltrace $(PACKAGE_VERSION)/g" < \
-   $(top_srcdir)/bindings/python/babeltrace/babeltrace.i.in > \
-   $(top_builddir)/bindings/python/babeltrace/babeltrace.i
-
-AM_CFLAGS = $(PYTHON_INCLUDE) -I$(top_srcdir)/include/ \
-   -I$(top_srcdir)/bindings/python/babeltrace
-
-EXTRA_DIST = babeltrace.i.in
-nodist_python_PYTHON = babeltrace.py
-pyexec_LTLIBRARIES = _babeltrace.la
-
-MAINTAINERCLEANFILES = babeltrace_wrap.c babeltrace.py
-
-nodist__babeltrace_la_SOURCES = babeltrace_wrap.c
-_babeltrace_la_SOURCES = python-complements.h python-complements.c
-_babeltrace_la_LDFLAGS = -module
-
-_babeltrace_la_CFLAGS = $(GLIB_CFLAGS) $(AM_CFLAGS)
-
-_babeltrace_la_LIBS = $(GLIB_LIBS)
-
-_babeltrace_la_LIBADD = $(top_builddir)/formats/ctf/libbabeltrace-ctf.la \
-   $(top_builddir)/formats/ctf-text/libbabeltrace-ctf-text.

[lttng-dev] [PATCH lttng-ust] Fix: (un)install targets of Python agent

2017-02-28 Thread Francis Deslauriers
This Makefile was using Distutils' setup.py to install the Python agent
but was using the Autoconf's $pkgpythondir variable for the uninstall
process. The two folders can be different on some distributions which
made the uninstall attempting to delete a non-existant folder and
effectively not uninstalling.

We now save the paths of the installed files and use this information
during the uninstallation.

Also, we print a warning if the install directory is not included in the
PYTHONPATH variable.

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 .gitignore  |  1 +
 python-lttngust/Makefile.am | 22 
 python-lttngust/setup.py.in | 62 +
 3 files changed, 59 insertions(+), 26 deletions(-)

diff --git a/.gitignore b/.gitignore
index 0d322b1..fe43230 100644
--- a/.gitignore
+++ b/.gitignore
@@ -86,3 +86,4 @@ python-lttngust/lttngust/__init__.py
 python-lttngust/**/*.pyc
 python-lttngust/build
 python-lttngust/setup.py
+python-lttngust/installed_files.txt
diff --git a/python-lttngust/Makefile.am b/python-lttngust/Makefile.am
index cc28989..d7c2071 100644
--- a/python-lttngust/Makefile.am
+++ b/python-lttngust/Makefile.am
@@ -1,25 +1,27 @@
 # Use setup.py for the installation instead of Autoconf.
 # This ease the installation process and assure a *pythonic*
 # installation.
-agent_path=lttngust
+INSTALLED_FILES=$(builddir)/installed_files.txt
 all-local:
$(PYTHON) setup.py build --verbose
 
+# This target installs the Python package and saves the path of all the
+# installed files in the INSTALLED_FILES text file to be used during this
+# uninstallation
 install-exec-local:
-   @opts="--prefix=$(prefix) --verbose --no-compile $(DISTSETUPOPTS)"; \
+   @opts="--prefix=$(prefix) --verbose --record $(INSTALLED_FILES) 
--no-compile $(DISTSETUPOPTS)"; \
if [ "$(DESTDIR)" != "" ]; then \
opts="$$opts --root=$(DESTDIR)"; \
fi; \
$(PYTHON) setup.py install $$opts;
 
 clean-local:
-   rm -rf build
+   rm -rf $(builddir)/build
 
+# Distutils' setup.py does not include an uninstall target, we thus need to do
+# it manually. We use the INSTALLED_FILES file produced during the install to
+# clean up the install folder and delete the folder it self.
 uninstall-local:
-   rm -rf $(DESTDIR)$(pkgpythondir)
-
-EXTRA_DIST=$(agent_path)
-
-# Remove automake generated file before dist
-dist-hook:
-   rm -rf $(distdir)/$(agent_path)/__init__.py
+   cat $(INSTALLED_FILES) | xargs rm -rf
+   cat $(INSTALLED_FILES) | $(GREP) "__init__.py" | xargs dirname | xargs 
rmdir
+   rm -f $(INSTALLED_FILES)
diff --git a/python-lttngust/setup.py.in b/python-lttngust/setup.py.in
index 370fd61..89cd5f0 100644
--- a/python-lttngust/setup.py.in
+++ b/python-lttngust/setup.py.in
@@ -15,22 +15,52 @@
 # along with this library; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
 
+import sys
+
 from distutils.core import setup, Extension
 
+PY_PATH_WARN_MSG = """
+-WARNING
+The install directory used:\n ({})\nis not included in your PYTHONPATH.
+
+To add this directory to your Python search path permanently you can add the
+following command to your .bashrc/.zshrc:
+export PYTHONPATH="${{PYTHONPATH}}:{}"
+
+"""
+
+def main():
+dist = setup(name='lttngust',
+version='@PACKAGE_VERSION@',
+description='LTTng-UST Python agent',
+packages=['lttngust'],
+package_dir={'lttngust': 'lttngust'},
+options={'build': {'build_base': 'build'}},
+url='http://lttng.org',
+license='LGPL-2.1',
+classifiers=[
+'Development Status :: 5 - Production/Stable',
+'Intended Audience :: Developers',
+'License :: OSI Approved :: GNU Lesser General Public License 
v2 (LGPLv2)',
+'Programming Language :: Python :: 2.7',
+'Programming Language :: Python :: 3'
+'Topic :: System :: Logging',
+])
+
+# After the installation, we check that the install directory is included in
+# the Python search path and we print a warning message when it's not. We need
+# to do this because Python search path differs depending on the distro and
+# some distros don't include any `/usr/local/` (the default install prefix) in
+# the search path. This is also useful for out-of-tree installs and tests. It's
+# only relevant to make this check on the `install` command.
+
+if 'install' in dist.command_obj:
+install_dir = dist.command_obj['install'].install_libbase
+ 

[lttng-dev] [PATCH babeltrace v3] Build Python bindings with distutils for consistent installs

2017-02-27 Thread Francis Deslauriers
v3: changes PYTHON_PATH -> PYTHONPATH in commit message and warning message.

This patch changes the build system used to compile and install the
Python Bindings. Distutils is used to find the right install directory.
When the install directory generated from the install prefix is not in
the Python search path (PYTHONPATH), we print a warning explaining what
can be done to include it.
It uses Distutils which is part of the Python standard library.

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 .gitignore| 10 +++-
 bindings/python/Makefile.am   | 58 +-
 bindings/python/babeltrace/Makefile.am| 30 ++
 bindings/python/babeltrace/__init__.py.in | 25 
 bindings/python/setup.py.in   | 85 +++
 configure.ac  | 13 ++--
 m4/python_modules.m4  | 23 
 tests/bin/intersection/bt_python_helper.py.in |  8 +--
 8 files changed, 187 insertions(+), 65 deletions(-)
 create mode 100644 bindings/python/babeltrace/__init__.py.in
 create mode 100644 bindings/python/setup.py.in
 delete mode 100644 m4/python_modules.m4

diff --git a/.gitignore b/.gitignore
index a7c9e3c..9259b6f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -47,8 +47,12 @@ converter/babeltrace-log
 core
 formats/ctf/metadata/ctf-parser.output
 stamp-h1
-bindings/python/babeltrace.i
-bindings/python/babeltrace.py
-bindings/python/babeltrace_wrap.c
+bindings/python/setup.py
+bindings/python/installed_files.txt
+bindings/python/build
+bindings/python/babeltrace/__init__.py
+bindings/python/babeltrace/babeltrace.i
+bindings/python/babeltrace/babeltrace.py
+bindings/python/babeltrace/babeltrace_wrap.c
 babeltrace.pc
 babeltrace-ctf.pc
diff --git a/bindings/python/Makefile.am b/bindings/python/Makefile.am
index d6b3648..37ae14e 100644
--- a/bindings/python/Makefile.am
+++ b/bindings/python/Makefile.am
@@ -1,3 +1,59 @@
 if USE_PYTHON
-SUBDIRS = babeltrace
+SUBDIRS = babeltrace .
+
+AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include -I$(srcdir)/babeltrace/
+
+# Since the shared object used by the python bindings is not built with libtool
+# we need to manually set the `rpath` during linkage
+AM_LDFLAGS=-L$(top_builddir)/formats/ctf/.libs -L$(top_builddir)/lib/.libs 
-Wl,-rpath,$(prefix)/lib
+
+INSTALLED_FILES=installed_files.txt
+
+all-local: build-python-bindings.stamp
+
+$(builddir)/babeltrace/__init__.py: $(srcdir)/babeltrace/__init__.py.in
+   cd babeltrace && $(MAKE) __init__.py
+
+$(builddir)/babeltrace/babeltrace.i: $(srcdir)/babeltrace/babeltrace.i.in
+   cd babeltrace && $(MAKE) babeltrace.i
+
+BINDINGS_DEPS=setup.py \
+   babeltrace/__init__.py \
+   babeltrace/babeltrace.i \
+   babeltrace/python-complements.c \
+   babeltrace/python-complements.h
+
+BUILD_FLAGS=CC="$(CC)" \
+   CFLAGS="$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(GLIB_CFLAGS) 
$(AM_CFLAGS)" \
+   CPPFLAGS="$(AM_CPPFLAGS) $(CPPFLAGS)" \
+   LDFLAGS="$(AM_LDFLAGS) $(LDFLAGS)"
+
+build-python-bindings.stamp: $(BINDINGS_DEPS)
+   $(BUILD_FLAGS) $(PYTHON) $(builddir)/setup.py build_ext
+   $(BUILD_FLAGS) $(PYTHON) $(builddir)/setup.py build
+   touch $@
+
+# This target installs the Python package and saves the path of all the
+# installed files in the INSTALLED_FILES text file to be used during this
+# uninstallation
+install-exec-local:
+   @opts="--prefix=$(prefix) --verbose --record $(INSTALLED_FILES) 
--no-compile $(DISTSETUPOPTS)"; \
+   if [ "$(DESTDIR)" != "" ]; then \
+   opts="$$opts --root=$(DESTDIR)"; \
+   fi; \
+   $(PYTHON) $(builddir)/setup.py install $$opts;
+
+clean-local:
+   rm -rf $(builddir)/build
+
+# Distutils' setup.py does not include an uninstall target, we thus need to do 
it
+# manually. We use the INSTALLED_FILES file produced during the install to
+# clean up the install folder and delete the folder it self.
+uninstall-local:
+   cat $(builddir)/$(INSTALLED_FILES) | xargs rm -rf
+   cat $(builddir)/$(INSTALLED_FILES) | $(GREP) "__init__.py" | xargs 
dirname | xargs rmdir
+   rm -f $(builddir)/$(INSTALLED_FILES)
+
+CLEANFILES = babeltrace/babeltrace_wrap.c babeltrace/babeltrace.py 
build-python-bindings.stamp
+DISTCLEANFILES = setup.py
 endif
diff --git a/bindings/python/babeltrace/Makefile.am 
b/bindings/python/babeltrace/Makefile.am
index 11dcdf0..f612aa6 100644
--- a/bindings/python/babeltrace/Makefile.am
+++ b/bindings/python/babeltrace/Makefile.am
@@ -1,31 +1,9 @@
+if USE_PYTHON
 babeltrace.i: babeltrace.i.in
sed "s/BABELTRACE_VERSION_STR/Babeltrace $(PACKAGE_VERSION)/g" < \
$(top_srcdir)/bindings/python/babeltrace/babeltrace.i.in >

Re: [lttng-dev] Beginner question: how to inspect scheduling of multi-threaded user application?

2016-08-24 Thread Francis Deslauriers
Hi David,
If you specifically want to trace the scheduling of the threads of your
app, you don't need custom tracepoints.
Enabling the sched_switch kernel event will give you both of cpu id and
thread id. Look at the cpu_id and next_tid fields.

You can enable the sched_switch event using : lttng enable-event -k
sched_switch

Cheers,
Francis

2016-08-24 3:17 GMT-04:00 David Aldrich :

> Hi
>
>
>
> I am new to tracing in Linux and to lttng. I have a multi-threaded user
> application and I want to see:
>
>
>
> 1)  When the threads are scheduled to run
>
> 2)  Which cores the threads are running on.
>
>
>
> I have installed lttng on Ubuntu 14.04 LTS.  I am expecting to visualise
> the trace using TraceCompass.
>
>
>
> I have read the following doc section:
>
>
>
> http://lttng.org/docs/#doc-tracing-your-own-user-application
>
>
>
> In order to collect my trace, must I define custom tracepoint definitions ( in
> a tracepoint provider header file ), and insert tracepoints into my user
> application, or is there a simpler way of achieving my goal?
>
>
>
> Best regards
>
>
>
> David
>
>
>
> ___
> lttng-dev mailing list
> lttng-dev@lists.lttng.org
> https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
>
>
___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-tools] Fix: test case can not rely on sched_process_free, use _fork instead

2016-11-08 Thread Francis Deslauriers
sched_process_free may not be called during the tracing session if there
is very little activity on the machine the test is run on. We change
this validate to sched_process_fork since we are sure there will be
atleast one generated by the final lttng stop.

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 tests/regression/kernel/test_event_basic | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/regression/kernel/test_event_basic 
b/tests/regression/kernel/test_event_basic
index aeca02b..584bfc8 100755
--- a/tests/regression/kernel/test_event_basic
+++ b/tests/regression/kernel/test_event_basic
@@ -32,14 +32,14 @@ function test_event_basic()
 
lttng_enable_kernel_event $SESSION_NAME "sched_switch"
lttng_enable_kernel_event $SESSION_NAME "sched_process_exit"
-   lttng_enable_kernel_event $SESSION_NAME "sched_process_free"
+   lttng_enable_kernel_event $SESSION_NAME "sched_process_fork"
 
start_lttng_tracing_ok
stop_lttng_tracing_ok
 
validate_trace "sched_switch" $TRACE_PATH
validate_trace "sched_process_exit" $TRACE_PATH
-   validate_trace "sched_process_free" $TRACE_PATH
+   validate_trace "sched_process_fork" $TRACE_PATH
 
destroy_lttng_session_ok $SESSION_NAME
 
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


Re: [lttng-dev] [PATCH lttng-tools] Fix: test case can not rely on sched_process_free, use _fork instead

2016-11-08 Thread Francis Deslauriers
Please omit this patch. I am preparing a more generic one.

Thank you,
-- 
Francis Deslauriers
Software developer
EfficiOS inc.

2016-11-08 11:05 GMT-05:00 Francis Deslauriers <
francis.deslauri...@efficios.com>:

> sched_process_free may not be called during the tracing session if there
> is very little activity on the machine the test is run on. We change
> this validate to sched_process_fork since we are sure there will be
> atleast one generated by the final lttng stop.
>
> Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
> ---
>  tests/regression/kernel/test_event_basic | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tests/regression/kernel/test_event_basic
> b/tests/regression/kernel/test_event_basic
> index aeca02b..584bfc8 100755
> --- a/tests/regression/kernel/test_event_basic
> +++ b/tests/regression/kernel/test_event_basic
> @@ -32,14 +32,14 @@ function test_event_basic()
>
> lttng_enable_kernel_event $SESSION_NAME "sched_switch"
> lttng_enable_kernel_event $SESSION_NAME "sched_process_exit"
> -   lttng_enable_kernel_event $SESSION_NAME "sched_process_free"
> +   lttng_enable_kernel_event $SESSION_NAME "sched_process_fork"
>
> start_lttng_tracing_ok
> stop_lttng_tracing_ok
>
> validate_trace "sched_switch" $TRACE_PATH
> validate_trace "sched_process_exit" $TRACE_PATH
> -   validate_trace "sched_process_free" $TRACE_PATH
> +   validate_trace "sched_process_fork" $TRACE_PATH
>
> destroy_lttng_session_ok $SESSION_NAME
>
> --
> 2.7.4
>
>
___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-tools] Fix: test cases now rely on explicit workloads

2016-11-08 Thread Francis Deslauriers
Run a process explicitly in the tracing session to generate the enabled events
rather than relying on the events generated by the lttng CLI.

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 tests/regression/kernel/test_all_events  |  6 ++
 tests/regression/kernel/test_event_basic | 14 --
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/tests/regression/kernel/test_all_events 
b/tests/regression/kernel/test_all_events
index 50002f4..713c717 100755
--- a/tests/regression/kernel/test_all_events
+++ b/tests/regression/kernel/test_all_events
@@ -21,6 +21,8 @@ CURDIR=$(dirname $0)/
 TESTDIR=$CURDIR/../..
 NUM_TESTS=8
 
+TESTCMD="/bin/true"
+
 source $TESTDIR/utils/utils.sh
 
 function test_all_event()
@@ -33,6 +35,10 @@ function test_all_event()
lttng_enable_kernel_event $SESSION_NAME
 
start_lttng_tracing_ok
+
+   # Running a process and waiting for its completion forces the 
triggering of a
+   # sched_switch event
+   eval ${TESTCMD}
stop_lttng_tracing_ok
 
validate_trace "sched_switch" $TRACE_PATH
diff --git a/tests/regression/kernel/test_event_basic 
b/tests/regression/kernel/test_event_basic
index aeca02b..1a10a2c 100755
--- a/tests/regression/kernel/test_event_basic
+++ b/tests/regression/kernel/test_event_basic
@@ -21,6 +21,8 @@ CURDIR=$(dirname $0)/
 TESTDIR=$CURDIR/../..
 NUM_TESTS=20
 
+TESTCMD="/bin/true"
+
 source $TESTDIR/utils/utils.sh
 
 function test_event_basic()
@@ -32,14 +34,18 @@ function test_event_basic()
 
lttng_enable_kernel_event $SESSION_NAME "sched_switch"
lttng_enable_kernel_event $SESSION_NAME "sched_process_exit"
-   lttng_enable_kernel_event $SESSION_NAME "sched_process_free"
+   lttng_enable_kernel_event $SESSION_NAME "sched_process_fork"
 
start_lttng_tracing_ok
+
+   # Running a process and waiting for its completion forces the 
triggering of
+   # fork, sched_switch and exit events
+   eval ${TESTCMD}
stop_lttng_tracing_ok
 
validate_trace "sched_switch" $TRACE_PATH
validate_trace "sched_process_exit" $TRACE_PATH
-   validate_trace "sched_process_free" $TRACE_PATH
+   validate_trace "sched_process_fork" $TRACE_PATH
 
destroy_lttng_session_ok $SESSION_NAME
 
@@ -57,6 +63,10 @@ function test_enable_after_start()
 
start_lttng_tracing_ok
lttng_enable_kernel_event $SESSION_NAME "sched_process_exit"
+
+   # Running a process and waiting for its completion forces the 
triggering of
+   # sched_switch and exit events
+   eval ${TESTCMD}
stop_lttng_tracing_ok
 
validate_trace "sched_switch" $TRACE_PATH
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-tools v2] Fix: test cases now rely on explicit workloads

2016-11-08 Thread Francis Deslauriers
Run a process explicitly in the tracing session to generate the enabled events
rather than relying on the events generated by the lttng CLI.

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 tests/regression/kernel/test_all_events  |  6 ++
 tests/regression/kernel/test_event_basic | 14 --
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/tests/regression/kernel/test_all_events 
b/tests/regression/kernel/test_all_events
index 50002f4..80a8020 100755
--- a/tests/regression/kernel/test_all_events
+++ b/tests/regression/kernel/test_all_events
@@ -21,6 +21,8 @@ CURDIR=$(dirname $0)/
 TESTDIR=$CURDIR/../..
 NUM_TESTS=8
 
+TESTCMD="grep -V -q > /dev/null"
+
 source $TESTDIR/utils/utils.sh
 
 function test_all_event()
@@ -33,6 +35,10 @@ function test_all_event()
lttng_enable_kernel_event $SESSION_NAME
 
start_lttng_tracing_ok
+
+   # Running a process and waiting for its completion forces the 
triggering of a
+   # sched_switch event
+   eval ${TESTCMD}
stop_lttng_tracing_ok
 
validate_trace "sched_switch" $TRACE_PATH
diff --git a/tests/regression/kernel/test_event_basic 
b/tests/regression/kernel/test_event_basic
index aeca02b..43c4fda 100755
--- a/tests/regression/kernel/test_event_basic
+++ b/tests/regression/kernel/test_event_basic
@@ -21,6 +21,8 @@ CURDIR=$(dirname $0)/
 TESTDIR=$CURDIR/../..
 NUM_TESTS=20
 
+TESTCMD="grep -V -q > /dev/null"
+
 source $TESTDIR/utils/utils.sh
 
 function test_event_basic()
@@ -32,14 +34,18 @@ function test_event_basic()
 
lttng_enable_kernel_event $SESSION_NAME "sched_switch"
lttng_enable_kernel_event $SESSION_NAME "sched_process_exit"
-   lttng_enable_kernel_event $SESSION_NAME "sched_process_free"
+   lttng_enable_kernel_event $SESSION_NAME "sched_process_fork"
 
start_lttng_tracing_ok
+
+   # Running a process and waiting for its completion forces the 
triggering of
+   # fork, sched_switch and exit events
+   eval ${TESTCMD}
stop_lttng_tracing_ok
 
validate_trace "sched_switch" $TRACE_PATH
validate_trace "sched_process_exit" $TRACE_PATH
-   validate_trace "sched_process_free" $TRACE_PATH
+   validate_trace "sched_process_fork" $TRACE_PATH
 
destroy_lttng_session_ok $SESSION_NAME
 
@@ -57,6 +63,10 @@ function test_enable_after_start()
 
start_lttng_tracing_ok
lttng_enable_kernel_event $SESSION_NAME "sched_process_exit"
+
+   # Running a process and waiting for its completion forces the 
triggering of
+   # sched_switch and exit events
+   eval ${TESTCMD}
stop_lttng_tracing_ok
 
validate_trace "sched_switch" $TRACE_PATH
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


Re: [lttng-dev] [PATCH lttng-tools v2] Fix: test cases now rely on explicit workloads

2016-11-08 Thread Francis Deslauriers
2016-11-08 15:06 GMT-05:00 Nathan Lynch <nathan_ly...@mentor.com>:

> On 11/08/2016 01:49 PM, Francis Deslauriers wrote:
> > Run a process explicitly in the tracing session to generate the enabled
> events
> > rather than relying on the events generated by the lttng CLI.
>
> [...]
>
> > diff --git a/tests/regression/kernel/test_all_events
> b/tests/regression/kernel/test_all_events
> > index 50002f4..80a8020 100755
> > --- a/tests/regression/kernel/test_all_events
> > +++ b/tests/regression/kernel/test_all_events
> > @@ -21,6 +21,8 @@ CURDIR=$(dirname $0)/
> >  TESTDIR=$CURDIR/../..
> >  NUM_TESTS=8
> >
> > +TESTCMD="grep -V -q > /dev/null"
> > +
>
> What was wrong with /bin/true, as in v1 of this patch?


I used grep because the configure script looks for it already
At the moment, we don't check if /bin/true is installed on the machine
using the configure script.


> FYI, Busybox grep doesn't know -V:
>
> # grep -V -q >/dev/null
> grep: invalid option -- 'V'
> BusyBox v1.24.1 (2016-11-08 12:59:13 CST) multi-call binary.
>
> Usage: grep [-HhnlLoqvsriwFE] [-m N] [-A/B/C N] PATTERN/-e PATTERN.../-f
> FILE [FILE]...
>
> # echo $?
> 1
>
> It looks like the testcases don't care about the exit status of TESTCMD,
> but you may want to redirect stderr to /dev/null as well.
>

Good point.
I could do: grep "foo" /dev/null

Thank you,
-- 
Francis Deslauriers
Software developer
EfficiOS inc.


>
> ___
> lttng-dev mailing list
> lttng-dev@lists.lttng.org
> https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
>
___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


Re: [lttng-dev] [PATCH lttng-tools v2] Fix: test cases now rely on explicit workloads

2016-11-10 Thread Francis Deslauriers
Agreed. Let me send this in a final version of this patch.

Thanks,
Francis

2016-11-08 16:07 GMT-05:00 Mathieu Desnoyers <mathieu.desnoy...@efficios.com
>:

> - On Nov 8, 2016, at 3:46 PM, Francis Deslauriers <
> francis.deslauri...@efficios.com> wrote:
>
> 2016-11-08 15:06 GMT-05:00 Nathan Lynch <nathan_ly...@mentor.com>:
>
>> On 11/08/2016 01:49 PM, Francis Deslauriers wrote:
>> > Run a process explicitly in the tracing session to generate the enabled
>> events
>> > rather than relying on the events generated by the lttng CLI.
>>
>> [...]
>>
>> > diff --git a/tests/regression/kernel/test_all_events
>> b/tests/regression/kernel/test_all_events
>> > index 50002f4..80a8020 100755
>> > --- a/tests/regression/kernel/test_all_events
>> > +++ b/tests/regression/kernel/test_all_events
>> > @@ -21,6 +21,8 @@ CURDIR=$(dirname $0)/
>> >  TESTDIR=$CURDIR/../..
>> >  NUM_TESTS=8
>> >
>> > +TESTCMD="grep -V -q > /dev/null"
>> > +
>>
>> What was wrong with /bin/true, as in v1 of this patch?
>
> I used grep because the configure script looks for it already
> At the moment, we don't check if /bin/true is installed on the machine
> using the configure script.
>
>
>> FYI, Busybox grep doesn't know -V:
>>
>> # grep -V -q >/dev/null
>> grep: invalid option -- 'V'
>> BusyBox v1.24.1 (2016-11-08 12:59:13 CST) multi-call binary.
>>
>> Usage: grep [-HhnlLoqvsriwFE] [-m N] [-A/B/C N] PATTERN/-e PATTERN.../-f
>> FILE [FILE]...
>>
>> # echo $?
>> 1
>>
>> It looks like the testcases don't care about the exit status of TESTCMD,
>> but you may want to redirect stderr to /dev/null as well.
>>
> Good point.
> I could do: grep "foo" /dev/null
>
>
> utils/utils.sh:45:# We set the default lttng-sessiond path to /bin/true to
> prevent the spawning
> utils/utils.sh:49:export LTTNG_SESSIOND_PATH="/bin/true"
>
> already used.
>
> So unless anyone complain about it, let's use it.
>
> If someone complains, then we need to fix the configure detection.
>
> Thanks,
>
> Mathieu
>
>
> Thank you,
> --
> Francis Deslauriers
> Software developer
> EfficiOS inc.
>
>>
>> ___________
>> lttng-dev mailing list
>> lttng-dev@lists.lttng.org
>> https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
>>
>
>
>
>
>
> ___
> lttng-dev mailing list
> lttng-dev@lists.lttng.org
> https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
>
>
> --
> Mathieu Desnoyers
> EfficiOS Inc.
> http://www.efficios.com
>



-- 
Francis Deslauriers
Software developer
EfficiOS inc.
___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-tools v3] Fix: test cases now rely on explicit workloads

2016-11-10 Thread Francis Deslauriers
Run a process explicitly in the tracing session to generate the enabled events
rather than relying on the events generated by the lttng CLI.
---
 tests/regression/kernel/test_all_events  |  6 ++
 tests/regression/kernel/test_event_basic | 14 --
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/tests/regression/kernel/test_all_events 
b/tests/regression/kernel/test_all_events
index 50002f4..713c717 100755
--- a/tests/regression/kernel/test_all_events
+++ b/tests/regression/kernel/test_all_events
@@ -21,6 +21,8 @@ CURDIR=$(dirname $0)/
 TESTDIR=$CURDIR/../..
 NUM_TESTS=8
 
+TESTCMD="/bin/true"
+
 source $TESTDIR/utils/utils.sh
 
 function test_all_event()
@@ -33,6 +35,10 @@ function test_all_event()
lttng_enable_kernel_event $SESSION_NAME
 
start_lttng_tracing_ok
+
+   # Running a process and waiting for its completion forces the 
triggering of a
+   # sched_switch event
+   eval ${TESTCMD}
stop_lttng_tracing_ok
 
validate_trace "sched_switch" $TRACE_PATH
diff --git a/tests/regression/kernel/test_event_basic 
b/tests/regression/kernel/test_event_basic
index aeca02b..1a10a2c 100755
--- a/tests/regression/kernel/test_event_basic
+++ b/tests/regression/kernel/test_event_basic
@@ -21,6 +21,8 @@ CURDIR=$(dirname $0)/
 TESTDIR=$CURDIR/../..
 NUM_TESTS=20
 
+TESTCMD="/bin/true"
+
 source $TESTDIR/utils/utils.sh
 
 function test_event_basic()
@@ -32,14 +34,18 @@ function test_event_basic()
 
lttng_enable_kernel_event $SESSION_NAME "sched_switch"
lttng_enable_kernel_event $SESSION_NAME "sched_process_exit"
-   lttng_enable_kernel_event $SESSION_NAME "sched_process_free"
+   lttng_enable_kernel_event $SESSION_NAME "sched_process_fork"
 
start_lttng_tracing_ok
+
+   # Running a process and waiting for its completion forces the 
triggering of
+   # fork, sched_switch and exit events
+   eval ${TESTCMD}
stop_lttng_tracing_ok
 
validate_trace "sched_switch" $TRACE_PATH
validate_trace "sched_process_exit" $TRACE_PATH
-   validate_trace "sched_process_free" $TRACE_PATH
+   validate_trace "sched_process_fork" $TRACE_PATH
 
destroy_lttng_session_ok $SESSION_NAME
 
@@ -57,6 +63,10 @@ function test_enable_after_start()
 
start_lttng_tracing_ok
lttng_enable_kernel_event $SESSION_NAME "sched_process_exit"
+
+   # Running a process and waiting for its completion forces the 
triggering of
+   # sched_switch and exit events
+   eval ${TESTCMD}
stop_lttng_tracing_ok
 
validate_trace "sched_switch" $TRACE_PATH
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-tools] Fix: add missing refcount of loaded modules

2016-11-21 Thread Francis Deslauriers
Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 src/bin/lttng-sessiond/modprobe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/bin/lttng-sessiond/modprobe.c 
b/src/bin/lttng-sessiond/modprobe.c
index 0502740..03545ef 100644
--- a/src/bin/lttng-sessiond/modprobe.c
+++ b/src/bin/lttng-sessiond/modprobe.c
@@ -343,7 +343,7 @@ static int modprobe_lttng(struct kern_modules_param 
*modules,
}
} else {
DBG("Modprobe successfully %s", modules[i].name);
-   modules[i].loaded;
+   modules[i].loaded = true;
}
}
 
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] LTTng User Survey 2016

2016-11-03 Thread Francis Deslauriers
Hi all,

I recently joined the LTTng community and I am curious to better understand
what crowd is forming this community. So I had the idea of putting together
a small survey. This information is also useful for maintainers when
deciding what trade offs users are willing to take.

This is a really short survey of 7 multiple choices questions. I would
really appreciate it if you took a little bit of your time to fill it up.

https://goo.gl/forms/mqbAGSU2TIVZEySk1

I will keep it opened for two weeks and then reply to this message with a
summary of the results.

Thank you,
-- 
Francis Deslauriers
Software developer
EfficiOS inc.
___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-tools] Fix: support for older versions of Babeltrace in test script

2016-12-20 Thread Francis Deslauriers
A new context field was introduced in version LTTng 2.8 that is printed
by Babeltrace prior to v1.2.5. This regex thus fails to match the
output. Since the context fields are not used by the script, we create a
non-capturing group for these fields that matches on both old and new
Babeltrace.
This is causing problems on Ubuntu 14.04 Trusty when building
lttng-tools from source and using the Babeltrace package from the
official repository (v1.2.1) to run the test suite.

Also, this patch removes commented and used code in the function but
keeps the names of non-capturing groups for readability.

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
CC: Philippe Proulx <ppro...@efficios.com>
---
 tests/utils/babelstats.pl | 31 +--
 1 file changed, 9 insertions(+), 22 deletions(-)

diff --git a/tests/utils/babelstats.pl b/tests/utils/babelstats.pl
index 37a9b06..16766ba 100755
--- a/tests/utils/babelstats.pl
+++ b/tests/utils/babelstats.pl
@@ -141,31 +141,18 @@ my @events;
 
 while (<>)
 {
-   my $timestamp   = '\[(.*)\]';
-   my $elapsed = '\((.*)\)';
-   my $hostname= '.*';
-   my $pname   = '.*';
-   my $pinfo   = '.*';
-   my $pid = '\d+';
-   my $tp_event= '.*';
-   my $cpu_info= '{\scpu_id\s=\s(\d+)\s\}';
-   my $fields  = '{(.*)}';
+   my $timestamp   = '\[(?:.*)\]';
+   my $elapsed = '\((?:.*)\)';
+   my $hostname= '(?:.*)';
+   my $tp_event= '(.*)';
+   my $pkt_context = '(?:\{[^}]*\},\s)*';
+   my $fields  = '\{(.*)\}$';
 
# Parse babeltrace text output format
-   if 
(/$timestamp\s$elapsed\s($pinfo)\s($tp_event):\s$cpu_info,\s$fields/) {
+   if (/$timestamp\s$elapsed\s$hostname\s$tp_event:\s$pkt_context$fields/) 
{
my %event_hash;
-   $event_hash{'timestamp'}   = $1;
-   $event_hash{'elapsed'} = $2;
-   $event_hash{'pinfo'}   = $3;
-
-#  my @split_pinfo = split(':', $3);
-#  $event_hash{'hostname'}= $split_pinfo[0];
-#  $event_hash{'pname'}   = defined($split_pinfo[1]) ? 
$split_pinfo[1] : undef;
-#  $event_hash{'pid'} = defined($split_pinfo[2]) ? 
$split_pinfo[2] : undef;
-
-   $event_hash{'tp_event'}= $4;
-   $event_hash{'cpu_id'}  = $5;
-   $event_hash{'fields'}  = parse_fields($6);
+   $event_hash{'tp_event'}= $1;
+   $event_hash{'fields'}  = parse_fields($2);
 
push @events, \%event_hash;
}
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-modules] Fix formatting in strutils_star_glob_match_char_cb explanation

2017-03-17 Thread Francis Deslauriers
Replace tabs for spaces in example scenario

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 lttng-string-utils.c | 108 +--
 1 file changed, 54 insertions(+), 54 deletions(-)

diff --git a/lttng-string-utils.c b/lttng-string-utils.c
index 94de1cf..7485380 100644
--- a/lttng-string-utils.c
+++ b/lttng-string-utils.c
@@ -145,139 +145,139 @@ retry:
 * Example:
 *
 * candidate: hi ev every onyx one
-*  ^
+*^
 * pattern:   hi*every*one
-*  ^
+*^
 *
 * candidate: hi ev every onyx one
-*   ^
+* ^
 * pattern:   hi*every*one
-*   ^
+* ^
 *
 * candidate: hi ev every onyx one
-*^
+*  ^
 * pattern:   hi*every*one
-*^
+*  ^
 *
 * candidate: hi ev every onyx one
-*^
+*  ^
 * pattern:   hi*every*one
-* ^ MISMATCH
+*   ^ MISMATCH
 *
 * candidate: hi ev every onyx one
-* ^
+*   ^
 * pattern:   hi*every*one
-* ^
+*   ^
 *
 * candidate: hi ev every onyx one
-* ^^
+*   ^^
 * pattern:   hi*every*one
-* ^^
+*   ^^
 *
 * candidate: hi ev every onyx one
-* ^ ^
+*   ^ ^
 * pattern:   hi*every*one
-* ^ ^ MISMATCH
+*   ^ ^ MISMATCH
 *
 * candidate: hi ev every onyx one
-*  ^
+*^
 * pattern:   hi*every*one
-* ^ MISMATCH
+*   ^ MISMATCH
 *
 * candidate: hi ev every onyx one
-*   ^
+* ^
 * pattern:   hi*every*one
-* ^ MISMATCH
+*   ^ MISMATCH
 *
 * candidate: hi ev every onyx one
-*^
+*  ^
 * pattern:   hi*every*one
-* ^
+*   ^
 *
 * candidate: hi ev every onyx one
-*^^
+*  ^^
 * pattern:   hi*every*one
-* ^^
+*   ^^
 *
 * candidate: hi ev every onyx one
-*^ ^
+*  ^ ^
 * pattern:   hi*every*one
-* ^ ^
+*   ^ ^
 *
 * candidate: hi ev every onyx one
-*^  ^
+*  ^  ^
 * pattern:   hi*every*one
-* ^  ^
+*   ^  ^
 *
 * candidate: hi ev every onyx one
-*^   ^
+*  ^   ^
 * pattern:   hi*every*one
-* ^   ^
+*   ^   ^
 *
 * candidate: hi ev every onyx one
-* ^
+*   ^
 * pattern:   hi*every*one
-*  ^
+*^
 *
 * candidate: hi ev every onyx one
-* ^
+*   ^
 * pattern:   hi*every*one
-*   ^ MISMATCH
+* ^ MISMATCH
 *
 * candidate: hi ev every onyx one
-*  ^
+*^
 * pattern:   hi*every*one
-*   ^
+* ^
 *
 * candidate: hi ev every onyx one
-*  ^^
+*^^
 * pattern:   hi*every*one
-*   ^^
+* ^^
 *
 * candidate: hi ev every onyx one
-*  ^ ^
+*^ ^
 * pattern:   hi*every*one
-*   ^ ^ MISMATCH
+* ^ ^ MISMATCH
 *
 * candidate: hi ev every on

[lttng-dev] [PATCH lttng-ust] Fix formatting in strutils_star_glob_match explanation

2017-03-17 Thread Francis Deslauriers
Replace tabs for spaces in example scenario

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 liblttng-ust/string-utils.c | 108 ++--
 1 file changed, 54 insertions(+), 54 deletions(-)

diff --git a/liblttng-ust/string-utils.c b/liblttng-ust/string-utils.c
index d597da3..cc61038 100644
--- a/liblttng-ust/string-utils.c
+++ b/liblttng-ust/string-utils.c
@@ -124,139 +124,139 @@ retry:
 * Example:
 *
 * candidate: hi ev every onyx one
-*  ^
+*^
 * pattern:   hi*every*one
-*  ^
+*^
 *
 * candidate: hi ev every onyx one
-*   ^
+* ^
 * pattern:   hi*every*one
-*   ^
+* ^
 *
 * candidate: hi ev every onyx one
-*^
+*  ^
 * pattern:   hi*every*one
-*^
+*  ^
 *
 * candidate: hi ev every onyx one
-*^
+*  ^
 * pattern:   hi*every*one
-* ^ MISMATCH
+*   ^ MISMATCH
 *
 * candidate: hi ev every onyx one
-* ^
+*   ^
 * pattern:   hi*every*one
-* ^
+*   ^
 *
 * candidate: hi ev every onyx one
-* ^^
+*   ^^
 * pattern:   hi*every*one
-* ^^
+*   ^^
 *
 * candidate: hi ev every onyx one
-* ^ ^
+*   ^ ^
 * pattern:   hi*every*one
-* ^ ^ MISMATCH
+*   ^ ^ MISMATCH
 *
 * candidate: hi ev every onyx one
-*  ^
+*^
 * pattern:   hi*every*one
-* ^ MISMATCH
+*   ^ MISMATCH
 *
 * candidate: hi ev every onyx one
-*   ^
+* ^
 * pattern:   hi*every*one
-* ^ MISMATCH
+*   ^ MISMATCH
 *
 * candidate: hi ev every onyx one
-*^
+*  ^
 * pattern:   hi*every*one
-* ^
+*   ^
 *
 * candidate: hi ev every onyx one
-*^^
+*  ^^
 * pattern:   hi*every*one
-* ^^
+*   ^^
 *
 * candidate: hi ev every onyx one
-*^ ^
+*  ^ ^
 * pattern:   hi*every*one
-* ^ ^
+*   ^ ^
 *
 * candidate: hi ev every onyx one
-*^  ^
+*  ^  ^
 * pattern:   hi*every*one
-* ^  ^
+*   ^  ^
 *
 * candidate: hi ev every onyx one
-*^   ^
+*  ^   ^
 * pattern:   hi*every*one
-* ^   ^
+*   ^   ^
 *
 * candidate: hi ev every onyx one
-* ^
+*   ^
 * pattern:   hi*every*one
-*  ^
+*^
 *
 * candidate: hi ev every onyx one
-* ^
+*   ^
 * pattern:   hi*every*one
-*   ^ MISMATCH
+* ^ MISMATCH
 *
 * candidate: hi ev every onyx one
-*  ^
+*^
 * pattern:   hi*every*one
-*   ^
+* ^
 *
 * candidate: hi ev every onyx one
-*  ^^
+*^^
 * pattern:   hi*every*one
-*   ^^
+* ^^
 *
 * candidate: hi ev every onyx one
-*  ^ ^
+*^ ^
 * pattern:   hi*every*one
-*   ^ ^ MISMATCH
+* ^ ^ MISMATCH
 *
 * candidate: hi ev every on

[lttng-dev] [PATCH babeltrace v5] Build Python bindings with distutils for consistent installs

2017-04-11 Thread Francis Deslauriers
v5: Manually load shared objects used by the Babeltrace Python module

This patch changes the build system used to compile and install the
Python Bindings. Distutils is used to find the right install directory.
When the install directory generated from the install prefix is not in
the Python search path (PYTHONPATH), we print a warning explaining what
can be done to include it.
It uses Distutils which is part of the Python standard library.

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 .gitignore| 10 +++-
 bindings/python/Makefile.am   | 57 +-
 bindings/python/babeltrace/Makefile.am| 30 ++
 bindings/python/babeltrace/__init__.py.in | 25 
 bindings/python/setup.py.in   | 84 +++
 configure.ac  | 14 +++--
 m4/python_modules.m4  | 23 
 tests/bin/intersection/bt_python_helper.py.in | 17 +++---
 8 files changed, 195 insertions(+), 65 deletions(-)
 create mode 100644 bindings/python/babeltrace/__init__.py.in
 create mode 100644 bindings/python/setup.py.in
 delete mode 100644 m4/python_modules.m4

diff --git a/.gitignore b/.gitignore
index a7c9e3c..9259b6f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -47,8 +47,12 @@ converter/babeltrace-log
 core
 formats/ctf/metadata/ctf-parser.output
 stamp-h1
-bindings/python/babeltrace.i
-bindings/python/babeltrace.py
-bindings/python/babeltrace_wrap.c
+bindings/python/setup.py
+bindings/python/installed_files.txt
+bindings/python/build
+bindings/python/babeltrace/__init__.py
+bindings/python/babeltrace/babeltrace.i
+bindings/python/babeltrace/babeltrace.py
+bindings/python/babeltrace/babeltrace_wrap.c
 babeltrace.pc
 babeltrace-ctf.pc
diff --git a/bindings/python/Makefile.am b/bindings/python/Makefile.am
index d6b3648..9e44127 100644
--- a/bindings/python/Makefile.am
+++ b/bindings/python/Makefile.am
@@ -1,3 +1,58 @@
 if USE_PYTHON
-SUBDIRS = babeltrace
+SUBDIRS = babeltrace .
+
+INSTALLED_FILES=$(builddir)/installed_files.txt
+
+AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include -I$(srcdir)/babeltrace/
+
+# Since the shared object used by the python bindings is not built with libtool
+# we need to manually set the `rpath` during linkage
+AM_LDFLAGS=-L$(top_builddir)/formats/ctf/.libs -L$(top_builddir)/lib/.libs
+all-local: build-python-bindings.stamp
+
+$(builddir)/babeltrace/__init__.py: $(srcdir)/babeltrace/__init__.py.in
+   cd babeltrace && $(MAKE) __init__.py
+
+$(builddir)/babeltrace/babeltrace.i: $(srcdir)/babeltrace/babeltrace.i.in
+   cd babeltrace && $(MAKE) babeltrace.i
+
+BINDINGS_DEPS=setup.py \
+   babeltrace/__init__.py \
+   babeltrace/babeltrace.i \
+   babeltrace/python-complements.c \
+   babeltrace/python-complements.h
+
+BUILD_FLAGS=CC="$(CC)" \
+   CFLAGS="$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(GLIB_CFLAGS) 
$(AM_CFLAGS)" \
+   CPPFLAGS="$(AM_CPPFLAGS) $(CPPFLAGS)" \
+   LDFLAGS="$(AM_LDFLAGS) $(LDFLAGS)"
+
+build-python-bindings.stamp: $(BINDINGS_DEPS)
+   $(BUILD_FLAGS) $(PYTHON) $(builddir)/setup.py build_ext
+   $(BUILD_FLAGS) $(PYTHON) $(builddir)/setup.py build
+   touch $@
+
+install-exec-local: build-python-bindings.stamp
+   @opts="--prefix=$(prefix) --record $(INSTALLED_FILES) --verbose 
--no-compile $(DISTSETUPOPTS)"; \
+   if [ "$(DESTDIR)" != "" ]; then \
+   opts="$$opts --root=$(DESTDIR)"; \
+   fi; \
+   $(PYTHON) $(builddir)/setup.py install $$opts;
+
+clean-local:
+   rm -rf $(builddir)/build
+
+# Distutils' setup.py does not include an uninstall target, we thus need to do
+# it manually. We save the path of the files that were installed during the 
install target
+# and delete them during the uninstallation.
+uninstall-local:
+   if [ "$(DESTDIR)" != "" ]; then \
+   $(SED) -i "s|^|$(DESTDIR)/|g" $(INSTALLED_FILES); \
+   fi
+   cat $(INSTALLED_FILES) | xargs rm -rf || true
+   $(GREP) "__init__.py" $(INSTALLED_FILES) | xargs dirname | xargs rm -rf 
|| true
+   rm -f $(INSTALLED_FILES)
+
+CLEANFILES = babeltrace/babeltrace_wrap.c babeltrace/babeltrace.py 
build-python-bindings.stamp
+DISTCLEANFILES = setup.py
 endif
diff --git a/bindings/python/babeltrace/Makefile.am 
b/bindings/python/babeltrace/Makefile.am
index 11dcdf0..f612aa6 100644
--- a/bindings/python/babeltrace/Makefile.am
+++ b/bindings/python/babeltrace/Makefile.am
@@ -1,31 +1,9 @@
+if USE_PYTHON
 babeltrace.i: babeltrace.i.in
sed "s/BABELTRACE_VERSION_STR/Babeltrace $(PACKAGE_VERSION)/g" < \
$(top_srcdir)/bindings/python/babeltrace/babeltrace.i.in > \
$(top_builddir)/bindings/pytho

[lttng-dev] [PATCH lttng-ust v2] Fix: (un)install targets of Python agent

2017-03-02 Thread Francis Deslauriers
This Makefile was using Distutils' setup.py to install the Python agent
but was using the Autoconf's $pkgpythondir variable for the uninstall
process. The two folders can be different on some distributions which
made the uninstall attempting to delete a non-existant folder and
effectively not uninstalling.

We now run a phony installation of the bindings in a temporary directory
and use the tree structure of the install folder to infere the location
of the files on the system to delete them.

Also, we print a warning if the install directory is not included in the
PYTHONPATH variable.

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 python-lttngust/Makefile.am | 38 ---
 python-lttngust/setup.py.in | 64 +
 2 files changed, 77 insertions(+), 25 deletions(-)

diff --git a/python-lttngust/Makefile.am b/python-lttngust/Makefile.am
index cc28989..c5bb167 100644
--- a/python-lttngust/Makefile.am
+++ b/python-lttngust/Makefile.am
@@ -1,7 +1,6 @@
 # Use setup.py for the installation instead of Autoconf.
 # This ease the installation process and assure a *pythonic*
 # installation.
-agent_path=lttngust
 all-local:
$(PYTHON) setup.py build --verbose
 
@@ -13,13 +12,34 @@ install-exec-local:
$(PYTHON) setup.py install $$opts;
 
 clean-local:
-   rm -rf build
+   rm -rf $(builddir)/build
 
-uninstall-local:
-   rm -rf $(DESTDIR)$(pkgpythondir)
-
-EXTRA_DIST=$(agent_path)
+# Distutils' setup.py does not include an uninstall target, we thus need to do
+# it manually. We fake an install in a temporary folder and use the generated
+# tree structure to infere the actual location within the install prefix.
+# 1. Create temporary file and folder
+# 2. Set the root install folder for a temporary folder
+# 3. Install in that temporary folder and record all the files installed
+# 4. If DESTDIR is set, prepend it to the paths of the install files
+# 5. Remove the installed files and the Python package folder
+# 6. Remove the files created by this target
 
-# Remove automake generated file before dist
-dist-hook:
-   rm -rf $(distdir)/$(agent_path)/__init__.py
+uninstall-local:
+   $(eval TMP_INSTALLED_FILES:=$(shell mktemp 
$(builddir)/tmp-installed-files-XX))
+   $(eval TMP_INSTALL_DIR:=$(shell mktemp -d 
$(builddir)/tmp-install-dir-XX))
+   $(eval TMP_BUILD_DIR:=$(shell mktemp -d 
$(builddir)/tmp-build-dir-XX))
+   @opts="--root=$(TMP_INSTALL_DIR) --prefix=$(prefix) --record 
$(TMP_INSTALLED_FILES) --no-compile $(DISTSETUPOPTS)"; \
+   if [ "$(DESTDIR)" != "" ]; then \
+   opts="$$opts --root=$(DESTDIR)"; \
+   else \
+   opts="$$opts --root=$(TMP_INSTALL_DIR)"; \
+   fi; \
+   $(PYTHON) setup.py build --build-base $(TMP_BUILD_DIR) install $$opts ; 
\
+   if [ "$(DESTDIR)" != "" ]; then \
+   $(SED) -i "s|^|$(DESTDIR)/|g" $(TMP_INSTALLED_FILES); \
+   fi; \
+   cat $(TMP_INSTALLED_FILES) | xargs rm -rf
+   $(GREP) "__init__.py" $(TMP_INSTALLED_FILES) | xargs dirname | xargs rm 
-rf
+   rm -f $(TMP_INSTALLED_FILES)
+   rm -rf $(TMP_INSTALL_DIR)
+   rm -rf $(TMP_BUILD_DIR)
diff --git a/python-lttngust/setup.py.in b/python-lttngust/setup.py.in
index 370fd61..303d624 100644
--- a/python-lttngust/setup.py.in
+++ b/python-lttngust/setup.py.in
@@ -15,22 +15,54 @@
 # along with this library; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
 
+import os
+import sys
+
 from distutils.core import setup, Extension
 
+PY_PATH_WARN_MSG = """
+-WARNING
+The install directory used:\n ({0})\nis not included in your PYTHONPATH.
+
+To add this directory to your Python search path permanently you can add the
+following command to your .bashrc/.zshrc:
+export PYTHONPATH="${{PYTHONPATH}}:{0}"
+
+"""
+
+def main():
+dist = setup(name='lttngust',
+version='@PACKAGE_VERSION@',
+description='LTTng-UST Python agent',
+packages=['lttngust'],
+package_dir={'lttngust': 'lttngust'},
+options={'build': {'build_base': 'build'}},
+url='http://lttng.org',
+license='LGPL-2.1',
+classifiers=[
+'Development Status :: 5 - Production/Stable',
+'Intended Audience :: Developers',
+'License :: OSI Approved :: GNU Lesser General Public License 
v2 (LGPLv2)',
+'Programming Language :: Python :: 2.7',
+'Programming Language :: Python :: 3'
+'Topic :: System :: Logging',
+])
+
+# 

[lttng-dev] [PATCH lttng-modules] Fix: atomic_add_unless() returns true/false rather than prior value

2017-03-08 Thread Francis Deslauriers
The previous implementation assumed that `atomic_add_unless` returned the
prior value of the atomic counter when in fact it returned if addition was
successful(true) or overflowed(false).
Since `atomic_add_unless` can not return INT_MAX, the `lttng_kref_get`
always returned that the call was successful.

This issue had a low likelihood of being triggered since the two refcounts
of the counters used with this call are both bounded by the maximum
number of file descriptors on the system.

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 wrapper/kref.h | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/wrapper/kref.h b/wrapper/kref.h
index eedefbf..f30a9ae 100644
--- a/wrapper/kref.h
+++ b/wrapper/kref.h
@@ -36,11 +36,7 @@
  */
 static inline int lttng_kref_get(struct kref *kref)
 {
-   if (atomic_add_unless(>refcount, 1, INT_MAX) != INT_MAX) {
-   return 1;
-   } else {
-   return 0;
-   }
+   return atomic_add_unless(>refcount, 1, INT_MAX);
 }
 
 #endif /* _LTTNG_WRAPPER_KREF_H */
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-modules v3] Fix: atomic_add_unless() returns true/false rather than prior value

2017-03-08 Thread Francis Deslauriers
The previous implementation assumed that `atomic_add_unless` returned
the prior value of the atomic counter when in fact it returned if the
addition was performed (true) or not performed (false).
Since `atomic_add_unless` can not return INT_MAX, the `lttng_kref_get`
always returned that the call was successful.

This issue had a low likelihood of being triggered since the two refcounts
of the counters used with this call are both bounded by the maximum
number of file descriptors on the system.

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 wrapper/kref.h | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/wrapper/kref.h b/wrapper/kref.h
index eedefbf..f30a9ae 100644
--- a/wrapper/kref.h
+++ b/wrapper/kref.h
@@ -36,11 +36,7 @@
  */
 static inline int lttng_kref_get(struct kref *kref)
 {
-   if (atomic_add_unless(>refcount, 1, INT_MAX) != INT_MAX) {
-   return 1;
-   } else {
-   return 0;
-   }
+   return atomic_add_unless(>refcount, 1, INT_MAX);
 }
 
 #endif /* _LTTNG_WRAPPER_KREF_H */
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-modules] Fix: use of uninitialized ret value in lttng_abi_open_metadata_stream

2017-03-08 Thread Francis Deslauriers
Fixes the following compiler warning:

lttng-abi.c: In function ‘lttng_metadata_ioctl’:
lttng-abi.c:971:6: warning: ‘ret’ may be used uninitialized in this function 
[-Wmaybe-uninitialized]
  int ret;
  ^

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 lttng-abi.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lttng-abi.c b/lttng-abi.c
index e193f43..478a591 100644
--- a/lttng-abi.c
+++ b/lttng-abi.c
@@ -998,8 +998,11 @@ int lttng_abi_open_metadata_stream(struct file 
*channel_file)
goto notransport;
}
 
-   if (!lttng_kref_get(>metadata_cache->refcount))
+   if (!lttng_kref_get(>metadata_cache->refcount)) {
+   ret = -EOVERFLOW;
goto kref_error;
+   }
+
ret = lttng_abi_create_stream_fd(channel_file, stream_priv,
_metadata_ring_buffer_file_operations);
if (ret < 0)
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH babeltrace v4] Build Python bindings with distutils for consistent installs

2017-03-06 Thread Francis Deslauriers
v4: Fix DESTDIR behaviour on (un)install targets.

This patch changes the build system used to compile and install the
Python Bindings. Distutils is used to find the right install directory.
When the install directory generated from the install prefix is not in
the Python search path (PYTHONPATH), we print a warning explaining what
can be done to include it.
It uses Distutils which is part of the Python standard library.

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 .gitignore| 10 +++-
 bindings/python/Makefile.am   | 58 +-
 bindings/python/babeltrace/Makefile.am| 30 ++
 bindings/python/babeltrace/__init__.py.in | 25 
 bindings/python/setup.py.in   | 84 +++
 configure.ac  | 14 +++--
 m4/python_modules.m4  | 23 
 tests/bin/intersection/bt_python_helper.py.in |  8 +--
 8 files changed, 187 insertions(+), 65 deletions(-)
 create mode 100644 bindings/python/babeltrace/__init__.py.in
 create mode 100644 bindings/python/setup.py.in
 delete mode 100644 m4/python_modules.m4

diff --git a/.gitignore b/.gitignore
index a7c9e3c..9259b6f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -47,8 +47,12 @@ converter/babeltrace-log
 core
 formats/ctf/metadata/ctf-parser.output
 stamp-h1
-bindings/python/babeltrace.i
-bindings/python/babeltrace.py
-bindings/python/babeltrace_wrap.c
+bindings/python/setup.py
+bindings/python/installed_files.txt
+bindings/python/build
+bindings/python/babeltrace/__init__.py
+bindings/python/babeltrace/babeltrace.i
+bindings/python/babeltrace/babeltrace.py
+bindings/python/babeltrace/babeltrace_wrap.c
 babeltrace.pc
 babeltrace-ctf.pc
diff --git a/bindings/python/Makefile.am b/bindings/python/Makefile.am
index d6b3648..0009546 100644
--- a/bindings/python/Makefile.am
+++ b/bindings/python/Makefile.am
@@ -1,3 +1,59 @@
 if USE_PYTHON
-SUBDIRS = babeltrace
+SUBDIRS = babeltrace .
+
+INSTALLED_FILES=$(builddir)/installed_files.txt
+
+AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include -I$(srcdir)/babeltrace/
+
+# Since the shared object used by the python bindings is not built with libtool
+# we need to manually set the `rpath` during linkage
+AM_LDFLAGS=-L$(top_builddir)/formats/ctf/.libs -L$(top_builddir)/lib/.libs 
-Wl,-rpath,$(prefix)/lib
+
+all-local: build-python-bindings.stamp
+
+$(builddir)/babeltrace/__init__.py: $(srcdir)/babeltrace/__init__.py.in
+   cd babeltrace && $(MAKE) __init__.py
+
+$(builddir)/babeltrace/babeltrace.i: $(srcdir)/babeltrace/babeltrace.i.in
+   cd babeltrace && $(MAKE) babeltrace.i
+
+BINDINGS_DEPS=setup.py \
+   babeltrace/__init__.py \
+   babeltrace/babeltrace.i \
+   babeltrace/python-complements.c \
+   babeltrace/python-complements.h
+
+BUILD_FLAGS=CC="$(CC)" \
+   CFLAGS="$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(GLIB_CFLAGS) 
$(AM_CFLAGS)" \
+   CPPFLAGS="$(AM_CPPFLAGS) $(CPPFLAGS)" \
+   LDFLAGS="$(AM_LDFLAGS) $(LDFLAGS)"
+
+build-python-bindings.stamp: $(BINDINGS_DEPS)
+   $(BUILD_FLAGS) $(PYTHON) $(builddir)/setup.py build_ext
+   $(BUILD_FLAGS) $(PYTHON) $(builddir)/setup.py build
+   touch $@
+
+install-exec-local: build-python-bindings.stamp
+   @opts="--prefix=$(prefix) --record $(INSTALLED_FILES) --verbose 
--no-compile $(DISTSETUPOPTS)"; \
+   if [ "$(DESTDIR)" != "" ]; then \
+   opts="$$opts --root=$(DESTDIR)"; \
+   fi; \
+   $(PYTHON) $(builddir)/setup.py install $$opts;
+
+clean-local:
+   rm -rf $(builddir)/build
+
+# Distutils' setup.py does not include an uninstall target, we thus need to do
+# it manually. We save the path of the files that were installed during the 
install target
+# and delete them during the uninstallation.
+uninstall-local:
+   if [ "$(DESTDIR)" != "" ]; then \
+   $(SED) -i "s|^|$(DESTDIR)/|g" $(INSTALLED_FILES); \
+   fi
+   cat $(INSTALLED_FILES) | xargs rm -rf || true
+   $(GREP) "__init__.py" $(INSTALLED_FILES) | xargs dirname | xargs rm -rf 
|| true
+   rm -f $(INSTALLED_FILES)
+
+CLEANFILES = babeltrace/babeltrace_wrap.c babeltrace/babeltrace.py 
build-python-bindings.stamp
+DISTCLEANFILES = setup.py
 endif
diff --git a/bindings/python/babeltrace/Makefile.am 
b/bindings/python/babeltrace/Makefile.am
index 11dcdf0..f612aa6 100644
--- a/bindings/python/babeltrace/Makefile.am
+++ b/bindings/python/babeltrace/Makefile.am
@@ -1,31 +1,9 @@
+if USE_PYTHON
 babeltrace.i: babeltrace.i.in
sed "s/BABELTRACE_VERSION_STR/Babeltrace $(PACKAGE_VERSION)/g" < \
$(top_srcdir)/bindings/python/babeltrace/babeltrace.i.in > \
$(top_builddir)/

[lttng-dev] [PATCH lttng-modules] Fix: section mismatch warning caused by __exit annotation

2017-03-07 Thread Francis Deslauriers
lttng_logger_exit is used in a non-exit function so it can not be
annotated with `__exit`

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 probes/lttng.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/probes/lttng.c b/probes/lttng.c
index 58aa515..8810fa2 100644
--- a/probes/lttng.c
+++ b/probes/lttng.c
@@ -129,7 +129,7 @@ error:
return ret;
 }
 
-void __exit lttng_logger_exit(void)
+void lttng_logger_exit(void)
 {
__lttng_events_exit__lttng();
if (lttng_logger_dentry)
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-modules v2] Fix: changes to the vm_op fault cb prototype in libringbuffer

2017-03-07 Thread Francis Deslauriers
Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 lib/ringbuffer/ring_buffer_mmap.c | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/lib/ringbuffer/ring_buffer_mmap.c 
b/lib/ringbuffer/ring_buffer_mmap.c
index 35d30e7..4b1b7b3 100644
--- a/lib/ringbuffer/ring_buffer_mmap.c
+++ b/lib/ringbuffer/ring_buffer_mmap.c
@@ -32,7 +32,7 @@
 /*
  * fault() vm_op implementation for ring buffer file mapping.
  */
-static int lib_ring_buffer_fault(struct vm_area_struct *vma, struct vm_fault 
*vmf)
+static int lib_ring_buffer_fault_compat(struct vm_area_struct *vma, struct 
vm_fault *vmf)
 {
struct lib_ring_buffer *buf = vma->vm_private_data;
struct channel *chan = buf->backend.chan;
@@ -65,6 +65,19 @@ static int lib_ring_buffer_fault(struct vm_area_struct *vma, 
struct vm_fault *vm
return 0;
 }
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0))
+static int lib_ring_buffer_fault(struct vm_fault *vmf)
+{
+   struct vm_area_struct *vma = vmf->vma;
+   return lib_ring_buffer_fault_compat(vma, vmf);
+}
+#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
+static int lib_ring_buffer_fault(struct vm_area_struct *vma, struct vm_fault 
*vmf)
+{
+   return lib_ring_buffer_fault_compat(vma, vmf);
+}
+#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
+
 /*
  * vm_ops for ring buffer file mappings.
  */
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-modules] Fix: update mm_vmscan instrumentation for kernel 4.11

2017-03-07 Thread Francis Deslauriers
Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 instrumentation/events/lttng-module/mm_vmscan.h | 62 -
 1 file changed, 60 insertions(+), 2 deletions(-)

diff --git a/instrumentation/events/lttng-module/mm_vmscan.h 
b/instrumentation/events/lttng-module/mm_vmscan.h
index 36ebd5c..5def917 100644
--- a/instrumentation/events/lttng-module/mm_vmscan.h
+++ b/instrumentation/events/lttng-module/mm_vmscan.h
@@ -281,8 +281,36 @@ LTTNG_TRACEPOINT_EVENT_MAP(mm_shrink_slab_end,
 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)) */
 #endif
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,8,0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0))
+LTTNG_TRACEPOINT_EVENT(mm_vmscan_lru_isolate,
+
+   TP_PROTO(int classzone_idx,
+   int order,
+   unsigned long nr_requested,
+   unsigned long nr_scanned,
+   unsigned long nr_skipped,
+   unsigned long nr_taken,
+   isolate_mode_t isolate_mode,
+   int lru
+   ),
 
+   TP_ARGS(classzone_idx, order, nr_requested, nr_scanned, nr_skipped,
+   nr_taken, isolate_mode, lru
+   ),
+
+   TP_FIELDS(
+   ctf_integer(int, classzone_idx, classzone_idx)
+   ctf_integer(int, order, order)
+   ctf_integer(unsigned long, nr_requested, nr_requested)
+   ctf_integer(unsigned long, nr_scanned, nr_scanned)
+   ctf_integer(unsigned long, nr_skipped, nr_skipped)
+   ctf_integer(unsigned long, nr_taken, nr_taken)
+   ctf_integer(isolate_mode_t, isolate_mode, isolate_mode)
+   ctf_integer(int, lru, lru)
+   )
+)
+
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4,8,0))
 LTTNG_TRACEPOINT_EVENT_CLASS(mm_vmscan_lru_isolate_template,
 
TP_PROTO(int classzone_idx,
@@ -485,7 +513,37 @@ LTTNG_TRACEPOINT_EVENT(mm_vmscan_writepage,
 )
 #endif
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,8,0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0))
+LTTNG_TRACEPOINT_EVENT(mm_vmscan_lru_shrink_inactive,
+
+   TP_PROTO(int nid,
+   unsigned long nr_scanned, unsigned long nr_reclaimed,
+   unsigned long nr_dirty, unsigned long nr_writeback,
+   unsigned long nr_congested, unsigned long nr_immediate,
+   unsigned long nr_activate, unsigned long nr_ref_keep,
+   unsigned long nr_unmap_fail,
+   int priority, int file),
+
+   TP_ARGS(nid, nr_scanned, nr_reclaimed, nr_dirty, nr_writeback,
+   nr_congested, nr_immediate, nr_activate, nr_ref_keep,
+   nr_unmap_fail, priority, file),
+
+   TP_FIELDS(
+   ctf_integer(int, nid, nid)
+   ctf_integer(unsigned long, nr_scanned, nr_scanned)
+   ctf_integer(unsigned long, nr_reclaimed, nr_reclaimed)
+   ctf_integer(unsigned long, nr_dirty, nr_dirty)
+   ctf_integer(unsigned long, nr_writeback, nr_writeback)
+   ctf_integer(unsigned long, nr_congested, nr_congested)
+   ctf_integer(unsigned long, nr_immediate, nr_immediate)
+   ctf_integer(unsigned long, nr_activate, nr_activate)
+   ctf_integer(unsigned long, nr_ref_keep, nr_ref_keep)
+   ctf_integer(unsigned long, nr_unmap_fail, nr_unmap_fail)
+   ctf_integer(int, priority, priority)
+   ctf_integer(int, reclaim_flags, trace_shrink_flags(file))
+   )
+)
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4,8,0))
 LTTNG_TRACEPOINT_EVENT(mm_vmscan_lru_shrink_inactive,
 
TP_PROTO(int nid,
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-modules] Fix: update btrfs instrumentation for kernel 4.11

2017-03-07 Thread Francis Deslauriers
Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 instrumentation/events/lttng-module/btrfs.h | 9 +
 1 file changed, 9 insertions(+)

diff --git a/instrumentation/events/lttng-module/btrfs.h 
b/instrumentation/events/lttng-module/btrfs.h
index cc7ba50..2955e28 100644
--- a/instrumentation/events/lttng-module/btrfs.h
+++ b/instrumentation/events/lttng-module/btrfs.h
@@ -87,9 +87,18 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(btrfs__inode, 
btrfs_inode_evict,
 
 LTTNG_TRACEPOINT_EVENT(btrfs_get_extent,
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0))
+
+   TP_PROTO(struct btrfs_root *root, struct btrfs_inode *inode,
+   struct extent_map *map),
+
+#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
+
TP_PROTO(struct btrfs_root *root, struct inode *inode,
struct extent_map *map),
 
+#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
+
TP_ARGS(root, inode, map),
 
TP_FIELDS(
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-modules] Fix: changes to the vm_op fault cb prototype in libringbuffer

2017-03-07 Thread Francis Deslauriers
Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 lib/ringbuffer/ring_buffer_mmap.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/lib/ringbuffer/ring_buffer_mmap.c 
b/lib/ringbuffer/ring_buffer_mmap.c
index 35d30e7..1ca45a7 100644
--- a/lib/ringbuffer/ring_buffer_mmap.c
+++ b/lib/ringbuffer/ring_buffer_mmap.c
@@ -32,8 +32,14 @@
 /*
  * fault() vm_op implementation for ring buffer file mapping.
  */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0))
+static int lib_ring_buffer_fault(struct vm_fault *vmf)
+{
+   struct vm_area_struct *vma = vmf->vma;
+#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
 static int lib_ring_buffer_fault(struct vm_area_struct *vma, struct vm_fault 
*vmf)
 {
+#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
struct lib_ring_buffer *buf = vma->vm_private_data;
struct channel *chan = buf->backend.chan;
const struct lib_ring_buffer_config *config = >backend.config;
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-modules] Fix: update scsi instrumentation for kernel 4.11

2017-03-07 Thread Francis Deslauriers
Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 instrumentation/events/lttng-module/block.h | 154 ++--
 1 file changed, 146 insertions(+), 8 deletions(-)

diff --git a/instrumentation/events/lttng-module/block.h 
b/instrumentation/events/lttng-module/block.h
index 4373edf..152609c 100644
--- a/instrumentation/events/lttng-module/block.h
+++ b/instrumentation/events/lttng-module/block.h
@@ -10,6 +10,10 @@
 #include 
 #include 
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0))
+#include 
+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
+
 #ifndef _TRACE_BLOCK_DEF_
 #define _TRACE_BLOCK_DEF_
 
@@ -164,6 +168,7 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(block_buffer, 
block_dirty_buffer,
 )
 #endif
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0))
 LTTNG_TRACEPOINT_EVENT_CLASS_CODE(block_rq_with_error,
 
TP_PROTO(struct request_queue *q, struct request *rq),
@@ -178,6 +183,50 @@ LTTNG_TRACEPOINT_EVENT_CLASS_CODE(block_rq_with_error,
),
 
TP_code_pre(
+   if (blk_rq_is_scsi(rq)) {
+   struct scsi_request *scsi_rq = scsi_req(rq);
+   tp_locvar->sector = 0;
+   tp_locvar->nr_sector = 0;
+   tp_locvar->cmd = scsi_rq->cmd;
+   tp_locvar->cmd_len = scsi_rq->cmd_len;
+   } else {
+   tp_locvar->sector = blk_rq_pos(rq);
+   tp_locvar->nr_sector = blk_rq_sectors(rq);
+   tp_locvar->cmd = NULL;
+   tp_locvar->cmd_len = 0;
+   }
+   ),
+
+   TP_FIELDS(
+   ctf_integer(dev_t, dev,
+   rq->rq_disk ? disk_devt(rq->rq_disk) : 0)
+   ctf_integer(sector_t, sector, tp_locvar->sector)
+   ctf_integer(unsigned int, nr_sector, tp_locvar->nr_sector)
+   ctf_integer(int, errors, rq->errors)
+   blk_rwbs_ctf_integer(unsigned int, rwbs,
+   lttng_req_op(rq), lttng_req_rw(rq), blk_rq_bytes(rq))
+   ctf_sequence_hex(unsigned char, cmd,
+   tp_locvar->cmd, size_t, tp_locvar->cmd_len)
+   ),
+
+   TP_code_post()
+)
+#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
+LTTNG_TRACEPOINT_EVENT_CLASS_CODE(block_rq_with_error,
+
+   TP_PROTO(struct request_queue *q, struct request *rq),
+
+   TP_ARGS(q, rq),
+
+   TP_locvar(
+   sector_t sector;
+   unsigned int nr_sector;
+   unsigned char *cmd;
+   size_t cmd_len;
+   ),
+
+   TP_code_pre(
+
if (rq->cmd_type == REQ_TYPE_BLOCK_PC) {
tp_locvar->sector = 0;
tp_locvar->nr_sector = 0;
@@ -205,6 +254,7 @@ LTTNG_TRACEPOINT_EVENT_CLASS_CODE(block_rq_with_error,
 
TP_code_post()
 )
+#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
 
 /**
  * block_rq_abort - abort block operation request
@@ -239,14 +289,6 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(block_rq_with_error, 
block_rq_requeue,
TP_ARGS(q, rq)
 )
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,5)  \
-   || LTTNG_KERNEL_RANGE(3,12,21, 3,13,0)  \
-   || LTTNG_KERNEL_RANGE(3,10,41, 3,11,0)  \
-   || LTTNG_KERNEL_RANGE(3,4,91, 3,5,0)\
-   || LTTNG_KERNEL_RANGE(3,2,58, 3,3,0)\
-   || LTTNG_UBUNTU_KERNEL_RANGE(3,13,11,28, 3,14,0,0)  \
-   || LTTNG_RHEL_KERNEL_RANGE(3,10,0,229,0,0, 3,11,0,0,0,0))
-
 /**
  * block_rq_complete - block IO operation completed by device driver
  * @q: queue containing the block operation request
@@ -259,6 +301,52 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(block_rq_with_error, 
block_rq_requeue,
  * do for the request. If @rq->bio is non-NULL then there is
  * additional work required to complete the request.
  */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0))
+LTTNG_TRACEPOINT_EVENT_CODE(block_rq_complete,
+
+   TP_PROTO(struct request_queue *q, struct request *rq,
+unsigned int nr_bytes),
+
+   TP_ARGS(q, rq, nr_bytes),
+
+   TP_locvar(
+   unsigned char *cmd;
+   size_t cmd_len;
+   ),
+
+   TP_code_pre(
+   if (blk_rq_is_scsi(rq)) {
+   struct scsi_request *scsi_rq = scsi_req(rq);
+   tp_locvar->cmd = scsi_rq->cmd;
+   tp_locvar->cmd_len = scsi_rq->cmd_len;
+   } else {
+   tp_locvar->cmd = NULL;
+   tp_locvar->cmd_len = 0;
+   }
+   ),
+
+   TP_FIELDS(
+   ctf_integer(dev_t, dev,
+   rq->rq_disk ? disk_devt(rq->rq_disk) : 0)
+   ctf_integer(sector_t, sector, blk_rq_pos(rq))
+

[lttng-dev] [PATCH lttng-modules] Fix: timers cputime_t arguments replaced by ull in kernel 4.11

2017-03-07 Thread Francis Deslauriers
cputime_t was changed to ull in the kernel commit: 858cf3a

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 instrumentation/events/lttng-module/timer.h | 38 +
 1 file changed, 38 insertions(+)

diff --git a/instrumentation/events/lttng-module/timer.h 
b/instrumentation/events/lttng-module/timer.h
index 9c02c96..d62fd25 100644
--- a/instrumentation/events/lttng-module/timer.h
+++ b/instrumentation/events/lttng-module/timer.h
@@ -248,6 +248,26 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class, 
hrtimer_cancel,
  * zero, otherwise it is started
  * @expires:   the itimers expiry time
  */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0))
+LTTNG_TRACEPOINT_EVENT_MAP(itimer_state,
+
+   timer_itimer_state,
+
+   TP_PROTO(int which, const struct itimerval *const value,
+unsigned long long expires),
+
+   TP_ARGS(which, value, expires),
+
+   TP_FIELDS(
+   ctf_integer(int, which, which)
+   ctf_integer(unsigned long long, expires, expires)
+   ctf_integer(long, value_sec, value->it_value.tv_sec)
+   ctf_integer(long, value_usec, value->it_value.tv_usec)
+   ctf_integer(long, interval_sec, value->it_interval.tv_sec)
+   ctf_integer(long, interval_usec, value->it_interval.tv_usec)
+   )
+)
+#else /* if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
 LTTNG_TRACEPOINT_EVENT_MAP(itimer_state,
 
timer_itimer_state,
@@ -266,6 +286,7 @@ LTTNG_TRACEPOINT_EVENT_MAP(itimer_state,
ctf_integer(long, interval_usec, value->it_interval.tv_usec)
)
 )
+#endif /* #else (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
 
 /**
  * itimer_expire - called when itimer expires
@@ -273,6 +294,22 @@ LTTNG_TRACEPOINT_EVENT_MAP(itimer_state,
  * @pid:   pid of the process which owns the timer
  * @now:   current time, used to calculate the latency of itimer
  */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0))
+LTTNG_TRACEPOINT_EVENT_MAP(itimer_expire,
+
+   timer_itimer_expire,
+
+   TP_PROTO(int which, struct pid *pid, unsigned long long now),
+
+   TP_ARGS(which, pid, now),
+
+   TP_FIELDS(
+   ctf_integer(int , which, which)
+   ctf_integer(pid_t, pid, pid_nr(pid))
+   ctf_integer(unsigned long long, now, now)
+   )
+)
+#else /* if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
 LTTNG_TRACEPOINT_EVENT_MAP(itimer_expire,
 
timer_itimer_expire,
@@ -287,6 +324,7 @@ LTTNG_TRACEPOINT_EVENT_MAP(itimer_expire,
ctf_integer(cputime_t, now, now)
)
 )
+#endif /* #else (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
 
 #endif /*  LTTNG_TRACE_TIMER_H */
 
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-modules] Fix: atomic_add_unless() already returns zero on overflow

2017-03-07 Thread Francis Deslauriers
Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 wrapper/kref.h | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/wrapper/kref.h b/wrapper/kref.h
index eedefbf..f30a9ae 100644
--- a/wrapper/kref.h
+++ b/wrapper/kref.h
@@ -36,11 +36,7 @@
  */
 static inline int lttng_kref_get(struct kref *kref)
 {
-   if (atomic_add_unless(>refcount, 1, INT_MAX) != INT_MAX) {
-   return 1;
-   } else {
-   return 0;
-   }
+   return atomic_add_unless(>refcount, 1, INT_MAX);
 }
 
 #endif /* _LTTNG_WRAPPER_KREF_H */
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-modules] Fix: kref changes for kernel 4.11

2017-03-07 Thread Francis Deslauriers
The underlying type of `struct kref` changed in kernel 4.11 from an
atomic_t to a refcount_t. This change was introduced in kernel
commit:10383ae. This commit also added a builtin overflow checks to
`kref_get()` so we use it.

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 wrapper/kref.h | 8 
 1 file changed, 8 insertions(+)

diff --git a/wrapper/kref.h b/wrapper/kref.h
index f30a9ae..8db05b5 100644
--- a/wrapper/kref.h
+++ b/wrapper/kref.h
@@ -34,9 +34,17 @@
  *
  * Return 1 if reference is taken, 0 otherwise (overflow).
  */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0))
+static inline int lttng_kref_get(struct kref *kref)
+{
+   kref_get(kref);
+   return 1;
+}
+#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
 static inline int lttng_kref_get(struct kref *kref)
 {
return atomic_add_unless(>refcount, 1, INT_MAX);
 }
+#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
 
 #endif /* _LTTNG_WRAPPER_KREF_H */
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-modules] Fix: NULL pointer dereference of THIS_MODULE with built-in modules

2017-05-17 Thread Francis Deslauriers
THIS MODULE is defined to 0 when a module is built-in the kernel [1].
This caused NULL pointer dereference when booting a kernel with the
lttng-modules built-in.
To fix this issue, add #if guard around the wrapper_lttng_fixup_sig
function checking if the MODULE macro is defined to confirm that this
piece of code will end up in a module and not in the kernel itself.

[1]: linux/include/linux/export.h:32
Fixes: #1107

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 wrapper/tracepoint.h | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/wrapper/tracepoint.h b/wrapper/tracepoint.h
index 367cdf4..780f9a8 100644
--- a/wrapper/tracepoint.h
+++ b/wrapper/tracepoint.h
@@ -87,6 +87,10 @@ int wrapper_tracepoint_module_notify(struct notifier_block 
*nb,
}
 }
 
+#endif /* CONFIG_MODULE_SIG */
+
+#if defined(CONFIG_MODULE_SIG) && defined(MODULE)
+
 static inline
 int wrapper_lttng_fixup_sig(struct module *mod)
 {
@@ -106,7 +110,7 @@ int wrapper_lttng_fixup_sig(struct module *mod)
return ret;
 }
 
-#else /* CONFIG_MODULE_SIG */
+#else /* #if defined(CONFIG_MODULE_SIG) && defined(MODULE) */
 
 static inline
 int wrapper_lttng_fixup_sig(struct module *mod)
@@ -114,6 +118,6 @@ int wrapper_lttng_fixup_sig(struct module *mod)
return 0;
 }
 
-#endif /* #else CONFIG_MODULE_SIG */
+#endif /*#else #if defined(CONFIG_MODULE_SIG) && defined(MODULE) */
 
 #endif /* _LTTNG_WRAPPER_TRACEPOINT_H */
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH] Test: Replace test relying pselect6(2) man page error

2017-05-11 Thread Francis Deslauriers
The `pselect_fd_too_big` test is checking for the case where the `nfds`
is larger than the number of open files allowed for this process
(RLIMIT_NOFILE). According to the man page, if `nfds` > RLIMIT_NOFILE is
evaluate to true the pselect6 syscall should return EINVAL.

In fact, the Linux implementation of the pselect6 syscall[1] does not
compare the `nfds` and RLIMIT_NOFILE but rather caps `nfds` to the
highest numbered fd of the current process.

It was observed elsewhere that there is a discrepancy between the manual
page and the implementation [2].

As a solution, replace the current testcase with one that checks the
behaviour of the syscall when passed an invalid FD.

[1]:https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/select.c#n619
[2]:https://patchwork.kernel.org/patch/9345805/

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
Signed-off-by: Julien Desfossez <jdesfos...@efficios.com>
---
 tests/regression/kernel/select_poll_epoll.c| 39 +-
 tests/regression/kernel/test_select_poll_epoll |  6 ++--
 .../kernel/validate_select_poll_epoll.py   | 13 
 3 files changed, 33 insertions(+), 25 deletions(-)

diff --git a/tests/regression/kernel/select_poll_epoll.c 
b/tests/regression/kernel/select_poll_epoll.c
index 4b703b3..1d767b0 100644
--- a/tests/regression/kernel/select_poll_epoll.c
+++ b/tests/regression/kernel/select_poll_epoll.c
@@ -437,30 +437,38 @@ void ppoll_fds_ulong_max(void)
 }
 
 /*
- * Select is limited to 1024 FDs, should output a pselect event
- * with 0 FDs.
+ * Pass a invalid file descriptor to pselect6(). The syscall should return
+ * -EBADF. The recorded event should contain a ret=-EBADF (-9).
  */
-void pselect_fd_too_big(void)
+void pselect_invalid_fd(void)
 {
-   long rfds[2048 / (sizeof(long) * CHAR_BIT)] = { 0 };
+   fd_set rfds;
int ret;
-   int fd2;
+   int fd;
char buf[BUF_SIZE];
 
/*
-* Test if nfds > 1024.
-* Make sure ulimit is set correctly (ulimit -n 2048).
+* Open a file, close it and use the closed FD in the pselect6 call
 */
-   fd2 = dup2(wait_fd, 2047);
-   if (fd2 != 2047) {
-   perror("dup2");
-   return;
+
+   fd = open("/dev/null", O_RDONLY);
+   if (fd == -1) {
+   perror("open");
+   goto error;
}
 
-   FD_SET(fd2, (fd_set *) );
-   ret = syscall(SYS_pselect6, fd2 + 1, , NULL, NULL, NULL, NULL);
+   ret = close(fd);
 
if (ret == -1) {
+   perror("close");
+   goto error;
+   }
+
+   FD_ZERO();
+   FD_SET(fd, );
+
+   ret = syscall(SYS_pselect6, fd + 1, , NULL, NULL, NULL, NULL);
+   if (ret == -1) {
perror("# pselect()");
} else if (ret) {
printf("# [pselect] data available\n");
@@ -471,7 +479,8 @@ void pselect_fd_too_big(void)
} else {
printf("# [pselect] timeout\n");
}
-
+error:
+   return;
 }
 
 /*
@@ -892,7 +901,7 @@ int main(int argc, const char **argv)
run_working_cases();
break;
case 3:
-   pselect_fd_too_big();
+   pselect_invalid_fd();
break;
case 4:
test_ppoll_big();
diff --git a/tests/regression/kernel/test_select_poll_epoll 
b/tests/regression/kernel/test_select_poll_epoll
index e01866f..ec034e6 100755
--- a/tests/regression/kernel/test_select_poll_epoll
+++ b/tests/regression/kernel/test_select_poll_epoll
@@ -126,13 +126,13 @@ function test_timeout_cases()
rm -rf $TRACE_PATH
 }
 
-function test_big_pselect()
+function test_pselect_invalid_fd()
 {
TRACE_PATH=$(mktemp -d)
SESSION_NAME="syscall_payload"
SYSCALL_LIST="pselect6"
 
-   diag "pselect with a FD > 1023"
+   diag "pselect with invalid FD"
 
create_lttng_session_ok $SESSION_NAME $TRACE_PATH
 
@@ -384,7 +384,7 @@ skip $isroot "Root access is needed. Skipping all tests." 
$NUM_TESTS ||
 
test_working_cases
test_timeout_cases
-   test_big_pselect
+   test_pselect_invalid_fd
test_big_ppoll
test_ppoll_overflow
test_pselect_invalid_ptr
diff --git a/tests/regression/kernel/validate_select_poll_epoll.py 
b/tests/regression/kernel/validate_select_poll_epoll.py
index f4946e7..613cec3 100755
--- a/tests/regression/kernel/validate_select_poll_epoll.py
+++ b/tests/regression/kernel/validate_select_poll_epoll.py
@@ -450,8 +450,8 @@ class Test2(TraceParser):
 class Test3(TraceParser):
 def __init__(self, trace, pid):
 super().__init__(trace, pid)
-self.expect["select_too_big_in"] = 0
-self.expect["select_too_big_out"] = 0
+self.expect["se

Re: [lttng-dev] tracing page_faults with lttng?

2017-05-24 Thread Francis Deslauriers
Hi Milian,
Are you running on an x86 processor?
The pagefault tracepoints are called : x86_exceptions_page_fault_user,
x86_exceptions_page_fault_kernel
Can you see those tracepoints when you run: lttng list --kernel

Thank you,
Francis

2017-05-24 12:00 GMT-04:00 Milian Wolff <milian.wo...@kdab.com>:

> Hey all,
>
> when I trace with perf, I can see page_faults occurring. But when I do
> something like the following with lttng:
>
> lttng create
> lttng enable-channel kernel -k
> lttng enable-event -c kernel -k -a
> lttng start
> # trigger page faults
> lttng stop
>
> then I do not see any page faults in tracecompass/babeltrace. What do I
> need
> to do to see those too? I'm aware that lttng comes with its own set of
> tracepoints - i.e. it's not using the same tracepoints that perf knows
> about.
> But googling shows me e.g. this:
>
> https://lists.lttng.org/pipermail/lttng-dev/2013-April/019954.html
> https://lists.lttng.org/pipermail/lttng-dev/2016-May/026033.html
>
> Which sounds like the feature should be available in lttng too?
>
> I'm using the ArchLinux packages in AUR, i.e. version 2.9.2 of LTTng and
> kernel 4.10.13-1.
>
> Thanks
> --
> Milian Wolff | milian.wo...@kdab.com | Software Engineer
> KDAB (Deutschland) GmbH KG, a KDAB Group company
> Tel: +49-30-521325470
> KDAB - The Qt Experts
> ___
> lttng-dev mailing list
> lttng-dev@lists.lttng.org
> https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
>
>


-- 
Francis Deslauriers
Software developer
EfficiOS inc.
___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-modules] Fix: Build ftrace probe on kernels prior to 4.12

2017-05-30 Thread Francis Deslauriers
Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 probes/Kbuild | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/probes/Kbuild b/probes/Kbuild
index fe869d0..78bf3fb 100644
--- a/probes/Kbuild
+++ b/probes/Kbuild
@@ -267,8 +267,9 @@ ifneq ($(CONFIG_DYNAMIC_FTRACE),)
 echo "warn" ; \
 exit ; \
   fi; \
-  echo "lttng-ftrace.o" ; \
-fi;)
+fi; \
+echo "lttng-ftrace.o" ; \
+)
   ifeq ($(ftrace),warn)
 $(warning Files $(ftrace_dep) not found. Probe "ftrace" is disabled. Use 
full kernel source tree to enable it.)
 ftrace =
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-tools V2] Test: Replace test relying pselect6(2) man page ambiguity

2017-05-31 Thread Francis Deslauriers
The `pselect_fd_too_big` test is checking for the case where the `nfds`
is larger than the number of open files allowed for this process
(RLIMIT_NOFILE).

According to the ERRORS section of the pselect6(2) kernel man page[1], if
`nfds` > RLIMIT_NOFILE is evaluate to true the pselect6 syscall should
return EINVAL but the BUGS section mentions that the current
implementation ignores any FD larger than the highest numbered FD of the
current process.

This is in fact what happens, the Linux implementation of the pselect6
syscall[2] does not compare the `nfds` and RLIMIT_NOFILE but rather caps
`nfds` to the highest numbered FD of the current process as the BUGS
kernel man page mentionned.

It was observed elsewhere that there is a discrepancy between the manual
page and the implementation[3].

As a solution, replace the current testcase with one that checks the
behaviour of the syscall when passed an invalid FD.

[1]:http://man7.org/linux/man-pages/man2/pselect6.2.html
[2]:https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/select.c#n619
[3]:https://patchwork.kernel.org/patch/9345805/

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
Signed-off-by: Julien Desfossez <jdesfos...@efficios.com>
---
 tests/regression/kernel/select_poll_epoll.c| 39 +-
 tests/regression/kernel/test_select_poll_epoll |  6 ++--
 .../kernel/validate_select_poll_epoll.py   | 13 
 3 files changed, 33 insertions(+), 25 deletions(-)

diff --git a/tests/regression/kernel/select_poll_epoll.c 
b/tests/regression/kernel/select_poll_epoll.c
index 4b703b3..1d767b0 100644
--- a/tests/regression/kernel/select_poll_epoll.c
+++ b/tests/regression/kernel/select_poll_epoll.c
@@ -437,30 +437,38 @@ void ppoll_fds_ulong_max(void)
 }
 
 /*
- * Select is limited to 1024 FDs, should output a pselect event
- * with 0 FDs.
+ * Pass a invalid file descriptor to pselect6(). The syscall should return
+ * -EBADF. The recorded event should contain a ret=-EBADF (-9).
  */
-void pselect_fd_too_big(void)
+void pselect_invalid_fd(void)
 {
-   long rfds[2048 / (sizeof(long) * CHAR_BIT)] = { 0 };
+   fd_set rfds;
int ret;
-   int fd2;
+   int fd;
char buf[BUF_SIZE];
 
/*
-* Test if nfds > 1024.
-* Make sure ulimit is set correctly (ulimit -n 2048).
+* Open a file, close it and use the closed FD in the pselect6 call
 */
-   fd2 = dup2(wait_fd, 2047);
-   if (fd2 != 2047) {
-   perror("dup2");
-   return;
+
+   fd = open("/dev/null", O_RDONLY);
+   if (fd == -1) {
+   perror("open");
+   goto error;
}
 
-   FD_SET(fd2, (fd_set *) );
-   ret = syscall(SYS_pselect6, fd2 + 1, , NULL, NULL, NULL, NULL);
+   ret = close(fd);
 
if (ret == -1) {
+   perror("close");
+   goto error;
+   }
+
+   FD_ZERO();
+   FD_SET(fd, );
+
+   ret = syscall(SYS_pselect6, fd + 1, , NULL, NULL, NULL, NULL);
+   if (ret == -1) {
perror("# pselect()");
} else if (ret) {
printf("# [pselect] data available\n");
@@ -471,7 +479,8 @@ void pselect_fd_too_big(void)
} else {
printf("# [pselect] timeout\n");
}
-
+error:
+   return;
 }
 
 /*
@@ -892,7 +901,7 @@ int main(int argc, const char **argv)
run_working_cases();
break;
case 3:
-   pselect_fd_too_big();
+   pselect_invalid_fd();
break;
case 4:
test_ppoll_big();
diff --git a/tests/regression/kernel/test_select_poll_epoll 
b/tests/regression/kernel/test_select_poll_epoll
index e01866f..ec034e6 100755
--- a/tests/regression/kernel/test_select_poll_epoll
+++ b/tests/regression/kernel/test_select_poll_epoll
@@ -126,13 +126,13 @@ function test_timeout_cases()
rm -rf $TRACE_PATH
 }
 
-function test_big_pselect()
+function test_pselect_invalid_fd()
 {
TRACE_PATH=$(mktemp -d)
SESSION_NAME="syscall_payload"
SYSCALL_LIST="pselect6"
 
-   diag "pselect with a FD > 1023"
+   diag "pselect with invalid FD"
 
create_lttng_session_ok $SESSION_NAME $TRACE_PATH
 
@@ -384,7 +384,7 @@ skip $isroot "Root access is needed. Skipping all tests." 
$NUM_TESTS ||
 
test_working_cases
test_timeout_cases
-   test_big_pselect
+   test_pselect_invalid_fd
test_big_ppoll
test_ppoll_overflow
test_pselect_invalid_ptr
diff --git a/tests/regression/kernel/validate_select_poll_epoll.py 
b/tests/regression/kernel/validate_select_poll_epoll.py
index f4946e7..613cec3 100755
--- a/tests/regression/kernel/validate_select_poll_epoll.py
+++ b/tests/regression/kernel/validate_select_poll_epo

Re: [lttng-dev] How to user perf probes and module tracepoints in lttng

2017-10-11 Thread Francis Deslauriers
Hi,
2017-10-11 17:10 GMT-04:00 avkumar <anilz...@gmail.com>:
>
> Perf probes:
> How can we add the dynamic trace points created by perf probe into lttng? 
> When I add the perf probe as kprobe type I get missing tracepoint error, If I 
> add the perf probe as tracepoint , Lttng does not complain but it does not 
> collect any data when the tracepoint is hit.
>
> perf probe -l
>   probe:tcp_gro(on tcp_gro_receive@net/ipv4/tcp_offload.c with addr 
> len)
>
> lttng enable-event -k --probe=tcp_gro

First, you have to give your probe event a name.
Second, tcp_gro has to be a kernel symbol. According to the Perf
output above, the symbol name is `tcp_gro_receive` so the command you
want to run is:
lttng enable-event -k --probe=tcp_gro_receive EVENT_NAME

> Error: Missing event name(s).
>
> When I add it as a trace point
>
> lttng enable-event -k probe:tcp_gro
> Kernel event probe:tcp_gro created in channel channel0]
>
> it does not give any error but no data is collected

It's expected if you don't have a kernel tracepoint named
"probe:tcp_gro"(you probably don't) currently loaded in your kernel.
There is no error because there is no way for the kernel tracer if the
tracepoint is part of an not-yet-loaded kernel module or not.
"probe:tcp_gro" is a Perf specific description of the kprobe you
enabled. You can not directly reuse this description in the
lttng-enable-event command. To use the `lttng enable-event -k
TRACEPOINT`, try the `lttng list -k` command (with a lttng-sessiond
running as root) to list the currently available tracepoints.

>
>
>
> Module tracepoints:
> I created module tracepoints in the kernel and compiled the trace points. The 
> header file is in the driver module directory. When I write the adaptation 
> layer for lttng, it does not compile as it is not able to fien the header 
> file. I have given fill path name to the header file and still it does not 
> work.

Can you give us a bit more details. Could you send us a pastebin of
the error you get?

Thank you,
Francis

>
>
> Thanks
>
>
>
>
>
> _______
> lttng-dev mailing list
> lttng-dev@lists.lttng.org
> https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
>



-- 
Francis Deslauriers
Software developer
EfficiOS inc.
___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


Re: [lttng-dev] How to user perf probes and module tracepoints in lttng

2017-10-12 Thread Francis Deslauriers
2017-10-12 9:50 GMT-04:00 avkumar <anilz...@gmail.com>:
> Francis,
> The suggestion you gave works, but the issue I was trying to solve was to be
> able to peer into the structures passed to the function and get some
> information from that. That is the reason I pulled out the variables in perf
> probe. When I use the way you have suggested I am not able to figure out how
> to get it to print the skb length and skb address. Is there a way to do it(
> skb is passed into those functions?)

Hi,
LTTng doesn't currently support saving variables and function
parameters on --probe (kprobe) and --function (kretprobe) events.

Thank you,
Francis

> Reg the trace point compile error:
> I figured that one out.  I had to have the source files for the kernel to
> get that to work. I could not do with only header file for the kernel.
> Once I had the source files and  set the KERNELDIR to the root of the source
> files ( compiled) it worked.
>
> Thanks
>
>
>
> On Wed, Oct 11, 2017 at 4:49 PM, Francis Deslauriers
> <francis.deslauri...@efficios.com> wrote:
>>
>> Hi,
>> 2017-10-11 17:10 GMT-04:00 avkumar <anilz...@gmail.com>:
>> >
>> > Perf probes:
>> > How can we add the dynamic trace points created by perf probe into
>> > lttng? When I add the perf probe as kprobe type I get missing tracepoint
>> > error, If I add the perf probe as tracepoint , Lttng does not complain but
>> > it does not collect any data when the tracepoint is hit.
>> >
>> > perf probe -l
>> >   probe:tcp_gro(on tcp_gro_receive@net/ipv4/tcp_offload.c with
>> > addr len)
>> >
>> > lttng enable-event -k --probe=tcp_gro
>>
>> First, you have to give your probe event a name.
>> Second, tcp_gro has to be a kernel symbol. According to the Perf
>> output above, the symbol name is `tcp_gro_receive` so the command you
>> want to run is:
>> lttng enable-event -k --probe=tcp_gro_receive EVENT_NAME
>>
>> > Error: Missing event name(s).
>> >
>> > When I add it as a trace point
>> >
>> > lttng enable-event -k probe:tcp_gro
>> > Kernel event probe:tcp_gro created in channel channel0]
>> >
>> > it does not give any error but no data is collected
>>
>> It's expected if you don't have a kernel tracepoint named
>> "probe:tcp_gro"(you probably don't) currently loaded in your kernel.
>> There is no error because there is no way for the kernel tracer if the
>> tracepoint is part of an not-yet-loaded kernel module or not.
>> "probe:tcp_gro" is a Perf specific description of the kprobe you
>> enabled. You can not directly reuse this description in the
>> lttng-enable-event command. To use the `lttng enable-event -k
>> TRACEPOINT`, try the `lttng list -k` command (with a lttng-sessiond
>> running as root) to list the currently available tracepoints.
>>
>> >
>> >
>> >
>> > Module tracepoints:
>> > I created module tracepoints in the kernel and compiled the trace
>> > points. The header file is in the driver module directory. When I write the
>> > adaptation layer for lttng, it does not compile as it is not able to fien
>> > the header file. I have given fill path name to the header file and still 
>> > it
>> > does not work.
>>
>> Can you give us a bit more details. Could you send us a pastebin of
>> the error you get?
>>
>> Thank you,
>> Francis
>>
>> >
>> >
>> > Thanks
>> >
>> >
>> >
>> >
>> >
>> > ___
>> > lttng-dev mailing list
>> > lttng-dev@lists.lttng.org
>> > https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
>> >
>>
>>
>>
>> --
>> Francis Deslauriers
>> Software developer
>> EfficiOS inc.
>
>



-- 
Francis Deslauriers
Software developer
EfficiOS inc.
___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-ust 6/8] Manually dlopen() liblttng-ust.so to prevent unloading

2018-02-02 Thread Francis Deslauriers
dlopen() increments the refcount of the library thus preventing the
refcount to reach zero in the case of dlclose;

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 configure.ac  |  1 +
 liblttng-ust/Makefile.am  |  2 ++
 liblttng-ust/lttng-ust-comm.c | 22 ++
 3 files changed, 25 insertions(+)

diff --git a/configure.ac b/configure.ac
index b0b4157..4fc6f9c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -25,6 +25,7 @@ m4_define([UST_LIB_V_MINOR], [0])
 m4_define([UST_LIB_V_PATCH], [0])
 
 AC_SUBST([LTTNG_UST_LIBRARY_VERSION], 
[UST_LIB_V_MAJOR:UST_LIB_V_MINOR:UST_LIB_V_PATCH])
+AC_SUBST([LTTNG_UST_LIBRARY_VERSION_MAJOR], [UST_LIB_V_MAJOR])
 # note: remember to update tracepoint.h dlopen() to match this version
 # number. TODO: eventually automate by exporting the major number.
 
diff --git a/liblttng-ust/Makefile.am b/liblttng-ust/Makefile.am
index 982be69..a7edfd5 100644
--- a/liblttng-ust/Makefile.am
+++ b/liblttng-ust/Makefile.am
@@ -60,6 +60,8 @@ liblttng_ust_runtime_la_SOURCES = \
string-utils.c \
string-utils.h
 
+liblttng_ust_runtime_la_CFLAGS = 
-DLTTNG_UST_LIBRARY_VERSION_MAJOR=\"$(LTTNG_UST_LIBRARY_VERSION_MAJOR)\"
+
 if HAVE_PERF_EVENT
 liblttng_ust_runtime_la_SOURCES += \
lttng-context-perf-counters.c \
diff --git a/liblttng-ust/lttng-ust-comm.c b/liblttng-ust/lttng-ust-comm.c
index 511b9cf..ed912b8 100644
--- a/liblttng-ust/lttng-ust-comm.c
+++ b/liblttng-ust/lttng-ust-comm.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -59,6 +60,9 @@
 #include "../libringbuffer/getcpu.h"
 #include "getenv.h"
 
+/* Concatenate lttng ust shared library name with its major version number. */
+#define LTTNG_UST_LIB_SO_NAME "liblttng-ust.so." 
LTTNG_UST_LIBRARY_VERSION_MAJOR
+
 /*
  * Has lttng ust comm constructor been called ?
  */
@@ -1648,6 +1652,7 @@ void __attribute__((constructor)) lttng_ust_init(void)
pthread_attr_t thread_attr;
int timeout_mode;
int ret;
+   void *handle;
 
if (uatomic_xchg(, 1) == 1)
return;
@@ -1662,6 +1667,23 @@ void __attribute__((constructor)) lttng_ust_init(void)
lttng_ust_loaded = 1;
 
/*
+* Manually load liblttng-ust.so to increment the dynamic loader's 
internal
+* refcount for this library so it never becomes zero, thus never gets
+* unloaded from the address space of the process. Since we are already
+* running in the constructor of the LTTNG_UST_LIB_SO_NAME library, 
calling
+* dlopen will simply increment the refcount and no additionnal work is
+* needed by the dynamic loader as the shared library is already loaded 
in
+* the address space. As a safe guard, we use the RTLD_NODELETE flag to
+* prevent unloading of the UST library if its refcount becomes zero
+* (which should never happen). Do the return value check but discard 
the
+* handle at the end of the function as it's not needed.
+*/
+   handle = dlopen(LTTNG_UST_LIB_SO_NAME, RTLD_LAZY | RTLD_NODELETE);
+   if (!handle) {
+   ERR("dlopen of liblttng-ust shared library (%s).", 
LTTNG_UST_LIB_SO_NAME);
+   }
+
+   /*
 * We want precise control over the order in which we construct
 * our sub-libraries vs starting to receive commands from
 * sessiond (otherwise leading to errors when trying to create
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-ust 3/8] Cleanup: Move version numbers in separate variables in configure script

2018-02-02 Thread Francis Deslauriers
Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 configure.ac | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index fb2f278..b0b4157 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,7 +20,11 @@ AC_SUBST([PATCHLEVEL_VERSION], [V_PATCH])
 # Following the numbering scheme proposed by libtool for the library version
 # 
http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
 # This is the library version of liblttng-ust.
-AC_SUBST([LTTNG_UST_LIBRARY_VERSION], [0:0:0])
+m4_define([UST_LIB_V_MAJOR], [0])
+m4_define([UST_LIB_V_MINOR], [0])
+m4_define([UST_LIB_V_PATCH], [0])
+
+AC_SUBST([LTTNG_UST_LIBRARY_VERSION], 
[UST_LIB_V_MAJOR:UST_LIB_V_MINOR:UST_LIB_V_PATCH])
 # note: remember to update tracepoint.h dlopen() to match this version
 # number. TODO: eventually automate by exporting the major number.
 
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-ust 1/8] Remove duplicate provider name checks

2018-02-02 Thread Francis Deslauriers
From: Mathieu Desnoyers <mathieu.desnoy...@efficios.com>

It's now possible to register a probe provider with a name that has
already been registered. This is useful when wanting to load a new
version of a shared library on a already running process.

Changes are necessary in the lttng-session daemon to support cases where
the newly register event has a different probe payload.

Taking a simple case where a probe provider is registered twice, the
tracepoint call site will have two probes registered to it and thus will
generate two events in the trace.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoy...@efficios.com>
Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 include/lttng/ust-tracepoint-event.h |  2 +-
 liblttng-ust/lttng-events.c  | 11 ---
 liblttng-ust/lttng-probes.c  | 23 +--
 3 files changed, 2 insertions(+), 34 deletions(-)

diff --git a/include/lttng/ust-tracepoint-event.h 
b/include/lttng/ust-tracepoint-event.h
index 15399c7..ec292d2 100644
--- a/include/lttng/ust-tracepoint-event.h
+++ b/include/lttng/ust-tracepoint-event.h
@@ -1007,7 +1007,7 @@ _TP_COMBINE_TOKENS(__lttng_events_init__, 
TRACEPOINT_PROVIDER)(void)
_TP_COMBINE_TOKENS(__tracepoint_provider_check_, TRACEPOINT_PROVIDER)();
ret = lttng_probe_register(&_TP_COMBINE_TOKENS(__probe_desc___, 
TRACEPOINT_PROVIDER));
if (ret) {
-   fprintf(stderr, "LTTng-UST: Error (%d) while registering 
tracepoint probe. Duplicate registration of tracepoint probes having the same 
name is not allowed.\n", ret);
+   fprintf(stderr, "LTTng-UST: Error (%d) while registering 
tracepoint probe.\n", ret);
abort();
}
 }
diff --git a/liblttng-ust/lttng-events.c b/liblttng-ust/lttng-events.c
index bfdae4f..f4a7ccc 100644
--- a/liblttng-ust/lttng-events.c
+++ b/liblttng-ust/lttng-events.c
@@ -537,7 +537,6 @@ int lttng_event_create(const struct lttng_event_desc *desc,
struct lttng_event *event;
struct lttng_session *session = chan->session;
struct cds_hlist_head *head;
-   struct cds_hlist_node *node;
int ret = 0;
size_t name_len = strlen(event_name);
uint32_t hash;
@@ -546,15 +545,6 @@ int lttng_event_create(const struct lttng_event_desc *desc,
 
hash = jhash(event_name, name_len, 0);
head = >session->events_ht.table[hash & (LTTNG_UST_EVENT_HT_SIZE 
- 1)];
-   cds_hlist_for_each_entry(event, node, head, hlist) {
-   assert(event->desc);
-   if (!strncmp(event->desc->name, desc->name,
-   LTTNG_UST_SYM_NAME_LEN - 1)
-   && chan == event->chan) {
-   ret = -EEXIST;
-   goto exist;
-   }
-   }
 
notify_socket = lttng_get_notify_socket(session->owner);
if (notify_socket < 0) {
@@ -623,7 +613,6 @@ sessiond_register_error:
 cache_error:
 create_enum_error:
 socket_error:
-exist:
return ret;
 }
 
diff --git a/liblttng-ust/lttng-probes.c b/liblttng-ust/lttng-probes.c
index 390265a..a09497f 100644
--- a/liblttng-ust/lttng-probes.c
+++ b/liblttng-ust/lttng-probes.c
@@ -148,20 +148,6 @@ struct cds_list_head *lttng_get_probe_list_head(void)
 }
 
 static
-const struct lttng_probe_desc *find_provider(const char *provider)
-{
-   struct lttng_probe_desc *iter;
-   struct cds_list_head *probe_list;
-
-   probe_list = lttng_get_probe_list_head();
-   cds_list_for_each_entry(iter, probe_list, head) {
-   if (!strcmp(iter->provider, provider))
-   return iter;
-   }
-   return NULL;
-}
-
-static
 int check_provider_version(struct lttng_probe_desc *desc)
 {
/*
@@ -206,13 +192,6 @@ int lttng_probe_register(struct lttng_probe_desc *desc)
 
ust_lock_nocheck();
 
-   /*
-* Check if the provider has already been registered.
-*/
-   if (find_provider(desc->provider)) {
-   ret = -EEXIST;
-   goto end;
-   }
cds_list_add(>lazy_init_head, _probe_init);
desc->lazy = 1;
DBG("adding probe %s containing %u events to lazy registration list",
@@ -224,7 +203,7 @@ int lttng_probe_register(struct lttng_probe_desc *desc)
 */
if (lttng_session_active())
fixup_lazy_probes();
-end:
+
ust_unlock();
return ret;
 }
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-ust 0/8] Support provider duplicates and unloading

2018-02-02 Thread Francis Deslauriers
This patch set adds the support for duplicated probe providers and
support for unloading probe providers using dlclose().

It allows to advance scenarios where probe providers can be upgraded
during tracing.

For example, during tracing the user could dlopen() a new version of a probe
provider and dlclose() the previous one. All this without stop tracing.

A patch set for lttng-tools project is necessary to take advantage of
those changes.

The lttng-tools changes can be found on this branch of my Github fork:
https://github.com/frdeso/lttng-tools/commits/multi-lib-support

Francis Deslauriers (7):
  Fix: missing event removal from the event hashtable
  Cleanup: Move version numbers in separate variables in configure
script
  Add probe provider unregister function
  Fix: missing enum removal from the enum hashtable
  Manually dlopen() liblttng-ust.so to prevent unloading
  Rename lttng_ust_enum_get to lttng_ust_enum_get_from_desc
  Support unloading of probe providers

Mathieu Desnoyers (1):
  Remove duplicate provider name checks

 configure.ac |   7 +-
 include/lttng/ust-events.h   |   6 +-
 include/lttng/ust-tracepoint-event.h |   2 +-
 liblttng-ust-comm/lttng-ust-comm.c   |   3 +-
 liblttng-ust/Makefile.am |   2 +
 liblttng-ust/lttng-events.c  | 139 ++-
 liblttng-ust/lttng-probes.c  |  28 ++-
 liblttng-ust/lttng-ust-comm.c|  22 ++
 liblttng-ust/tracepoint.c|  43 ---
 liblttng-ust/ust-core.c  |  11 ++-
 10 files changed, 200 insertions(+), 63 deletions(-)

-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-ust 8/8] Support unloading of probe providers

2018-02-02 Thread Francis Deslauriers
With this commit, it's now possible to dlclose() a library containing an
actively used probe provider.

The destructor of such library will now iterate over all the sessions
and over all probe definitions to unregister them from the respective
callsites in the process.

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 liblttng-ust/lttng-events.c | 22 +-
 liblttng-ust/lttng-probes.c |  5 -
 liblttng-ust/tracepoint.c   | 43 ++-
 3 files changed, 59 insertions(+), 11 deletions(-)

diff --git a/liblttng-ust/lttng-events.c b/liblttng-ust/lttng-events.c
index 07385d7..698210c 100644
--- a/liblttng-ust/lttng-events.c
+++ b/liblttng-ust/lttng-events.c
@@ -793,7 +793,7 @@ void lttng_create_event_if_missing(struct lttng_enabler 
*enabler)
  */
 void lttng_probe_provider_unregister_events(struct lttng_probe_desc 
*provider_desc)
 {
-   int i;
+   unsigned int i, j;
struct cds_list_head *sessionsp;
struct lttng_session *session;
struct cds_hlist_head *head;
@@ -867,7 +867,27 @@ void lttng_probe_provider_unregister_events(struct 
lttng_probe_desc *provider_de
head = >events_ht.table[hash & 
(LTTNG_UST_EVENT_HT_SIZE - 1)];
cds_hlist_for_each_entry(event, node, head, hlist) {
if (event_desc == event->desc) {
+   /* Destroy enums of the current event. 
*/
+   for (j = 0; j < event->desc->nr_fields; 
j++) {
+   const struct lttng_event_field 
*field;
+   const struct lttng_enum_desc 
*enum_desc;
+   struct lttng_enum *curr_enum;
+
+   field = 
&(event->desc->fields[j]);
+   if (field->type.atype != 
atype_enum) {
+   continue;
+   }
+
+   enum_desc = 
field->type.u.basic.enumeration.desc;
+   curr_enum = 
lttng_ust_enum_get_from_desc(session, enum_desc);
+   if (curr_enum) {
+   
_lttng_enum_destroy(curr_enum);
+   }
+   }
+
+   /* Destroy event. */
_lttng_event_destroy(event);
+
break;
}
}
diff --git a/liblttng-ust/lttng-probes.c b/liblttng-ust/lttng-probes.c
index a09497f..862b19e 100644
--- a/liblttng-ust/lttng-probes.c
+++ b/liblttng-ust/lttng-probes.c
@@ -226,7 +226,10 @@ void lttng_probe_unregister(struct lttng_probe_desc *desc)
cds_list_del(>head);
else
cds_list_del(>lazy_init_head);
-   DBG("just unregistered probe %s", desc->provider);
+
+   lttng_probe_provider_unregister_events(desc);
+   DBG("just unregistered probes of provider %s", desc->provider);
+
ust_unlock();
 }
 
diff --git a/liblttng-ust/tracepoint.c b/liblttng-ust/tracepoint.c
index 14b8231..8c630a6 100644
--- a/liblttng-ust/tracepoint.c
+++ b/liblttng-ust/tracepoint.c
@@ -107,8 +107,8 @@ struct tracepoint_entry {
struct lttng_ust_tracepoint_probe *probes;
int refcount;   /* Number of times armed. 0 if disarmed. */
int callsite_refcount;  /* how many libs use this tracepoint */
-   const char *signature;
-   char name[0];
+   char *signature;
+   char *name;
 };
 
 struct tp_probes {
@@ -132,6 +132,7 @@ struct callsite_entry {
struct cds_hlist_node hlist;/* hash table node */
struct cds_list_head node;  /* lib list of callsites node */
struct lttng_ust_tracepoint *tp;
+   bool tp_entry_callsite_ref; /* Has a tp_entry took a ref on this 
callsite*/
 };
 
 /* coverity[+alloc] */
@@ -284,6 +285,8 @@ static struct tracepoint_entry *add_tracepoint(const char 
*name,
struct cds_hlist_node *node;
struct tracepoint_entry *e;
size_t name_len = strlen(name);
+   size_t sig_len = strlen(signature);
+   size_t sig_off, name_off;
uint32_t hash;
 
if (name_len > LTTNG_UST_SYM_NAME_LEN - 1) {
@@ -298,19 +301,29 @@ static struct tracepoint_entry *add_tracepoint(const char 
*name,
return ERR_PTR(-EEXIST);/* Already there */
}
}
+
/*
-* Using zmalloc here to allocate a variable length element. Could
-* cause some memory fra

[lttng-dev] [PATCH lttng-ust 4/8] Add probe provider unregister function

2018-02-02 Thread Francis Deslauriers
Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 include/lttng/ust-events.h  |  1 +
 liblttng-ust/lttng-events.c | 89 +
 2 files changed, 90 insertions(+)

diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h
index caf7e63..019b0eb 100644
--- a/include/lttng/ust-events.h
+++ b/include/lttng/ust-events.h
@@ -656,6 +656,7 @@ void synchronize_trace(void);
 
 int lttng_probe_register(struct lttng_probe_desc *desc);
 void lttng_probe_unregister(struct lttng_probe_desc *desc);
+void lttng_probe_provider_unregister_events(struct lttng_probe_desc *desc);
 int lttng_fix_pending_events(void);
 int lttng_probes_init(void);
 void lttng_probes_exit(void);
diff --git a/liblttng-ust/lttng-events.c b/liblttng-ust/lttng-events.c
index 7419f78..e8d4857 100644
--- a/liblttng-ust/lttng-events.c
+++ b/liblttng-ust/lttng-events.c
@@ -789,6 +789,95 @@ void lttng_create_event_if_missing(struct lttng_enabler 
*enabler)
 }
 
 /*
+ * Iterate over all the UST sessions to unregister and destroy all probes from
+ * the probe provider descriptor passed in arguments. Must me called with the
+ * ust_lock held.
+ */
+void lttng_probe_provider_unregister_events(struct lttng_probe_desc 
*provider_desc)
+{
+   int i;
+   struct cds_list_head *sessionsp;
+   struct lttng_session *session;
+   struct cds_hlist_head *head;
+   struct cds_hlist_node *node;
+   struct lttng_event *event;
+
+   /* Get handle on list of sessions. */
+   sessionsp = _lttng_get_sessions();
+
+   /*
+* Iterate over all events in the probe provider descriptions and 
sessions
+* to queue the unregistration of the events.
+*/
+   for (i = 0; i < provider_desc->nr_events; i++) {
+   const char *event_name;
+   uint32_t hash;
+   size_t name_len;
+   const struct lttng_event_desc *event_desc;
+
+   event_desc = provider_desc->event_desc[i];
+   event_name = event_desc->name;
+   name_len = strlen(event_name);
+   hash = jhash(event_name, name_len, 0);
+
+   /* Iterate over all session to find the current event 
description. */
+   cds_list_for_each_entry(session, sessionsp, node) {
+
+   /*
+* Get the list of events in the hashtable bucket and 
iterate to
+* find the event matching this descriptor.
+*/
+   head = >events_ht.table[hash & 
(LTTNG_UST_EVENT_HT_SIZE - 1)];
+   cds_hlist_for_each_entry(event, node, head, hlist) {
+   if (event_desc == event->desc) {
+
+   /* Queue the unregistration of this 
event. */
+   _lttng_event_unregister(event);
+   break;
+   }
+   }
+   }
+   }
+
+   /* Wait for grace period. */
+   synchronize_trace();
+   /* Prune the unregistration queue. */
+   __tracepoint_probe_prune_release_queue();
+
+   /*
+* It is now safe to destroy the events and remove them from the event 
list
+* and hashtables.
+*/
+   for (i = 0; i < provider_desc->nr_events; i++) {
+   const char *event_name;
+   uint32_t hash;
+   size_t name_len;
+   const struct lttng_event_desc *event_desc;
+
+   event_desc = provider_desc->event_desc[i];
+   event_name = event_desc->name;
+   name_len = strlen(event_name);
+   hash = jhash(event_name, name_len, 0);
+
+   /* Iterate over all sessions to find the current event 
description. */
+   cds_list_for_each_entry(session, sessionsp, node) {
+
+   /*
+* Get the list of events in the hashtable bucket and 
iterate to
+* find the event matching this descriptor.
+*/
+   head = >events_ht.table[hash & 
(LTTNG_UST_EVENT_HT_SIZE - 1)];
+   cds_hlist_for_each_entry(event, node, head, hlist) {
+   if (event_desc == event->desc) {
+   _lttng_event_destroy(event);
+   break;
+   }
+   }
+   }
+   }
+}
+
+/*
  * Create events associated with an enabler (if not already present),
  * and add backward reference from the event to the enabler.
  */
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-ust 2/8] Fix: missing event removal from the event hashtable

2018-02-02 Thread Francis Deslauriers
Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 liblttng-ust/lttng-events.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/liblttng-ust/lttng-events.c b/liblttng-ust/lttng-events.c
index f4a7ccc..7419f78 100644
--- a/liblttng-ust/lttng-events.c
+++ b/liblttng-ust/lttng-events.c
@@ -883,7 +883,11 @@ void _lttng_event_destroy(struct lttng_event *event)
 {
struct lttng_enabler_ref *enabler_ref, *tmp_enabler_ref;
 
+   /* Remove from event list. */
cds_list_del(>node);
+   /* Remove from event hash table. */
+   cds_hlist_del(>hlist);
+
lttng_destroy_context(event->ctx);
lttng_free_event_filter_runtime(event);
/* Free event enabler refs */
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-ust 5/8] Fix: missing enum removal from the enum hashtable

2018-02-02 Thread Francis Deslauriers
Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 liblttng-ust/lttng-events.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/liblttng-ust/lttng-events.c b/liblttng-ust/lttng-events.c
index e8d4857..2b679b5 100644
--- a/liblttng-ust/lttng-events.c
+++ b/liblttng-ust/lttng-events.c
@@ -990,6 +990,7 @@ static
 void _lttng_enum_destroy(struct lttng_enum *_enum)
 {
cds_list_del(&_enum->node);
+   cds_hlist_del(&_enum->hlist);
free(_enum);
 }
 
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-tools 0/5] Support probes with the same name but different event payload

2018-02-07 Thread Francis Deslauriers
This patch set allows for multiple probes with the same name to be
hooked on the same callsite. Right now, the Session Daemon only
considers the name and signature of the events to determine if two
events are identical. This could lead to trace corruptions when two
probes would have the same name and signature but really different
binary trace layouts.

We now compare probes by doing a deep compare of every field.
If two events are _exactly_ the same then the same event ID will be
used, if they are different a new event ID is created.

When used with this UST patch set[1], it is possible to dlclose probe
provider and callsite libraries during tracing.

This patch set also includes regression tests for both the deep
comparaison and the newly added dlclose capability.

[1]: https://github.com/frdeso/lttng-ust/tree/dlclose-support

Francis Deslauriers (5):
  Fix: probes should not be compared by their names and callsite
signatures
  Fix: should pass the reg_enum_lookup pointer directly
  Tests: allow the use of regular expressions to match events
  Tests: add function to validate the number of an event name in
metadata
  Tests: add duplicated providers tests

 configure.ac|   1 +
 src/bin/lttng-sessiond/Makefile.am  |   3 +-
 src/bin/lttng-sessiond/ust-field-utils.c| 261 +++
 src/bin/lttng-sessiond/ust-field-utils.h|  29 +++
 src/bin/lttng-sessiond/ust-registry.c   |  44 +++-
 tests/fast_regression   |   1 +
 tests/regression/ust/multi-lib/Makefile.am  | 114 +++
 tests/regression/ust/multi-lib/README   |  21 ++
 tests/regression/ust/multi-lib/callsites.c  |  34 +++
 tests/regression/ust/multi-lib/callsites.h  |  21 ++
 tests/regression/ust/multi-lib/multi-lib-test.c | 251 +++
 tests/regression/ust/multi-lib/probes.c |  18 ++
 tests/regression/ust/multi-lib/probes.h | 195 ++
 tests/regression/ust/multi-lib/test_multi_lib   | 262 
 tests/unit/Makefile.am  |   1 +
 tests/utils/utils.sh|  27 ++-
 16 files changed, 1270 insertions(+), 13 deletions(-)
 create mode 100644 src/bin/lttng-sessiond/ust-field-utils.c
 create mode 100644 src/bin/lttng-sessiond/ust-field-utils.h
 create mode 100644 tests/regression/ust/multi-lib/Makefile.am
 create mode 100644 tests/regression/ust/multi-lib/README
 create mode 100644 tests/regression/ust/multi-lib/callsites.c
 create mode 100644 tests/regression/ust/multi-lib/callsites.h
 create mode 100644 tests/regression/ust/multi-lib/multi-lib-test.c
 create mode 100644 tests/regression/ust/multi-lib/probes.c
 create mode 100644 tests/regression/ust/multi-lib/probes.h
 create mode 100755 tests/regression/ust/multi-lib/test_multi_lib

-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-tools 4/5] Tests: add function to validate the number of an event name in metadata

2018-02-07 Thread Francis Deslauriers
Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 tests/utils/utils.sh | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh
index 9bf1fcc..60df376 100644
--- a/tests/utils/utils.sh
+++ b/tests/utils/utils.sh
@@ -1343,6 +1343,29 @@ function add_context_kernel_fail()
add_context_lttng 1 -k "$@"
 }
 
+function validate_metadata_event ()
+{
+   local event_name=$1
+   local nr_event_id=$2
+   local trace_path=$3
+
+   local metadata_file=$(find $trace_path | grep metadata)
+   local metadata_path=$(dirname $metadata_file)
+
+   which $BABELTRACE_BIN >/dev/null
+   skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches"
+
+   local count=$($BABELTRACE_BIN --output-format=ctf-metadata 
$metadata_path | grep $event_name | wc -l)
+
+   if [ "$count" -ne "$nr_event_id" ]; then
+   fail "Metadata match with the metadata of $count event(s) named 
$event_name"
+   diag "$count matching event id found in metadata"
+   else
+   pass "Metadata match with the metadata of $count event(s) named 
$event_name"
+   fi
+
+}
+
 function trace_matches ()
 {
local event_name=$1
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-tools 5/5] Tests: add duplicated providers tests

2018-02-07 Thread Francis Deslauriers
Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 configure.ac|   1 +
 tests/fast_regression   |   1 +
 tests/regression/ust/multi-lib/Makefile.am  | 114 +++
 tests/regression/ust/multi-lib/README   |  21 ++
 tests/regression/ust/multi-lib/callsites.c  |  34 +++
 tests/regression/ust/multi-lib/callsites.h  |  21 ++
 tests/regression/ust/multi-lib/multi-lib-test.c | 251 +++
 tests/regression/ust/multi-lib/probes.c |  18 ++
 tests/regression/ust/multi-lib/probes.h | 195 ++
 tests/regression/ust/multi-lib/test_multi_lib   | 262 
 10 files changed, 918 insertions(+)
 create mode 100644 tests/regression/ust/multi-lib/Makefile.am
 create mode 100644 tests/regression/ust/multi-lib/README
 create mode 100644 tests/regression/ust/multi-lib/callsites.c
 create mode 100644 tests/regression/ust/multi-lib/callsites.h
 create mode 100644 tests/regression/ust/multi-lib/multi-lib-test.c
 create mode 100644 tests/regression/ust/multi-lib/probes.c
 create mode 100644 tests/regression/ust/multi-lib/probes.h
 create mode 100755 tests/regression/ust/multi-lib/test_multi_lib

diff --git a/configure.ac b/configure.ac
index b6ea39c..e22872c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1090,6 +1090,7 @@ AC_CONFIG_FILES([
tests/regression/ust/buffers-pid/Makefile
tests/regression/ust/periodical-metadata-flush/Makefile
tests/regression/ust/multi-session/Makefile
+   tests/regression/ust/multi-lib/Makefile
tests/regression/ust/overlap/Makefile
tests/regression/ust/overlap/demo/Makefile
tests/regression/ust/linking/Makefile
diff --git a/tests/fast_regression b/tests/fast_regression
index bbce068..f76b53d 100644
--- a/tests/fast_regression
+++ b/tests/fast_regression
@@ -21,6 +21,7 @@ regression/tools/regen-statedump/test_ust
 regression/ust/before-after/test_before_after
 regression/ust/buffers-pid/test_buffers_pid
 regression/ust/multi-session/test_multi_session
+regression/ust/multi-lib/test_multi_lib
 regression/ust/nprocesses/test_nprocesses
 regression/ust/overlap/test_overlap
 regression/ust/java-jul/test_java_jul
diff --git a/tests/regression/ust/multi-lib/Makefile.am 
b/tests/regression/ust/multi-lib/Makefile.am
new file mode 100644
index 000..f78ce7f
--- /dev/null
+++ b/tests/regression/ust/multi-lib/Makefile.am
@@ -0,0 +1,114 @@
+noinst_SCRIPTS = test_multi_lib
+noinst_PROGRAMS = exec-with-callsites exec-without-callsites
+
+exec_with_callsites_SOURCES = multi-lib-test.c callsites.c
+exec_with_callsites_LDFLAGS = -ldl -lpopt
+exec_with_callsites_CFLAGS = -DHAS_CALLSITES=1
+
+exec_without_callsites_SOURCES = multi-lib-test.c
+exec_without_callsites_LDFLAGS = -ldl -lpopt -llttng-ust
+exec_without_callsites_LDADD = probes.o
+exec_without_callsites_CFLAGS = -DHAS_CALLSITES=0
+
+PROBES_SRC=probes.c probes.h
+PROBES_LDF=-shared -module -llttng-ust -avoid-version -rpath 
$(abs_builddir)/.libs/
+PROBES_CF=-c -I$(srcdir)/
+
+probes.o: probes.c probes.h
+   $(CC) $(PROBES_CF) -o $@ $<
+
+noinst_LTLIBRARIES = libprobes_a.la libprobes_a_prime.la \
+   libprobes_b.la libprobes_c.la libprobes_c_prime.la \
+   libprobes_d.la libprobes_e.la libprobes_f.la \
+   libprobes_g.la libprobes_h.la libprobes_i.la \
+   libprobes_j.la libprobes_k.la libprobes_l.la \
+   libprobes_m.la libprobes_n.la libprobes_o.la \
+   libprobes_p.la
+
+noinst_LTLIBRARIES += libcallsites_1.la libcallsites_2.la
+
+CALLSITES_SRC=callsites.c callsites.h
+CALLSITES_LDF=-shared -module -llttng-ust -avoid-version -rpath 
$(abs_builddir)/.libs/
+CALLSITES_CF=-c -I.
+
+libprobes_a_la_SOURCES = $(PROBES_SRC)
+libprobes_a_la_LDFLAGS = $(PROBES_LDF)
+libprobes_a_la_CFLAGS = $(PROBES_CF) -DACTIVATE_PROBES_A
+
+libprobes_a_prime_la_SOURCES = $(PROBES_SRC)
+libprobes_a_prime_la_LDFLAGS = $(PROBES_LDF)
+libprobes_a_prime_la_CFLAGS = $(PROBES_CF) -DACTIVATE_PROBES_A
+
+libprobes_b_la_SOURCES = $(PROBES_SRC)
+libprobes_b_la_LDFLAGS = $(PROBES_LDF)
+libprobes_b_la_CFLAGS = $(PROBES_CF) -DACTIVATE_PROBES_B
+
+libprobes_c_la_SOURCES = $(PROBES_SRC)
+libprobes_c_la_LDFLAGS = $(PROBES_LDF)
+libprobes_c_la_CFLAGS = $(PROBES_CF) -DACTIVATE_PROBES_C
+
+libprobes_c_prime_la_SOURCES = $(PROBES_SRC)
+libprobes_c_prime_la_LDFLAGS = $(PROBES_LDF)
+libprobes_c_prime_la_CFLAGS = $(PROBES_CF) -DACTIVATE_PROBES_C
+
+libprobes_d_la_SOURCES = $(PROBES_SRC)
+libprobes_d_la_LDFLAGS = $(PROBES_LDF)
+libprobes_d_la_CFLAGS = $(PROBES_CF) -DACTIVATE_PROBES_D
+
+libprobes_e_la_SOURCES = $(PROBES_SRC)
+libprobes_e_la_LDFLAGS = $(PROBES_LDF)
+libprobes_e_la_CFLAGS = $(PROBES_CF) -DACTIVATE_PROBES_E
+
+libprobes_f_la_SOURCES = $(PROBES_SRC)
+libprobes_f_la_LDFLAGS = $(PROBES_LDF)
+libprobes_f_la_CFLAGS = $(PROBES_CF) -DACTIVATE

[lttng-dev] [PATCH lttng-tools 3/5] Tests: allow the use of regular expressions to match events

2018-02-07 Thread Francis Deslauriers
Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 tests/utils/utils.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh
index e8dfcda..9bf1fcc 100644
--- a/tests/utils/utils.sh
+++ b/tests/utils/utils.sh
@@ -1457,7 +1457,7 @@ function validate_trace_exp()
which $BABELTRACE_BIN >/dev/null
skip $? -ne 0 "Babeltrace binary not found. Skipping trace validation"
 
-   traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep ${event_exp} | 
wc -l)
+   traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep 
--extended-regexp ${event_exp} | wc -l)
if [ "$traced" -ne 0 ]; then
pass "Validate trace for expression '${event_exp}', $traced 
events"
else
@@ -1476,7 +1476,7 @@ function validate_trace_only_exp()
which $BABELTRACE_BIN >/dev/null
skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches"
 
-   local count=$($BABELTRACE_BIN $trace_path | grep ${event_exp} | wc -l)
+   local count=$($BABELTRACE_BIN $trace_path | grep --extended-regexp 
${event_exp} | wc -l)
local total=$($BABELTRACE_BIN $trace_path | wc -l)
 
if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-tools 1/5] Fix: probes should not be compared by their names and callsite signatures

2018-02-07 Thread Francis Deslauriers
Events with different payloads but identical name and signatures could
lead to corrupted trace as the Session Daemon would consider them
identical and give them the same event ID.

Events should be compared using the name, loglevel, fields and
model_emf_uri to ensure that their serialized layout is the same.

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 src/bin/lttng-sessiond/Makefile.am   |   3 +-
 src/bin/lttng-sessiond/ust-field-utils.c | 261 +++
 src/bin/lttng-sessiond/ust-field-utils.h |  29 
 src/bin/lttng-sessiond/ust-registry.c|  40 -
 tests/unit/Makefile.am   |   1 +
 5 files changed, 325 insertions(+), 9 deletions(-)
 create mode 100644 src/bin/lttng-sessiond/ust-field-utils.c
 create mode 100644 src/bin/lttng-sessiond/ust-field-utils.h

diff --git a/src/bin/lttng-sessiond/Makefile.am 
b/src/bin/lttng-sessiond/Makefile.am
index 413fe75..6fc1809 100644
--- a/src/bin/lttng-sessiond/Makefile.am
+++ b/src/bin/lttng-sessiond/Makefile.am
@@ -40,7 +40,8 @@ lttng_sessiond_SOURCES = utils.c utils.h \
 if HAVE_LIBLTTNG_UST_CTL
 lttng_sessiond_SOURCES += trace-ust.c ust-registry.c ust-app.c \
ust-consumer.c ust-consumer.h ust-thread.c \
-   ust-metadata.c ust-clock.h agent-thread.c agent-thread.h
+   ust-metadata.c ust-clock.h agent-thread.c 
agent-thread.h \
+   ust-field-utils.h ust-field-utils.c
 endif
 
 # Add main.c at the end for compile order
diff --git a/src/bin/lttng-sessiond/ust-field-utils.c 
b/src/bin/lttng-sessiond/ust-field-utils.c
new file mode 100644
index 000..3c2da14
--- /dev/null
+++ b/src/bin/lttng-sessiond/ust-field-utils.c
@@ -0,0 +1,261 @@
+/*
+ * Copyright (C) 2018 - Francis Deslauriers <francis.deslauri...@efficios.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License, version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include 
+#include 
+
+#include "ust-field-utils.h"
+
+/*
+ * The ustctl_field is made of a combinaison of C basic types
+ * ustctl_basic_type and _ustctl_basic_type.
+ *
+ * ustctl_basic_type contains an enumeration describing the abstract type.
+ * _ustctl_basic_type does _NOT_ contain an enumeration describing the
+ * abstract type.
+ *
+ * A layer is needed to use the same code for both structures.
+ * When dealing with _ustctl_basic_type, we need to use the abstract type of
+ * the ustctl_type struct.
+ */
+
+/*
+ * Compare two ustctl_integer_type fields.
+ * Returns 1 if both are identical.
+ */
+static bool match_ustctl_field_integer(struct ustctl_integer_type *first,
+   struct ustctl_integer_type *second)
+{
+   bool match = true;
+   match &= first->size == second->size;
+   match &= first->alignment == second->alignment;
+   match &= first->signedness == second->signedness;
+   match &= first->encoding == second->encoding;
+   match &= first->base == second->base;
+   match &= first->reverse_byte_order == second->reverse_byte_order;
+
+   return match;
+}
+
+/*
+ * Compare two _ustctl_basic_type fields known to be of type integer.
+ * Returns 1 if both are identical.
+ */
+static bool match_ustctl_field_integer_from_raw_basic_type(
+   union _ustctl_basic_type *first, union 
_ustctl_basic_type *second)
+{
+   return match_ustctl_field_integer(>integer, >integer);
+}
+
+/*
+ * Compare two _ustctl_basic_type fields known to be of type enum.
+ * Returns 1 if both are identical.
+ */
+static bool match_ustctl_field_enum_from_raw_basic_type(
+   union _ustctl_basic_type *first, union 
_ustctl_basic_type *second)
+{
+   /*
+* Compare enumeration ID. Enumeration ID is provided to the 
application by
+* the session daemon before event registration.
+*/
+   if (first->enumeration.id != second->enumeration.id) {
+   goto no_match;
+   }
+
+   /*
+* Sanity check of the name and container type. Those were already 
checked
+* during enum registration.
+*/
+   if (strncmp(first->enumeration.name, second->enumeration.name,
+   LTTNG_UST_SYM_NAME_LEN)) {
+   goto no_match;
+   }
+   if (match_ustctl_fi

Re: [lttng-dev] [PATCH lttng-ust 4/8] Add probe provider unregister function

2018-02-08 Thread Francis Deslauriers
2018-02-07 15:54 GMT-05:00 Mathieu Desnoyers <mathieu.desnoy...@efficios.com>:
>
> - On Feb 2, 2018, at 2:48 PM, Francis Deslauriers 
> francis.deslauri...@efficios.com wrote:
>
>> Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
>> ---
>> include/lttng/ust-events.h  |  1 +
>> liblttng-ust/lttng-events.c | 89 
>> +
>> 2 files changed, 90 insertions(+)
>>
>> diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h
>> index caf7e63..019b0eb 100644
>> --- a/include/lttng/ust-events.h
>> +++ b/include/lttng/ust-events.h
>> @@ -656,6 +656,7 @@ void synchronize_trace(void);
>>
>> int lttng_probe_register(struct lttng_probe_desc *desc);
>> void lttng_probe_unregister(struct lttng_probe_desc *desc);
>> +void lttng_probe_provider_unregister_events(struct lttng_probe_desc *desc);
>> int lttng_fix_pending_events(void);
>> int lttng_probes_init(void);
>> void lttng_probes_exit(void);
>> diff --git a/liblttng-ust/lttng-events.c b/liblttng-ust/lttng-events.c
>> index 7419f78..e8d4857 100644
>> --- a/liblttng-ust/lttng-events.c
>> +++ b/liblttng-ust/lttng-events.c
>> @@ -789,6 +789,95 @@ void lttng_create_event_if_missing(struct lttng_enabler
>> *enabler)
>> }
>>
>> /*
>> + * Iterate over all the UST sessions to unregister and destroy all probes 
>> from
>> + * the probe provider descriptor passed in arguments. Must me called with 
>> the
>
> passed in arguments -> received as argument
>
>> + * ust_lock held.
>> + */
>> +void lttng_probe_provider_unregister_events(struct lttng_probe_desc
>> *provider_desc)
>> +{
>> + int i;
>
> move int i; to the last variable (shortest line).
>
>> + struct cds_list_head *sessionsp;
>> + struct lttng_session *session;
>> + struct cds_hlist_head *head;
>> + struct cds_hlist_node *node;
>> + struct lttng_event *event;
>> +
>> + /* Get handle on list of sessions. */
>> + sessionsp = _lttng_get_sessions();
>> +
>> + /*
>> +  * Iterate over all events in the probe provider descriptions and 
>> sessions
>> +  * to queue the unregistration of the events.
>> +  */
>> + for (i = 0; i < provider_desc->nr_events; i++) {
>> + const char *event_name;
>> + uint32_t hash;
>> + size_t name_len;
>> + const struct lttng_event_desc *event_desc;
>
> same here about var definition layout.
>
>> +
>> + event_desc = provider_desc->event_desc[i];
>> + event_name = event_desc->name;
>> + name_len = strlen(event_name);
>> + hash = jhash(event_name, name_len, 0);
>> +
>> + /* Iterate over all session to find the current event 
>> description. */
>> + cds_list_for_each_entry(session, sessionsp, node) {
>
> remove whiteline.
>
>> +
>> + /*
>> +  * Get the list of events in the hashtable bucket and 
>> iterate to
>> +  * find the event matching this descriptor.
>> +  */
>> + head = >events_ht.table[hash & 
>> (LTTNG_UST_EVENT_HT_SIZE - 1)];
>> + cds_hlist_for_each_entry(event, node, head, hlist) {
>> + if (event_desc == event->desc) {
>> +
>> + /* Queue the unregistration of this 
>> event. */
>> + _lttng_event_unregister(event);
>> + break;
>> + }
>> + }
>> + }
>> + }
>> +
>> + /* Wait for grace period. */
>> + synchronize_trace();
>> + /* Prune the unregistration queue. */
>> + __tracepoint_probe_prune_release_queue();
>> +
>> + /*
>> +  * It is now safe to destroy the events and remove them from the event 
>> list
>> +  * and hashtables.
>> +  */
>> + for (i = 0; i < provider_desc->nr_events; i++) {
>> + const char *event_name;
>> + uint32_t hash;
>> + size_t name_len;
>> + const struct lttng_event_desc *event_desc;
>
> same.
>
>> +
>> + event_desc = provider_desc->event_desc[i];
>> + event_name = event_desc->name;
>>

Re: [lttng-dev] [PATCH lttng-tools 2/5] Fix: should pass the reg_enum_lookup pointer directly

2018-02-08 Thread Francis Deslauriers
2018-02-07 15:48 GMT-05:00 Mathieu Desnoyers <mathieu.desnoy...@efficios.com>:
> - On Feb 7, 2018, at 2:36 PM, Francis Deslauriers 
> francis.deslauri...@efficios.com wrote:
>
>> As the ht_hash_enum and ht_match_enum functions are not changing the
>> pointer there is no need to pass the address of the pointer.
>
> The changelog seems too nice. The current situation is that the arguments
> passed to the cds_lfht_lookup() function do not match the args expected by 
> ht_has_enum
> and ht_match_enum, and by chance we probably always end up comparing with 
> garbage ?
>
> The changelog should better describe the current problem.

Here is a revised version:

Fix: calling ht_{hash, match}_enum with wrong argument

ht_hash_enum and ht_match_enum are currently called with the address of the
pointer to a ust_registry_enum rather than the expected pointer to a
ust_registry_enum. This means that those function calls would end up
using garbage for hashing and comparing.


Thank you,
Francis

>
> Thanks,
>
> Mathieu
>
>>
>> Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
>> ---
>> src/bin/lttng-sessiond/ust-registry.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/bin/lttng-sessiond/ust-registry.c
>> b/src/bin/lttng-sessiond/ust-registry.c
>> index e336b9e..cd6fdac 100644
>> --- a/src/bin/lttng-sessiond/ust-registry.c
>> +++ b/src/bin/lttng-sessiond/ust-registry.c
>> @@ -558,8 +558,8 @@ struct ust_registry_enum *
>>   struct lttng_ht_iter iter;
>>
>>   cds_lfht_lookup(session->enums->ht,
>> - ht_hash_enum((void *) _enum_lookup, lttng_ht_seed),
>> - ht_match_enum, _enum_lookup, );
>> + ht_hash_enum((void *) reg_enum_lookup, lttng_ht_seed),
>> + ht_match_enum, reg_enum_lookup, );
>>   node = lttng_ht_iter_get_node_str();
>>   if (!node) {
>>   goto end;
>> --
>> 2.7.4
>>
>> ___________
>> lttng-dev mailing list
>> lttng-dev@lists.lttng.org
>> https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
>
> --
> Mathieu Desnoyers
> EfficiOS Inc.
> http://www.efficios.com



-- 
Francis Deslauriers
Software developer
EfficiOS inc.
___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


Re: [lttng-dev] [PATCH lttng-tools 1/5] Fix: probes should not be compared by their names and callsite signatures

2018-02-08 Thread Francis Deslauriers
2018-02-07 15:43 GMT-05:00 Mathieu Desnoyers <mathieu.desnoy...@efficios.com>:
> - On Feb 7, 2018, at 2:36 PM, Francis Deslauriers 
> francis.deslauri...@efficios.com wrote:
>
>> Events with different payloads but identical name and signatures could
>> lead to corrupted trace as the Session Daemon would consider them
>> identical and give them the same event ID.
>>
>> Events should be compared using the name, loglevel, fields and
>> model_emf_uri to ensure that their serialized layout is the same.
>
> model_emf_uri has no impact on the serialized layout, but does have an
> impact on what ends up in the metadata description for the event. The
> changelog should be adapated to clarify this.

I understand, how about this:
Fix: probes should be compared strictly by events metadata

Currently, events are compared using names and signatures. Events
with different payloads but identical name and signatures could
lead to corrupted trace as the Session Daemon would consider them
identical and give them the same event ID.

Events should be compared using the name, loglevel, fields and
model_emf_uri to ensure that their respective metadata is the same.

>
>>
>> Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
>> ---
>> src/bin/lttng-sessiond/Makefile.am   |   3 +-
>> src/bin/lttng-sessiond/ust-field-utils.c | 261 
>> +++
>> src/bin/lttng-sessiond/ust-field-utils.h |  29 
>> src/bin/lttng-sessiond/ust-registry.c|  40 -
>> tests/unit/Makefile.am   |   1 +
>> 5 files changed, 325 insertions(+), 9 deletions(-)
>> create mode 100644 src/bin/lttng-sessiond/ust-field-utils.c
>> create mode 100644 src/bin/lttng-sessiond/ust-field-utils.h
>>
>> diff --git a/src/bin/lttng-sessiond/Makefile.am
>> b/src/bin/lttng-sessiond/Makefile.am
>> index 413fe75..6fc1809 100644
>> --- a/src/bin/lttng-sessiond/Makefile.am
>> +++ b/src/bin/lttng-sessiond/Makefile.am
>> @@ -40,7 +40,8 @@ lttng_sessiond_SOURCES = utils.c utils.h \
>> if HAVE_LIBLTTNG_UST_CTL
>> lttng_sessiond_SOURCES += trace-ust.c ust-registry.c ust-app.c \
>>   ust-consumer.c ust-consumer.h ust-thread.c \
>> - ust-metadata.c ust-clock.h agent-thread.c 
>> agent-thread.h
>> + ust-metadata.c ust-clock.h agent-thread.c 
>> agent-thread.h \
>> + ust-field-utils.h ust-field-utils.c
>> endif
>>
>> # Add main.c at the end for compile order
>> diff --git a/src/bin/lttng-sessiond/ust-field-utils.c
>> b/src/bin/lttng-sessiond/ust-field-utils.c
>> new file mode 100644
>> index 000..3c2da14
>> --- /dev/null
>> +++ b/src/bin/lttng-sessiond/ust-field-utils.c
>> @@ -0,0 +1,261 @@
>> +/*
>> + * Copyright (C) 2018 - Francis Deslauriers 
>> <francis.deslauri...@efficios.com>
>> + *
>> + * This program is free software; you can redistribute it and/or modify it
>> + * under the terms of the GNU General Public License, version 2 only, as
>> + * published by the Free Software Foundation.
>> + *
>> + * This program is distributed in the hope that it will be useful, but 
>> WITHOUT
>> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
>> + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
>> + * more details.
>> + *
>> + * You should have received a copy of the GNU General Public License along 
>> with
>> + * this program; if not, write to the Free Software Foundation, Inc., 51
>> + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
>> + */
>> +
>> +#include 
>> +#include 
>> +
>> +#include "ust-field-utils.h"
>> +
>> +/*
>> + * The ustctl_field is made of a combinaison of C basic types
>
> combination
Done.
>
>> + * ustctl_basic_type and _ustctl_basic_type.
>> + *
>> + * ustctl_basic_type contains an enumeration describing the abstract type.
>> + * _ustctl_basic_type does _NOT_ contain an enumeration describing the
>> + * abstract type.
>> + *
>> + * A layer is needed to use the same code for both structures.
>> + * When dealing with _ustctl_basic_type, we need to use the abstract type of
>> + * the ustctl_type struct.
>> + */
>> +
>> +/*
>> + * Compare two ustctl_integer_type fields.
>> + * Returns 1 if both are identical.
>> + */
>> +static bool match_ustctl_field_integer(struct ustctl_integer_type *first,
>> + struct ustctl_integer_type *second)
>> +{
>> +   

Re: [lttng-dev] [PATCH lttng-ust 5/8] Fix: missing enum removal from the enum hashtable

2018-02-08 Thread Francis Deslauriers
2018-02-07 15:55 GMT-05:00 Mathieu Desnoyers <mathieu.desnoy...@efficios.com>:
> - On Feb 2, 2018, at 2:48 PM, Francis Deslauriers 
> francis.deslauri...@efficios.com wrote:
>
> Is it a fix or a preparation step for a new feature ?
Same thought process that with: cds_hlist_del(>hlist);

Thanks,
Francis
>
> Thanks,
>
> Mathieu
>
>> Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
>> ---
>> liblttng-ust/lttng-events.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/liblttng-ust/lttng-events.c b/liblttng-ust/lttng-events.c
>> index e8d4857..2b679b5 100644
>> --- a/liblttng-ust/lttng-events.c
>> +++ b/liblttng-ust/lttng-events.c
>> @@ -990,6 +990,7 @@ static
>> void _lttng_enum_destroy(struct lttng_enum *_enum)
>> {
>>   cds_list_del(&_enum->node);
>> + cds_hlist_del(&_enum->hlist);
>>   free(_enum);
>> }
>>
>> --
>> 2.7.4
>
> --
> Mathieu Desnoyers
> EfficiOS Inc.
> http://www.efficios.com



-- 
Francis Deslauriers
Software developer
EfficiOS inc.
___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


Re: [lttng-dev] [PATCH lttng-ust 2/8] Fix: missing event removal from the event hashtable

2018-02-08 Thread Francis Deslauriers
2018-02-07 15:50 GMT-05:00 Mathieu Desnoyers <mathieu.desnoy...@efficios.com>:
>
>
> - On Feb 2, 2018, at 2:48 PM, Francis Deslauriers 
> francis.deslauri...@efficios.com wrote:
>
> Is this really a fix ? Or is it a preparation step in order to be able to
> remove events before the end of the session lifetime ?

It's not a fix in the sense that it was not causing issues because it
was only called at session destruction.
But it's a fix in the sense that the _lttng_event_destroy function was
not doing all the work necessary to destroy an event passed as
argument. Taken by itself, a call to this function would leave one of
the hlists of the hash table in a incorrect state by freeing an
element without cds_hlist_del() it from the hlist before.

That was my thought process. What do you think?

Thank you,
Francis

> Thanks,
>
> Mathieu
>
>
>> Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
>> ---
>> liblttng-ust/lttng-events.c | 4 
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/liblttng-ust/lttng-events.c b/liblttng-ust/lttng-events.c
>> index f4a7ccc..7419f78 100644
>> --- a/liblttng-ust/lttng-events.c
>> +++ b/liblttng-ust/lttng-events.c
>> @@ -883,7 +883,11 @@ void _lttng_event_destroy(struct lttng_event *event)
>> {
>>   struct lttng_enabler_ref *enabler_ref, *tmp_enabler_ref;
>>
>> + /* Remove from event list. */
>>   cds_list_del(>node);
>> + /* Remove from event hash table. */
>> + cds_hlist_del(>hlist);
>> +
>>   lttng_destroy_context(event->ctx);
>>   lttng_free_event_filter_runtime(event);
>>   /* Free event enabler refs */
>> --
>> 2.7.4
>
> --
> Mathieu Desnoyers
> EfficiOS Inc.
> http://www.efficios.com



-- 
Francis Deslauriers
Software developer
EfficiOS inc.
___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


Re: [lttng-dev] [PATCH lttng-ust 6/8] Manually dlopen() liblttng-ust.so to prevent unloading

2018-02-08 Thread Francis Deslauriers
2018-02-07 15:59 GMT-05:00 Mathieu Desnoyers <mathieu.desnoy...@efficios.com>:
> - On Feb 2, 2018, at 2:48 PM, Francis Deslauriers 
> francis.deslauri...@efficios.com wrote:
>
>> dlopen() increments the refcount of the library thus preventing the
>> refcount to reach zero in the case of dlclose;
>
> The changelog and comment do not explain _why_ this is needed.
>
> The scenario is:
>
> - an application is _not_ linked against liblttng-ust.so
> - the application dlopen() a tracepoint probe,
> - the tracepoint probe .so is linked against liblttng-ust, and this is what 
> ends up
>   getting lttng-ust loaded,
>
> Given that our goal is to allow dlclose() of tracepoint probes (new 
> features), we don't
> want the side effect of this dlclose() to also try to unload liblttng-ust. 
> Because
> liblttng-ust does _not_ support being dlclose'd, we need to "pin" it in 
> memory by
> grabbing an extra reference on the library, with a NODELETE RTLD flag.
>
I agree, here is a revised version of the commit message and comment:

Manually dlopen() liblttng-ust.so to prevent unloading

The support of dlclose() allows for the following problematic scenario:
- Application is not linked against the liblttng-ust.so
- Application dlopen() a probe provider library that is linked against
liblttng-ust.so
- Application dlclose() the probe provider

In this scenario, the probe provider has a dependency on liblttng-ust.so, so
when it's loaded by the application, liblttng-ust.so is loaded too. The probe
provider library now has the only reference to the liblttng-ust.so library.
When the application calls dlclose() on it, all its references are dropped,
thus triggering the unloading of both the probe provider library and
liblttng-ust.so.

This scenario is problematic because the probe provider needs the
liblttng-ust.so library to complete its own unloading. As we can't control the
order in which libraries are unloaded, we must ensure that liblttng-ust.so is
not unloaded before the probe provider. To prevent that unloading, we pin it in
memory by grabbing an extra reference on the library, with a RTLD_NODELETE
flag. This will prevent the dynamic loader from ever removing the
liblttng-ust.so library from the process' address space.


Thank you,
Francis

> Thanks,
>
> Mathieu
>
>
>>
>> Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
>> ---
>> configure.ac  |  1 +
>> liblttng-ust/Makefile.am  |  2 ++
>> liblttng-ust/lttng-ust-comm.c | 22 ++
>> 3 files changed, 25 insertions(+)
>>
>> diff --git a/configure.ac b/configure.ac
>> index b0b4157..4fc6f9c 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -25,6 +25,7 @@ m4_define([UST_LIB_V_MINOR], [0])
>> m4_define([UST_LIB_V_PATCH], [0])
>>
>> AC_SUBST([LTTNG_UST_LIBRARY_VERSION],
>> [UST_LIB_V_MAJOR:UST_LIB_V_MINOR:UST_LIB_V_PATCH])
>> +AC_SUBST([LTTNG_UST_LIBRARY_VERSION_MAJOR], [UST_LIB_V_MAJOR])
>> # note: remember to update tracepoint.h dlopen() to match this version
>> # number. TODO: eventually automate by exporting the major number.
>>
>> diff --git a/liblttng-ust/Makefile.am b/liblttng-ust/Makefile.am
>> index 982be69..a7edfd5 100644
>> --- a/liblttng-ust/Makefile.am
>> +++ b/liblttng-ust/Makefile.am
>> @@ -60,6 +60,8 @@ liblttng_ust_runtime_la_SOURCES = \
>>   string-utils.c \
>>   string-utils.h
>>
>> +liblttng_ust_runtime_la_CFLAGS =
>> -DLTTNG_UST_LIBRARY_VERSION_MAJOR=\"$(LTTNG_UST_LIBRARY_VERSION_MAJOR)\"
>> +
>> if HAVE_PERF_EVENT
>> liblttng_ust_runtime_la_SOURCES += \
>>   lttng-context-perf-counters.c \
>> diff --git a/liblttng-ust/lttng-ust-comm.c b/liblttng-ust/lttng-ust-comm.c
>> index 511b9cf..ed912b8 100644
>> --- a/liblttng-ust/lttng-ust-comm.c
>> +++ b/liblttng-ust/lttng-ust-comm.c
>> @@ -27,6 +27,7 @@
>> #include 
>> #include 
>> #include 
>> +#include 
>> #include 
>> #include 
>> #include 
>> @@ -59,6 +60,9 @@
>> #include "../libringbuffer/getcpu.h"
>> #include "getenv.h"
>>
>> +/* Concatenate lttng ust shared library name with its major version number. 
>> */
>> +#define LTTNG_UST_LIB_SO_NAME "liblttng-ust.so."
>> LTTNG_UST_LIBRARY_VERSION_MAJOR
>> +
>> /*
>>  * Has lttng ust comm constructor been called ?
>>  */
>> @@ -1648,6 +1652,7 @@ void __attribute__((constructor)) lttng_ust_init(void)
>>   pthread_attr_t thread_attr;
>>   int timeout_mode;
>>   int ret;
>> + void *handle;
>>
>>   if (uatomic_xchg(, 1)

[lttng-dev] [PATCH lttng-ust v2 5/6] Rename lttng_ust_enum_get to lttng_ust_enum_get_from_desc

2018-02-09 Thread Francis Deslauriers
Change the prototype to take a descriptor instead of a char *.
Now that provider names can have duplicates enum names are not
necessarily unique.

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 include/lttng/ust-events.h |  5 +++--
 liblttng-ust-comm/lttng-ust-comm.c |  3 +--
 liblttng-ust/lttng-events.c| 14 ++
 liblttng-ust/ust-core.c| 11 +--
 4 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h
index 019b0eb..8673350 100644
--- a/include/lttng/ust-events.h
+++ b/include/lttng/ust-events.h
@@ -731,8 +731,9 @@ int lttng_session_active(void);
 typedef int (*t_statedump_func_ptr)(struct lttng_session *session);
 void lttng_handle_pending_statedump(void *owner);
 struct cds_list_head *_lttng_get_sessions(void);
-struct lttng_enum *lttng_ust_enum_get(struct lttng_session *session,
-   const char *enum_name);
+
+struct lttng_enum *lttng_ust_enum_get_from_desc(struct lttng_session *session,
+   const struct lttng_enum_desc *enum_desc);
 
 void lttng_ust_dl_update(void *ip);
 void lttng_ust_fixup_fd_tracker_tls(void);
diff --git a/liblttng-ust-comm/lttng-ust-comm.c 
b/liblttng-ust-comm/lttng-ust-comm.c
index 9fe6d28..d95e31d 100644
--- a/liblttng-ust-comm/lttng-ust-comm.c
+++ b/liblttng-ust-comm/lttng-ust-comm.c
@@ -874,8 +874,7 @@ int serialize_basic_type(struct lttng_session *session,
if (session) {
const struct lttng_enum *_enum;
 
-   _enum = lttng_ust_enum_get(session,
-   lbt->enumeration.desc->name);
+   _enum = lttng_ust_enum_get_from_desc(session, 
lbt->enumeration.desc);
if (!_enum)
return -EINVAL;
ubt->enumeration.id = _enum->id;
diff --git a/liblttng-ust/lttng-events.c b/liblttng-ust/lttng-events.c
index 57eb6f7..e130ec6 100644
--- a/liblttng-ust/lttng-events.c
+++ b/liblttng-ust/lttng-events.c
@@ -257,21 +257,19 @@ int lttng_enum_create(const struct lttng_enum_desc *desc,
const char *enum_name = desc->name;
struct lttng_enum *_enum;
struct cds_hlist_head *head;
-   struct cds_hlist_node *node;
int ret = 0;
size_t name_len = strlen(enum_name);
uint32_t hash;
int notify_socket;
 
+   /* Check if this enum is already registered for this session. */
hash = jhash(enum_name, name_len, 0);
head = >enums_ht.table[hash & (LTTNG_UST_ENUM_HT_SIZE - 1)];
-   cds_hlist_for_each_entry(_enum, node, head, hlist) {
-   assert(_enum->desc);
-   if (!strncmp(_enum->desc->name, desc->name,
-   LTTNG_UST_SYM_NAME_LEN - 1)) {
-   ret = -EEXIST;
-   goto exist;
-   }
+
+   _enum = lttng_ust_enum_get_from_desc(session, desc);
+   if (_enum) {
+   ret = -EEXIST;
+   goto exist;
}
 
notify_socket = lttng_get_notify_socket(session->owner);
diff --git a/liblttng-ust/ust-core.c b/liblttng-ust/ust-core.c
index 5355f5c..76f729a 100644
--- a/liblttng-ust/ust-core.c
+++ b/liblttng-ust/ust-core.c
@@ -63,21 +63,20 @@ void lttng_transport_unregister(struct lttng_transport 
*transport)
 /*
  * Needed by comm layer.
  */
-struct lttng_enum *lttng_ust_enum_get(struct lttng_session *session,
-   const char *enum_name)
+struct lttng_enum *lttng_ust_enum_get_from_desc(struct lttng_session *session,
+   const struct lttng_enum_desc *enum_desc)
 {
struct lttng_enum *_enum;
struct cds_hlist_head *head;
struct cds_hlist_node *node;
-   size_t name_len = strlen(enum_name);
+   size_t name_len = strlen(enum_desc->name);
uint32_t hash;
 
-   hash = jhash(enum_name, name_len, 0);
+   hash = jhash(enum_desc->name, name_len, 0);
head = >enums_ht.table[hash & (LTTNG_UST_ENUM_HT_SIZE - 1)];
cds_hlist_for_each_entry(_enum, node, head, hlist) {
assert(_enum->desc);
-   if (!strncmp(_enum->desc->name, enum_name,
-   LTTNG_UST_SYM_NAME_LEN - 1))
+   if (_enum->desc == enum_desc)
return _enum;
}
return NULL;
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-ust v2 2/6] Cleanup: Move version numbers in separate variables in configure script

2018-02-09 Thread Francis Deslauriers
Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 configure.ac | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index fb2f278..b0b4157 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,7 +20,11 @@ AC_SUBST([PATCHLEVEL_VERSION], [V_PATCH])
 # Following the numbering scheme proposed by libtool for the library version
 # 
http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
 # This is the library version of liblttng-ust.
-AC_SUBST([LTTNG_UST_LIBRARY_VERSION], [0:0:0])
+m4_define([UST_LIB_V_MAJOR], [0])
+m4_define([UST_LIB_V_MINOR], [0])
+m4_define([UST_LIB_V_PATCH], [0])
+
+AC_SUBST([LTTNG_UST_LIBRARY_VERSION], 
[UST_LIB_V_MAJOR:UST_LIB_V_MINOR:UST_LIB_V_PATCH])
 # note: remember to update tracepoint.h dlopen() to match this version
 # number. TODO: eventually automate by exporting the major number.
 
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-ust v2 0/6] Support provider duplicates and unloading

2018-02-09 Thread Francis Deslauriers
This patch set adds the support for duplicated probe providers and
support for unloading probe providers using dlclose().

It allows to advance scenarios where probe providers can be upgraded
during tracing.

For example, during tracing the user could dlopen() a new version of a probe
provider and dlclose() the previous one. All this without stop tracing.

A patch set for lttng-tools project is necessary to take advantage of
those changes.

The lttng-tools changes can be found on this branch of my Github fork:
https://github.com/frdeso/lttng-tools/commits/multi-lib-support

Francis Deslauriers (5):
  Cleanup: Move version numbers in separate variables in configure
script
  Add probe provider unregister function
  Manually dlopen() liblttng-ust.so to prevent unloading
  Rename lttng_ust_enum_get to lttng_ust_enum_get_from_desc
  Support unloading of probe providers

Mathieu Desnoyers (1):
  Remove duplicate provider name checks

 configure.ac |   7 +-
 include/lttng/ust-events.h   |   6 +-
 include/lttng/ust-tracepoint-event.h |   2 +-
 liblttng-ust-comm/lttng-ust-comm.c   |   3 +-
 liblttng-ust/Makefile.am |   2 +
 liblttng-ust/lttng-events.c  | 135 ++-
 liblttng-ust/lttng-probes.c  |  28 ++--
 liblttng-ust/lttng-ust-comm.c|  25 +++
 liblttng-ust/tracepoint.c|  43 ---
 liblttng-ust/ust-core.c  |  11 ++-
 10 files changed, 199 insertions(+), 63 deletions(-)

-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-ust v2 6/6] Support unloading of probe providers

2018-02-09 Thread Francis Deslauriers
With this commit, it's now possible to dlclose() a library containing an
actively used probe provider.

The destructor of such library will now iterate over all the sessions
and over all probe definitions to unregister them from the respective
callsites in the process.

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---

v2:
Coding style fixes.
---
 liblttng-ust/lttng-events.c |  2 +-
 liblttng-ust/lttng-probes.c |  5 -
 liblttng-ust/tracepoint.c   | 43 ++-
 3 files changed, 39 insertions(+), 11 deletions(-)

diff --git a/liblttng-ust/lttng-events.c b/liblttng-ust/lttng-events.c
index e130ec6..255c4b9 100644
--- a/liblttng-ust/lttng-events.c
+++ b/liblttng-ust/lttng-events.c
@@ -798,7 +798,7 @@ void lttng_probe_provider_unregister_events(struct 
lttng_probe_desc *provider_de
struct lttng_session *session;
struct cds_hlist_head *head;
struct lttng_event *event;
-   int i;
+   unsigned int i, j;
 
/* Get handle on list of sessions. */
sessionsp = _lttng_get_sessions();
diff --git a/liblttng-ust/lttng-probes.c b/liblttng-ust/lttng-probes.c
index a09497f..862b19e 100644
--- a/liblttng-ust/lttng-probes.c
+++ b/liblttng-ust/lttng-probes.c
@@ -226,7 +226,10 @@ void lttng_probe_unregister(struct lttng_probe_desc *desc)
cds_list_del(>head);
else
cds_list_del(>lazy_init_head);
-   DBG("just unregistered probe %s", desc->provider);
+
+   lttng_probe_provider_unregister_events(desc);
+   DBG("just unregistered probes of provider %s", desc->provider);
+
ust_unlock();
 }
 
diff --git a/liblttng-ust/tracepoint.c b/liblttng-ust/tracepoint.c
index 14b8231..2c25d46 100644
--- a/liblttng-ust/tracepoint.c
+++ b/liblttng-ust/tracepoint.c
@@ -107,8 +107,8 @@ struct tracepoint_entry {
struct lttng_ust_tracepoint_probe *probes;
int refcount;   /* Number of times armed. 0 if disarmed. */
int callsite_refcount;  /* how many libs use this tracepoint */
-   const char *signature;
-   char name[0];
+   char *signature;
+   char *name;
 };
 
 struct tp_probes {
@@ -132,6 +132,7 @@ struct callsite_entry {
struct cds_hlist_node hlist;/* hash table node */
struct cds_list_head node;  /* lib list of callsites node */
struct lttng_ust_tracepoint *tp;
+   bool tp_entry_callsite_ref; /* Has a tp_entry took a ref on this 
callsite */
 };
 
 /* coverity[+alloc] */
@@ -284,6 +285,8 @@ static struct tracepoint_entry *add_tracepoint(const char 
*name,
struct cds_hlist_node *node;
struct tracepoint_entry *e;
size_t name_len = strlen(name);
+   size_t sig_len = strlen(signature);
+   size_t sig_off, name_off;
uint32_t hash;
 
if (name_len > LTTNG_UST_SYM_NAME_LEN - 1) {
@@ -298,19 +301,29 @@ static struct tracepoint_entry *add_tracepoint(const char 
*name,
return ERR_PTR(-EEXIST);/* Already there */
}
}
+
/*
-* Using zmalloc here to allocate a variable length element. Could
-* cause some memory fragmentation if overused.
+* Using zmalloc here to allocate a variable length elements: name and
+* signature. Could cause some memory fragmentation if overused.
 */
-   e = zmalloc(sizeof(struct tracepoint_entry) + name_len + 1);
+   name_off = sizeof(struct tracepoint_entry);
+   sig_off = name_off + name_len + 1;
+
+   e = zmalloc(sizeof(struct tracepoint_entry) + name_len + 1 + sig_len + 
1);
if (!e)
return ERR_PTR(-ENOMEM);
-   memcpy(>name[0], name, name_len + 1);
+   e->name = (char *) e + name_off;
+   memcpy(e->name, name, name_len + 1);
e->name[name_len] = '\0';
+
+   e->signature = (char *) e + sig_off;
+   memcpy(e->signature, signature, sig_len + 1);
+   e->signature[sig_len] = '\0';
+
e->probes = NULL;
e->refcount = 0;
e->callsite_refcount = 0;
-   e->signature = signature;
+
cds_hlist_add_head(>hlist, head);
return e;
 }
@@ -405,6 +418,7 @@ static void add_callsite(struct tracepoint_lib * lib, 
struct lttng_ust_tracepoin
if (!tp_entry)
return;
tp_entry->callsite_refcount++;
+   e->tp_entry_callsite_ref = true;
 }
 
 /*
@@ -417,7 +431,8 @@ static void remove_callsite(struct callsite_entry *e)
 
tp_entry = get_tracepoint(e->tp->name);
if (tp_entry) {
-   tp_entry->callsite_refcount--;
+   if (e->tp_entry_callsite_ref)
+   tp_entry->callsite_refcount--;
if (tp_entry->callsite_refcount == 0)
disable_tracepoint(e->tp);
}
@@ -453,10 +468,15 @@ static void tracepoint

[lttng-dev] [PATCH lttng-ust v2 1/6] Remove duplicate provider name checks

2018-02-09 Thread Francis Deslauriers
From: Mathieu Desnoyers <mathieu.desnoy...@efficios.com>

It's now possible to register a probe provider with a name that has
already been registered. This is useful when wanting to load a new
version of a shared library on a already running process.

Changes are necessary in the lttng-session daemon to support cases where
the newly register event has a different probe payload.

Taking a simple case where a probe provider is registered twice, the
tracepoint call site will have two probes registered to it and thus will
generate two events in the trace.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoy...@efficios.com>
Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 include/lttng/ust-tracepoint-event.h |  2 +-
 liblttng-ust/lttng-events.c  | 11 ---
 liblttng-ust/lttng-probes.c  | 23 +--
 3 files changed, 2 insertions(+), 34 deletions(-)

diff --git a/include/lttng/ust-tracepoint-event.h 
b/include/lttng/ust-tracepoint-event.h
index 15399c7..ec292d2 100644
--- a/include/lttng/ust-tracepoint-event.h
+++ b/include/lttng/ust-tracepoint-event.h
@@ -1007,7 +1007,7 @@ _TP_COMBINE_TOKENS(__lttng_events_init__, 
TRACEPOINT_PROVIDER)(void)
_TP_COMBINE_TOKENS(__tracepoint_provider_check_, TRACEPOINT_PROVIDER)();
ret = lttng_probe_register(&_TP_COMBINE_TOKENS(__probe_desc___, 
TRACEPOINT_PROVIDER));
if (ret) {
-   fprintf(stderr, "LTTng-UST: Error (%d) while registering 
tracepoint probe. Duplicate registration of tracepoint probes having the same 
name is not allowed.\n", ret);
+   fprintf(stderr, "LTTng-UST: Error (%d) while registering 
tracepoint probe.\n", ret);
abort();
}
 }
diff --git a/liblttng-ust/lttng-events.c b/liblttng-ust/lttng-events.c
index bfdae4f..f4a7ccc 100644
--- a/liblttng-ust/lttng-events.c
+++ b/liblttng-ust/lttng-events.c
@@ -537,7 +537,6 @@ int lttng_event_create(const struct lttng_event_desc *desc,
struct lttng_event *event;
struct lttng_session *session = chan->session;
struct cds_hlist_head *head;
-   struct cds_hlist_node *node;
int ret = 0;
size_t name_len = strlen(event_name);
uint32_t hash;
@@ -546,15 +545,6 @@ int lttng_event_create(const struct lttng_event_desc *desc,
 
hash = jhash(event_name, name_len, 0);
head = >session->events_ht.table[hash & (LTTNG_UST_EVENT_HT_SIZE 
- 1)];
-   cds_hlist_for_each_entry(event, node, head, hlist) {
-   assert(event->desc);
-   if (!strncmp(event->desc->name, desc->name,
-   LTTNG_UST_SYM_NAME_LEN - 1)
-   && chan == event->chan) {
-   ret = -EEXIST;
-   goto exist;
-   }
-   }
 
notify_socket = lttng_get_notify_socket(session->owner);
if (notify_socket < 0) {
@@ -623,7 +613,6 @@ sessiond_register_error:
 cache_error:
 create_enum_error:
 socket_error:
-exist:
return ret;
 }
 
diff --git a/liblttng-ust/lttng-probes.c b/liblttng-ust/lttng-probes.c
index 390265a..a09497f 100644
--- a/liblttng-ust/lttng-probes.c
+++ b/liblttng-ust/lttng-probes.c
@@ -148,20 +148,6 @@ struct cds_list_head *lttng_get_probe_list_head(void)
 }
 
 static
-const struct lttng_probe_desc *find_provider(const char *provider)
-{
-   struct lttng_probe_desc *iter;
-   struct cds_list_head *probe_list;
-
-   probe_list = lttng_get_probe_list_head();
-   cds_list_for_each_entry(iter, probe_list, head) {
-   if (!strcmp(iter->provider, provider))
-   return iter;
-   }
-   return NULL;
-}
-
-static
 int check_provider_version(struct lttng_probe_desc *desc)
 {
/*
@@ -206,13 +192,6 @@ int lttng_probe_register(struct lttng_probe_desc *desc)
 
ust_lock_nocheck();
 
-   /*
-* Check if the provider has already been registered.
-*/
-   if (find_provider(desc->provider)) {
-   ret = -EEXIST;
-   goto end;
-   }
cds_list_add(>lazy_init_head, _probe_init);
desc->lazy = 1;
DBG("adding probe %s containing %u events to lazy registration list",
@@ -224,7 +203,7 @@ int lttng_probe_register(struct lttng_probe_desc *desc)
 */
if (lttng_session_active())
fixup_lazy_probes();
-end:
+
ust_unlock();
return ret;
 }
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-tools v2 5/5] Tests: add duplicated providers tests

2018-02-09 Thread Francis Deslauriers
Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 configure.ac|   1 +
 tests/fast_regression   |   1 +
 tests/regression/ust/multi-lib/Makefile.am  | 114 +++
 tests/regression/ust/multi-lib/README   |  21 ++
 tests/regression/ust/multi-lib/callsites.c  |  34 +++
 tests/regression/ust/multi-lib/callsites.h  |  21 ++
 tests/regression/ust/multi-lib/multi-lib-test.c | 251 +++
 tests/regression/ust/multi-lib/probes.c |  18 ++
 tests/regression/ust/multi-lib/probes.h | 195 ++
 tests/regression/ust/multi-lib/test_multi_lib   | 262 
 10 files changed, 918 insertions(+)
 create mode 100644 tests/regression/ust/multi-lib/Makefile.am
 create mode 100644 tests/regression/ust/multi-lib/README
 create mode 100644 tests/regression/ust/multi-lib/callsites.c
 create mode 100644 tests/regression/ust/multi-lib/callsites.h
 create mode 100644 tests/regression/ust/multi-lib/multi-lib-test.c
 create mode 100644 tests/regression/ust/multi-lib/probes.c
 create mode 100644 tests/regression/ust/multi-lib/probes.h
 create mode 100755 tests/regression/ust/multi-lib/test_multi_lib

diff --git a/configure.ac b/configure.ac
index b6ea39c..e22872c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1090,6 +1090,7 @@ AC_CONFIG_FILES([
tests/regression/ust/buffers-pid/Makefile
tests/regression/ust/periodical-metadata-flush/Makefile
tests/regression/ust/multi-session/Makefile
+   tests/regression/ust/multi-lib/Makefile
tests/regression/ust/overlap/Makefile
tests/regression/ust/overlap/demo/Makefile
tests/regression/ust/linking/Makefile
diff --git a/tests/fast_regression b/tests/fast_regression
index bbce068..f76b53d 100644
--- a/tests/fast_regression
+++ b/tests/fast_regression
@@ -21,6 +21,7 @@ regression/tools/regen-statedump/test_ust
 regression/ust/before-after/test_before_after
 regression/ust/buffers-pid/test_buffers_pid
 regression/ust/multi-session/test_multi_session
+regression/ust/multi-lib/test_multi_lib
 regression/ust/nprocesses/test_nprocesses
 regression/ust/overlap/test_overlap
 regression/ust/java-jul/test_java_jul
diff --git a/tests/regression/ust/multi-lib/Makefile.am 
b/tests/regression/ust/multi-lib/Makefile.am
new file mode 100644
index 000..f78ce7f
--- /dev/null
+++ b/tests/regression/ust/multi-lib/Makefile.am
@@ -0,0 +1,114 @@
+noinst_SCRIPTS = test_multi_lib
+noinst_PROGRAMS = exec-with-callsites exec-without-callsites
+
+exec_with_callsites_SOURCES = multi-lib-test.c callsites.c
+exec_with_callsites_LDFLAGS = -ldl -lpopt
+exec_with_callsites_CFLAGS = -DHAS_CALLSITES=1
+
+exec_without_callsites_SOURCES = multi-lib-test.c
+exec_without_callsites_LDFLAGS = -ldl -lpopt -llttng-ust
+exec_without_callsites_LDADD = probes.o
+exec_without_callsites_CFLAGS = -DHAS_CALLSITES=0
+
+PROBES_SRC=probes.c probes.h
+PROBES_LDF=-shared -module -llttng-ust -avoid-version -rpath 
$(abs_builddir)/.libs/
+PROBES_CF=-c -I$(srcdir)/
+
+probes.o: probes.c probes.h
+   $(CC) $(PROBES_CF) -o $@ $<
+
+noinst_LTLIBRARIES = libprobes_a.la libprobes_a_prime.la \
+   libprobes_b.la libprobes_c.la libprobes_c_prime.la \
+   libprobes_d.la libprobes_e.la libprobes_f.la \
+   libprobes_g.la libprobes_h.la libprobes_i.la \
+   libprobes_j.la libprobes_k.la libprobes_l.la \
+   libprobes_m.la libprobes_n.la libprobes_o.la \
+   libprobes_p.la
+
+noinst_LTLIBRARIES += libcallsites_1.la libcallsites_2.la
+
+CALLSITES_SRC=callsites.c callsites.h
+CALLSITES_LDF=-shared -module -llttng-ust -avoid-version -rpath 
$(abs_builddir)/.libs/
+CALLSITES_CF=-c -I.
+
+libprobes_a_la_SOURCES = $(PROBES_SRC)
+libprobes_a_la_LDFLAGS = $(PROBES_LDF)
+libprobes_a_la_CFLAGS = $(PROBES_CF) -DACTIVATE_PROBES_A
+
+libprobes_a_prime_la_SOURCES = $(PROBES_SRC)
+libprobes_a_prime_la_LDFLAGS = $(PROBES_LDF)
+libprobes_a_prime_la_CFLAGS = $(PROBES_CF) -DACTIVATE_PROBES_A
+
+libprobes_b_la_SOURCES = $(PROBES_SRC)
+libprobes_b_la_LDFLAGS = $(PROBES_LDF)
+libprobes_b_la_CFLAGS = $(PROBES_CF) -DACTIVATE_PROBES_B
+
+libprobes_c_la_SOURCES = $(PROBES_SRC)
+libprobes_c_la_LDFLAGS = $(PROBES_LDF)
+libprobes_c_la_CFLAGS = $(PROBES_CF) -DACTIVATE_PROBES_C
+
+libprobes_c_prime_la_SOURCES = $(PROBES_SRC)
+libprobes_c_prime_la_LDFLAGS = $(PROBES_LDF)
+libprobes_c_prime_la_CFLAGS = $(PROBES_CF) -DACTIVATE_PROBES_C
+
+libprobes_d_la_SOURCES = $(PROBES_SRC)
+libprobes_d_la_LDFLAGS = $(PROBES_LDF)
+libprobes_d_la_CFLAGS = $(PROBES_CF) -DACTIVATE_PROBES_D
+
+libprobes_e_la_SOURCES = $(PROBES_SRC)
+libprobes_e_la_LDFLAGS = $(PROBES_LDF)
+libprobes_e_la_CFLAGS = $(PROBES_CF) -DACTIVATE_PROBES_E
+
+libprobes_f_la_SOURCES = $(PROBES_SRC)
+libprobes_f_la_LDFLAGS = $(PROBES_LDF)
+libprobes_f_la_CFLAGS = $(PROBES_CF) -DACTIVATE

[lttng-dev] [PATCH lttng-tools v2 1/5] Fix: probes should be compared strictly by events metadata

2018-02-09 Thread Francis Deslauriers
Currently, events are compared using names and signatures. Events
with different payloads but identical name and signatures could
lead to corrupted trace because the Session Daemon would consider them
identical and give them the same event ID.

Events should be compared using the name, loglevel, fields and
model_emf_uri to ensure that their respective metadata is the same.

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 src/bin/lttng-sessiond/Makefile.am   |   3 +-
 src/bin/lttng-sessiond/ust-field-utils.c | 289 +++
 src/bin/lttng-sessiond/ust-field-utils.h |  29 
 src/bin/lttng-sessiond/ust-registry.c|  42 -
 tests/unit/Makefile.am   |   1 +
 5 files changed, 354 insertions(+), 10 deletions(-)
 create mode 100644 src/bin/lttng-sessiond/ust-field-utils.c
 create mode 100644 src/bin/lttng-sessiond/ust-field-utils.h

diff --git a/src/bin/lttng-sessiond/Makefile.am 
b/src/bin/lttng-sessiond/Makefile.am
index 413fe75..6fc1809 100644
--- a/src/bin/lttng-sessiond/Makefile.am
+++ b/src/bin/lttng-sessiond/Makefile.am
@@ -40,7 +40,8 @@ lttng_sessiond_SOURCES = utils.c utils.h \
 if HAVE_LIBLTTNG_UST_CTL
 lttng_sessiond_SOURCES += trace-ust.c ust-registry.c ust-app.c \
ust-consumer.c ust-consumer.h ust-thread.c \
-   ust-metadata.c ust-clock.h agent-thread.c agent-thread.h
+   ust-metadata.c ust-clock.h agent-thread.c 
agent-thread.h \
+   ust-field-utils.h ust-field-utils.c
 endif
 
 # Add main.c at the end for compile order
diff --git a/src/bin/lttng-sessiond/ust-field-utils.c 
b/src/bin/lttng-sessiond/ust-field-utils.c
new file mode 100644
index 000..8388052
--- /dev/null
+++ b/src/bin/lttng-sessiond/ust-field-utils.c
@@ -0,0 +1,289 @@
+/*
+ * Copyright (C) 2018 - Francis Deslauriers <francis.deslauri...@efficios.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License, version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include 
+#include 
+
+#include "ust-field-utils.h"
+
+/*
+ * The ustctl_field is made of a combination of C basic types
+ * ustctl_basic_type and _ustctl_basic_type.
+ *
+ * ustctl_basic_type contains an enumeration describing the abstract type.
+ * _ustctl_basic_type does _NOT_ contain an enumeration describing the
+ * abstract type.
+ *
+ * A layer is needed to use the same code for both structures.
+ * When dealing with _ustctl_basic_type, we need to use the abstract type of
+ * the ustctl_type struct.
+ */
+
+/*
+ * Compare two ustctl_integer_type fields.
+ * Returns 1 if both are identical.
+ */
+static bool match_ustctl_field_integer(struct ustctl_integer_type *first,
+   struct ustctl_integer_type *second)
+{
+   if (first->size != second->size) {
+   goto no_match;
+   }
+   if (first->alignment != second->alignment) {
+   goto no_match;
+   }
+   if (first->signedness != second->signedness) {
+   goto no_match;
+   }
+   if (first->encoding != second->encoding) {
+   goto no_match;
+   }
+   if (first->base != second->base) {
+   goto no_match;
+   }
+   if (first->reverse_byte_order != second->reverse_byte_order) {
+   goto no_match;
+   }
+
+   return true;
+
+no_match:
+   return false;
+}
+
+/*
+ * Compare two _ustctl_basic_type fields known to be of type integer.
+ * Returns 1 if both are identical.
+ */
+static bool match_ustctl_field_integer_from_raw_basic_type(
+   union _ustctl_basic_type *first, union 
_ustctl_basic_type *second)
+{
+   return match_ustctl_field_integer(>integer, >integer);
+}
+
+/*
+ * Compare two _ustctl_basic_type fields known to be of type enum.
+ * Returns 1 if both are identical.
+ */
+static bool match_ustctl_field_enum_from_raw_basic_type(
+   union _ustctl_basic_type *first, union 
_ustctl_basic_type *second)
+{
+   /*
+* Compare enumeration ID. Enumeration ID is provided to the 
application by
+* the session daemon before event registration.
+*/
+   if (first->enumeration.id != second->enumeration.id) {
+   goto no_match;
+   }
+
+   /*
+* Sanity check of the name and container

[lttng-dev] [PATCH lttng-tools v2 0/5] Support probes with the same name but different event payload

2018-02-09 Thread Francis Deslauriers
This patch set allows for multiple probes with the same name to be
hooked on the same callsite. Right now, the Session Daemon only
considers the name and signature of the events to determine if two
events are identical. This could lead to trace corruptions when two
probes would have the same name and signature but really different
binary trace layouts.

We now compare probes by doing a deep compare of every field. If two
events are _exactly_ the same and have the same metadata then the same
event ID will be used, if they are different a new event ID is created.

When used with its corresponding UST patch set[1], it allows for dynamic
library upgrade scenarios during tracing. The user can now dlopen a new
version of a provider library and dlclose an old version without
restarting the process.

This patch set also includes regression tests for both the deep
comparaison and the newly added dlclose capability.

[1]: https://github.com/frdeso/lttng-ust/tree/dlclose-support

Francis Deslauriers (5):
  Fix: probes should be compared strictly by events metadata
  Fix: calling ht_{hash, match}_enum with wrong argument
  Tests: allow the use of regular expressions to match events
  Tests: add function to validate the number of an event name in
metadata
  Tests: add duplicated providers tests

 configure.ac|   1 +
 src/bin/lttng-sessiond/Makefile.am  |   3 +-
 src/bin/lttng-sessiond/ust-field-utils.c| 289 
 src/bin/lttng-sessiond/ust-field-utils.h|  29 +++
 src/bin/lttng-sessiond/ust-registry.c   |  46 +++-
 tests/fast_regression   |   1 +
 tests/regression/ust/multi-lib/Makefile.am  | 114 ++
 tests/regression/ust/multi-lib/README   |  21 ++
 tests/regression/ust/multi-lib/callsites.c  |  34 +++
 tests/regression/ust/multi-lib/callsites.h  |  21 ++
 tests/regression/ust/multi-lib/multi-lib-test.c | 251 
 tests/regression/ust/multi-lib/probes.c |  18 ++
 tests/regression/ust/multi-lib/probes.h | 195 
 tests/regression/ust/multi-lib/test_multi_lib   | 262 +
 tests/unit/Makefile.am  |   1 +
 tests/utils/utils.sh|  27 ++-
 16 files changed, 1299 insertions(+), 14 deletions(-)
 create mode 100644 src/bin/lttng-sessiond/ust-field-utils.c
 create mode 100644 src/bin/lttng-sessiond/ust-field-utils.h
 create mode 100644 tests/regression/ust/multi-lib/Makefile.am
 create mode 100644 tests/regression/ust/multi-lib/README
 create mode 100644 tests/regression/ust/multi-lib/callsites.c
 create mode 100644 tests/regression/ust/multi-lib/callsites.h
 create mode 100644 tests/regression/ust/multi-lib/multi-lib-test.c
 create mode 100644 tests/regression/ust/multi-lib/probes.c
 create mode 100644 tests/regression/ust/multi-lib/probes.h
 create mode 100755 tests/regression/ust/multi-lib/test_multi_lib

-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-tools v2 3/5] Tests: allow the use of regular expressions to match events

2018-02-09 Thread Francis Deslauriers
Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 tests/utils/utils.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh
index e8dfcda..9bf1fcc 100644
--- a/tests/utils/utils.sh
+++ b/tests/utils/utils.sh
@@ -1457,7 +1457,7 @@ function validate_trace_exp()
which $BABELTRACE_BIN >/dev/null
skip $? -ne 0 "Babeltrace binary not found. Skipping trace validation"
 
-   traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep ${event_exp} | 
wc -l)
+   traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep 
--extended-regexp ${event_exp} | wc -l)
if [ "$traced" -ne 0 ]; then
pass "Validate trace for expression '${event_exp}', $traced 
events"
else
@@ -1476,7 +1476,7 @@ function validate_trace_only_exp()
which $BABELTRACE_BIN >/dev/null
skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches"
 
-   local count=$($BABELTRACE_BIN $trace_path | grep ${event_exp} | wc -l)
+   local count=$($BABELTRACE_BIN $trace_path | grep --extended-regexp 
${event_exp} | wc -l)
local total=$($BABELTRACE_BIN $trace_path | wc -l)
 
if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-tools v2 2/5] Fix: calling ht_{hash, match}_enum with wrong argument

2018-02-09 Thread Francis Deslauriers
ht_hash_enum and ht_match_enum are currently called with the address of the
pointer to a ust_registry_enum rather than the expected pointer to a
ust_registry_enum. This means that those function calls would end up
using garbage for hashing and comparing.

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 src/bin/lttng-sessiond/ust-registry.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/bin/lttng-sessiond/ust-registry.c 
b/src/bin/lttng-sessiond/ust-registry.c
index a875515..19bd30f 100644
--- a/src/bin/lttng-sessiond/ust-registry.c
+++ b/src/bin/lttng-sessiond/ust-registry.c
@@ -558,8 +558,8 @@ struct ust_registry_enum *
struct lttng_ht_iter iter;
 
cds_lfht_lookup(session->enums->ht,
-   ht_hash_enum((void *) _enum_lookup, lttng_ht_seed),
-   ht_match_enum, _enum_lookup, );
+   ht_hash_enum((void *) reg_enum_lookup, lttng_ht_seed),
+   ht_match_enum, reg_enum_lookup, );
node = lttng_ht_iter_get_node_str();
if (!node) {
goto end;
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-tools v2 4/5] Tests: add function to validate the number of an event name in metadata

2018-02-09 Thread Francis Deslauriers
Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 tests/utils/utils.sh | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh
index 9bf1fcc..60df376 100644
--- a/tests/utils/utils.sh
+++ b/tests/utils/utils.sh
@@ -1343,6 +1343,29 @@ function add_context_kernel_fail()
add_context_lttng 1 -k "$@"
 }
 
+function validate_metadata_event ()
+{
+   local event_name=$1
+   local nr_event_id=$2
+   local trace_path=$3
+
+   local metadata_file=$(find $trace_path | grep metadata)
+   local metadata_path=$(dirname $metadata_file)
+
+   which $BABELTRACE_BIN >/dev/null
+   skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches"
+
+   local count=$($BABELTRACE_BIN --output-format=ctf-metadata 
$metadata_path | grep $event_name | wc -l)
+
+   if [ "$count" -ne "$nr_event_id" ]; then
+   fail "Metadata match with the metadata of $count event(s) named 
$event_name"
+   diag "$count matching event id found in metadata"
+   else
+   pass "Metadata match with the metadata of $count event(s) named 
$event_name"
+   fi
+
+}
+
 function trace_matches ()
 {
local event_name=$1
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-ust v2 4/6] Manually dlopen() liblttng-ust.so to prevent unloading

2018-02-09 Thread Francis Deslauriers
The support of probe provider dlclose() allows for the following problematic
scenario:
- Application is not linked against the liblttng-ust.so
- Application dlopen() a probe provider library that is linked against
liblttng-ust.so
- Application dlclose() the probe provider

In this scenario, the probe provider has a dependency on liblttng-ust.so, so
when it's loaded by the application, liblttng-ust.so is loaded too. The probe
provider library now has the only reference to the liblttng-ust.so library.
When the application calls dlclose() on it, all its references are dropped,
thus triggering the unloading of both the probe provider library and
liblttng-ust.so.

This scenario is problematic because lttng ust_listener_threads are in DETACHED
state. We cannot join them and therefore we cannot unload the library
containing the code they run. Only the operating system can free those
resources.

The reason why those threads are in DETACHED state is to quickly teardown
applications on process exit.

A possible solution to investigate: if we can determine whether liblttng-ust.so
is being dlopen (directly or undirectly) or it's linked against the
application, we could set the detached state accordingly.

To prevent that unloading, we pin it in memory by grabbing an extra reference
on the library, with a RTLD_NODELETE flag. This will prevent the dynamic loader
from ever removing the liblttng-ust.so library from the process' address space.

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---

v2:
Rephrase commit message and comment
---

 configure.ac  |  1 +
 liblttng-ust/Makefile.am  |  2 ++
 liblttng-ust/lttng-ust-comm.c | 25 +
 3 files changed, 28 insertions(+)

diff --git a/configure.ac b/configure.ac
index b0b4157..4fc6f9c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -25,6 +25,7 @@ m4_define([UST_LIB_V_MINOR], [0])
 m4_define([UST_LIB_V_PATCH], [0])
 
 AC_SUBST([LTTNG_UST_LIBRARY_VERSION], 
[UST_LIB_V_MAJOR:UST_LIB_V_MINOR:UST_LIB_V_PATCH])
+AC_SUBST([LTTNG_UST_LIBRARY_VERSION_MAJOR], [UST_LIB_V_MAJOR])
 # note: remember to update tracepoint.h dlopen() to match this version
 # number. TODO: eventually automate by exporting the major number.
 
diff --git a/liblttng-ust/Makefile.am b/liblttng-ust/Makefile.am
index 982be69..a7edfd5 100644
--- a/liblttng-ust/Makefile.am
+++ b/liblttng-ust/Makefile.am
@@ -60,6 +60,8 @@ liblttng_ust_runtime_la_SOURCES = \
string-utils.c \
string-utils.h
 
+liblttng_ust_runtime_la_CFLAGS = 
-DLTTNG_UST_LIBRARY_VERSION_MAJOR=\"$(LTTNG_UST_LIBRARY_VERSION_MAJOR)\"
+
 if HAVE_PERF_EVENT
 liblttng_ust_runtime_la_SOURCES += \
lttng-context-perf-counters.c \
diff --git a/liblttng-ust/lttng-ust-comm.c b/liblttng-ust/lttng-ust-comm.c
index 511b9cf..57e5ce6 100644
--- a/liblttng-ust/lttng-ust-comm.c
+++ b/liblttng-ust/lttng-ust-comm.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -59,6 +60,9 @@
 #include "../libringbuffer/getcpu.h"
 #include "getenv.h"
 
+/* Concatenate lttng ust shared library name with its major version number. */
+#define LTTNG_UST_LIB_SO_NAME "liblttng-ust.so." 
LTTNG_UST_LIBRARY_VERSION_MAJOR
+
 /*
  * Has lttng ust comm constructor been called ?
  */
@@ -1648,6 +1652,7 @@ void __attribute__((constructor)) lttng_ust_init(void)
pthread_attr_t thread_attr;
int timeout_mode;
int ret;
+   void *handle;
 
if (uatomic_xchg(, 1) == 1)
return;
@@ -1662,6 +1667,26 @@ void __attribute__((constructor)) lttng_ust_init(void)
lttng_ust_loaded = 1;
 
/*
+* We need to ensure that the liblttng-ust library is not unloaded to 
avoid
+* the unloading of code used by the ust_listener_threads as we can not
+* reliably know when they exited. To do that, manually load
+* liblttng-ust.so to increment the dynamic loader's internal refcount 
for
+* this library so it never becomes zero, thus never gets unloaded from 
the
+* address space of the process. Since we are already running in the
+* constructor of the LTTNG_UST_LIB_SO_NAME library, calling dlopen will
+* simply increment the refcount and no additionnal work is needed by 
the
+* dynamic loader as the shared library is already loaded in the address
+* space. As a safe guard, we use the RTLD_NODELETE flag to prevent
+* unloading of the UST library if its refcount becomes zero (which 
should
+* never happen). Do the return value check but discard the handle at 
the
+* end of the function as it's not needed.
+*/
+   handle = dlopen(LTTNG_UST_LIB_SO_NAME, RTLD_LAZY | RTLD_NODELETE);
+   if (!handle) {
+   ERR("dlopen of liblttng-ust shared library (%s).", 
LTTNG_UST_LIB_SO_NAME);
+   }
+
+   /*
 * We want precise control over the 

[lttng-dev] [PATCH lttng-ust] Fix: destructors do not run on probe provider dlclose

2018-02-21 Thread Francis Deslauriers
Calling dlclose on a probe provider library does not unregister the
probes from the callsites as the destructors are not executed.

The __tracepoints__disable_destructors weak symbol was exposed by probe
providers, liblttng-ust.so and liblttng-ust-tracepoint.so libraries. If
a probe provider was loaded first into the address space, its definition
would be binded to the symbol. All the subsequent libraries using the
symbol would use the existing definition of the symbol. Thus creating a
a situation where liblttng-ust.so or liblttng-ust-tracepoint.so would
have a dependency on the probe provider library.

This was preventing the dynamic loader from unloading the library as it
was still in use by other libraries. Because of this, the execution of
its destructors and the unregistration of the probes was postponed.

To overcome this issue, we no longer expose this symbol in the
tracepoint.h file to remove the explicit dependency of the probe
provider on the symbol. We instead use the existing dlopen handle on
liblttng-ust-tracepoint.so to get an handle on a getter and setter
functions for this value.

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 include/lttng/tracepoint.h | 31 ++-
 liblttng-ust/tracepoint.c  | 26 ++
 2 files changed, 40 insertions(+), 17 deletions(-)

diff --git a/include/lttng/tracepoint.h b/include/lttng/tracepoint.h
index 39f2c4d..95f5de9 100644
--- a/include/lttng/tracepoint.h
+++ b/include/lttng/tracepoint.h
@@ -221,26 +221,13 @@ struct lttng_ust_tracepoint_dlopen {
void (*rcu_read_lock_sym_bp)(void);
void (*rcu_read_unlock_sym_bp)(void);
void *(*rcu_dereference_sym_bp)(void *p);
+   void (*tracepoint_set_destructors_disabled)(int is_disabled);
+   int (*tracepoint_get_destructors_disabled)(void);
 };
 
 extern struct lttng_ust_tracepoint_dlopen tracepoint_dlopen;
 extern struct lttng_ust_tracepoint_dlopen *tracepoint_dlopen_ptr;
 
-/* Disable tracepoint destructors. */
-int __tracepoints__disable_destructors __attribute__((weak));
-
-/*
- * Programs that have threads that survive after they exit, and
- * therefore call library destructors, should disable the tracepoint
- * destructors by calling tracepoint_disable_destructors(). This will
- * leak the tracepoint instrumentation library shared object, leaving
- * its teardown to the operating system process teardown.
- */
-static inline void tracepoint_disable_destructors(void)
-{
-   __tracepoints__disable_destructors = 1;
-}
-
 /*
  * These weak symbols, the constructor, and destructor take care of
  * registering only _one_ instance of the tracepoints per shared-ojbect
@@ -335,7 +322,8 @@ __tracepoints__destroy(void)
return;
if (!tracepoint_dlopen_ptr)
tracepoint_dlopen_ptr = _dlopen;
-   if (!__tracepoints__disable_destructors
+   if (tracepoint_dlopen_ptr->tracepoint_get_destructors_disabled
+   && 
!tracepoint_dlopen_ptr->tracepoint_get_destructors_disabled()
&& tracepoint_dlopen_ptr->liblttngust_handle
&& !__tracepoint_ptrs_registered) {
ret = dlclose(tracepoint_dlopen_ptr->liblttngust_handle);
@@ -423,6 +411,14 @@ __tracepoints__ptrs_init(void)
URCU_FORCE_CAST(int (*)(struct lttng_ust_tracepoint * const *),
dlsym(tracepoint_dlopen_ptr->liblttngust_handle,
"tracepoint_unregister_lib"));
+   tracepoint_dlopen_ptr->tracepoint_set_destructors_disabled =
+   URCU_FORCE_CAST(void (*)(int),
+   dlsym(tracepoint_dlopen_ptr->liblttngust_handle,
+   "tracepoint_set_destructors_disabled"));
+   tracepoint_dlopen_ptr->tracepoint_get_destructors_disabled =
+   URCU_FORCE_CAST(int (*)(void),
+   dlsym(tracepoint_dlopen_ptr->liblttngust_handle,
+   "tracepoint_get_destructors_disabled"));
__tracepoint__init_urcu_sym();
if (tracepoint_dlopen_ptr->tracepoint_register_lib) {

tracepoint_dlopen_ptr->tracepoint_register_lib(__start___tracepoints_ptrs,
@@ -444,7 +440,8 @@ __tracepoints__ptrs_destroy(void)
tracepoint_dlopen_ptr = _dlopen;
if (tracepoint_dlopen_ptr->tracepoint_unregister_lib)

tracepoint_dlopen_ptr->tracepoint_unregister_lib(__start___tracepoints_ptrs);
-   if (!__tracepoints__disable_destructors
+   if (tracepoint_dlopen_ptr->tracepoint_get_destructors_disabled
+   && 
!tracepoint_dlopen_ptr->tracepoint_get_destructors_disabled()
&& tracepoint_dlopen_ptr->liblttngust_handle

[lttng-dev] [PATCH lttng-ust v2] Fix: destructors do not run on probe provider dlclose

2018-02-22 Thread Francis Deslauriers
Calling dlclose on the probe provider library that first loaded
__tracepoints__disable_destructors in the symbol table does not
unregister the probes from the callsites as the destructors are not
executed.

The __tracepoints__disable_destructors weak symbol is exposed by probe
providers, liblttng-ust.so and liblttng-ust-tracepoint.so libraries. If
a probe provider is loaded first into the address space, its definition
is binded to the symbol. All the subsequent loaded libraries using the
symbol will use the existing definition of the symbol, thus creating a
situation where liblttng-ust.so or liblttng-ust-tracepoint.so depend on
the probe provider library.

This prevents the dynamic loader from unloading the library as it is
still in use by other libraries. Because of this, the execution of its
destructors and the unregistration of the probes is postponed.

To overcome this issue, we no longer expose this symbol in the
tracepoint.h file to remove the explicit dependency of the probe
provider on the symbol. We instead use the existing dlopen handle on
liblttng-ust-tracepoint.so to get handles on getter and setter functions
for this value.

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 include/lttng/tracepoint.h | 82 +++---
 liblttng-ust/tracepoint.c  | 35 
 2 files changed, 98 insertions(+), 19 deletions(-)

diff --git a/include/lttng/tracepoint.h b/include/lttng/tracepoint.h
index 39f2c4d..d285347 100644
--- a/include/lttng/tracepoint.h
+++ b/include/lttng/tracepoint.h
@@ -226,21 +226,6 @@ struct lttng_ust_tracepoint_dlopen {
 extern struct lttng_ust_tracepoint_dlopen tracepoint_dlopen;
 extern struct lttng_ust_tracepoint_dlopen *tracepoint_dlopen_ptr;
 
-/* Disable tracepoint destructors. */
-int __tracepoints__disable_destructors __attribute__((weak));
-
-/*
- * Programs that have threads that survive after they exit, and
- * therefore call library destructors, should disable the tracepoint
- * destructors by calling tracepoint_disable_destructors(). This will
- * leak the tracepoint instrumentation library shared object, leaving
- * its teardown to the operating system process teardown.
- */
-static inline void tracepoint_disable_destructors(void)
-{
-   __tracepoints__disable_destructors = 1;
-}
-
 /*
  * These weak symbols, the constructor, and destructor take care of
  * registering only _one_ instance of the tracepoints per shared-ojbect
@@ -265,6 +250,47 @@ struct lttng_ust_tracepoint_dlopen tracepoint_dlopen
 struct lttng_ust_tracepoint_dlopen *tracepoint_dlopen_ptr
__attribute__((weak, visibility("hidden")));
 
+/*
+ * Tracepoint dynamic linkage handling (callbacks). Hidden visibility: shared
+ * across objects in a module/main executable. The callbacks are used to
+ * control and check if the destructors should be executed.
+ */
+struct lttng_ust_tracepoint_destructors_syms {
+   void (*tracepoint_enable_destructors)(void);
+   void (*tracepoint_disable_destructors)(void);
+   int (*tracepoint_get_destructors_state)(void);
+};
+
+extern struct lttng_ust_tracepoint_destructors_syms 
tracepoint_destructors_syms;
+extern struct lttng_ust_tracepoint_destructors_syms 
*tracepoint_destructors_syms_ptr;
+
+struct lttng_ust_tracepoint_destructors_syms tracepoint_destructors_syms
+   __attribute__((weak, visibility("hidden")));
+struct lttng_ust_tracepoint_destructors_syms *tracepoint_destructors_syms_ptr
+   __attribute__((weak, visibility("hidden")));
+
+static inline void tracepoint_disable_destructors(void)
+{
+   if (!tracepoint_dlopen_ptr)
+   tracepoint_dlopen_ptr = _dlopen;
+   if (!tracepoint_destructors_syms_ptr)
+   tracepoint_destructors_syms_ptr = _destructors_syms;
+   if (tracepoint_dlopen_ptr->liblttngust_handle
+   && 
tracepoint_destructors_syms_ptr->tracepoint_disable_destructors)
+   
tracepoint_destructors_syms_ptr->tracepoint_disable_destructors();
+}
+
+static inline void tracepoint_enable_destructors(void)
+{
+   if (!tracepoint_dlopen_ptr)
+   tracepoint_dlopen_ptr = _dlopen;
+   if (!tracepoint_destructors_syms_ptr)
+   tracepoint_destructors_syms_ptr = _destructors_syms;
+   if (tracepoint_dlopen_ptr->liblttngust_handle
+   && 
tracepoint_destructors_syms_ptr->tracepoint_enable_destructors)
+   
tracepoint_destructors_syms_ptr->tracepoint_enable_destructors();
+}
+
 #ifndef _LGPL_SOURCE
 static inline void lttng_ust_notrace
 __tracepoint__init_urcu_sym(void);
@@ -335,8 +361,11 @@ __tracepoints__destroy(void)
return;
if (!tracepoint_dlopen_ptr)
tracepoint_dlopen_ptr = _dlopen;
-   if (!__tracepoints__disable_destructors
-   && tracepoint_dlopen_ptr->liblttngust_handle
+   if (

[lttng-dev] [PATCH lttng-ust v4] Fix: destructors do not run on probe provider dlclose

2018-02-26 Thread Francis Deslauriers
Calling dlclose on the probe provider library that first loaded
__tracepoints__disable_destructors in the symbol table does not
unregister the probes from the callsites as the destructors are not
executed.

The __tracepoints__disable_destructors weak symbol is exposed by probe
providers, liblttng-ust.so and liblttng-ust-tracepoint.so libraries. If
a probe provider is loaded first into the address space, its definition
is bound to the symbol. All the subsequent loaded libraries using the
symbol will use the existing definition of the symbol, thus creating a
situation where liblttng-ust.so or liblttng-ust-tracepoint.so depend on
the probe provider library.

This prevents the dynamic loader from unloading the library as it is
still in use by other libraries. Because of this, the execution of its
destructors and the unregistration of the probes is postponed.

To overcome this issue, we no longer expose this symbol in the
tracepoint.h file to remove the explicit dependency of the probe
provider on the symbol. We instead use the existing dlopen handle on
liblttng-ust-tracepoint.so to get handles on getter and setter functions
for this value.

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 include/lttng/tracepoint.h | 82 +++---
 liblttng-ust/tracepoint.c  | 56 +++
 2 files changed, 119 insertions(+), 19 deletions(-)

diff --git a/include/lttng/tracepoint.h b/include/lttng/tracepoint.h
index 39f2c4d..d285347 100644
--- a/include/lttng/tracepoint.h
+++ b/include/lttng/tracepoint.h
@@ -226,21 +226,6 @@ struct lttng_ust_tracepoint_dlopen {
 extern struct lttng_ust_tracepoint_dlopen tracepoint_dlopen;
 extern struct lttng_ust_tracepoint_dlopen *tracepoint_dlopen_ptr;
 
-/* Disable tracepoint destructors. */
-int __tracepoints__disable_destructors __attribute__((weak));
-
-/*
- * Programs that have threads that survive after they exit, and
- * therefore call library destructors, should disable the tracepoint
- * destructors by calling tracepoint_disable_destructors(). This will
- * leak the tracepoint instrumentation library shared object, leaving
- * its teardown to the operating system process teardown.
- */
-static inline void tracepoint_disable_destructors(void)
-{
-   __tracepoints__disable_destructors = 1;
-}
-
 /*
  * These weak symbols, the constructor, and destructor take care of
  * registering only _one_ instance of the tracepoints per shared-ojbect
@@ -265,6 +250,47 @@ struct lttng_ust_tracepoint_dlopen tracepoint_dlopen
 struct lttng_ust_tracepoint_dlopen *tracepoint_dlopen_ptr
__attribute__((weak, visibility("hidden")));
 
+/*
+ * Tracepoint dynamic linkage handling (callbacks). Hidden visibility: shared
+ * across objects in a module/main executable. The callbacks are used to
+ * control and check if the destructors should be executed.
+ */
+struct lttng_ust_tracepoint_destructors_syms {
+   void (*tracepoint_enable_destructors)(void);
+   void (*tracepoint_disable_destructors)(void);
+   int (*tracepoint_get_destructors_state)(void);
+};
+
+extern struct lttng_ust_tracepoint_destructors_syms 
tracepoint_destructors_syms;
+extern struct lttng_ust_tracepoint_destructors_syms 
*tracepoint_destructors_syms_ptr;
+
+struct lttng_ust_tracepoint_destructors_syms tracepoint_destructors_syms
+   __attribute__((weak, visibility("hidden")));
+struct lttng_ust_tracepoint_destructors_syms *tracepoint_destructors_syms_ptr
+   __attribute__((weak, visibility("hidden")));
+
+static inline void tracepoint_disable_destructors(void)
+{
+   if (!tracepoint_dlopen_ptr)
+   tracepoint_dlopen_ptr = _dlopen;
+   if (!tracepoint_destructors_syms_ptr)
+   tracepoint_destructors_syms_ptr = _destructors_syms;
+   if (tracepoint_dlopen_ptr->liblttngust_handle
+   && 
tracepoint_destructors_syms_ptr->tracepoint_disable_destructors)
+   
tracepoint_destructors_syms_ptr->tracepoint_disable_destructors();
+}
+
+static inline void tracepoint_enable_destructors(void)
+{
+   if (!tracepoint_dlopen_ptr)
+   tracepoint_dlopen_ptr = _dlopen;
+   if (!tracepoint_destructors_syms_ptr)
+   tracepoint_destructors_syms_ptr = _destructors_syms;
+   if (tracepoint_dlopen_ptr->liblttngust_handle
+   && 
tracepoint_destructors_syms_ptr->tracepoint_enable_destructors)
+   
tracepoint_destructors_syms_ptr->tracepoint_enable_destructors();
+}
+
 #ifndef _LGPL_SOURCE
 static inline void lttng_ust_notrace
 __tracepoint__init_urcu_sym(void);
@@ -335,8 +361,11 @@ __tracepoints__destroy(void)
return;
if (!tracepoint_dlopen_ptr)
tracepoint_dlopen_ptr = _dlopen;
-   if (!__tracepoints__disable_destructors
-   && tracepoi

[lttng-dev] [PATCH lttng-ust v3] Fix: destructors do not run on probe provider dlclose

2018-02-26 Thread Francis Deslauriers
Calling dlclose on the probe provider library that first loaded
__tracepoints__disable_destructors in the symbol table does not
unregister the probes from the callsites as the destructors are not
executed.

The __tracepoints__disable_destructors weak symbol is exposed by probe
providers, liblttng-ust.so and liblttng-ust-tracepoint.so libraries. If
a probe provider is loaded first into the address space, its definition
is bound to the symbol. All the subsequent loaded libraries using the
symbol will use the existing definition of the symbol, thus creating a
situation where liblttng-ust.so or liblttng-ust-tracepoint.so depend on
the probe provider library.

This prevents the dynamic loader from unloading the library as it is
still in use by other libraries. Because of this, the execution of its
destructors and the unregistration of the probes is postponed.

To overcome this issue, we no longer expose this symbol in the
tracepoint.h file to remove the explicit dependency of the probe
provider on the symbol. We instead use the existing dlopen handle on
liblttng-ust-tracepoint.so to get handles on getter and setter functions
for this value.

Signed-off-by: Francis Deslauriers <francis.deslauri...@efficios.com>
---
 include/lttng/tracepoint.h | 82 +++---
 liblttng-ust/tracepoint.c  | 61 ++
 2 files changed, 124 insertions(+), 19 deletions(-)

diff --git a/include/lttng/tracepoint.h b/include/lttng/tracepoint.h
index 39f2c4d..d285347 100644
--- a/include/lttng/tracepoint.h
+++ b/include/lttng/tracepoint.h
@@ -226,21 +226,6 @@ struct lttng_ust_tracepoint_dlopen {
 extern struct lttng_ust_tracepoint_dlopen tracepoint_dlopen;
 extern struct lttng_ust_tracepoint_dlopen *tracepoint_dlopen_ptr;
 
-/* Disable tracepoint destructors. */
-int __tracepoints__disable_destructors __attribute__((weak));
-
-/*
- * Programs that have threads that survive after they exit, and
- * therefore call library destructors, should disable the tracepoint
- * destructors by calling tracepoint_disable_destructors(). This will
- * leak the tracepoint instrumentation library shared object, leaving
- * its teardown to the operating system process teardown.
- */
-static inline void tracepoint_disable_destructors(void)
-{
-   __tracepoints__disable_destructors = 1;
-}
-
 /*
  * These weak symbols, the constructor, and destructor take care of
  * registering only _one_ instance of the tracepoints per shared-ojbect
@@ -265,6 +250,47 @@ struct lttng_ust_tracepoint_dlopen tracepoint_dlopen
 struct lttng_ust_tracepoint_dlopen *tracepoint_dlopen_ptr
__attribute__((weak, visibility("hidden")));
 
+/*
+ * Tracepoint dynamic linkage handling (callbacks). Hidden visibility: shared
+ * across objects in a module/main executable. The callbacks are used to
+ * control and check if the destructors should be executed.
+ */
+struct lttng_ust_tracepoint_destructors_syms {
+   void (*tracepoint_enable_destructors)(void);
+   void (*tracepoint_disable_destructors)(void);
+   int (*tracepoint_get_destructors_state)(void);
+};
+
+extern struct lttng_ust_tracepoint_destructors_syms 
tracepoint_destructors_syms;
+extern struct lttng_ust_tracepoint_destructors_syms 
*tracepoint_destructors_syms_ptr;
+
+struct lttng_ust_tracepoint_destructors_syms tracepoint_destructors_syms
+   __attribute__((weak, visibility("hidden")));
+struct lttng_ust_tracepoint_destructors_syms *tracepoint_destructors_syms_ptr
+   __attribute__((weak, visibility("hidden")));
+
+static inline void tracepoint_disable_destructors(void)
+{
+   if (!tracepoint_dlopen_ptr)
+   tracepoint_dlopen_ptr = _dlopen;
+   if (!tracepoint_destructors_syms_ptr)
+   tracepoint_destructors_syms_ptr = _destructors_syms;
+   if (tracepoint_dlopen_ptr->liblttngust_handle
+   && 
tracepoint_destructors_syms_ptr->tracepoint_disable_destructors)
+   
tracepoint_destructors_syms_ptr->tracepoint_disable_destructors();
+}
+
+static inline void tracepoint_enable_destructors(void)
+{
+   if (!tracepoint_dlopen_ptr)
+   tracepoint_dlopen_ptr = _dlopen;
+   if (!tracepoint_destructors_syms_ptr)
+   tracepoint_destructors_syms_ptr = _destructors_syms;
+   if (tracepoint_dlopen_ptr->liblttngust_handle
+   && 
tracepoint_destructors_syms_ptr->tracepoint_enable_destructors)
+   
tracepoint_destructors_syms_ptr->tracepoint_enable_destructors();
+}
+
 #ifndef _LGPL_SOURCE
 static inline void lttng_ust_notrace
 __tracepoint__init_urcu_sym(void);
@@ -335,8 +361,11 @@ __tracepoints__destroy(void)
return;
if (!tracepoint_dlopen_ptr)
tracepoint_dlopen_ptr = _dlopen;
-   if (!__tracepoints__disable_destructors
-   && tracepoi

[lttng-dev] [CFP] Call For Presentations reminder and registration for Tracing Summit 2018 on Oct 25th in Edinburgh, UK

2018-08-17 Thread Francis Deslauriers
Hi all,

This is a friendly reminder that the deadline for submitting talk proposals for
Tracing Summit 2018[1] is coming up soon (Sept 1st). Submit you talk today
using submiss...@tracingsummit.org and don't forget to include the following:
- Talk title,
- Talk abstract (900 characters maximum),
- Description of the targeted audience (900 characters maximum),
- Short biography (900 characters maximum).

The Tracing Summit 2018 will be held in Edinburgh, UK on October 25th, 2018, at
the Edinburgh International Conference Centre, co-located with the Open Source
Summit & Embedded Linux Conference 2018.

You can register right now either through the Open Source Summit Europe
registration page[2] by adding the free Tracing Summit addon or by registering
specifically for the Tracing Summit using this registration form[3].

Thank you,

On behalf of the Diagnostic and Monitoring Workgroup,
Francis Deslauriers

[1] https://tracingsummit.org/wiki/TracingSummit2018
[2] https://www.regonline.com/OSSEU2018
[3] https://regonline.com/tracingsummit18
___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] Tracing Summit 2018 - CFP extended until Sept. 10th

2018-09-05 Thread Francis Deslauriers
Hi all,

To take into account that a lot of people are on vacations over the month of
August, we are announcing the extension of the CFP for the Tracing Summit
2018
until Monday September 10th. This gives 6 more days to get your talk
proposals
in.

Thank you to all of you who submitted talks. We received great ones!

More info: https://tracingsummit.org/wiki/TracingSummit2018

Thank you,

--
On behalf of the Diagnostic and Monitoring Workgroup,
Francis Deslauriers
___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-ust] Move symbol preventing unloading of probe providers

2018-09-04 Thread Francis Deslauriers
Issue
=
Calling dlclose on the probe provider library that first loaded
__tracepoints__disable_destructors in the symbol table does not
unregister the probes from the callsites as the destructors are not
executed.

The __tracepoints__disable_destructors weak symbol is exposed by probe
providers, liblttng-ust.so and liblttng-ust-tracepoint.so libraries. If
a probe provider is loaded first into the address space, its definition
is bound to the symbol. All the subsequent loaded libraries using the
symbol will use the existing definition of the symbol, thus creating a
situation where liblttng-ust.so or liblttng-ust-tracepoint.so depend on
the probe provider library.

This prevents the dynamic loader from unloading the library as it is
still in use by other libraries. Because of this, the execution of its
destructors and the unregistration of the probes is postponed. Since the
unregistration of the probes is postponed, event will be generate if the
callsite is executed even though the probes should not be loaded.

Solution

To overcome this issue, we no longer expose this symbol in the
tracepoint.h file to remove the explicit dependency of the probe
provider on the symbol. We instead use the existing dlopen handle on
liblttng-ust-tracepoint.so and use dlsym to get handles on functions
that disable and get the state of the destructors.

Version compatibility
=
- This change is backward compatible with UST applications and libraries
  built on lttng-ust version before 2.11. Those applications will use
  the __tracepoints__disable_destructors symbol that is now only exposed
  by the liblttng-ust-tracepoint.so library. This symbol is alway
  checked in 2.11 in case an old app is running.

- Applications built with this change will also work in older versions
  of lttng-ust as there is a check to see if the new destructor state
  checking method should be used, if it should not we fallback to a
  compatibility method. To ensure compatibility in this case, we also
  look up and keep up to date the __tracepoints__disable_destructors
  value using the dlopen-dlsym combo.

Signed-off-by: Francis Deslauriers 
---
 include/lttng/tracepoint.h | 108 ++---
 liblttng-ust/tracepoint.c  |  40 +
 2 files changed, 123 insertions(+), 25 deletions(-)

diff --git a/include/lttng/tracepoint.h b/include/lttng/tracepoint.h
index 39f2c4d..9b52bc6 100644
--- a/include/lttng/tracepoint.h
+++ b/include/lttng/tracepoint.h
@@ -226,21 +226,6 @@ struct lttng_ust_tracepoint_dlopen {
 extern struct lttng_ust_tracepoint_dlopen tracepoint_dlopen;
 extern struct lttng_ust_tracepoint_dlopen *tracepoint_dlopen_ptr;
 
-/* Disable tracepoint destructors. */
-int __tracepoints__disable_destructors __attribute__((weak));
-
-/*
- * Programs that have threads that survive after they exit, and
- * therefore call library destructors, should disable the tracepoint
- * destructors by calling tracepoint_disable_destructors(). This will
- * leak the tracepoint instrumentation library shared object, leaving
- * its teardown to the operating system process teardown.
- */
-static inline void tracepoint_disable_destructors(void)
-{
-   __tracepoints__disable_destructors = 1;
-}
-
 /*
  * These weak symbols, the constructor, and destructor take care of
  * registering only _one_ instance of the tracepoints per shared-ojbect
@@ -265,6 +250,39 @@ struct lttng_ust_tracepoint_dlopen tracepoint_dlopen
 struct lttng_ust_tracepoint_dlopen *tracepoint_dlopen_ptr
__attribute__((weak, visibility("hidden")));
 
+/*
+ * Tracepoint dynamic linkage handling (callbacks). Hidden visibility: shared
+ * across objects in a module/main executable. The callbacks are used to
+ * control and check if the destructors should be executed.
+ */
+struct lttng_ust_tracepoint_destructors_syms {
+   int *old_tracepoint_disable_destructors;
+   void (*tracepoint_disable_destructors)(void);
+   int (*tracepoint_get_destructors_state)(void);
+};
+
+extern struct lttng_ust_tracepoint_destructors_syms 
tracepoint_destructors_syms;
+extern struct lttng_ust_tracepoint_destructors_syms 
*tracepoint_destructors_syms_ptr;
+
+struct lttng_ust_tracepoint_destructors_syms tracepoint_destructors_syms
+   __attribute__((weak, visibility("hidden")));
+struct lttng_ust_tracepoint_destructors_syms *tracepoint_destructors_syms_ptr
+   __attribute__((weak, visibility("hidden")));
+
+static inline void tracepoint_disable_destructors(void)
+{
+   if (!tracepoint_dlopen_ptr)
+   tracepoint_dlopen_ptr = _dlopen;
+   if (!tracepoint_destructors_syms_ptr)
+   tracepoint_destructors_syms_ptr = _destructors_syms;
+   if (tracepoint_dlopen_ptr->liblttngust_handle
+   && 
tracepoint_destructors_syms_ptr->tracepoint_disable_destructors) {
+   
tracepoint_destructors_syms_ptr->t

[lttng-dev] [CFP] Tracing Summit 2018 Call for Presentations, October 25th, 2018, Edinburgh, UK

2018-07-05 Thread Francis Deslauriers
Hi,

This is a Call for Presentations for the Tracing Summit 2018 which will be
held
in Edinburgh, UK on October 25th, 2018, at the Edinburgh International
Conference Centre, co-located with the Open Source Summit Europe & Embedded
Linux Conference Europe.

The Tracing Summit is single-day, single-track conference on the topic of
tracing. The event focuses on the field of software and hardware tracing,
gathering developers and end-users of tracing and trace analysis
tools. The main goal of the Tracing Summit is to provide space for
discussion
between people of the various areas that benefit from tracing, namely
parallel,
distributed and/or real-time systems, as well as kernel development.

We are welcoming 30 minutes presentations from both users and developers,
on topics covering, but not limited to:

 * Investigation workflow of Real-Time, latency, and throughput issues,
 * Trace collection and extraction,
 * Trace filtering,
 * Trace aggregation,
 * Trace formats,
 * Tracing multi-core systems,
 * Trace abstraction,
 * Trace modeling,
 * Automated trace analysis (e.g. dependency analysis),
 * Tracing large clusters and distributed systems,
 * Hardware-level tracing (e.g. DSP, GPU, bare-metal),
 * Trace visualisation,
 * Interaction between debugging and tracing,
 * Tracing remote control,
 * Analysis of large trace datasets,
 * Cloud trace collection and analysis,
 * Integration between trace tools,
 * Live tracing & monitoring.

Those can cover recently available technologies, ongoing work, and yet
non-existing technologies (which are compellingly interesting to
end-users). Please understand that this open forum is not the proper
place to present sales or marketing pitches, nor technologies which are
prevented from being freely used in open source.

If you are interested in presenting, please submit a proposal to
submiss...@tracingsummit.org before *September 1st, 2018, at 23:59 EST*.

Please provide the following information:
 * Talk title,
 * Talk abstract, (900 characters maximum)
 * Description of the targeted audience (900 characters maximum),
 * Short biography (900 characters maximum).

Attending the Tracing Summit is free of charge. More details on registration
will be available shortly, be sure to checkout the Tracing Summit 2018
website
for all the latest information on this topic:
https://www.tracingsummit.org/wiki/TracingSummit2018

The Tracing Summit is organized by the Linux Foundation Diagnostic and
Monitoring Workgroup (https://diamon.org).

The Tracing Summit is sponsored by EfficiOS <https://www.efficios.com/>.
Please let us know if your company
is interested in sponsoring this event.

Thank you,

On behalf of the Diagnostic and Monitoring Workgroup,
Francis Deslauriers & Mathieu Desnoyers
___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [BETA RELEASE] LTTng Scope 0.4

2018-10-15 Thread Francis Deslauriers
Hi all,

We are announcing the release of LTTng Scope 0.4.0.

This release has a few improvements over LTTng Scope 0.3:

* Open more than one trace thanks to the new "Trace Project Setup"
  window. (e.g. Kernel + UST traces)

  You can always reopen this window to add traces to or remove traces
  from the current trace project by clicking
  "File" -> "Project Setup..." or by right-clicking the project item in
  the left pane and clicking "Project Setup".

* Event count chart: use vertical bars instead of an area chart. A given
  bar indicates the number of event records of which the timestamps are
  between the beginning and the end of the bar.

* Event count chart: use natural ticks, depending on the current zoom
  level, on the horizontal (time) axis. For example, the difference
  between individual ticks can be 100 ms, 500 ms, 1 s, 2 s, 15 s, 30
  minutes, 1 day, etc.

* Event count chart: add axis units ("Count / Time") below the view's
  title on the left.

* Add the version to the main window's title bar.

* Bug fix: refresh the views when you move vertical dividers or when you
  resize the main window.

* Bug fix: event count chart: round tick labels correctly to avoid
  noticing floating point number errors.

Of course, because LTTng Scope's development is still in the beta phase,
you could discover bugs when trying the tool. Feel free to report them
on GitHub: <https://github.com/lttng/lttng-scope/issues>.

Project's description and screenshot:
<https://lttng.org/beta/#lttng-scope>

GitHub page:
<https://github.com/lttng/lttng-scope>

Installer for Linux:

<https://lttng.org/files/lttng-scope/lttng-scope-0.4.0-linux-x64-installer.run>

Installer for Windows:

<https://lttng.org/files/lttng-scope/lttng-scope-0.4.0-windows-installer.exe>

Installer for macOS:
<https://lttng.org/files/lttng-scope/lttng-scope-0.4.0-osx-installer.dmg>

On the behalf of the EfficiOS team,

--
Francis Deslauriers
Software developer
EfficiOS inc.
___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] Tracing Summit 2018 Schedule Released

2018-09-28 Thread Francis Deslauriers
Hi all,

We're happy to announce the schedule for the Tracing Summit 2018 is now
available. We're going to have an amazing conference with diverse topics such
as trace analysis, hardware tracing, and distributed systems tracing.

Check out the schedule and talk abstracts on the Tracing Summit wiki. [1]

Tracing Summit 2018 will be held in Edinburgh, UK on October 25th, 2018,
Don't forget to register for the summit, it's free! [2]

See you in October!

[1]: https://tracingsummit.org/wiki/TracingSummit2018#Schedule
[2]: https://tracingsummit.org/wiki/TracingSummit2018#Registration

-- 
Francis Deslauriers
Software developer
EfficiOS inc.
___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


  1   2   >