linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6 v2] trace-cmd/kernelshark: Fixed build, cleanups and fix kernelshark
@ 2020-12-16 23:19 Steven Rostedt
  2020-12-16 23:19 ` [PATCH 1/6 v2] trace-cmd: Move add_event_pid() out of #ifndef NO_PTRACE Steven Rostedt
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Steven Rostedt @ 2020-12-16 23:19 UTC (permalink / raw)
  To: linux-trace-devel; +Cc: Yordan Karadzhov (VMware)

Sent out a v1, but the change log of patch 2 had issues that quilt 
could not deal with, and was rejected. The v1 had just the first
three patches. This series has more to handle KernelShark v1 building.

Steven Rostedt (VMware) (5):
      trace-cmd: Move add_event_pid() out of #ifndef NO_PTRACE
      trace-cmd: Add #include <fcntl.h> to trace-cmd-private.h
      trace-cmd: Add a make-trace-cmd.sh script to simplify creating a trace-cmd package
      trace-cmd: Do not have local builds of libtraceevent or libtracefs use system headers
      kernelshark: Build libtraceevent and libtracefs locally

Yordan Karadzhov (VMware) (1):
      trace-cmd: Re-enable the build of KernelShark v1

----
 Makefile                                          | 24 ++++++++++++------
 PACKAGING                                         | 30 ++++++++++++++++++++++
 kernel-shark/CMakeLists.txt                       |  1 +
 kernel-shark/build/FindTraceCmd.cmake             | 29 +++++----------------
 kernel-shark/src/libkshark.c                      | 14 ++++++----
 kernel-shark/src/libkshark.h                      |  2 +-
 lib/trace-cmd/include/private/trace-cmd-private.h |  1 +
 lib/traceevent/Makefile                           |  6 +++++
 lib/tracefs/Makefile                              |  8 ++++++
 make-trace-cmd.sh                                 | 31 +++++++++++++++++++++++
 tracecmd/trace-record.c                           | 12 ++++-----
 11 files changed, 115 insertions(+), 43 deletions(-)
 create mode 100644 PACKAGING
 create mode 100755 make-trace-cmd.sh

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/6 v2] trace-cmd: Move add_event_pid() out of #ifndef NO_PTRACE
  2020-12-16 23:19 [PATCH 0/6 v2] trace-cmd/kernelshark: Fixed build, cleanups and fix kernelshark Steven Rostedt
@ 2020-12-16 23:19 ` Steven Rostedt
  2020-12-16 23:19 ` [PATCH 2/6 v2] trace-cmd: Add #include <fcntl.h> to trace-cmd-private.h Steven Rostedt
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Steven Rostedt @ 2020-12-16 23:19 UTC (permalink / raw)
  To: linux-trace-devel; +Cc: Yordan Karadzhov (VMware)

From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

When NO_PTRACE is defined, add_event_pid() is also not defined, but it is
used outside of NO_PTRACE pre processor block. And this causes a
"add_event_pid" not defined build failure.

Fixes: 0844cff1c ("trace-cmd: Fix "trace-cmd reset" command to restore the default value of set_event_pid")
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 tracecmd/trace-record.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index f8baed7dcd47..e2d1cedf05fb 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -1312,8 +1312,13 @@ out:
 	free(pidfds);
 	return ret;
 }
-#ifndef NO_PTRACE
 
+static void add_event_pid(struct buffer_instance *instance, const char *buf)
+{
+	tracefs_instance_file_write(instance->tracefs, "set_event_pid", buf);
+}
+
+#ifndef NO_PTRACE
 /**
  * append_pid_filter - add a new pid to an existing filter
  * @curr_filter: the filter to append to. If NULL, then allocate one
@@ -1369,11 +1374,6 @@ static void update_sched_events(struct buffer_instance *instance, int pid)
 static int open_instance_fd(struct buffer_instance *instance,
 			    const char *file, int flags);
 
-static void add_event_pid(struct buffer_instance *instance, const char *buf)
-{
-	tracefs_instance_file_write(instance->tracefs, "set_event_pid", buf);
-}
-
 static void add_new_filter_child_pid(int pid, int child)
 {
 	struct buffer_instance *instance;
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/6 v2] trace-cmd: Add #include <fcntl.h> to trace-cmd-private.h
  2020-12-16 23:19 [PATCH 0/6 v2] trace-cmd/kernelshark: Fixed build, cleanups and fix kernelshark Steven Rostedt
  2020-12-16 23:19 ` [PATCH 1/6 v2] trace-cmd: Move add_event_pid() out of #ifndef NO_PTRACE Steven Rostedt
