Linux-Trace-Devel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] kernel-shark: Get the path to trace-cmd executable from _INSTALL_PREFIX
@ 2019-07-23 18:25 Yordan Karadzhov (VMware)
  2019-07-23 18:48 ` Steven Rostedt
  0 siblings, 1 reply; 2+ messages in thread
From: Yordan Karadzhov (VMware) @ 2019-07-23 18:25 UTC (permalink / raw)
  To: rostedt; +Cc: linux-trace-devel, Yordan Karadzhov (VMware)

The absolute path to the trace-cmd executable gets derived from
"_INSTALL_PREFIX", and the "Record" dialog will be using its installed
version. This is done because nothing guaranties that the trace-cmd
executable will be presented at the time when the KernelShark package
is built. The rule has one exception and this is the case when the build
type is "Debug". In "Debug" mode the "Record" dialog will try to use the
version of the trace-cmd executable from the build location.

Sugested-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 kernel-shark/CMakeLists.txt           |  8 ++++----
 kernel-shark/README                   |  7 ++++++-
 kernel-shark/build/FindTraceCmd.cmake | 10 ++++++++--
 3 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/kernel-shark/CMakeLists.txt b/kernel-shark/CMakeLists.txt
index 45c6f23..075c4af 100644
--- a/kernel-shark/CMakeLists.txt
+++ b/kernel-shark/CMakeLists.txt
@@ -13,6 +13,10 @@ message("\n project: Kernel Shark: (version: ${KS_VERSION_STRING})\n")
 
 set(KS_DIR ${CMAKE_SOURCE_DIR})
 
+if (NOT _INSTALL_PREFIX)
+    set(_INSTALL_PREFIX "/usr/local")
+endif (NOT _INSTALL_PREFIX)
+
 include(${KS_DIR}/build/FindTraceCmd.cmake)
 include(${KS_DIR}/build/FindJSONC.cmake)
 
@@ -50,10 +54,6 @@ if (NOT CMAKE_CXX_FLAGS_PACKAGE)
     set(CMAKE_CXX_FLAGS_PACKAGE "-O3")
 endif (NOT CMAKE_CXX_FLAGS_PACKAGE)
 
-if (NOT _INSTALL_PREFIX)
-    set(_INSTALL_PREFIX "/usr/local")
-endif (NOT _INSTALL_PREFIX)
-
 set(KS_PLUGIN_INSTALL_PREFIX ${_INSTALL_PREFIX}/lib/${KS_APP_NAME}/plugins/)
 
 set(KS_ICON        KS_icon_shark.svg)
diff --git a/kernel-shark/README b/kernel-shark/README
index 7e50479..6c360bb 100644
--- a/kernel-shark/README
+++ b/kernel-shark/README
@@ -86,9 +86,14 @@ By default this build type adds the "-O2" compiler flag. Package maintainers
 can chose their own compiler flags by providing the corresponding
 CMAKE_XXXX_FLAGS_PACKAGE Command-Line options (see the example below).
 
-Note that when built as a "Package" the RPATH-s of the executables are
+-- Note that when built as a "Package" the RPATH-s of the executables are
 set directly to _INSTALL_PREFIX/lib/kernelshark/
 
+-- Note that when built as a "Debug" the "Record" dialog will try to use the
+version of the trace-cmd executable from the build location. In all other cases
+the dialog will derive the absolut path to the trace-cmd executable from
+"_INSTALL_PREFIX", hence the dialog will use the installed version.
+
 If no build types is specified, the type will be "RelWithDebInfo".
 
 Examples:
diff --git a/kernel-shark/build/FindTraceCmd.cmake b/kernel-shark/build/FindTraceCmd.cmake
index 2da4eee..d3e145c 100644
--- a/kernel-shark/build/FindTraceCmd.cmake
+++ b/kernel-shark/build/FindTraceCmd.cmake
@@ -21,6 +21,12 @@ if (CMAKE_BUILD_TYPE MATCHES Debug)
 
 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/
@@ -43,11 +49,11 @@ find_path(TRACECMD_INCLUDE_DIR  NAMES  trace-cmd/trace-cmd.h)
 find_library(TRACECMD_LIBRARY   NAMES  trace-cmd/libtracecmd.so)
 find_library(TRACEEVENT_LIBRARY NAMES  traceevent/libtraceevent.so)
 
-IF (TRACECMD_INCLUDE_DIR AND TRACECMD_LIBRARY AND TRACECMD_EXECUTABLE)
+IF (TRACECMD_INCLUDE_DIR AND TRACECMD_LIBRARY)
 
   SET(TRACECMD_FOUND TRUE)
 
-ENDIF (TRACECMD_INCLUDE_DIR AND TRACECMD_LIBRARY AND TRACECMD_EXECUTABLE)
+ENDIF (TRACECMD_INCLUDE_DIR AND TRACECMD_LIBRARY)
 
 IF (TRACECMD_FOUND)
 
-- 
2.20.1


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

* Re: [PATCH] kernel-shark: Get the path to trace-cmd executable from _INSTALL_PREFIX
  2019-07-23 18:25 [PATCH] kernel-shark: Get the path to trace-cmd executable from _INSTALL_PREFIX Yordan Karadzhov (VMware)
@ 2019-07-23 18:48 ` Steven Rostedt
  0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2019-07-23 18:48 UTC (permalink / raw)
  To: Yordan Karadzhov (VMware); +Cc: linux-trace-devel

On Tue, 23 Jul 2019 21:25:42 +0300
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com> wrote:

