Re: [PATCH 2/3] perf build: Use libtraceevent from the system

Arnaldo Carvalho de Melo
2022-12-06T16:39:07Z

Em Tue, Dec 06, 2022 at 01:30:33PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Tue, Dec 06, 2022 at 01:23:45PM -0300, Arnaldo Carvalho de Melo escreveu:
> > Em Tue, Dec 06, 2022 at 01:20:12PM -0300, Arnaldo Carvalho de Melo escreveu:
> > >
> > > util/scripting-engines/trace-event-perl.c:104:43: error: ‘struct tep_print_flag_sym’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
> > > 104 | static void define_symbolic_values(struct tep_print_flag_sym *field,
> > > | ^~~~~~~~~~~~~~~~~~
> > > util/scripting-engines/trace-event-perl.c: In function ‘define_symbolic_values’:
> >
> > This cured it, folding into your patch:
> >
> > diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c
> > index 5b602b6d46854133..0bacb49408f84adf 100644
> > --- a/tools/perf/util/scripting-engines/trace-event-perl.c
> > +++ b/tools/perf/util/scripting-engines/trace-event-perl.c
> > @@ -27,6 +27,7 @@
> > #include <errno.h>
> > #include <linux/bitmap.h>
> > #include <linux/time64.h>
> > +#include <traceevent/event-parse.h>
> >
> > #include <stdbool.h>
> > /* perl needs the following define, right after including stdbool.h */
>
> Building with NO_LIBTRACEEVENT=1 I get:
>
> CC /tmp/build/perf/util/cap.o
> util/data-convert-bt.c: In function ‘get_tracepoint_field_type’:
> util/data-convert-bt.c:194:36: error: invalid use of undefined type ‘struct tep_format_field’
> 194 | unsigned long flags = field->flags;
> | ^~
> util/data-convert-bt.c:196:21: error: ‘TEP_FIELD_IS_STRING’ undeclared (first use in this function)
> 196 | if (flags & TEP_FIELD_IS_STRING)
> | ^~~~~~~~~~~~~~~~~~~
> util/data-convert-bt.c:196:21: note: each undeclared identifier is reported only once for each function it appears in
> util/data-convert-bt.c:199:23: error: ‘TEP_FIELD_IS_SIGNED’ undeclared (first use in this function)
> 199 | if (!(flags & TEP_FIELD_IS_SIGNED)) {
> | ^~~~~~~~~~~~~~~~~~~
> util/data-convert-bt.c:201:29: error: ‘TEP_FIELD_IS_LONG’ undeclared (first use in this function)
> 201 | if (flags & TEP_FIELD_IS_LONG || flags & TEP_FIELD_IS_POINTER)
> | ^~~~~~~~~~~~~~~~~
>
>
> working on it...

Below makes it progress a bit, now to look at the perl Context stuff.

diff --git a/tools/perf/builtin-data.c b/tools/perf/builtin-data.c
index c22d82d2a73c4d96..b2a9a3b7f68d7f6f 100644
--- a/tools/perf/builtin-data.c
+++ b/tools/perf/builtin-data.c
@@ -78,12 +78,13 @@ static int cmd_data_convert(int argc, const char **argv)
return bt_convert__perf2json(input_name, to_json, &opts);

if (to_ctf) {
-#ifdef HAVE_LIBBABELTRACE_SUPPORT
+#if defined(HAVE_LIBBABELTRACE_SUPPORT) && defined(HAVE_LIBTRACEEVENT)
return bt_convert__perf2ctf(input_name, to_ctf, &opts);
#else
pr_err("The libbabeltrace support is not compiled in. perf should be "
"compiled with environment variables LIBBABELTRACE=1 and "
- "LIBBABELTRACE_DIR=/path/to/libbabeltrace/\n");
+ "LIBBABELTRACE_DIR=/path/to/libbabeltrace/.\n"
+ "Check also if libbtraceevent devel files are available.\n");
return -1;
#endif
}
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index c7993fb025cf180f..255bc751d19452f2 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -189,7 +189,10 @@ perf-$(CONFIG_LIBUNWIND) += unwind-libunwind.o
perf-$(CONFIG_LIBUNWIND_X86) += libunwind/x86_32.o
perf-$(CONFIG_LIBUNWIND_AARCH64) += libunwind/arm64.o

-perf-$(CONFIG_LIBBABELTRACE) += data-convert-bt.o
+ifeq ($(CONFIG_TRACEEVENT),y)
+ perf-$(CONFIG_LIBBABELTRACE) += data-convert-bt.o
+endif
+
perf-y += data-convert-json.o

perf-y += scripting-engines/