@ 2020-12-16 23:19 ` Steven Rostedt
  2020-12-16 23:19 ` [PATCH 3/6 v2] trace-cmd: Add a make-trace-cmd.sh script to simplify creating a trace-cmd package Steven Rostedt
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Steven Rostedt @ 2020-12-16 23:19 UTC (permalink / raw)
  To: linux-trace-devel; +Cc: Yordan Karadzhov (VMware)

From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

Getting the following warning in the build:

lib/trace-cmd/include/private/trace-cmd-private.h:276:41: warning: `struct iovec` declared inside parameter list will not be visible outside of this definition or declaration
  276 |         unsigned short id, const struct iovec *vector, int count);
      |                                         ^~~~~

The file trace-cmd-private.h needs to include fcntl.h to get the iovec structure
definition.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 lib/trace-cmd/include/private/trace-cmd-private.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/trace-cmd/include/private/trace-cmd-private.h b/lib/trace-cmd/include/private/trace-cmd-private.h
index a0dac5da14d6..6494581527a3 100644
--- a/lib/trace-cmd/include/private/trace-cmd-private.h
+++ b/lib/trace-cmd/include/private/trace-cmd-private.h
@@ -6,6 +6,7 @@
 #ifndef _TRACE_CMD_PRIVATE_H
 #define _TRACE_CMD_PRIVATE_H
 
+#include <fcntl.h> /* for iovec */
 #include <sys/types.h>
 #include "traceevent/event-parse.h"
 #include "trace-cmd/trace-cmd.h"
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/6 v2] trace-cmd: Add a make-trace-cmd.sh script to simplify creating a trace-cmd package
  2020-12-16 23:19 [PATCH 0/6 v2] trace-cmd/kernelshark: Fixed build, cleanups and fix kernelshark Steven Rostedt
  2020-12-16 23:19 ` [PATCH 1/6 v2] trace-cmd: Move add_event_pid() out of #ifndef NO_PTRACE Steven Rostedt
  2020-12-16 23:19 ` [PATCH 2/6 v2] trace-cmd: Add #include <fcntl.h> to trace-cmd-private.h Steven Rostedt
@ 2020-12-16 23:19 ` Steven Rostedt
  2020-12-16 23:19 ` [PATCH 4/6 v2] trace-cmd: Do not have local builds of libtraceevent or libtracefs use system headers Steven Rostedt
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Steven Rostedt @ 2020-12-16 23:19 UTC (permalink / raw)
  To: linux-trace-devel; +Cc: Yordan Karadzhov (VMware)

From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

Add a script "make-trace-cmd.sh" and a help file "PACKAGKING" to describe
what it does. The make-trace-cmd.sh will help create a full directory that
has libtraceevent, libtracefs, libtracecmd and trace-cmd binary without
needing to install them on the host machine.

As described in PACKAGING, the steps to do so are:

 git clone git://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git
 git clone git://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git
 git clone git://git.kernel.org/pub/scm/utils/trace-cmd/trace-cmd.git

 cd libtraceevent
 INSTALL_PATH=/tmp/install ../trace-cmd/make-trace-cmd.sh install

 cd ../libtracefs
 INSTALL_PATH=/tmp/install ../trace-cmd/make-trace-cmd.sh install

 cd ../trace-cmd
 INSTALL_PATH=/tmp/install ./make-trace-cmd.sh install install_libs

 cd /tmp/install
 tar cvjf /tmp/trace-cmd-files.tar.bz2 .