> The absolute path to the trace-cmd executable gets derived from
> "_INSTALL_PREFIX", and the "Record" dialog will be using its installed
> version. This is done because nothing guaranties that the trace-cmd
> executable will be presented at the time when the KernelShark package
> is built. The rule has one exception and this is the case when the build
> type is "Debug". In "Debug" mode the "Record" dialog will try to use the
> version of the trace-cmd executable from the build location.
> 
> Sugested-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>

Thanks Yordan!

I just applied this and tested it this way.

On my build system, I removed all trace-cmd and kernelshark code, and
did this:

 $ mkdir /tmp/packages
 $ make clean
 $ make DESTDIR=/tmp/packages prefix=/usr install_gui
 $ cd /tmp/packages
 $ tar -cvjf /tmp/ks-package.tar.bz2 .
 $ scp /tmp/ks-package.tar.bz2 test-machine:/tmp

on test-machine:

 $ su -
 # cd /
 # tar xvf /tmp/ks-package.tar.bz2
 # cd ~
 # which kernelshark
/usr/bin/kernelshark
 # kernelshark

And tried a record, and all seems to be working!

-- Steve


> ---
>  kernel-shark/CMakeLists.txt           |  8 ++++----
>  kernel-shark/README                   |  7 ++++++-
>  kernel-shark/build/FindTraceCmd.cmake | 10 ++++++++--
>  3 files changed, 18 insertions(+), 7 deletions(-)
> 
> diff --git a/kernel-shark/CMakeLists.txt b/kernel-shark/CMakeLists.txt
> index 45c6f23..075c4af 100644
> --- a/kernel-shark/CMakeLists.txt
> +++ b/kernel-shark/CMakeLists.txt
> @@ -13,6 +13,10 @@ message("\n project: Kernel Shark: (version: ${KS_VERSION_STRING})\n")
>  
>  set(KS_DIR ${CMAKE_SOURCE_DIR})
>  
> +if (NOT _INSTALL_PREFIX)
> +    set(_INSTALL_PREFIX "/usr/local")
> +endif (NOT _INSTALL_PREFIX)
> +
>  include(${KS_DIR}/build/FindTraceCmd.cmake)
>  include(${KS_DIR}/build/FindJSONC.cmake)
>  
> @@ -50,10 +54,6 @@ if (NOT CMAKE_CXX_FLAGS_PACKAGE)
>      set(CMAKE_CXX_FLAGS_PACKAGE "-O3")
>  endif (NOT CMAKE_CXX_FLAGS_PACKAGE)
>  
> -if (NOT _INSTALL_PREFIX)
> -    set(_INSTALL_PREFIX "/usr/local")
> -endif (NOT _INSTALL_PREFIX)
> -
>  set(KS_PLUGIN_INSTALL_PREFIX ${_INSTALL_PREFIX}/lib/${KS_APP_NAME}/plugins/)
>  
>  set(KS_ICON        KS_icon_shark.svg)
> diff --git a/kernel-shark/README b/kernel-shark/README
> index 7e50479..6c360bb 100644
> --- a/kernel-shark/README
> +++ b/kernel-shark/README
> @@ -86,9 +86,14 @@ By default this build type adds the "-O2" compiler flag. Package maintainers
>  can chose their own compiler flags by providing the corresponding
>  CMAKE_XXXX_FLAGS_PACKAGE Command-Line options (see the example below).
>  
> -Note that when built as a "Package" the RPATH-s of the executables are
> +-- Note that when built as a "Package" the RPATH-s of the executables are
>  set directly to _INSTALL_PREFIX/lib/kernelshark/
>  
> +-- Note that when built as a "Debug" the "Record" dialog will try to use the
> +version of the trace-cmd executable from the build location. In all other cases
> +the dialog will derive the absolut path to the trace-cmd executable from
> +"_INSTALL_PREFIX", hence the dialog will use the installed version.
> +
>  If no build types is specified, the type will be "RelWithDebInfo".
>  
>  Examples:
> diff --git a/kernel-shark/build/FindTraceCmd.cmake b/kernel-shark/build/FindTraceCmd.cmake
> index 2da4eee..d3e145c 100644
> --- a/kernel-shark/build/FindTraceCmd.cmake
> +++ b/kernel-shark/build/FindTraceCmd.cmake
> @@ -21,6 +21,12 @@ if (CMAKE_BUILD_TYPE MATCHES Debug)
>  
>  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/
> @@ -43,11 +49,11 @@ find_path(TRACECMD_INCLUDE_DIR  NAMES  trace-cmd/trace-cmd.h)
>  find_library(TRACECMD_LIBRARY   NAMES  trace-cmd/libtracecmd.so)
>  find_library(TRACEEVENT_LIBRARY NAMES  traceevent/libtraceevent.so)
>  
> -IF (TRACECMD_INCLUDE_DIR AND TRACECMD_LIBRARY AND TRACECMD_EXECUTABLE)
> +IF (TRACECMD_INCLUDE_DIR AND TRACECMD_LIBRARY)
>  
>    SET(TRACECMD_FOUND TRUE)
>  
> -ENDIF (TRACECMD_INCLUDE_DIR AND TRACECMD_LIBRARY AND TRACECMD_EXECUTABLE)
> +ENDIF (TRACECMD_INCLUDE_DIR AND TRACECMD_LIBRARY)
>  
>  IF (TRACECMD_FOUND)
>  


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

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-23 18:25 [PATCH] kernel-shark: Get the path to trace-cmd executable from _INSTALL_PREFIX Yordan Karadzhov (VMware)
2019-07-23 18:48 ` Steven Rostedt

Linux-Trace-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-trace-devel/0 linux-trace-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-trace-devel linux-trace-devel/ https://lore.kernel.org/linux-trace-devel \
		linux-trace-devel@vger.kernel.org linux-trace-devel@archiver.kernel.org
	public-inbox-index linux-trace-devel


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-trace-devel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox