Skip to contentSkip to conversation

kernel-shark: Get the path to trace-cmd executable from _INSTALL_PREFIX

PATCH In review Yordan Karadzhov (VMware) 2 participants 2 messages Jul 23, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kernel-shark: Get the path to trace-cmd executable from _INSTALL_PREFIX

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.

---
 kernel-shark/CMakeLists.txt           |  8 ++++----
 kernel-shark/README                   |  7 ++++++-
 kernel-shark/build/FindTraceCmd.cmake | 10 ++++++++--
 3 files changed, 18 insertions(+), 7 deletions(-)
kernel-shark/CMakeLists.txt +4 -4
index 45c6f23..075c4af 100644
@@ -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)
kernel-shark/README +6 -1
index 7e50479..6c360bb 100644
@@ -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:
kernel-shark/build/FindTraceCmd.cmake +8 -2
index 2da4eee..d3e145c 100644
@@ -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)
 
Signature · 1 line
2.20.1
#1 lore raw
Quoted 10 lines · On Tue, 23 Jul 2019 21:25:42 +0300 "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.

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

Quoted 83 lines
---
 kernel-shark/CMakeLists.txt           |  8 ++++----
 kernel-shark/README                   |  7 ++++++-
 kernel-shark/build/FindTraceCmd.cmake | 10 ++++++++--
 3 files changed, 18 insertions(+), 7 deletions(-)
kernel-shark/CMakeLists.txt +4 -4
index 45c6f23..075c4af 100644
@@ -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)
kernel-shark/README +6 -1
index 7e50479..6c360bb 100644
@@ -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:
kernel-shark/build/FindTraceCmd.cmake +8 -2
index 2da4eee..d3e145c 100644
@@ -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)