And then the tarball of /tmp/trace-cmd-files.tar.bz2 will can be extracted
on another machine at the root directory, and trace-cmd will be installed there.

Note, the above process uses the /usr prefix. To have the package be
installed in /usr/local, add:

 PREFIX=/usr/local

in front of each of the make-trace-cmd.sh commands.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 PACKAGING         | 30 ++++++++++++++++++++++++++++++
 make-trace-cmd.sh | 31 +++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+)
 create mode 100644 PACKAGING
 create mode 100755 make-trace-cmd.sh

diff --git a/PACKAGING b/PACKAGING
new file mode 100644
index 000000000000..7e7d20653017
--- /dev/null
+++ b/PACKAGING
@@ -0,0 +1,30 @@
+The libtracefs and libtraceevent packages are required for trace-cmd
+and libtracecmd.so
+
+In order to create a package directory with libtraceevent, libtracefs
+and libtracecmd and trace-cmd, you can follow these steps:
+
+ git clone git://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git
+ git clone git://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git
+ git clone git://git.kernel.org/pub/scm/utils/trace-cmd/trace-cmd.git
+
+ cd libtraceevent
+ INSTALL_PATH=/tmp/install ../trace-cmd/make-trace-cmd.sh install
+
+ cd ../libtracefs
+ INSTALL_PATH=/tmp/install ../trace-cmd/make-trace-cmd.sh install
+
+ cd ../trace-cmd
+ INSTALL_PATH=/tmp/install ./make-trace-cmd.sh install install_libs
+
+ cd /tmp/install
+ tar cvjf /tmp/trace-cmd-files.tar.bz2 .
+
+And then the tarball of /tmp/trace-cmd-files.tar.bz2 will can be extracted
+on another machine at the root directory, and trace-cmd will be installed there.
+
+Note, to define a prefix, add a PREFIX variable before calling make-trace-cmd.sh
+
+ For example:
+
+  PREFIX=/usr/local INSTALL_PATH=/tmp/install ./make-trace-cmd.sh install
diff --git a/make-trace-cmd.sh b/make-trace-cmd.sh
new file mode 100755
index 000000000000..ddff18146c84
--- /dev/null
+++ b/make-trace-cmd.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+if [ -z "$INSTALL_PATH" ]; then
+	echo
+	echo 'Error: No $INSTALL_PATH defined'
+	echo
+	echo "   usage: [PREFIX=prefix][BUILD_PATH=/path/to/build] INSTALL_PATH=/path/to/install make-trace-cmd.sh install|install_libs|clean|uninstall"
+	echo
+	echo "     Used to create a self contained directory to copy to other machines."
+	echo
+	echo "   Please read PACKAGING for more information."
+	echo
+	exit
+fi
+
+if [ ! -d $INSTALL_PATH ]; then
+	mkdir $INSTALL_PATH
+fi
+
+if [ ! -z "$BUILD_PATH" ]; then
+	if [ ! -d $BUILD_PATH ]; then
+		mkdir $BUILD_PATH
+	fi
+	O_PATH="O=$BUILD_PATH"
+fi
+
+if [ -z "$PREFIX" ]; then
+	PREFIX="/usr"
+fi
+
+PKG_CONFIG="pkg-config --with-path $INSTALL_PATH/usr/lib64/pkgconfig --define-variable=prefix=$INSTALL_PATH/$PREFIX" CFLAGS="-g -Wall -I$INSTALL_PATH/$PREFIX/include" make DESTDIR=$INSTALL_PATH  $O_PATH prefix=$PREFIX $@
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/6 v2] trace-cmd: Do not have local builds of libtraceevent or libtracefs use system headers
  2020-12-16 23:19 [PATCH 0/6 v2] trace-cmd/kernelshark: Fixed build, cleanups and fix kernelshark Steven Rostedt
                   ` (2 preceding siblings ...)
  2020-12-16 23:19 ` [PATCH 3/6 v2] trace-cmd: Add a make-trace-cmd.sh script to simplify creating a trace-cmd package Steven Rostedt
