[lttng-dev] [LTTNG] Empty traces output file

2018-02-09 Thread Shieryn Tjandra
Good Evening,

Hi There,

I have inquiries regarding LTTNG, I followed the tutorial in this link :

http://lttng.org/docs/v2.10/#doc-tracing-your-own-user-application

However, after executing the c application, when I checked whether the
process was in the userspace event (UST), the process was not there. Next,
I tried to record the  traces, as I thought, my traces output file does not
contain any traces. I also have make sure that liblttng-ust has been
installed. I really appreciate if you can help me to overcome this problem,
if you need additional file, let me know.

I am using centos 7 by the way.

Here is my command line
[root@localhost tracepractice]# gcc -c -I. app_tp.c
[root@localhost tracepractice]# gcc -c app.c -lpthread
[root@localhost tracepractice]# gcc -o try app.o app_tp.o -lpthread
-llttng-ust -ldl
[root@localhost tracepractice]# ./try and beyond
Main thread: : pid = 17231 lwp = 17231 priority = 0
Thread 4: : pid = 17231 lwp = 17234 priority = 0
Thread 2: : pid = 17231 lwp = 17236 priority = 8
Thread 1: : pid = 17231 lwp = 17237 priority = 12
Thread 1: Hello! I am thread 4 and I more important than 1, 2 and 3. My
count is now 0
Thread 3: : pid = 17231 lwp = 17235 priority = 4
Thread 4: Hello! I am thread 1 and I not very important. My count
is now 1
Thread 2: Hello! I am thread 3 and I more important than 1 and 2. My
count is now 0
Thread 3: Hello! I am thread 2 and I more important than 1. My
count is now 1
Thread 2: Hello! I am thread 3 and I more important than 1 and 2. My
count is now 262144
Thread 3: Hello! I am thread 2 and I more important than 1. My
count is now 262145
sig_ala [cound down=1]
sig_ala [cound down=0]
[root@localhost tracepractice]# lttng-sessiond --daemonize
[root@localhost tracepractice]# lttng list --userspace
UST events:
-
None

[root@localhost tracepractice]# lttng create mytrace
Session mytrace created.
Traces will be written in /root/lttng-traces/mytrace-20180209-013417
[root@localhost tracepractice]# lttng enable-event --userspace
app_tp:first_tracepoint
UST event app_tp:first_tracepoint created in channel channel0
[root@localhost tracepractice]# lttng start
Tracing started for session mytrace
[root@localhost tracepractice]# ./try
Main thread: : pid = 17301 lwp = 17301 priority = 0
Thread 4: : pid = 17301 lwp = 17304 priority = 0
Thread 2: : pid = 17301 lwp = 17306 priority = 8
Thread 1: : pid = 17301 lwp = 17307 priority = 12
Thread 1: Hello! I am thread 4 and I more important than 1, 2 and 3. My
count is now 0
Thread 4: Hello! I am thread 1 and I not very important. My count
is now 1
Thread 3: : pid = 17301 lwp = 17305 priority = 4
Thread 2: Hello! I am thread 3 and I more important than 1 and 2. My
count is now 0
Thread 3: Hello! I am thread 2 and I more important than 1. My
count is now 1
Thread 2: Hello! I am thread 3 and I more important than 1 and 2. My
count is now 262144
Thread 3: Hello! I am thread 2 and I more important than 1. My
count is now 262145
sig_ala [cound down=1]
Thread 2: Hello! I am thread 3 and I more important than 1 and 2. My
count is now 524288
Thread 3: Hello! I am thread 2 and I more important than 1. My
count is now 524289
sig_ala [cound down=0]
[root@localhost tracepractice]# lttng stop
Waiting for data availability
Tracing stopped for session mytrace
[root@localhost tracepractice]# babeltrace ~/lttng-traces/mytrace*
[root@localhost tracepractice]# ls ~/lttng-traces/mytrace* -l
total 0
drwxrwx---. 3 root root 17 Feb  9 01:35 ust


Thank you.


-- 


Best Regards,

*Shieryn Tjandra*











-- 


Best Regards,

*Shieryn Tjandra*
*+1 613 501 0606*
___
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 
---
 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_PROBES_F
+

[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 
---
 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 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 
---
 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 
+ *
+ * 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 type. Those were already 
checked
+* during enum registration.
+*/
+   

[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 
---
 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 
---
 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


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

2018-02-09 Thread Mathieu Desnoyers
All merged into lttng-ust master, thanks!

Mathieu

- On Feb 9, 2018, at 3:15 PM, Francis Deslauriers 
francis.deslauri...@efficios.com wrote:

> 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

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
___
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 v2 4/6] Manually dlopen() liblttng-ust.so to prevent unloading

2018-02-09 Thread Mathieu Desnoyers
Cleaned up this changelog, which has tabs (should be spaces), and has
lines above ~74 columns (which is odd in a git log).

Thanks,

Mathieu

- On Feb 9, 2018, at 3:15 PM, Francis Deslauriers 
francis.deslauri...@efficios.com wrote:

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

[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 
---
 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 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 
---

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 order in which we construct
 * our sub-libraries 

[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 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 
---
 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 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 
---

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_sync_callsites(const char *name)
if (strncmp(name, tp->name, LTTNG_UST_SYM_NAME_LEN - 1))

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

2018-02-09 Thread Francis Deslauriers
From: Mathieu Desnoyers 

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 
Signed-off-by: Francis Deslauriers 
---
 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