[lttng-dev] [RFC babeltrace 0/2] fs-src: add metadata-src parameter
Alexander Aring
aring at mojatatu.com
Tue May 1 10:51:22 EDT 2018
Hi,
On Mon, Apr 30, 2018 at 07:11:30PM -0400, Philippe Proulx wrote:
> On Mon, Apr 30, 2018 at 5:31 PM, Alexander Aring <aring at mojatatu.com> wrote:
> > Hi,
> >
> > my use-case is just... we have several application with the same metadata
> > file. Currently I build a wrapper around babeltrace to run something like:
> >
> > find $(TRACE_DIR}/* -maxdepth 1 -type d -exec cp ${PATH_TO_MY_APP_DATA}/ctf/metadata '{}' \;
> >
> > which is terrible... so I try this here somehow.
> > As you see it has no support for fs-query and I didn't figured out yet
> > for what fs-query is for.
> >
> > Also I was struggle some hours how to tell popt the right argument string,
> > it need to be:
> >
> > --metadata-src=\"/usr/share/$APP_DIR/ctf\"
> >
> > with the ugly escape things... I saw there is a complex INI parser system
> > behind (never saw such complex option parser in an open source project).
>
> A note about this: there are two ways to add component initialization
> parameters with `babeltrace run`: with
>
> --params 'key1="the value", key2=23, key3=simple_string'
>
> and, for string parameters, with:
>
> --key key1 --value 'the value'
>
> The --params option parses what you call a "complex INI" format. It's
> not so complex in reality and well-explained in the man page.
When I have a string I need to use --key key1 --value 'the value'
otherwise key/value pairs?
I remember I saw the key value args somewhere... it seeems not be part
of babeltrace convert. I tried --params, and as the manpage said [0]:
Important
Like in the example above, make sure to single-quote the whole
argument when you run this command from a shell.
This did libpopt to parse something, but still get some "cannot create
components" error. I need to debug this more to figure out the "why".
So put everything in single quotes are important... yes this will tell
the shell to handle it as a full arg, I agree. And also there is a big
IMPORTANT in --help. :-)
I saw that source.ctf.fs had it's own implicit argument "--clock-offset"
which seemed to work for me and I tried the same with --metadata-src.
Seems to be a shortcut for --key key1 --value 'the value'.
According to the key value arg options:
It's somewhat misleading that you have args (--FOO) which need to be in a
special order e.g. --key and then --value (where value is a must after key).
Does libpopt have such feature? Anyway I would use --params always as it
accept key/value pairs as optarg.
>
> The job of `babeltrace convert` (the default command) is only to create
> a valid `babeltrace run` command line and run it. In your first patch,
I see that's why I see something when I just type my command. Then
source and sink will be connected by a magic way?
> you use append_implicit_component_param(): this one appends a key/value
> pair to the --params option's argument of a given implicit component.
> It's simply appending `,KEY=VAL` to the current INI-style parameter
> string for that component, which is why you need to pass the double
> quotes above, because the effective string to append is exactly:
>
> ,metadata-src="/usr/share/app-dir-expansion/ctf"
>
> What you want to do is have this instead:
>
> --key metadata-src --value /usr/share/app-dir-expansion/ctf
>
I am not sure how to pass these --key --value arguments. Manpage of
source.ctf.fs [0] doesn't say anything about these parameters.
> (where `app-dir-expansion` is the expansion of $APP_DIR). You can use
> append_implicit_component_extra_param() for this. This is what we use
> for complex string values like for --begin, --end, --debug-info-dir,
> etc. Then you could use:
>
> --metadata-src="/usr/share/$APP_DIR/ctf"
>
> so that popt returns `/usr/share/app-dir-expansion/ctf`.
>
When I implemented it and I try to run it. I get a confused parser error:
Command line error: Expecting value:
metadata-src=/foobar/ctf
---
arg was: --metadata-src="/foobar/ctf"
and maybe that's the reason why I don't like libpopt now. :-)
It's actually means babeltrace can not have "implicit shortcut args"
e.g. "--clock-offset" with a string value (as popt string type)?
Thanks for the answer and so fast...! :-)
- Alex
[0] http://man7.org/linux/man-pages/man1/babeltrace-convert.1.html
More information about the lttng-dev
mailing list