@ 2020-12-16 23:19 ` Steven Rostedt
  2020-12-16 23:19 ` [PATCH 5/6 v2] kernelshark: Build libtraceevent and libtracefs locally Steven Rostedt
  2020-12-16 23:19 ` [PATCH 6/6 v2] trace-cmd: Re-enable the build of KernelShark v1 Steven Rostedt
  5 siblings, 0 replies; 7+ messages in thread
From: Steven Rostedt @ 2020-12-16 23:19 UTC (permalink / raw)
  To: linux-trace-devel; +Cc: Yordan Karadzhov (VMware)

From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

If building locally, do not use system includes. This is needed for
kernelshark v1 to build libtraceevent and libtracefs. If the system header
files are used, there may be a mismatch with the frozen version of
libtraceevent or libtracefs that kernelshark will use, and the system
headers, and the build will fail.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 lib/traceevent/Makefile | 4 ++++
 lib/tracefs/Makefile    | 5 +++++
 2 files changed, 9 insertions(+)

diff --git a/lib/traceevent/Makefile b/lib/traceevent/Makefile
index 0dcd90c13328..21ef5a4ea59f 100644
--- a/lib/traceevent/Makefile
+++ b/lib/traceevent/Makefile
@@ -6,8 +6,12 @@ bdir:=$(obj)/lib/traceevent
 
 DEFAULT_TARGET = $(bdir)/libtraceevent.a
 
+LIBTRACEEVENT_CFLAGS = -I$(src)/include/traceevent -I$(src)/lib/traceevent/include
+
 CFLAGS += -I$(bdir)/include
 
+CFLAGS := $(LIBTRACEEVENT_CFLAGS) $(CFLAGS)
+
 OBJS =
 OBJS += event-parse.o
 OBJS += event-plugin.o
diff --git a/lib/tracefs/Makefile b/lib/tracefs/Makefile
index 021ae2b040de..6f4370d96f10 100644
--- a/lib/tracefs/Makefile
+++ b/lib/tracefs/Makefile
@@ -6,8 +6,13 @@ bdir:=$(obj)/lib/tracefs
 
 DEFAULT_TARGET = $(bdir)/libtracefs.a
 
+LIBTRACEEVENT_CFLAGS = -I$(src)/include/traceevent -I$(src)/lib/traceevent/include
+LIBTRACEFS_CFLAGS = -I$(src)/include/tracefs -I$(src)/lib/tracefs/include
+
 CFLAGS += -I$(bdir)/include
 
+CFLAGS := $(LIBTRACEEVENT_CFLAGS) $(LIBTRACEFS_CFLAGS) $(CFLAGS)
+
 OBJS =
 OBJS += tracefs-utils.o
 OBJS += tracefs-instance.o
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 5/6 v2] kernelshark: Build libtraceevent and libtracefs locally
  2020-12-16 23:19 [PATCH 0/6 v2] trace-cmd/kernelshark: Fixed build, cleanups and fix kernelshark Steven Rostedt
                   ` (3 preceding siblings ...)
  2020-12-16 23:19 ` [PATCH 4/6 v2] trace-cmd: Do not have local builds of libtraceevent or libtracefs use system headers Steven Rostedt
@ 2020-12-16 23:19 ` Steven Rostedt
  2020-12-16 23:19 ` [PATCH 6/6 v2] trace-cmd: Re-enable the build of KernelShark v1 Steven Rostedt
  5 siblings, 0 replies; 7+ messages in thread
From: Steven Rostedt @ 2020-12-16 23:19 UTC (permalink / raw)
  To: linux-trace-devel; +Cc: Yordan Karadzhov (VMware)

From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

kernelshark v1 is now frozen in favor of developing kernelshark v2. Do not
use the system libraries libtraceevent or libtracefs for kernelshark v1, as
they may not be suitable. Use the frozen libtraceevent and libtracefs that
is in the local repository.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 Makefile                | 24 ++++++++++++++++--------
 lib/traceevent/Makefile |  2 ++
 lib/tracefs/Makefile    |  3 +++
 3 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/Makefile b/Makefile
index 662d24ba288f..7aef50b34a56 100644
--- a/Makefile
+++ b/Makefile
@@ -354,19 +354,14 @@ $(PKG_CONFIG_FILE) : ${PKG_CONFIG_SOURCE_FILE}.template $(BUILD_PREFIX)
 $(kshark-dir)/build/Makefile: $(kshark-dir)/CMakeLists.txt
 	$(Q) cd $(kshark-dir)/build && $(CMAKE_COMMAND) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -D_INSTALL_PREFIX=$(prefix) -D_LIBDIR=$(libdir) ..
 
-gui: force
-	$(MAKE) $(CMD_TARGETS)
-	$(MAKE) $(kshark-dir)/build/Makefile
-	$(Q)$(MAKE) $(S) -C $(kshark-dir)/build
-	@echo "gui build complete"
-	@echo "  kernelshark located at $(kshark-dir)/bin"
-
 trace-cmd: force $(LIBTRACEEVENT_STATIC_BUILD) $(LIBTRACECMD_STATIC) $(LIBTRACEFS_STATIC_BUILD) \
 	force $(obj)/lib/trace-cmd/plugins/tracecmd_plugin_dir
 	$(Q)$(MAKE) -C $(src)/tracecmd $(obj)/tracecmd/$@
 
-$(LIBTRACEEVENT_STATIC): force $(obj)/lib/traceevent/plugins/trace_python_dir \
+LIBTRACEEVENT_DEPENDS = $(obj)/lib/traceevent/plugins/trace_python_dir \
 			 $(obj)/lib/traceevent/plugins/traceevent_plugin_dir
+
+$(LIBTRACEEVENT_STATIC): force $(LIBTRACEEVENT_DEPENDS)
 	$(Q)$(MAKE) -C $(src)/lib/traceevent libtraceevent
 
 $(LIBTRACECMD_STATIC): force
@@ -385,6 +380,19 @@ libtracefs.a: $(LIBTRACEFS_STATIC)
 
 libs: $(LIBTRACECMD_SHARED) $(LIBTRACEEVENT_STATIC_BUILD) $(LIBTRACEFS_STATIC_BUILD) $(PKG_CONFIG_FILE)
 
+libtraceevent_nowarn: $(LIBTRACEEVENT_DEPENDS)
+	$(Q)$(MAKE) -C $(src)/lib/traceevent $@
+
+libtracefs_nowarn: force
+	$(Q)$(MAKE) -C $(src)/lib/tracefs $@
+
+
+gui: force $(CMD_TARGETS) libtraceevent_nowarn libtracefs_nowarn
+	$(MAKE) $(kshark-dir)/build/Makefile
+	$(Q)$(MAKE) $(S) -C $(kshark-dir)/build
+	@echo "gui build complete"
+	@echo "  kernelshark located at $(kshark-dir)/bin"
+
 test: force $(LIBTRACEEVENT_STATIC_BUILD) $(LIBTRACEFS_STATIC_BUILD) $(LIBTRACECMD_STATIC)
 ifneq ($(CUNIT_INSTALLED),1)
 	$(error CUnit framework not installed, cannot build unit tests))
diff --git a/lib/traceevent/Makefile b/lib/traceevent/Makefile
index 21ef5a4ea59f..21eaffd21f7a 100644
--- a/lib/traceevent/Makefile
+++ b/lib/traceevent/Makefile
@@ -50,6 +50,8 @@ $(bdir)/libtraceevent.a: $(OBJS)
 
 libtraceevent: $(bdir)/libtraceevent.a warning
 
+libtraceevent_nowarn: $(bdir)/libtraceevent.a
+
 $(bdir)/%.o: %.c
 	$(Q)$(call do_fpic_compile)
 
diff --git a/lib/tracefs/Makefile b/lib/tracefs/Makefile
index 6f4370d96f10..74cb8829979f 100644
--- a/lib/tracefs/Makefile
+++ b/lib/tracefs/Makefile
@@ -47,6 +47,9 @@ $(bdir)/libtracefs.a: $(OBJS)
 	$(Q)$(call do_build_static_lib)
 
 libtracefs: $(bdir)/libtracefs.a warning
+
+libtracefs_nowarn: $(bdir)/libtracefs.a
+
 $(bdir)/%.o: %.c
 	$(Q)$(call do_fpic_compile)
 
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 6/6 v2] trace-cmd: Re-enable the build of KernelShark v1
  2020-12-16 23:19 [PATCH 0/6 v2] trace-cmd/kernelshark: Fixed build, cleanups and fix kernelshark Steven Rostedt
                   ` (4 preceding siblings ...)
  2020-12-16 23:19 ` [PATCH 5/6 v2] kernelshark: Build libtraceevent and libtracefs locally Steven Rostedt
@ 2020-12-16 23:19 ` Steven Rostedt
  5 siblings, 0 replies; 7+ messages in thread
