Re: [PATCH v2 05/15] tools lib traceevent: Introduced new traceevent API, for adding new plugins directories.

From: Steven Rostedt
Date: Tue Jul 07 2020 - 11:30:38 EST


On Wed, 8 Jul 2020 00:06:38 +0900
Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
> >
> > +/**
> > + * tep_add_plugin_path - Add a new plugin directory.
> > + * @tep: Trace event handler.
> > + * @path: Path to a directory. All files with extension .so in that
>
> Is the extension (".so") fixed? I think a new API has the suffix argument
> which may change it... ?

So this should add a "suffix" argument? NULL for ".so"?

>
>
> > + * directory will be loaded as plugins.
> > + *@prio: Load priority of the plugins in that directory.
> > + *
> > + * Returns -1 in case of an error, 0 otherwise.
> > + */
> > +int tep_add_plugin_path(struct tep_handle *tep, char *path,
> > + enum tep_plugin_load_priority prio)
> > +{
> > + struct tep_plugins_dir *dir;
> > +
> > + if (!tep || !path)
> > + return -1;
> > +
> > + dir = calloc(1, sizeof(*dir));
> > + if (!dir)
> > + return -1;
> > +
> > + dir->path = strdup(path);
>
> It needs to check the return value..

Yes it does indeed.

BTW, since these patches are already in trace-cmd.git, would be OK if
we just write patches on top of this series to address your concerns.
This way, we would be also adding them to trace-cmd.git as well.

I eventually want a separate libraries repo on kernel.org that this
lives in and remove it from the tools/lib directory of the kernel.

-- Steve


>
> > + dir->prio = prio;
> > + dir->next = tep->plugins_dir;
> > + tep->plugins_dir = dir;
> > +
> > + return 0;
> > +}
> > +
> > +void tep_free_plugin_paths(struct tep_handle *tep)
> > +{
> > + struct tep_plugins_dir *dir;
> > +
> > + if (!tep)
> > + return;
> > +
> > + dir = tep->plugins_dir;
> > + while (dir) {
> > + tep->plugins_dir = tep->plugins_dir->next;
> > + free(dir->path);
> > + free(dir);
> > + dir = tep->plugins_dir;
> > + }
> > +}
> > +
> > void
> > tep_unload_plugins(struct tep_plugin_list *plugin_list, struct tep_handle *tep)
> > {
> > --
> > 2.26.2
> >
> >