<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<span style="font-size: 14px;" class="">Hi there!</span>
<div class=""><span style="font-size: 14px;" class=""><br class="">
</span></div>
<div class=""><span style="font-size: 14px;" class="">I’m quite new to LTTng live technology and I need to create some kind of live LTTng events handling utility. Looking at babeltrace git repository I’ve found that there is a special format “lttng-live” and
some lttng-live-plugin that could be easily used in my own viewer, for example:</span></div>
<div class=""><span style="font-size: 14px;" class=""><br class="">
</span></div>
<div class="">
<div style="margin: 0px; line-height: normal;" class=""><span style="font-size: 14px;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">struct bt_context * ctx = </span>bt_context_create();</span></div>
</div>
<div class="">
<div style="margin: 0px; line-height: normal;" class=""><span style="font-size: 14px;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">int handle_id = bt_context_</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(191, 191, 191); background-color: rgb(102, 102, 102);" class="">add_tr</span><span style="font-variant-ligatures: no-common-ligatures;" class="">ace(ctx,
"<a href="net://127.0.0.1:5344/host/blah-blah-blah" class="">net://127.0.0.1:5344/host/blah-blah-blah</a>", "lttng-live", NULL, NULL, NULL);</span></span></div>
</div>
<div class=""><span style="font-size: 14px;" class=""><br class="">
</span></div>
<div class=""><span style="font-size: 14px;" class="">These lines enters infinite loop reading live LTTng data and prints out every single LTTng tracing event on a screen with use of “ctf-text” format module.</span></div>
<div class=""><span style="font-size: 14px;" class=""><br class="">
</span></div>
<div class=""><span style="font-size: 14px;" class="">Could you please recommend me the best way how to implement LTTng live events handling utility? </span></div>
<div class=""><span style="font-size: 14px;" class="">Is it possible to make use of “lttng-live” module to call my own “<span style="font-variant-ligatures: no-common-ligatures;" class="">struct bt_ctf_</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(191, 191, 191); background-color: rgb(102, 102, 102);" class="">event</span>”
event handler somehow?</span></div>
<div class=""><span style="font-size: 14px;" class=""><br class="">
</span></div>
<div class=""><span style="font-size: 14px;" class=""><br class="">
</span></div>
<div class=""><span style="font-size: 14px;" class="">Also, one thing that I’ve found while using ‘jemalloc' allocator is that code in file babeltrace/formats/lttng-live/lttng-live-plugin.c leads to memory double free:</span></div>
<div class="">
<div style="margin: 0px; line-height: normal;" class=""><span style="font-size: 14px;" class=""><br class="">
</span></div>
</div>
<div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; font-size: 14px;" class="">
<div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">static int lttng_live_open_trace_read(const char *path)</span></div>
<div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">{</span></div>
<div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">…</span></div>
<div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">
<div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">end_free:</span></div>
<div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> g_hash_table_destroy(ctx->session->ctf_traces);</span></div>
<div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> g_free(ctx->session);</span></div>
<div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> g_free(ctx->session->streams);</span></div>
<div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> g_free(ctx);</span></div>
<div style="margin: 0px; line-height: normal; min-height: 17px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class="">
</div>
<div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> if (lttng_live_should_quit()) {</span></div>
<div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> ret = 0;</span></div>
<div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> }</span></div>
<div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> return ret;</span></div>
<div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">}</span></div>
<div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><br class="">
</span></div>
<div style="margin: 0px; line-height: normal;" class="">Changing order of lines "g_free(ctx->session);” and “g_free(ctx->session->streams);” fixes it:</div>
<div style="margin: 0px; line-height: normal;" class=""><br class="">
</div>
<div style="margin: 0px; line-height: normal;" class="">
<div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">static int lttng_live_open_trace_read(const char *path)</span></div>
<div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">{</span></div>
<div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">…</span></div>
<div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">
<div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">end_free:</span></div>
<div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> g_hash_table_destroy(ctx->session->ctf_traces);</span></div>
<div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> g_free(ctx->session->streams);</span></div>
<div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> g_free(ctx->session);</span></div>
<div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> g_free(ctx);</span></div>
<div style="margin: 0px; line-height: normal; min-height: 17px;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""></span><br class="">
</div>
<div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> if (lttng_live_should_quit()) {</span></div>
<div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> ret = 0;</span></div>
<div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> }</span></div>
<div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> return ret;</span></div>
<div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">}</span></div>
<div class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><br class="">
</span></div>
<div class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><br class="">
</span></div>
<div class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><br class="">
</span></div>
</span></div>
</div>
</span></div>
</span></div>
<div class=""><span style="font-size: 14px;" class="">Thanks in advance!</span></div>
<div class=""><span style="font-size: 14px;" class=""><br class="">
</span></div>
<div class="">
<div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<span style="font-size: 14px;" class="">Evgeniy Osipov</span><br class="">
<br class="">
</div>
</div>
</div>
</div>
<br class="">
</div>
</body>
</html>