From: Steven Rostedt @ 2020-12-16 23:19 UTC (permalink / raw)
  To: linux-trace-devel; +Cc: Yordan Karadzhov (VMware)

From: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>

libtraceevent and libtracefs are now stand-alone libraries, independent
from trace-cmd, but nevertheless trace-cmd still provides legacy/obsolete
versions of this libraries. Since we are "freezing" KernelShark v1 and
all active development is now focused on  KernelShark v2, we will keep
v1 use the legacy/obsolete versions of the libraries.

An additional problem is that trace-filter-hash.h is no longer a public
header of libtracecmd. For this reason we are adding the path to the
tarce-cmd private headers to the list of header file locations.

We also remove the inclusion of event-utils.h in parse-utils.c in order
to fix a compilation error when building libtraceevent.a.

Link: https://lore.kernel.org/linux-trace-devel/20201216130715.181002-1-y.karadz@gmail.com

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
[ Removed Makefile libtraceevent updates as other commits handle them ]
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel-shark/CMakeLists.txt           |  1 +
 kernel-shark/build/FindTraceCmd.cmake | 29 ++++++---------------------
 kernel-shark/src/libkshark.c          | 14 ++++++++-----
 kernel-shark/src/libkshark.h          |  2 +-
 4 files changed, 17 insertions(+), 29 deletions(-)

