<font size=2 face="sans-serif">Thanks for the explanations.</font>
<br>
<br><font size=2 face="sans-serif">I currently feel that the effort to
get such a thing working is not going to materialize in the timeframe required
for my current work, and therefore, regrettably, I will have to work around
this somehow. I am currently thinking of using a combination of Python
and Cython to generate a wrapper for the babeltrace iterator. We'll see.</font>
<br>
<br><font size=2 face="sans-serif">Thanks,</font>
<br>
<br><font size=2 color=#000080 face="sans-serif">Amit Margalit</font>
<br><font size=2 color=#808000 face="sans-serif">IBM XIV </font><font size=2 face="sans-serif">-
<i>Storage Reinvented</i></font>
<br><font size=2 face="sans-serif">XIV-NAS Development Team</font>
<br><font size=2 face="sans-serif">Tel. 03</font><font size=2 face="Arial">-689-7774</font>
<br><font size=2 face="Arial">Fax. 03-689-7230</font>
<br>
<br>
<br>
<br><font size=1 color=#5f5f5f face="sans-serif">From:
</font><font size=1 face="sans-serif">Jérémie Galarneau <jeremie.galarneau@efficios.com></font>
<br><font size=1 color=#5f5f5f face="sans-serif">To:
</font><font size=1 face="sans-serif">Amit Margalit/Israel/IBM@IBMIL</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Cc:
</font><font size=1 face="sans-serif">lttng-dev@lists.lttng.org</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Date:
</font><font size=1 face="sans-serif">07/21/2013 10:07 PM</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Subject:
</font><font size=1 face="sans-serif">Re: [lttng-dev]
Question about filtering bytecode</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Sent by:
</font><font size=1 face="sans-serif">jeremie.galarneau@gmail.com</font>
<br>
<hr noshade>
<br>
<br>
<br><tt><font size=2>On Sun, Jul 21, 2013 at 1:51 AM, Amit Margalit <AMITM@il.ibm.com>
wrote:<br>
> Hi,<br>
><br>
> I was thinking more about a programmer's guide to using this mechanism.<br>
><br>
<br>
Unfortunately there is no programmer's guide on filters, but feel free<br>
to ask about specifics.<br>
<br>
> What I'd like to do is to have Babeltrace filter events it is showing
me<br>
> from an existing trace.<br>
><br>
> Consider the following example:<br>
><br>
> There are 3 types of tracepoints being captured (without filtering):<br>
><br>
> A debug log message (occasionally) which includes a "debug_level"
value<br>
> (1..10 with 1 being highest importance).<br>
> Function entry (via gcc -finstrument-functions or other instrumentation).<br>
> Function exit (similarly).<br>
><br>
> During a 1-hour period, I have 2-3 GB of trace data captured.<br>
> The trace includes events from 4 different processes.<br>
><br>
><br>
> If I use Babeltrace to read the trace I will get an enormously big
result in<br>
> text (~30-40GB at least).<br>
><br>
> I would like to be able to do something like this:<br>
><br>
> $ babeltrace --filter '$ctx.procname == "smbd" || debug_level
< 3'<br>
> /local/lttng-traces/ust/uid/2140/64-bit<br>
><br>
> This would then let me see any events from the "smbd" process
(since i added<br>
> procname to the context using lttng add-context) or debug messages
from all<br>
> processes where the debug level is 1 or 2.<br>
><br>
<br>
That would be a neat feature! There are currently no plans to support<br>
filtering in Babeltrace, but that contribution would be welcome.<br>
lttng-ust's filtering code is licensed under LGPL v2.1 so it could be<br>
library-fied and used by the ctf-text plug-in. In the meantime, I<br>
guess you could work around this limitation with a combination of AWK<br>
and shell scripting...<br>
<br>
> Regarding linking - I am referring to the function<br>
> lttng_enabler_event_link_bytecode(), called from<br>
> lttng-ust/liblttng-ust/lttng-events.c around line 628.<br>
><br>
<br>
Thanks for clarifying!<br>
<br>
Keep in mind that the filter's byte code is generated by the lttng<br>
binary without knowing the events' declarations. Thus, the byte code<br>
must go through a linking stage not completely unlike what is done by<br>
a regular linker. One of the objectives of the linking stage is<br>
setting the appropriate offsets to load an event's fields. The byte<br>
code is also "specialized" by resolving each field's type and
making<br>
sure the appropriate implementation of each operator is used. For<br>
instance, the FILTER_OP_EQ (check for equality) op-code is not<br>
implemented the same way for integers, doubles and strings (see<br>
lttng_filter_specialize_bytecode in lttng-filter-specialize.c).<br>
<br>
You may want to have a look at _lttng_filter_event_link_bytecode<br>
(lttng-ust/liblttng-ust/lttng-filter.c, line 318) to see how each step<br>
of the linking process is implemented.<br>
<br>
Regards,<br>
Jérémie<br>
<br>
> Thanks,<br>
><br>
> Amit Margalit<br>
> IBM XIV - Storage Reinvented<br>
> XIV-NAS Development Team<br>
> Tel. 03-689-7774<br>
> Fax. 03-689-7230<br>
><br>
><br>
><br>
> From: Jérémie Galarneau <jeremie.galarneau@efficios.com><br>
> To: Amit Margalit/Israel/IBM@IBMIL<br>
> Cc: lttng-dev@lists.lttng.org<br>
> Date: 07/18/2013 07:10 PM<br>
> Subject: Re: [lttng-dev] Question about
filtering bytecode<br>
> Sent by: jeremie.galarneau@gmail.com<br>
> ________________________________<br>
><br>
><br>
><br>
> Hi Amit,<br>
><br>
> You may find information on the Babeltrace API in babeltrace/doc/API.txt<br>
> The filtering mechanism used by the user space tracer is unrelated
to<br>
> Babeltrace.<br>
><br>
> As for the sequence of events, this is how I understand it.<br>
><br>
> When invoking the "lttng" binary with --enable-event and
a filter<br>
> option, a byte code is generated from the filtering rules<br>
> (lttng-tools/src/lib/lttng-ctl/lttng-ctl.c:704). This byte code is<br>
> then handed off to the session-daemon.<br>
><br>
> Then, when an instrumented application is launched and connects to
the<br>
> session-daemon, it receives the byte code while its events are being<br>
> enabled. To answer your question directly, that byte code will be<br>
> executed by the tracee when the event is "triggered"<br>
> (lttng-ust/liblttng-ust/lttng-filter-interpreter.c:175).<br>
><br>
> I'm not sure I understand your question about filter/event linking.
A<br>
> filter has to be linked to an event since its rules (expressions)
are<br>
> applied on that event's values. Could you clarify if that's not what<br>
> you meant?<br>
><br>
> Regards,<br>
> Jérémie<br>
><br>
> On Thu, Jul 18, 2013 at 3:12 AM, Amit Margalit <AMITM@il.ibm.com>
wrote:<br>
>> Hi,<br>
>><br>
>> I'm considering whether I can write a wrapper for the libbabeltrace
ctf<br>
>> iterator which provides a filtered "next()" method.<br>
>><br>
>> I've started reading the code in the hopes of understanding how
to do<br>
>> this,<br>
>> and yet, I'd really appreciate a link to some ordered documentation,
or -<br>
>> any other kind of explanation.<br>
>><br>
>> For example, one thing I still don't understand is the exact sequence,
and<br>
>> where the bytecode is actually executed? What is the meaning and
purpose<br>
>> of<br>
>> "linking" the filter to an event.<br>
>><br>
>> Thanks,<br>
>><br>
>> Amit Margalit<br>
>> IBM XIV - Storage Reinvented<br>
>> XIV-NAS Development Team<br>
>> Tel. 03-689-7774<br>
>> Fax. 03-689-7230<br>
>> _______________________________________________<br>
>> lttng-dev mailing list<br>
>> lttng-dev@lists.lttng.org<br>
>> </font></tt><a href="http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev"><tt><font size=2>http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev</font></tt></a><tt><font size=2><br>
>><br>
><br>
><br>
><br>
> --<br>
> Jérémie Galarneau<br>
> EfficiOS Inc.<br>
> </font></tt><a href=http://www.efficios.com/><tt><font size=2>http://www.efficios.com</font></tt></a><tt><font size=2><br>
><br>
><br>
<br>
<br>
<br>
-- <br>
Jérémie Galarneau<br>
EfficiOS Inc.<br>
</font></tt><a href=http://www.efficios.com/><tt><font size=2>http://www.efficios.com</font></tt></a><tt><font size=2><br>
<br>
</font></tt>
<br>