lttng-dev Archive mirror
 help / color / mirror / Atom feed
From: Simon Marchi via lttng-dev <lttng-dev@lists.lttng.org>
To: Maksim Khmelevskiy <mk.void.mail@gmail.com>
Cc: lttng-dev@lists.lttng.org
Subject: Re: [lttng-dev] C API message iterator example for libbabeltrace2
Date: Wed, 24 Aug 2022 11:56:09 -0400	[thread overview]
Message-ID: <9464af1b-abd9-16ad-886d-d1bfb7a88b8d@simark.ca> (raw)
In-Reply-To: <CACXehJA_FDBvnyUTSJ7k0fOOcFgPbr-7s9m-J8kdNVn=Vk28Xw@mail.gmail.com>

On 8/20/22 12:14, Maksim Khmelevskiy via lttng-dev wrote:
> Hi Simon,
> thanks for the reply!

> What I came up with for now is this example
> <https://github.com/ImMax/babeltrace/commit/2082a0f4d77d2edeec6fb95c308a79fb313f7a02>.
> It's probably has a lot of design mistakes but it's at least runnable.

Looks like a good prototype, it seems right.  Some hopefully
constructive comments:

 - You can probably use bt_plugin_find to find a plugin by name instead
   of your code that does it by hand
 - When you instantiate a src.ctf.fs component, it may have more than
   one port (there is one port per data stream), in which case you want
   to connect them all to a flt.utils.muxer component (which is what the
   CLI and the Python TraceCollectionMessageIterator class do) to funnel
   all the messages to a single output port.  Of course, if you know
   the CTF traces you deal with have a single data stream, that is not
   necessary.

> I also see that examples for C API aren't build, but maybe I'm wrong.

C API examples in the documentation indeed aren't built.

> Another thing, if you have lack of resources I would be happy to help, I could make a PR with your guidance and review.
>

> Answers to the questions:
> 1) Not sure that I completely understand the question, I wanted to parse events(name, fields), not the metadata file aligned with the CTF trace file.
> 2) Because I wanted to get C-structs directly from the CTF traces. I'm sure that it's very niche requirement, sane people would not need it.
> 3) I would do something like that, but I have a requirement of providing C structs. I guess to apply filters or do something else with traces (I'm not sure, not my idea, but I also find it weird)

Ok, I understand.  When you said you need to write "C structs", I
thought you meant that you needed to output some generated C code, for
instance convert event types to structures, for use in a program later.
But that's not the case, you want to take event payload and fill out
some structures at runtime, from what I can see.  That explains why you
want to use the C API and why you want to create and run a graph in your
own application.

Following your questions, I have written an example of creating and
running a graph, which I just submitted for review here:

  https://review.lttng.org/c/babeltrace/+/8741

It is roughly equivalent to this Python example:

  https://babeltrace.org/docs/v2.0/python/bt2/examples.html#build-and-run-a-trace-processing-graph

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

      reply	other threads:[~2022-08-24 15:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-12 13:19 [lttng-dev] C API message iterator example for libbabeltrace2 Maksim Khmelevskiy via lttng-dev
2022-08-19 15:00 ` Simon Marchi via lttng-dev
2022-08-20 16:14   ` Maksim Khmelevskiy via lttng-dev
2022-08-24 15:56     ` Simon Marchi via lttng-dev [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9464af1b-abd9-16ad-886d-d1bfb7a88b8d@simark.ca \
    --to=lttng-dev@lists.lttng.org \
    --cc=mk.void.mail@gmail.com \
    --cc=simark@simark.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).