diff --git a/kernel-shark/CMakeLists.txt b/kernel-shark/CMakeLists.txt
index c95249e9a235..0c0b8255d7a1 100644
--- a/kernel-shark/CMakeLists.txt
+++ b/kernel-shark/CMakeLists.txt
@@ -81,6 +81,7 @@ include_directories(${KS_DIR}/src/
                     ${KS_DIR}/build/src/
                     ${JSONC_INCLUDE_DIR}
                     ${TRACECMD_INCLUDE_DIR}
+                    ${TRACECMD_PRIVATE_INCLUDE_DIR}
                     ${TRACEFS_INCLUDE_DIR})
 
 message("")
diff --git a/kernel-shark/build/FindTraceCmd.cmake b/kernel-shark/build/FindTraceCmd.cmake
index c29b77911361..a40f70e54093 100644
--- a/kernel-shark/build/FindTraceCmd.cmake
+++ b/kernel-shark/build/FindTraceCmd.cmake
@@ -14,25 +14,15 @@
 # MESSAGE(" Looking for trace-cmd ...")
 
 # First search in the user provided paths.
-if (CMAKE_BUILD_TYPE MATCHES Debug)
-
-  find_program(TRACECMD_EXECUTABLE   NAMES  trace-cmd
-                                     PATHS  $ENV{TRACE_CMD}/tracecmd/
-                                            ${CMAKE_SOURCE_DIR}/../tracecmd/
-                                     NO_DEFAULT_PATH)
-
-endif (CMAKE_BUILD_TYPE MATCHES Debug)
-
-if (NOT TRACECMD_EXECUTABLE)
-
-  set(TRACECMD_EXECUTABLE "${_INSTALL_PREFIX}/bin/trace-cmd")
-
-endif (NOT TRACECMD_EXECUTABLE)
 
 find_path(TRACECMD_INCLUDE_DIR  NAMES  trace-cmd/trace-cmd.h
                                 PATHS  $ENV{TRACE_CMD}/include/
                                        ${CMAKE_SOURCE_DIR}/../include/
                                 NO_DEFAULT_PATH)
