[lttng-dev] UST context causes empty trace

Zifei Tong soariez at gmail.com
Sun May 12 05:27:29 EDT 2013


Hi,

I did some debugging one this issue. The problem only occurs when we
have more than one context field.
So this will not work, too:

lttng create
lttng enable-event -a -u
lttng add-context -u -t vpid
lttng add-context -u -t vtid
lttng start
$@
lttng stop
sleep 1
lttng view
lttng destroy

The problem I found out is wrong `fields` argument passed into
`ustcomm_register_channel`.
The `fields` argument passed is a pointer to the `event_field` of the
first element in a `lttng_ctx_field` array,
but not a `lttng_event_field` array as expected.

Please see the patch for more details.

The patch works on my machine. But I wonder if there is something
wrong or maybe a better fix.
Please review.

Thanks,

Zifei Tong

Signed-off-by: Zifei Tong <soariez at gmail.com>
---
 liblttng-ust/lttng-events.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/liblttng-ust/lttng-events.c b/liblttng-ust/lttng-events.c
index e4faf60..7afe13f 100644
--- a/liblttng-ust/lttng-events.c
+++ b/liblttng-ust/lttng-events.c
@@ -260,9 +260,10 @@ int lttng_session_enable(struct lttng_session *session)
 	 */
 	cds_list_for_each_entry(chan, &session->chan_head, node) {
 		const struct lttng_ctx *ctx;
-		const struct lttng_event_field *fields = NULL;
+		struct lttng_event_field *fields = NULL;
 		size_t nr_fields = 0;
 		uint32_t chan_id;
+		int i;

 		/* don't change it if session stop/restart */
 		if (chan->header_type)
@@ -270,7 +271,9 @@ int lttng_session_enable(struct lttng_session *session)
 		ctx = chan->ctx;
 		if (ctx) {
 			nr_fields = ctx->nr_fields;
-			fields = &ctx->fields->event_field;
+			fields = malloc(nr_fields * sizeof(struct lttng_event_field));
+			for (i = 0; i < nr_fields; i++)
+				fields[i] = ctx->fields[i].event_field;
 		}
 		ret = ustcomm_register_channel(notify_socket,
 			session->objd,
@@ -279,6 +282,8 @@ int lttng_session_enable(struct lttng_session *session)
 			fields,
 			&chan_id,
 			&chan->header_type);
+		if (fields != NULL)
+			free(fields);
 		if (ret) {
 			DBG("Error (%d) registering channel to sessiond", ret);
 			return ret;
-- 
1.8.2.2

On 5/12/13, Mathieu Desnoyers <mathieu.desnoyers at efficios.com> wrote:
> Yes, it's broken here too. Can you open a bug report against UST please?
>
> it looks like those are missing when we enable UST contexts:
>
> libust[26034/26049]: Sent register channel notification: chan_id 0,
> header_type 1
>  (in ustcomm_register_channel() at lttng-ust-comm.c:1053)
> [...]
> libust[26034/26034]: Sent register event notification for name
> "ust_tests_hello:tptest": ret_code 0, event_id 0
>  (in ustcomm_register_event() at lttng-ust-comm.c:948)
> libust[26034/26034]: Sent register event notification for name
> "ust_tests_hello:tptest_sighandler": ret_code 0, event_id 1
>  (in ustcomm_register_event() at lttng-ust-comm.c:948)
>
> (I get those in a run where I don't enable any UST context, but not in
> the problematic case)
>
> the rest seems to be there when launching the app with LTTNG_UST_DEBUG=1
> env var set. So it looks like an issue within UST.
>
> Thanks,
>
> Mathieu
>
> * Francis Giraldeau (francis.giraldeau at gmail.com) wrote:
>> With 2.2.0-rc2, when enabling some context for UST, the generated trace
>> is empty. Here is a small script to reproduce the problem:
>>
>> $ cat do.sh
>> lttng create
>> lttng enable-channel u -u
>> lttng enable-event -c u -a -u
>> lttng add-context -c u -u -t vpid -t vtid
>> lttng start
>> $@
>> lttng stop
>> lttng view
>> lttng destroy
>>
>> When commenting out the "add-context" command, then the trace is
>> generated correctly. Does someone else is able to confirm the problem?
>>
>> Thanks,
>>
>> Francis Giraldeau
>>
>
>
>
>> _______________________________________________
>> lttng-dev mailing list
>> lttng-dev at 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 at lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
>


-- 
--
Best Regards,
仝子飞 (Zifei Tong)
College of Computer Science and Technology, Zhejiang University

soariez at gmail.com / tongzifei at zju.edu.cn



More information about the lttng-dev mailing list