+find_path(TRACECMD_PRIVATE_INCLUDE_DIR  NAMES private/trace-filter-hash.h
+                                PATHS  $ENV{TRACE_CMD}/lib/trace-cmd/include/
+                                       ${CMAKE_SOURCE_DIR}/../lib/trace-cmd/include/
+                                NO_DEFAULT_PATH)
 find_path(TRACEFS_INCLUDE_DIR   NAMES  tracefs/tracefs.h
                                 PATHS  $ENV{TRACE_CMD}/include/
                                        ${CMAKE_SOURCE_DIR}/../include/
@@ -53,20 +43,13 @@ find_library(TRACEEVENT_LIBRARY NAMES  traceevent/libtraceevent.a
                                        ${CMAKE_SOURCE_DIR}/../lib/
                                 NO_DEFAULT_PATH)
 
-# If not found, search in the default system paths. Note that if the previous
-# search was successful "find_path" will do nothing this time.
 find_program(TRACECMD_EXECUTABLE   NAMES  trace-cmd)
-find_path(TRACECMD_INCLUDE_DIR  NAMES  trace-cmd/trace-cmd.h)
-find_path(TRACEFS_INCLUDE_DIR   NAMES  tracefs/tracefs.h)
-find_library(TRACECMD_LIBRARY   NAMES  trace-cmd/libtracecmd.so)
-find_library(TRACEFS_LIBRARY    NAMES  tracefs/libtracefs.so)
-find_library(TRACEEVENT_LIBRARY NAMES  traceevent/libtraceevent.so)
 
-IF (TRACECMD_INCLUDE_DIR AND TRACECMD_LIBRARY)
+IF (TRACECMD_INCLUDE_DIR AND TRACECMD_PRIVATE_INCLUDE_DIR AND TRACECMD_LIBRARY)
 
   SET(TRACECMD_FOUND TRUE)
 
-ENDIF (TRACECMD_INCLUDE_DIR AND TRACECMD_LIBRARY)
+ENDIF (TRACECMD_INCLUDE_DIR AND TRACECMD_PRIVATE_INCLUDE_DIR AND TRACECMD_LIBRARY)
 
 IF (TRACECMD_FOUND)
 
diff --git a/kernel-shark/src/libkshark.c b/kernel-shark/src/libkshark.c
index 52aacd3044eb..4e625a25e902 100644
--- a/kernel-shark/src/libkshark.c
+++ b/kernel-shark/src/libkshark.c
@@ -141,10 +141,14 @@ bool kshark_open(struct kshark_context *kshark_ctx, const char *file)
 
 	kshark_free_task_list(kshark_ctx);
 
-	handle = tracecmd_open(file);
+	handle = tracecmd_open_head(file);
 	if (!handle)
 		return false;
 
+	/* Read the tracing data from the file. */
+	if (tracecmd_init_data(handle) < 0)
+		return false;
+
 	if (pthread_mutex_init(&kshark_ctx->input_mutex, NULL) != 0) {
 		tracecmd_close(handle);
 		return false;
@@ -696,7 +700,7 @@ static ssize_t get_records(struct kshark_context *kshark_ctx,
 	int pid;
 	int cpu;
 
-	n_cpus = tracecmd_cpus(kshark_ctx->handle);
+	n_cpus = tep_get_cpus(kshark_ctx->pevent);;
 	cpu_list = calloc(n_cpus, sizeof(*cpu_list));
 	if (!cpu_list)
 		return -ENOMEM;
@@ -867,7 +871,7 @@ ssize_t kshark_load_data_entries(struct kshark_context *kshark_ctx,
 	if (total < 0)
 		goto fail;
 
-	n_cpus = tracecmd_cpus(kshark_ctx->handle);
+	n_cpus = tep_get_cpus(kshark_ctx->pevent);;
 
 	rows = calloc(total, sizeof(struct kshark_entry *));
 	if (!rows)
@@ -923,7 +927,7 @@ ssize_t kshark_load_data_records(struct kshark_context *kshark_ctx,
 	if (total < 0)
 		goto fail;
 
-	n_cpus = tracecmd_cpus(kshark_ctx->handle);
+	n_cpus = tep_get_cpus(kshark_ctx->pevent);;
 
 	rows = calloc(total, sizeof(struct tep_record *));
 	if (!rows)
@@ -1047,7 +1051,7 @@ size_t kshark_load_data_matrix(struct kshark_context *kshark_ctx,
 	if (total < 0)
 		goto fail;
 
-	n_cpus = tracecmd_cpus(kshark_ctx->handle);
+	n_cpus = tep_get_cpus(kshark_ctx->pevent);;
 
 	status = data_matrix_alloc(total, offset_array,
 					  cpu_array,
diff --git a/kernel-shark/src/libkshark.h b/kernel-shark/src/libkshark.h
index 0d6c50d10c1b..a9cba054a32f 100644
--- a/kernel-shark/src/libkshark.h
+++ b/kernel-shark/src/libkshark.h
@@ -26,7 +26,7 @@ extern "C" {
 
 // trace-cmd
 #include "trace-cmd/trace-cmd.h"
-#include "trace-cmd/trace-filter-hash.h"
+#include "private/trace-filter-hash.h"
 #include "traceevent/event-parse.h"
 #include "tracefs/tracefs.h"
 
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-12-16 23:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-16 23:19 [PATCH 0/6 v2] trace-cmd/kernelshark: Fixed build, cleanups and fix kernelshark Steven Rostedt
2020-12-16 23:19 ` [PATCH 1/6 v2] trace-cmd: Move add_event_pid() out of #ifndef NO_PTRACE Steven Rostedt
2020-12-16 23:19 ` [PATCH 2/6 v2] trace-cmd: Add #include <fcntl.h> to trace-cmd-private.h Steven Rostedt
2020-12-16 23:19 ` [PATCH 3/6 v2] trace-cmd: Add a make-trace-cmd.sh script to simplify creating a trace-cmd package Steven Rostedt
2020-12-16 23:19 ` [PATCH 4/6 v2] trace-cmd: Do not have local builds of libtraceevent or libtracefs use system headers Steven Rostedt
2020-12-16 23:19 ` [PATCH 5/6 v2] kernelshark: Build libtraceevent and libtracefs locally Steven Rostedt
2020-12-16 23:19 ` [PATCH 6/6 v2] trace-cmd: Re-enable the build of KernelShark v1 Steven Rostedt

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 NNTP newsgroup(s).