Skip to contentSkip to conversation

Complete the KernelShark v2 transformation

PATCH In review Yordan Karadzhov (VMware) 2 participants 29 messages Feb 11, 2021

lore
Share & tools
lore
#0 lore raw

v2 cover Complete the KernelShark v2 transformation

With this patch-set we complete the destructive part of the transformation of KernelShark towards v2 and the GUI is finally fully functional again.

v2 changes:
* Fixing the bug in patch
"kernel-shark: Update KsDualMarker and KsGLWidget", causing the error "Unable to find FreeSans font".

* New patches:
- kernel-shark: Search for font with Cmake at pre-build
- kernel-shark: Add pkg-config configuration for libkshark
- kernel-shark: Install libkshark-tepdata.h

Yordan Karadzhov (VMware) (27):
kernel-shark: Add get_stream_object()
kernel-shark: Do proper reset in kshark_close_all()
kernel-shark: Restore the counting of event handlers
kernel-shark: Fix a misleading comment
kernel-shark: Count the number of readout interfaces
kernel-shark: Update KsUtils
kernel-shark: Update KsModels and KsSearchFSM
kernel-shark: Add trace data files for CI testing
kernel-shark: Add plugin tests
kernel-shark: Add model tests
kernel-shark: Update KsWidgetsLib
kernel-shark: Add combo point to Mark
kernel-shark: Add new methods to KsPlot::Mark
kernel-shark: Update the plotting example
kernel-shark: Search for font with Cmake at pre-build
kernel-shark: Update KsDualMarker and KsGLWidget
kernel-shark: Update KsTraceGraph and KsQuickContextMenu
kernel-shark: Update KsTraceViewer
kernel-shark: Update KsAdvFilteringDialog
kernel-shark: Update KsCaptureDialog
kernel-shark: Update KsSession
kernel-shark: Update MissedEvents plugin
kernel-shark: Update KsMainWindow and kernelshark.cpp
kernel-shark: Clickable sched_event plugin shapes
kernel-shark: Show Task plots from command lime
kernel-shark: Add pkg-config configuration for libkshark
kernel-shark: Install libkshark-tepdata.h

 .github/workflows/main.yml    |    9 +
 CMakeLists.txt                |   41 +-
 README                        |    1 +
 build/cmake_clean.sh          |    4 +-
 build/deff.h.cmake            |    9 +
 build/libkshark.pc.cmake      |   10 +
 examples/CMakeLists.txt       |   30 +-
 examples/dataplot.cpp         |   88 ++-
 examples/widgetdemo.cpp       |   65 +-
 src/CMakeLists.txt            |   15 +-
 src/KsAdvFilteringDialog.cpp  |  200 ++++--
 src/KsAdvFilteringDialog.hpp  |   16 +-
 src/KsCaptureDialog.cpp       |   90 +--
 src/KsCaptureDialog.hpp       |    4 +-
 src/KsDualMarker.cpp          |   23 +-
 src/KsDualMarker.hpp          |   16 +-
 src/KsGLWidget.cpp            |  696 +++++++++++++-------
 src/KsGLWidget.hpp            |  187 ++++--
 src/KsMainWindow.cpp          |  786 ++++++++++++++--------
 src/KsMainWindow.hpp          |  108 ++-
 src/KsModels.cpp              |  112 +++-
 src/KsModels.hpp              |   28 +-
 src/KsPlotTools.cpp           |   23 +-
 src/KsPlotTools.hpp           |   27 +-
 src/KsPlugins.hpp             |    5 +
 src/KsQuickContextMenu.cpp    |  151 +++--
 src/KsQuickContextMenu.hpp    |   26 +-
 src/KsSearchFSM.cpp           |   12 +-
 src/KsSession.cpp             |  379 +++++++----
 src/KsSession.hpp             |   33 +-
 src/KsTraceGraph.cpp          |  426 ++++++------
 src/KsTraceGraph.hpp          |   48 +-
 src/KsTraceViewer.cpp         |   57 +-
 src/KsTraceViewer.hpp         |   13 +-
 src/KsUtils.cpp               | 1157 +++++++++++++++++++++++----------
 src/KsUtils.hpp               |  183 ++++--
 src/KsWidgetsLib.cpp          |  695 +++++++++++++++++---
 src/KsWidgetsLib.hpp          |  331 +++++++++-
 src/kernelshark.cpp           |   64 +-
 src/libkshark-plugin.c        |   25 +-
 src/libkshark.c               |   28 +-
 src/plugins/CMakeLists.txt    |   36 +-
 src/plugins/MissedEvents.cpp  |  105 ++-
 src/plugins/SchedEvents.cpp   |   58 +-
 src/plugins/missed_events.c   |   25 +-
 src/plugins/missed_events.h   |    4 +-
 src/plugins/sched_events.c    |    7 +
 src/plugins/sched_events.h    |    3 +
 tests/CMakeLists.txt          |   42 +-
 tests/get_test_data.sh        |   21 +
 tests/libkshark-gui-tests.cpp |  313 +++++++++
 tests/libkshark-tests.cpp     |  317 ++++++++-
 tests/test-input.c            |  134 ++++
 tests/test-input_ctrl.c       |  140 ++++
 tests/test-plugin_dpi.c       |   26 +
 tests/test-plugin_dpi_ctrl.c  |   32 +
 tests/test-plugin_dpi_err.c   |   26 +
 57 files changed, 5608 insertions(+), 1902 deletions(-)
 create mode 100644 build/libkshark.pc.cmake
 create mode 100755 tests/get_test_data.sh
 create mode 100644 tests/libkshark-gui-tests.cpp
 create mode 100644 tests/test-input.c
 create mode 100644 tests/test-input_ctrl.c
 create mode 100644 tests/test-plugin_dpi.c
 create mode 100644 tests/test-plugin_dpi_ctrl.c
 create mode 100644 tests/test-plugin_dpi_err.c
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/27 kernel-shark: Add get_stream_object()

In a previous patch we modified kshark_get_data_stream() to return NULL in the case when the kshark_data_stream object does not own a data processing interface. This was motivated by the idea that kshark_get_data_stream() is supposed to be used to access only successfully loaded data streams, which is not possible in the case when the data processing interface is not initialized. However, this creates a contradiction with the definition of the public method kshark_add_stream(). This method adds a stream without initializing its data processing interface. In this patch we add a static function that returns the Data stream object, regardless of the existence of the interface and we use this static function in all cases when the existence of the interface is not guaranteed.

---
 src/libkshark.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
src/libkshark.c +13 -2
index a54fdd5..c57ca01 100644
@@ -361,6 +361,17 @@ kshark_get_data_stream(struct kshark_context *kshark_ctx, int sd)
 	return NULL;
 }
 
+static struct kshark_data_stream *
+get_stream_object(struct kshark_context *kshark_ctx, int sd)
+{
+	if (sd >= 0 && sd <= kshark_ctx->stream_info.max_stream_id)
+		if (kshark_ctx->stream[sd] &&
+		    kshark_is_valid_stream(kshark_ctx->stream[sd]))
+			return kshark_ctx->stream[sd];
+
+	return NULL;
+}
+
 /**
  * @brief Get the Data stream object corresponding to a given entry
  *
@@ -443,7 +454,7 @@ int kshark_close(struct kshark_context *kshark_ctx, int sd)
 	struct kshark_data_stream *stream;
 	int ret;
 
-	stream = kshark_get_data_stream(kshark_ctx, sd);
+	stream = get_stream_object(kshark_ctx, sd);
 	if (!stream)
 		return -EFAULT;
 
@@ -1182,7 +1193,7 @@ bool kshark_filter_is_set(struct kshark_context *kshark_ctx, int sd)
 {
 	struct kshark_data_stream *stream;
 
-	stream = kshark_get_data_stream(kshark_ctx, sd);
+	stream = get_stream_object(kshark_ctx, sd);
 	if (!stream)
 		return false;
 
Signature · 1 line
2.25.1
#2 lore raw

PATCH v2 2/27 kernel-shark: Do proper reset in kshark_close_all()

In reply to Yordan Karadzhov (VMware)

The function is supposed to close all Data streams and reset the session context object (kshark_ctx). However, this is not happening completely, because after closing the individual streams, the context still contains the history of all closed stream Ids, recorded inside the array of data stream descriptors. In this patch we add a proper resetting of this array and its info descriptor.

---
 src/libkshark.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
src/libkshark.c +13 -0
index c57ca01..dc58dcf 100644
@@ -37,6 +37,7 @@ static bool kshark_default_context(struct kshark_context **context)
 	kshark_ctx->stream = calloc(KS_DEFAULT_NUM_STREAMS,
 				    sizeof(*kshark_ctx->stream));
 	kshark_ctx->stream_info.array_size = KS_DEFAULT_NUM_STREAMS;
+	kshark_ctx->stream_info.next_free_stream_id = 0;
 	kshark_ctx->stream_info.max_stream_id = -1;
 
 	/* Will free kshark_context_handler. */
@@ -484,10 +485,22 @@ int kshark_close(struct kshark_context *kshark_ctx, int sd)
  */
 void kshark_close_all(struct kshark_context *kshark_ctx)
 {
+	size_t mem_reset_size;
 	int i;
 
+	if (kshark_ctx->stream_info.max_stream_id < 0)
+		return;
+
 	for (i = 0; i <= kshark_ctx->stream_info.max_stream_id; ++i)
 		kshark_close(kshark_ctx, i);
+
+	/* Reset the array of data stream descriptors. */
+	mem_reset_size = (kshark_ctx->stream_info.max_stream_id + 1 ) *
+			 sizeof(*kshark_ctx->stream);
+	memset(kshark_ctx->stream, 0, mem_reset_size);
+
+	kshark_ctx->stream_info.next_free_stream_id = 0;
+	kshark_ctx->stream_info.max_stream_id = -1;
 }
 
 /**
Signature · 1 line
2.25.1
#3 lore raw

PATCH v2 3/27 kernel-shark: Restore the counting of event handlers

In reply to Yordan Karadzhov (VMware)

The number of the event handlers, successfully registered by the plugins is supposed to be counted and returned by the functions kshark_handle_dpi() and kshark_handle_all_dpis(). Although this is not used by the GUI, we want the API to support this feature. In this patch we fix a regression that was introduced during the transformation of the API for KernelShark v2.0.

---
 src/libkshark-plugin.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
src/libkshark-plugin.c +12 -8
index 74a5862..b85d0e9 100644
@@ -457,7 +457,6 @@ kshark_register_input(struct kshark_context *kshark_ctx,
 	input->interface = plugin;
 	input->next = kshark_ctx->inputs;
 	kshark_ctx->inputs = input;
-
 	return input;
 
  conflict:
@@ -635,7 +634,7 @@ void kshark_unregister_plugin_from_stream(struct kshark_data_stream *stream,
 	}
 }
 
-static void plugin_init(struct kshark_data_stream *stream,
+static int plugin_init(struct kshark_data_stream *stream,
 			struct kshark_dpi_list *plugin)
 {
 	int handler_count = plugin->interface->init(stream);
@@ -660,13 +659,18 @@ static void plugin_init(struct kshark_data_stream *stream,
 		plugin->status |= KSHARK_PLUGIN_FAILED;
 		plugin->status &= ~KSHARK_PLUGIN_LOADED;
 	}
+
+	return handler_count;
 }
 
-static void plugin_close(struct kshark_data_stream *stream,
+static int plugin_close(struct kshark_data_stream *stream,
 			 struct kshark_dpi_list *plugin)
 {
-	plugin->interface->close(stream);
+	int handler_count = plugin->interface->close(stream);
+
 	plugin->status &= ~KSHARK_PLUGIN_LOADED;
+
+	return handler_count;
 }
 
 /**
@@ -689,24 +693,24 @@ int kshark_handle_dpi(struct kshark_data_stream *stream,
 	switch (task_id) {
 	case KSHARK_PLUGIN_INIT:
 		if (plugin->status & KSHARK_PLUGIN_ENABLED)
-			plugin_init(stream, plugin);
+			handler_count += plugin_init(stream, plugin);
 
 		break;
 
 	case KSHARK_PLUGIN_UPDATE:
 		if (plugin->status & KSHARK_PLUGIN_LOADED)
-			plugin_close(stream, plugin);
+			handler_count -= plugin_close(stream, plugin);
 
 		plugin->status &= ~KSHARK_PLUGIN_FAILED;
 
 		if (plugin->status & KSHARK_PLUGIN_ENABLED)
-			plugin_init(stream, plugin);
+			handler_count += plugin_init(stream, plugin);
 
 		break;
 
 	case KSHARK_PLUGIN_CLOSE:
 		if (plugin->status & KSHARK_PLUGIN_LOADED)
-			plugin_close(stream, plugin);
+			handler_count -= plugin_close(stream, plugin);
 
 		plugin->status &= ~KSHARK_PLUGIN_FAILED;
 		break;
Signature · 1 line
2.25.1
#4 lore raw

PATCH v2 4/27 kernel-shark: Fix a misleading comment

In reply to Yordan Karadzhov (VMware)
---
 src/libkshark-plugin.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
src/libkshark-plugin.c +2 -1
index b85d0e9..bc68186 100644
@@ -577,7 +577,8 @@ kshark_register_plugin_to_stream(struct kshark_data_stream *stream,
 			 * The plugin has been registered already. Check if it
 			 * is initialized and if this is the case, close the
 			 * existing initialization. This way we guarantee a
-			 * clean new initialization from.
+			 * clean new initialization from kshark_handle_dpi()
+			 * or kshark_handle_all_dpis().
 			 */
 			if (plugin_list->status & KSHARK_PLUGIN_LOADED)
 				kshark_handle_dpi(stream, plugin_list,
Signature · 1 line
2.25.1
#5 lore raw

PATCH v2 5/27 kernel-shark: Count the number of readout interfaces

In reply to Yordan Karadzhov (VMware)

The number of readout interfaces, successfully registered by the plugins is supposed to be counted and stored in the session context object. Although this is not used by the GUI, we want the API to support this feature.

---
 src/libkshark-plugin.c | 2 ++
 1 file changed, 2 insertions(+)
src/libkshark-plugin.c +2 -0
index bc68186..ebd2579 100644
@@ -457,6 +457,7 @@ kshark_register_input(struct kshark_context *kshark_ctx,
 	input->interface = plugin;
 	input->next = kshark_ctx->inputs;
 	kshark_ctx->inputs = input;
+	kshark_ctx->n_inputs++;
 	return input;
 
  conflict:
@@ -489,6 +490,7 @@ void kshark_unregister_input(struct kshark_context *kshark_ctx,
 			*last = this_input->next;
 
 			free(this_input);
+			kshark_ctx->n_inputs--;
 
 			return;
 		}
Signature · 1 line
2.25.1
#6 lore raw

PATCH v2 6/27 kernel-shark: Update KsUtils

In reply to Yordan Karadzhov (VMware)

The compilation of KsUtils is re-enabled and all functionalities provided in it are made compatible with the new version of the C API of libkshark (KernelShark 2.0).

---
 CMakeLists.txt            |   10 +-
 build/deff.h.cmake        |    3 +
 src/CMakeLists.txt        |   73 +--
 src/KsUtils.cpp           | 1154 +++++++++++++++++++++++++------------
 src/KsUtils.hpp           |  181 ++++--
 tests/CMakeLists.txt      |    2 +-
 tests/libkshark-tests.cpp |    1 +
 7 files changed, 969 insertions(+), 455 deletions(-)
CMakeLists.txt +8 -2
index dd62091..e013916 100644
@@ -49,12 +49,18 @@ set(OpenGL_GL_PREFERENCE LEGACY)
 find_package(OpenGL)
 find_package(GLUT)
 
-# find_package(Qt5Widgets 5.7.1)
-# find_package(Qt5Network)
+find_package(Qt5Widgets 5.7.1)
+find_package(Qt5Network)
 if (Qt5Widgets_FOUND)
 
     message(STATUS "Found Qt5Widgets:  (version ${Qt5Widgets_VERSION})")
 
+    if(Qt5Widgets_VERSION VERSION_LESS "5.11")
+
+        set(QT_VERSION_LESS_5_11 TRUE)
+
+    endif()
+
 endif (Qt5Widgets_FOUND)
 
 find_package (Boost COMPONENTS unit_test_framework)
build/deff.h.cmake +3 -0
index 868ffec..5584574 100644
@@ -26,6 +26,9 @@
 /** GLUT has been found. */
 #cmakedefine GLUT_FOUND
 
+/** Qt - old version detected. */
+#cmakedefine QT_VERSION_LESS_5_11
+
 /** Semicolon-separated list of plugin names. */
 #define KS_BUILTIN_PLUGINS "@PLUGINS@"
 
src/CMakeLists.txt +37 -36

90 lines not on this page · raw message

src/KsUtils.cpp +798 -356

1,491 lines not on this page · raw message

src/KsUtils.hpp +121 -60

289 lines not on this page · raw message

tests/CMakeLists.txt +1 -1
index a1e3085..17b586e 100644
@@ -6,7 +6,7 @@ set(EXECUTABLE_OUTPUT_PATH           ${KS_TEST_DIR})
 add_executable(kshark-tests          libkshark-tests.cpp)
 target_include_directories(kshark-tests PRIVATE ${Boost_INCLUDE_DIRS})
 target_compile_definitions(kshark-tests PRIVATE "BOOST_TEST_DYN_LINK=1")
-target_link_libraries(kshark-tests   kshark
+target_link_libraries(kshark-tests   kshark-gui
                                      ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
 
 add_test(NAME              "libkshark_tests"
tests/libkshark-tests.cpp +1 -0
index 780a3fa..eb5cb1f 100644
@@ -46,6 +46,7 @@ BOOST_AUTO_TEST_CASE(add_remove_streams)
 	BOOST_CHECK_EQUAL(sd, -ENODEV);
 
 	kshark_close_all(kshark_ctx);
+	kshark_free(kshark_ctx);
 }
 
 #define ARRAY_DEFAULT_SIZE	1000
Signature · 1 line
2.25.1
#7 lore raw

PATCH v2 7/27 kernel-shark: Update KsModels and KsSearchFSM

In reply to Yordan Karadzhov (VMware)

The compilation of KsModels.cpp and KsSearchFSM.cpp is re-enabled and all functionalities are made compatible with the new version of the C API of libkshark (KernelShark 2.0). The two source files are updated in a single patch because of their interdependence.

---
 src/CMakeLists.txt  |  12 ++---
 src/KsModels.cpp    | 112 +++++++++++++++++++++++++++++++++++++-------
 src/KsModels.hpp    |  28 +++++++----
 src/KsSearchFSM.cpp |  12 ++++-
 4 files changed, 132 insertions(+), 32 deletions(-)
src/CMakeLists.txt +6 -6
index 5c9fe17..21d5b85 100644
@@ -66,10 +66,10 @@ endif (OPENGL_FOUND)
 if (Qt5Widgets_FOUND AND Qt5Network_FOUND)
 
     message(STATUS "libkshark-gui")
-    set (ks-guiLib_hdr  KsUtils.hpp)
-#                         KsModels.hpp
+    set (ks-guiLib_hdr  KsUtils.hpp
+                        KsModels.hpp
 #                         KsGLWidget.hpp
-#                         KsSearchFSM.hpp
+                        KsSearchFSM.hpp)
 #                         KsDualMarker.hpp
 #                         KsWidgetsLib.hpp
 #                         KsTraceGraph.hpp
@@ -81,11 +81,11 @@ if (Qt5Widgets_FOUND AND Qt5Network_FOUND)
 
     QT5_WRAP_CPP(ks-guiLib_hdr_moc ${ks-guiLib_hdr})
 
-    add_library(kshark-gui  SHARED  ${ks-guiLib_hdr_moc}    KsUtils.cpp)
-#                                                             KsModels.cpp
+    add_library(kshark-gui  SHARED  ${ks-guiLib_hdr_moc}    KsUtils.cpp
+                                                            KsModels.cpp
 #                                                             KsSession.cpp
 #                                                             KsGLWidget.cpp
-#                                                             KsSearchFSM.cpp
+                                                            KsSearchFSM.cpp)
 #                                                             KsDualMarker.cpp
 #                                                             KsWidgetsLib.cpp
 #                                                             KsTraceGraph.cpp
src/KsModels.cpp +95 -17

189 lines not on this page · raw message

src/KsModels.hpp +20 -8
index d360ad6..3a6d3f1 100644
@@ -26,6 +26,7 @@
 // KernelShark
 #include "libkshark.h"
 #include "libkshark-model.h"
+#include "KsPlotTools.hpp"
 #include "KsSearchFSM.hpp"
 
 /** A negative row index, to be used for deselecting the Passive Marker. */
@@ -45,7 +46,7 @@ public:
 	explicit KsViewModel(QObject *parent = nullptr);
 
 	/** Set the colors of the two markers. */
-	void setColors(const QColor &colA, const QColor &colB) {
+	void setMarkerColors(const QColor &colA, const QColor &colB) {
 		_colorMarkA = colA;
 		_colorMarkB = colB;
 	};
@@ -91,8 +92,16 @@ public:
 		      search_condition_func cond,
 		      QList<size_t> *matchList);
 
+	void loadColors();
+
+	/** Returns True is only one Data stream is open. */
+	bool singleStream() const {return _singleStream;}
+
 	/** Table columns Identifiers. */
 	enum {
+		/** Identifier of the Data stream. */
+		TRACE_VIEW_COL_STREAM,
+
 		/** Identifier of the Index column. */
 		TRACE_VIEW_COL_INDEX,
 
@@ -109,7 +118,7 @@ public:
 		TRACE_VIEW_COL_PID,
 
 		/** Identifier of the Latency Id column. */
-		TRACE_VIEW_COL_LAT,
+		TRACE_VIEW_COL_AUX,
 
 		/** Identifier of the Event name Id column. */
 		TRACE_VIEW_COL_EVENT,
@@ -122,6 +131,8 @@ public:
 	};
 
 private:
+	void _updateHeader();
+
 	/** Trace data array. */
 	kshark_entry		**_data;
 
@@ -142,6 +153,11 @@ private:
 
 	/** The color of the row selected by marker B. */
 	QColor	_colorMarkB;
+
+	/** True if only one Data stream is open. */
+	bool	_singleStream;
+
+	KsPlot::ColorTable	_streamColors;
 };
 
 /**
@@ -192,11 +208,7 @@ public:
 	 * Use the "row" index in the Proxy model to retrieve the "row" index
 	 * in the source model.
 	 */
-	int mapRowFromSource(int r) const
-	{
-		/*This works because the row number is shown in column "0". */
-		return this->data(this->index(r, 0)).toInt();
-	}
+	int mapRowFromSource(int r) const;
 
 	/** Get the source model. */
 	KsViewModel *source() {return _source;}
@@ -272,7 +284,7 @@ public:
 	/** Get the kshark_trace_histo object. */
 	kshark_trace_histo *histo() {return &_histo;}
 
-	void fill(kshark_entry **entries, size_t n);
+	void fill(KsDataStore *data);
 
 	void shiftForward(size_t n);
 
src/KsSearchFSM.cpp +11 -1
index 6a93ca7..a5f3682 100644
@@ -136,6 +136,16 @@ void KsSearchFSM ::_lockSearchPanel(bool lock)
 /** Act according to the provided input. */
 void NotDone::handleInput(KsSearchFSM* sm, sm_input_t input)
 {
+	int column = sm->column();
+	if (sm->_columnComboBox.findText(">>", Qt::MatchContains) < 0) {
+		/*
+		 * If only one Data stream (file) is loaded, the ">>" column
+		 * (TRACE_VIEW_COL_STREAM) is not shown. The column index has
+		 * to be corrected.
+		 */
+		++column;
+	}
+
 	switch(input) {
 	case sm_input_t::Start:
 		sm->_lastRowSearched = -1;
@@ -166,7 +176,7 @@ void Paused::handleInput(KsSearchFSM* sm, sm_input_t input)
 		sm->searchRestartVisible(false);
 
 		if (sm->column() != KsViewModel::TRACE_VIEW_COL_INFO &&
-		    sm->column() != KsViewModel::TRACE_VIEW_COL_LAT)
+		    sm->column() != KsViewModel::TRACE_VIEW_COL_AUX)
 			sm->_searchCountLabel.setText("");
 
 		sm->changeState(std::shared_ptr<InProgress>(new InProgress));
Signature · 1 line
2.25.1
#8 lore raw

PATCH v2 8/27 kernel-shark: Add trace data files for CI testing

In reply to Yordan Karadzhov (VMware)

The patch adds a procedure to download two trace data files that will be used by the CI tests. The files are obtained from a dedicated github repository. The tests cases using the trace data files will be added in following patches.

---
 .github/workflows/main.yml |  8 ++++++++
 CMakeLists.txt             |  3 ++-
 build/cmake_clean.sh       |  1 +
 tests/CMakeLists.txt       |  6 +++++-
 tests/get_test_data.sh     | 21 +++++++++++++++++++++
 5 files changed, 37 insertions(+), 2 deletions(-)
 create mode 100755 tests/get_test_data.sh
.github/workflows/main.yml +8 -0
index a35f003..2cce624 100644
@@ -35,6 +35,7 @@ jobs:
         make
         sudo make install
         sudo make install_libs
+
     - name: Create Build Environment
       # Some projects don't allow in-source building, so create a separate build directory
       # We'll use this as our working directory for all subsequent commands
@@ -61,3 +62,10 @@ jobs:
       shell: bash
       # Execute tests defined by the CMake configuration.
       run: ctest -C $BUILD_TYPE
+
+    - name: Upload Artifacts
+      if: ${{ always() }}
+      uses: actions/upload-artifact@v2
+      with:
+        name: artifacts-download
+        path: ${{runner.workspace}}/build/Testing/
CMakeLists.txt +2 -1
index e013916..26fb7ae 100644
@@ -123,8 +123,9 @@ add_subdirectory(${KS_DIR}/examples)
 
 if (Boost_FOUND)
 
+    set(KS_TEST_DIR                      "${KS_DIR}/tests")
     enable_testing()
-    add_subdirectory(${KS_DIR}/tests)
+    add_subdirectory(${KS_TEST_DIR})
 
 endif()
 
build/cmake_clean.sh +1 -0
index f70b545..b534014 100755
@@ -9,6 +9,7 @@ rm -rf src/
 rm -rf examples/
 rm -rf tests/
 rm -rf Testing/
+rm -f ../tests/*.dat
 rm -f ../lib/*
 rm ../kernelshark.desktop
 rm ../org.freedesktop.kshark-record.policy
tests/CMakeLists.txt +5 -1
index 17b586e..0847414 100644
@@ -1,6 +1,5 @@
 message("\n tests ...")
 
-set(KS_TEST_DIR                      "${KS_DIR}/tests")
 set(EXECUTABLE_OUTPUT_PATH           ${KS_TEST_DIR})
 
 add_executable(kshark-tests          libkshark-tests.cpp)
@@ -9,6 +8,11 @@ target_compile_definitions(kshark-tests PRIVATE "BOOST_TEST_DYN_LINK=1")
 target_link_libraries(kshark-tests   kshark-gui
                                      ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
 
+add_test(NAME              "get_test_data"
+         COMMAND           ${KS_TEST_DIR}/get_test_data.sh
+         WORKING_DIRECTORY ${KS_TEST_DIR})
+
+message(STATUS "libkshark-tests")
 add_test(NAME              "libkshark_tests"
          COMMAND           ${KS_TEST_DIR}/kshark-tests --log_format=HRF
          WORKING_DIRECTORY ${KS_TEST_DIR})
tests/get_test_data.sh new file +21 -0
new file mode 100755
index 0000000..b935d11
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+TEST_DIR=`dirname $0`
+TEST_DATA_DIR=kernel-shark_testdata
+TEST_DATA_REPO=https://github.com/yordan-karadzhov/${TEST_DATA_DIR}.git
+
+rm -fv ${TEST_DIR}/*.dat
+
+if [ -d "${TEST_DATA_DIR}" ]; then
+    rm -rf ${TEST_DATA_DIR}
+fi
+
+git clone ${TEST_DATA_REPO}
+
+if [ ! -d "${TEST_DATA_DIR}" ]; then
+    exit false
+fi
+
+rm -f ${TEST_DATA_DIR}/LICENSE
+cp -v ${TEST_DATA_DIR}/* ${TEST_DIR}/
+rm -rf ${TEST_DATA_DIR}
Signature · 1 line
2.25.1
#9 lore raw

PATCH v2 9/27 kernel-shark: Add plugin tests

In reply to Yordan Karadzhov (VMware)

We add a number of dummy plugins and we test the plugin-related part of the C API.

We also add few simple test cases of the functionalities provided in KSUtils.

---
 CMakeLists.txt                |  11 +-
 build/cmake_clean.sh          |   2 +-
 build/deff.h.cmake            |   3 +
 src/CMakeLists.txt            |   4 +-
 tests/CMakeLists.txt          |  34 +++-
 tests/libkshark-gui-tests.cpp | 227 +++++++++++++++++++++++++
 tests/libkshark-tests.cpp     | 309 +++++++++++++++++++++++++++++++++-
 tests/test-input.c            | 134 +++++++++++++++
 tests/test-input_ctrl.c       | 140 +++++++++++++++
 tests/test-plugin_dpi.c       |  26 +++
 tests/test-plugin_dpi_ctrl.c  |  32 ++++
 tests/test-plugin_dpi_err.c   |  26 +++
 12 files changed, 934 insertions(+), 14 deletions(-)
 create mode 100644 tests/libkshark-gui-tests.cpp
 create mode 100644 tests/test-input.c
 create mode 100644 tests/test-input_ctrl.c
 create mode 100644 tests/test-plugin_dpi.c
 create mode 100644 tests/test-plugin_dpi_ctrl.c
 create mode 100644 tests/test-plugin_dpi_err.c
CMakeLists.txt +7 -4
index 26fb7ae..b9b947e 100644
@@ -144,10 +144,13 @@ if (_DOXYGEN_DOC AND DOXYGEN_FOUND)
 
 endif ()
 
-configure_file( ${KS_DIR}/build/ks.desktop.cmake
-                ${KS_DIR}/${KS_APP_NAME}.desktop)
+configure_file(${KS_DIR}/build/deff.h.cmake
+               ${KS_DIR}/src/KsCmakeDef.hpp)
 
-configure_file( ${KS_DIR}/build/org.freedesktop.kshark-record.policy.cmake
-                ${KS_DIR}/org.freedesktop.kshark-record.policy)
+configure_file(${KS_DIR}/build/ks.desktop.cmake
+               ${KS_DIR}/${KS_APP_NAME}.desktop)
+
+configure_file(${KS_DIR}/build/org.freedesktop.kshark-record.policy.cmake
+               ${KS_DIR}/org.freedesktop.kshark-record.policy)
 
 message("")
build/cmake_clean.sh +1 -1
index b534014..2ca1136 100755
@@ -3,7 +3,7 @@ rm CMakeCache.txt
 rm cmake_install.cmake
 rm Makefile
 rm CTestTestfile.cmake
-rm DartConfiguration.tcl
+rm -f DartConfiguration.tcl
 rm -rf CMakeFiles/
 rm -rf src/
 rm -rf examples/
build/deff.h.cmake +3 -0
index 5584574..423a2fd 100644
@@ -29,6 +29,9 @@
 /** Qt - old version detected. */
 #cmakedefine QT_VERSION_LESS_5_11
 
+/** Location of the KernelShark tests. */
+#cmakedefine KS_TEST_DIR "@KS_TEST_DIR@"
+
 /** Semicolon-separated list of plugin names. */
 #define KS_BUILTIN_PLUGINS "@PLUGINS@"
 
src/CMakeLists.txt +1 -3
index 21d5b85..b308403 100644
@@ -137,8 +137,6 @@ if (Qt5Widgets_FOUND AND Qt5Network_FOUND)
 endif (Qt5Widgets_FOUND AND Qt5Network_FOUND)
 
 add_subdirectory(plugins)
+set(PLUGINS ${PLUGINS} PARENT_SCOPE)
 
 find_program(DO_AS_ROOT pkexec)
-
-configure_file( ${KS_DIR}/build/deff.h.cmake
-                ${KS_DIR}/src/KsCmakeDef.hpp)
tests/CMakeLists.txt +33 -1
index 0847414..28f711b 100644
@@ -1,18 +1,50 @@
 message("\n tests ...")
 
 set(EXECUTABLE_OUTPUT_PATH           ${KS_TEST_DIR})
+set(LIBRARY_OUTPUT_PATH              ${KS_TEST_DIR})
 
 add_executable(kshark-tests          libkshark-tests.cpp)
 target_include_directories(kshark-tests PRIVATE ${Boost_INCLUDE_DIRS})
 target_compile_definitions(kshark-tests PRIVATE "BOOST_TEST_DYN_LINK=1")
-target_link_libraries(kshark-tests   kshark-gui
+target_link_libraries(kshark-tests   kshark
                                      ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
 
 add_test(NAME              "get_test_data"
          COMMAND           ${KS_TEST_DIR}/get_test_data.sh
          WORKING_DIRECTORY ${KS_TEST_DIR})
 
+add_library(dummy_dpi             SHARED  test-plugin_dpi.c)
+set_target_properties(dummy_dpi   PROPERTIES PREFIX "plugin-")
+target_link_libraries(dummy_dpi   kshark)
+
+add_library(dummy_dpi_ctrl             SHARED  test-plugin_dpi_ctrl.c)
+set_target_properties(dummy_dpi_ctrl   PROPERTIES PREFIX "plugin-")
+target_link_libraries(dummy_dpi_ctrl   kshark)
+
+add_library(dummy_dpi_err             SHARED  test-plugin_dpi_err.c)
+set_target_properties(dummy_dpi_err   PROPERTIES PREFIX "plugin-")
+target_link_libraries(dummy_dpi_err   kshark)
+
+add_library(dummy_input             SHARED  test-input.c)
+set_target_properties(dummy_input   PROPERTIES PREFIX "input-")
+target_link_libraries(dummy_input   kshark)
+
+add_library(dummy_input_ctrl             SHARED  test-input_ctrl.c)
+set_target_properties(dummy_input_ctrl   PROPERTIES PREFIX "input-")
+target_link_libraries(dummy_input_ctrl   kshark)
+
 message(STATUS "libkshark-tests")
 add_test(NAME              "libkshark_tests"
          COMMAND           ${KS_TEST_DIR}/kshark-tests --log_format=HRF
          WORKING_DIRECTORY ${KS_TEST_DIR})
+
+add_executable(kshark-gui-tests          libkshark-gui-tests.cpp)
+target_include_directories(kshark-gui-tests PRIVATE ${Boost_INCLUDE_DIRS})
+target_compile_definitions(kshark-gui-tests PRIVATE "BOOST_TEST_DYN_LINK=1")
+target_link_libraries(kshark-gui-tests   kshark-gui
+                                     ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
+
+message(STATUS "libkshark-gui_tests")
+add_test(NAME              "libkshark-gui_tests"
+         COMMAND           ${KS_TEST_DIR}/kshark-gui-tests --log_format=HRF
+         WORKING_DIRECTORY ${KS_TEST_DIR})
tests/libkshark-gui-tests.cpp new file +227 -0

227 lines not on this page · raw message

tests/libkshark-tests.cpp +304 -5

345 lines not on this page · raw message

tests/test-input.c new file +134 -0

134 lines not on this page · raw message

tests/test-input_ctrl.c new file +140 -0

140 lines not on this page · raw message

tests/test-plugin_dpi.c new file +26 -0
new file mode 100644
index 0000000..82f94f3
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: LGPL-2.1
+
+/*
+ * Copyright (C) 2021 VMware Inc, Yordan Karadzhov <[email protected]>
+ */
+
+// C
+#include <stdio.h>
+
+// KernelShark
+#include "libkshark.h"
+#include "libkshark-plugin.h"
+
+/** Load this plugin. */
+int KSHARK_PLOT_PLUGIN_INITIALIZER(struct kshark_data_stream *stream)
+{
+	printf("--> plugin1\n");
+	return 1;
+}
+
+/** Unload this plugin. */
+int KSHARK_PLOT_PLUGIN_DEINITIALIZER(struct kshark_data_stream *stream)
+{
+	printf("<-- plugin1\n");
+	return 1;
+}
tests/test-plugin_dpi_ctrl.c new file +32 -0
new file mode 100644
index 0000000..5fafd1d
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: LGPL-2.1
+
+/*
+ * Copyright (C) 2021 VMware Inc, Yordan Karadzhov <[email protected]>
+ */
+
+// C
+#include <stdio.h>
+
+// KernelShark
+#include "libkshark.h"
+#include "libkshark-plugin.h"
+
+/** Load this plugin. */
+int KSHARK_PLOT_PLUGIN_INITIALIZER(struct kshark_data_stream *stream)
+{
+	printf("--> plugin2\n");
+	return 2;
+}
+
+/** Unload this plugin. */
+int KSHARK_PLOT_PLUGIN_DEINITIALIZER(struct kshark_data_stream *stream)
+{
+	printf("<-- plugin2\n");
+	return 2;
+}
+
+/** Initialize the control interface of the plugin. */
+void *KSHARK_MENU_PLUGIN_INITIALIZER(void *ptr)
+{
+	return NULL;
+}
tests/test-plugin_dpi_err.c new file +26 -0
new file mode 100644
index 0000000..4148930
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: LGPL-2.1
+
+/*
+ * Copyright (C) 2021 VMware Inc, Yordan Karadzhov <[email protected]>
+ */
+
+// C
+#include <stdio.h>
+
+// KernelShark
+#include "libkshark.h"
+#include "libkshark-plugin.h"
+
+/** Load this plugin. */
+int KSHARK_PLOT_PLUGIN_INITIALIZER(struct kshark_data_stream *stream)
+{
+	printf("--> plugin_err\n");
+	return 0;
+}
+
+/** Unload this plugin. */
+int KSHARK_PLOT_PLUGIN_DEINITIALIZER(struct kshark_data_stream *stream)
+{
+	printf("<-- plugin_err\n");
+	return 0;
+}
Signature · 1 line
2.25.1
#10 lore raw

PATCH v2 10/27 kernel-shark: Add model tests

In reply to Yordan Karadzhov (VMware)

We add few simple test cases of the KsModel functionalities.

---
 tests/libkshark-gui-tests.cpp | 59 +++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)
tests/libkshark-gui-tests.cpp +59 -0
index de6eb30..dedd69f 100644
@@ -12,6 +12,8 @@
 #include "libkshark.h"
 #include "libkshark-plugin.h"
 #include "KsUtils.hpp"
+#include "KsModels.hpp"
+
 
 using namespace KsUtils;
 
@@ -225,3 +227,60 @@ BOOST_AUTO_TEST_CASE(KsUtils_KsPluginManager)
 	kshark_free(kshark_ctx);
 	a.exit();
 }
+
+BOOST_AUTO_TEST_CASE(ViewModel)
+{
+	QStringList header{"#", "CPU", "Time Stamp", "Task", "PID", "Latency", "Event", "Info"};
+	struct kshark_context *kshark_ctx(nullptr);
+	KsViewModel model;
+	KsDataStore data;
+
+	data.loadDataFile(QString(KS_TEST_DIR) + "/trace_test1.dat", {});
+	model.fill(&data);
+	BOOST_CHECK_EQUAL(model.rowCount({}), N_RECORDS_TEST1);
+	BOOST_CHECK_EQUAL(model.columnCount({}), 8);
+	BOOST_CHECK_EQUAL(model.singleStream(), true);
+	BOOST_CHECK(model.header() == header);
+
+	data.appendDataFile(QString(KS_TEST_DIR) + "/trace_test2.dat", {});
+	BOOST_REQUIRE(kshark_instance(&kshark_ctx));
+	BOOST_CHECK(getStreamIdList(kshark_ctx) == QVector<int>({0, 1}));
+
+	model.update(&data);
+	header = QStringList{" >> "} + header;
+
+	BOOST_CHECK_EQUAL(model.rowCount({}), N_RECORDS_TEST1 + N_RECORDS_TEST2);
+	BOOST_CHECK_EQUAL(model.columnCount({}), 9);
+	BOOST_CHECK_EQUAL(model.singleStream(), false);
+	BOOST_CHECK(model.header() == header);
+
+	BOOST_CHECK(model.getValueStr(0, 0) == "1");
+	BOOST_CHECK(model.getValueStr(4, 1) == "trace-cmd");
+	BOOST_CHECK(model.getValueStr(5, 2) == "29474");
+	BOOST_CHECK(model.getValueStr(7, 2) == "sched/sched_switch");
+
+	BOOST_CHECK(model.getValueStr(0, N_RECORDS_TEST1 + N_RECORDS_TEST2 - 1) == "0");
+	BOOST_CHECK(model.getValueStr(4, N_RECORDS_TEST1 + N_RECORDS_TEST2 - 1) == "<idle>");
+
+	model.reset();
+	BOOST_CHECK_EQUAL(model.rowCount({}), 0);
+}
+
+BOOST_AUTO_TEST_CASE(GraphModel)
+{
+	struct kshark_context *kshark_ctx(nullptr);
+	KsGraphModel model;
+	KsDataStore data;
+
+	data.loadDataFile(QString(KS_TEST_DIR) + "/trace_test1.dat", {});
+	BOOST_REQUIRE(kshark_instance(&kshark_ctx));
+	BOOST_CHECK(getStreamIdList(kshark_ctx) == QVector<int>({0}));
+
+	model.fill(&data);
+	BOOST_CHECK_EQUAL(model.rowCount({}), KS_DEFAULT_NBUNS);
+	BOOST_CHECK(abs(model.histo()->min - data.rows()[0]->ts) < model.histo()->bin_size);
+	BOOST_CHECK(abs(model.histo()->max - data.rows()[N_RECORDS_TEST1 - 1]->ts) < model.histo()->bin_size);
+
+	model.reset();
+	BOOST_CHECK_EQUAL(model.rowCount({}), 0);
+}
Signature · 1 line
2.25.1
#11 lore raw

PATCH v2 11/27 kernel-shark: Update KsWidgetsLib

In reply to Yordan Karadzhov (VMware)

The compilation of KsWidgetsLib is re-enabled and all functionalities are made compatible with the new version of the C API of libkshark (KernelShark 2.0). We re-enable the widgetdemo example as well.

---
 examples/CMakeLists.txt |  24 +-
 examples/widgetdemo.cpp |  65 ++--
 src/CMakeLists.txt      |   8 +-
 src/KsUtils.cpp         |  29 ++
 src/KsWidgetsLib.cpp    | 695 +++++++++++++++++++++++++++++++++++-----
 src/KsWidgetsLib.hpp    | 331 +++++++++++++++++--
 6 files changed, 996 insertions(+), 156 deletions(-)
examples/CMakeLists.txt +12 -12
index b8bc79a..8360841 100644
@@ -23,15 +23,15 @@ target_link_libraries(confio   kshark)
 # message(STATUS "dataplot")
 # add_executable(dplot          dataplot.cpp)
 # target_link_libraries(dplot   kshark-plot)
-#
-# if (Qt5Widgets_FOUND)
-#
-#     message(STATUS "widgetdemo")
-#     add_executable(widgetdemo          widgetdemo.cpp)
-#     target_link_libraries(widgetdemo   kshark-gui)
-#
-#     message(STATUS "cmd_split")
-#     add_executable(cmd_split           cmd_split.cpp)
-#     target_link_libraries(cmd_split    kshark-gui)
-#
-# endif (Qt5Widgets_FOUND)
+
+if (Qt5Widgets_FOUND)
+
+    message(STATUS "widgetdemo")
+    add_executable(widgetdemo          widgetdemo.cpp)
+    target_link_libraries(widgetdemo   kshark-gui)
+
+    message(STATUS "cmd_split")
+    add_executable(cmd_split           cmd_split.cpp)
+    target_link_libraries(cmd_split    kshark-gui)
+
+endif (Qt5Widgets_FOUND)
examples/widgetdemo.cpp +31 -34

133 lines not on this page · raw message

src/CMakeLists.txt +4 -4
index b308403..140fed8 100644
@@ -69,9 +69,9 @@ if (Qt5Widgets_FOUND AND Qt5Network_FOUND)
     set (ks-guiLib_hdr  KsUtils.hpp
                         KsModels.hpp
 #                         KsGLWidget.hpp
-                        KsSearchFSM.hpp)
+                        KsSearchFSM.hpp
 #                         KsDualMarker.hpp
-#                         KsWidgetsLib.hpp
+                        KsWidgetsLib.hpp)
 #                         KsTraceGraph.hpp
 #                         KsTraceViewer.hpp
 #                         KsMainWindow.hpp
@@ -85,9 +85,9 @@ if (Qt5Widgets_FOUND AND Qt5Network_FOUND)
                                                             KsModels.cpp
 #                                                             KsSession.cpp
 #                                                             KsGLWidget.cpp
-                                                            KsSearchFSM.cpp)
+                                                            KsSearchFSM.cpp
 #                                                             KsDualMarker.cpp
-#                                                             KsWidgetsLib.cpp
+                                                            KsWidgetsLib.cpp)
 #                                                             KsTraceGraph.cpp
 #                                                             KsTraceViewer.cpp
 #                                                             KsMainWindow.cpp
src/KsUtils.cpp +29 -0
index 36f9b25..27cda55 100644
@@ -13,6 +13,7 @@
 #include "libkshark-plugin.h"
 #include "libkshark-tepdata.h"
 #include "KsUtils.hpp"
+#include "KsWidgetsLib.hpp"
 
 namespace KsUtils {
 
@@ -451,6 +452,34 @@ QStringList getFiles(QWidget *parent,
 	return getFilesDialog(parent, windowName, filter, lastFilePath);
 }
 
+/**
+ * @brief Open a standard Qt getFileName dialog and return the name of the
+ *	  selected file. Only one file can be selected.
+ */
+QString getSaveFile(QWidget *parent,
+		    const QString &windowName,
+		    const QString &filter,
+		    const QString &extension,
+		    QString &lastFilePath)
+{
+	QString fileName = getFileDialog(parent,
+					 windowName,
+					 filter,
+					 lastFilePath,
+					 true);
+
+	if (!fileName.isEmpty() && !fileName.endsWith(extension)) {
+		fileName += extension;
+
+		if (QFileInfo(fileName).exists()) {
+			if (!KsWidgetsLib::fileExistsDialog(fileName))
+				fileName.clear();
+		}
+	}
+
+	return fileName;
+}
+
 /**
  * @brief Separate the command line arguments inside the string taking into
  *	  account possible shell quoting and new lines.
src/KsWidgetsLib.cpp +609 -86

948 lines not on this page · raw message

src/KsWidgetsLib.hpp +311 -20

469 lines not on this page · raw message

Signature · 1 line
2.25.1
#12 lore raw

PATCH v2 12/27 kernel-shark: Add combo point to Mark

In reply to Yordan Karadzhov (VMware)

KsPlot::Mark uses colored point to highlight the selected trace event on CPU and Task plots. Here we add a combo point that will highlight the selected event in Combo plots, like "Virtual Combo" for example. Those Combo plots will be introduced at the level of the GUI code in successive patches.

---
 src/KsPlotTools.cpp | 23 ++++++++++++++++++++++-
 src/KsPlotTools.hpp | 15 ++++++++++++++-
 2 files changed, 36 insertions(+), 2 deletions(-)
src/KsPlotTools.cpp +22 -1
index ac9c5b2..225dc34 100644
@@ -701,7 +701,7 @@ void Mark::_draw(const Color &col, float size) const
 void Mark::setDPR(int dpr)
 {
 	_size = 1.5 * dpr;
-	_task._size = _cpu._size = 1.5 + 4.0 * dpr;
+	_task._size = _cpu._size = _combo._size = 1.5 + 4.0 * dpr;
 }
 
 /**
@@ -715,6 +715,7 @@ void Mark::setX(int x)
 	_b.setX(x);
 	_cpu.setX(x);
 	_task.setX(x);
+	_combo.setX(x);
 }
 
 /**
@@ -769,6 +770,26 @@ void Mark::setTaskVisible(bool v)
 	_task._visible = v;
 }
 
+/**
+ * @brief Set the visiblity of the Mark's Combo point.
+ *
+ * @param v: If True, the Task point will be visible.
+ */
+void Mark::setComboVisible(bool v)
+{
+	_combo._visible = v;
+}
+
+/**
+ * @brief Set the Y coordinates (vertical) of the Mark's Combo points.
+ *
+ * @param yCombo: Y coordinate of the Mark's Task point.
+ */
+void Mark::setComboY(int yCombo)
+{
+	_combo.setY(yCombo);
+}
+
 /**
  * @brief Create a default Bin.
  */
src/KsPlotTools.hpp +14 -1
index c993181..a9a5ba8 100644
@@ -406,6 +406,16 @@ public:
 	/** If True, the Mark will be plotted as a dashed line. */
 	void setDashed(bool d) {_dashed = d;}
 
+	/** Get the Y coordinate of the Mark's Combo point. */
+	int comboY() const {return _combo.y();}
+
+	void setComboY(int yCombo);
+
+	/** Is the Combo point visible. */
+	bool comboIsVisible() const {return _combo._visible;}
+
+	void setComboVisible(bool v);
+
 private:
 	void _draw(const Color &col, float size = 1.) const override;
 
@@ -421,7 +431,10 @@ private:
 	/** A point indicating the position of the Mark in a Task graph. */
 	Point _task;
 
-	/* If True, plot the Mark as a dashed line. */
+	/** A point indicating the position of the Mark in a Combo graph. */
+	Point _combo;
+
+	/** If True, plot the Mark as a dashed line. */
 	bool _dashed;
 };
 
Signature · 1 line
2.25.1
#13 lore raw

PATCH v2 13/27 kernel-shark: Add new methods to KsPlot::Mark

In reply to Yordan Karadzhov (VMware)

The new "get" methods are needed by the logic of the GUI.

---
 src/KsPlotTools.hpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)
src/KsPlotTools.hpp +12 -0
index a9a5ba8..1725926 100644
@@ -395,12 +395,24 @@ public:
 
 	void setY(int yA, int yB);
 
+	/** Get the Y coordinate of the Mark's CPU point. */
+	int cpuY() const {return _cpu.y();}
+
 	void setCPUY(int yCPU);
 
+	/** Is the CPU point visible. */
+	bool cpuIsVisible() const {return _cpu._visible;}
+
 	void setCPUVisible(bool v);
 
+	/** Get the Y coordinate of the Mark's Task point. */
+	int taskY() const {return _task.y();}
+
 	void setTaskY(int yTask);
 
+	/** Is the Task point visible. */
+	bool taskIsVisible() const {return _task._visible;}
+
 	void setTaskVisible(bool v);
 
 	/** If True, the Mark will be plotted as a dashed line. */
Signature · 1 line
2.25.1
#14 lore raw

PATCH v2 14/27 kernel-shark: Update the plotting example

In reply to Yordan Karadzhov (VMware)

The compilation of the plotting example is re-enabled and it is made compatible with the new version of the C API of libkshark (KernelShark 2.0).

---
 examples/CMakeLists.txt |  6 +--
 examples/dataplot.cpp   | 88 ++++++++++++++++++++++++++++-------------
 2 files changed, 63 insertions(+), 31 deletions(-)
examples/CMakeLists.txt +3 -3
index 8360841..e6af5f2 100644
@@ -20,9 +20,9 @@ message(STATUS "confogio")
 add_executable(confio          configio.c)
 target_link_libraries(confio   kshark)
 
-# message(STATUS "dataplot")
-# add_executable(dplot          dataplot.cpp)
-# target_link_libraries(dplot   kshark-plot)
+message(STATUS "dataplot")
+add_executable(dplot          dataplot.cpp)
+target_link_libraries(dplot   kshark-plot)
 
 if (Qt5Widgets_FOUND)
 
examples/dataplot.cpp +60 -28

198 lines not on this page · raw message

Signature · 1 line
2.25.1
#15 lore raw

PATCH v2 15/27 kernel-shark: Search for font with Cmake at pre-build

In reply to Yordan Karadzhov (VMware)

Being able to load the Truetype font is compulsory for the functioning of the visualization, hence the font must be considered as critical external dependency. Add a search for the font file next to the search of the other third party dependencies and have this file added as definition in the Cmake-generated header file. This way we do not need to search for the font every time when we open KernelShark.

---
 .github/workflows/main.yml |  1 +
 CMakeLists.txt             | 14 ++++++++++++++
 README                     |  1 +
 build/deff.h.cmake         |  3 +++
 examples/CMakeLists.txt    |  4 ++--
 src/CMakeLists.txt         |  4 ++--
 tests/CMakeLists.txt       | 22 +++++++++++++---------
 tests/libkshark-tests.cpp  |  9 +++++++++
 8 files changed, 45 insertions(+), 13 deletions(-)
.github/workflows/main.yml +1 -0
index 2cce624..4125354 100644
@@ -19,6 +19,7 @@ jobs:
         sudo apt-get update
         sudo apt-get install build-essential git cmake libjson-c-dev -y
         sudo apt-get install freeglut3-dev libxmu-dev libxi-dev -y
+        sudo apt-get install fonts-freefont-ttf
         sudo apt-get install qtbase5-dev libboost-all-dev -y
         git clone https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
         cd libtraceevent
CMakeLists.txt +14 -0
index b9b947e..8ca33fd 100644
@@ -49,6 +49,20 @@ set(OpenGL_GL_PREFERENCE LEGACY)
 find_package(OpenGL)
 find_package(GLUT)
 
+set(KS_FONT FreeSans)
+execute_process(COMMAND  bash "-c" "fc-list '${KS_FONT}' |grep ${KS_FONT}.ttf | cut -d':' -f 1 -z"
+                OUTPUT_VARIABLE TT_FONT_FILE)
+
+if (TT_FONT_FILE)
+
+  message(STATUS "Found font: ${TT_FONT_FILE}")
+
+else (TT_FONT_FILE)
+
+  message(WARNING "\nCould not find font ${KS_FONT}!\n")
+
+endif (TT_FONT_FILE)
+
 find_package(Qt5Widgets 5.7.1)
 find_package(Qt5Network)
 if (Qt5Widgets_FOUND)
README +1 -0
index d7efd96..a7e66df 100644
@@ -12,6 +12,7 @@ KernelShark has the following external dependencies:
 1. In order to install the packages on Ubuntu do the following:
     sudo apt-get install build-essential git cmake libjson-c-dev -y
     sudo apt-get install freeglut3-dev libxmu-dev libxi-dev -y
+    sudo apt-get install fonts-freefont-ttf
     sudo apt-get install qtbase5-dev -y
 
 1.1 I you want to be able to generate Doxygen documentation:
build/deff.h.cmake +3 -0
index 423a2fd..06cbf16 100644
@@ -26,6 +26,9 @@
 /** GLUT has been found. */
 #cmakedefine GLUT_FOUND
 
+/** Truetype font file. */
+#cmakedefine TT_FONT_FILE "@TT_FONT_FILE@"
+
 /** Qt - old version detected. */
 #cmakedefine QT_VERSION_LESS_5_11
 
examples/CMakeLists.txt +2 -2
index e6af5f2..bc17635 100644
@@ -24,7 +24,7 @@ message(STATUS "dataplot")
 add_executable(dplot          dataplot.cpp)
 target_link_libraries(dplot   kshark-plot)
 
-if (Qt5Widgets_FOUND)
+if (Qt5Widgets_FOUND AND TT_FONT_FILE)
 
     message(STATUS "widgetdemo")
     add_executable(widgetdemo          widgetdemo.cpp)
@@ -34,4 +34,4 @@ if (Qt5Widgets_FOUND)
     add_executable(cmd_split           cmd_split.cpp)
     target_link_libraries(cmd_split    kshark-gui)
 
-endif (Qt5Widgets_FOUND)
+endif (Qt5Widgets_FOUND AND TT_FONT_FILE)
src/CMakeLists.txt +2 -2
index 140fed8..6c02d82 100644
@@ -63,7 +63,7 @@ if (OPENGL_FOUND)
 
 endif (OPENGL_FOUND)
 
-if (Qt5Widgets_FOUND AND Qt5Network_FOUND)
+if (Qt5Widgets_FOUND AND Qt5Network_FOUND AND TT_FONT_FILE)
 
     message(STATUS "libkshark-gui")
     set (ks-guiLib_hdr  KsUtils.hpp
@@ -134,7 +134,7 @@ if (Qt5Widgets_FOUND AND Qt5Network_FOUND)
             DESTINATION ${_INSTALL_PREFIX}/bin/
                 COMPONENT                 kernelshark)
 
-endif (Qt5Widgets_FOUND AND Qt5Network_FOUND)
+endif (Qt5Widgets_FOUND AND Qt5Network_FOUND AND TT_FONT_FILE)
 
 add_subdirectory(plugins)
 set(PLUGINS ${PLUGINS} PARENT_SCOPE)
tests/CMakeLists.txt +13 -9
index 28f711b..1814c72 100644
@@ -38,13 +38,17 @@ add_test(NAME              "libkshark_tests"
          COMMAND           ${KS_TEST_DIR}/kshark-tests --log_format=HRF
          WORKING_DIRECTORY ${KS_TEST_DIR})
 
-add_executable(kshark-gui-tests          libkshark-gui-tests.cpp)
-target_include_directories(kshark-gui-tests PRIVATE ${Boost_INCLUDE_DIRS})
-target_compile_definitions(kshark-gui-tests PRIVATE "BOOST_TEST_DYN_LINK=1")
-target_link_libraries(kshark-gui-tests   kshark-gui
-                                     ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
+if (Qt5Widgets_FOUND AND TT_FONT_FILE)
 
-message(STATUS "libkshark-gui_tests")
-add_test(NAME              "libkshark-gui_tests"
-         COMMAND           ${KS_TEST_DIR}/kshark-gui-tests --log_format=HRF
-         WORKING_DIRECTORY ${KS_TEST_DIR})
+    add_executable(kshark-gui-tests          libkshark-gui-tests.cpp)
+    target_include_directories(kshark-gui-tests PRIVATE ${Boost_INCLUDE_DIRS})
+    target_compile_definitions(kshark-gui-tests PRIVATE "BOOST_TEST_DYN_LINK=1")
+    target_link_libraries(kshark-gui-tests   kshark-gui
+                          ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
+
+    message(STATUS "libkshark-gui_tests")
+    add_test(NAME              "libkshark-gui_tests"
+             COMMAND           ${KS_TEST_DIR}/kshark-gui-tests --log_format=HRF
+             WORKING_DIRECTORY ${KS_TEST_DIR})
+
+endif (Qt5Widgets_FOUND AND TT_FONT_FILE)
tests/libkshark-tests.cpp +9 -0
index a22c1e5..5f7c88a 100644
@@ -435,3 +435,12 @@ BOOST_AUTO_TEST_CASE(readout_plugins)
 
 	kshark_free(kshark_ctx);
 }
+
+BOOST_AUTO_TEST_CASE(check_font_found)
+{
+#ifdef TT_FONT_FILE
+BOOST_REQUIRE(true);
+#else
+BOOST_REQUIRE(false);
+#endif
+}
Signature · 1 line
2.25.1
#16 lore raw

PATCH v2 16/27 kernel-shark: Update KsDualMarker and KsGLWidget

In reply to Yordan Karadzhov (VMware)

The compilation of KsDualMarker.cpp and KsGLWidget.cpp is re-enabled and all functionalities are made compatible with the new version of the C API of libkshark (KernelShark 2.0). The two source files are updated in a single patch because of their interdependence.

---
 src/CMakeLists.txt   |   8 +-
 src/KsDualMarker.cpp |  23 +-
 src/KsDualMarker.hpp |  16 +-
 src/KsGLWidget.cpp   | 696 +++++++++++++++++++++++++++++--------------
 src/KsGLWidget.hpp   | 187 +++++++++---
 5 files changed, 629 insertions(+), 301 deletions(-)
src/CMakeLists.txt +4 -4
index 6c02d82..3dc7213 100644
@@ -68,9 +68,9 @@ if (Qt5Widgets_FOUND AND Qt5Network_FOUND AND TT_FONT_FILE)
     message(STATUS "libkshark-gui")
     set (ks-guiLib_hdr  KsUtils.hpp
                         KsModels.hpp
-#                         KsGLWidget.hpp
+                        KsGLWidget.hpp
                         KsSearchFSM.hpp
-#                         KsDualMarker.hpp
+                        KsDualMarker.hpp
                         KsWidgetsLib.hpp)
 #                         KsTraceGraph.hpp
 #                         KsTraceViewer.hpp
@@ -84,9 +84,9 @@ if (Qt5Widgets_FOUND AND Qt5Network_FOUND AND TT_FONT_FILE)
     add_library(kshark-gui  SHARED  ${ks-guiLib_hdr_moc}    KsUtils.cpp
                                                             KsModels.cpp
 #                                                             KsSession.cpp
-#                                                             KsGLWidget.cpp
+                                                            KsGLWidget.cpp
                                                             KsSearchFSM.cpp
-#                                                             KsDualMarker.cpp
+                                                            KsDualMarker.cpp
                                                             KsWidgetsLib.cpp)
 #                                                             KsTraceGraph.cpp
 #                                                             KsTraceViewer.cpp
src/KsDualMarker.cpp +9 -14
index 90c5373..9fb68e7 100644
@@ -59,10 +59,8 @@ void KsGraphMark::reset()
 {
 	_isSet = false;
 	_bin = -1;
-	_cpu = -1;
-	_task = -1;
 	_pos = 0;
-
+	_sd = 0;
 	_mark._visible = false;
 }
 
@@ -72,17 +70,17 @@ void KsGraphMark::reset()
  * @param data: Input location for the Data Store object.
  * @param histo: Input location for the model descriptor.
  * @param pos: The index inside the data array this marker will points to.
- * @param cpuGraph: The index of the CPU Graph this marker points to.
- * @param taskGraph: The index of the Task Graph this marker points to.
+ * @param sd: Data stream identifier.
  */
 bool KsGraphMark::set(const KsDataStore &data,
 		      kshark_trace_histo *histo,
-		      size_t pos, int cpuGraph, int taskGraph)
+		      ssize_t pos, int sd)
 {
 	uint8_t visFlags;
 
 	_isSet = true;
 	_pos = pos;
+	_sd = sd;
 	_ts = data.rows()[_pos]->ts;
 	visFlags = data.rows()[_pos]->visible;
 
@@ -92,9 +90,6 @@ bool KsGraphMark::set(const KsDataStore &data,
 	else
 		_mark.setDashed(true);
 
-	_cpu = cpuGraph;
-	_task = taskGraph;
-
 	if (_ts > histo->max || _ts < histo->min) {
 		_bin = -1;
 		_mark._visible = false;
@@ -119,7 +114,7 @@ bool KsGraphMark::update(const KsDataStore &data, kshark_trace_histo *histo)
 	if (!_isSet)
 		return false;
 
-	return set(data, histo, this->_pos, this->_cpu, this->_task);
+	return set(data, histo, this->_pos, this->_sd);
 }
 
 /** Unset the Marker and make it invisible. */
@@ -151,8 +146,8 @@ KsDualMarkerSM::KsDualMarkerSM(QWidget *parent)
 {
 	QString styleSheetA, styleSheetB;
 
-	_buttonA.setFixedWidth(STRING_WIDTH(" Marker A "));
-	_buttonB.setFixedWidth(STRING_WIDTH(" Marker B "));
+	_buttonA.setFixedWidth(STRING_WIDTH(" Marker A ") + FONT_WIDTH);
+	_buttonB.setFixedWidth(STRING_WIDTH(" Marker B ") + FONT_WIDTH);
 
 	for (auto const &l: {&_labelMA, &_labelMB, &_labelDelta}) {
 		l->setFrameStyle(QFrame::Panel | QFrame::Sunken);
@@ -318,10 +313,10 @@ void KsDualMarkerSM::updateMarkers(const KsDataStore &data,
 				   KsGLWidget *glw)
 {
 	if(_markA.update(data, glw->model()->histo()))
-		glw->setMark(&_markA);
+		glw->setMarkPoints(data, &_markA);
 
 	if(_markB.update(data, glw->model()->histo()))
-		glw->setMark(&_markB);
+		glw->setMarkPoints(data, &_markB);
 
 	updateLabels();
 }
src/KsDualMarker.hpp +5 -11
index 597bddb..0dcaf93 100644
@@ -66,9 +66,7 @@ public:
 
 	bool set(const KsDataStore &data,
 		 kshark_trace_histo *histo,
-		 size_t pos,
-		 int cpuGraph,
-		 int taskGraph);
+		 ssize_t pos, int sd);
 
 	bool update(const KsDataStore &data, kshark_trace_histo *histo);
 
@@ -83,24 +81,20 @@ public:
 
 	void remove();
 
-public:
 	/** Is this marker set. */
 	bool		_isSet;
 
 	/** The number of the bin this marker points to. */
 	int		_bin;
 
-	/** The index of the CPU Graph this marker points to. */
-	int		_cpu;
-
-	/** The  index of the Task Graph this marker points to. */
-	int		_task;
+	/** Data stream identifier of the Graph this marker points to. */
+	int		_sd;
 
 	/** The index inside the data array this marker points to. */
-	size_t		_pos;
+	ssize_t		_pos;
 
 	/** The timestamp of the marker. */
-	uint64_t	_ts;
+	int64_t		_ts;
 
 	/** The RGB color of the marker. */
 	QColor		_color;
src/KsGLWidget.cpp +473 -223

1,053 lines not on this page · raw message

src/KsGLWidget.hpp +138 -49

276 lines not on this page · raw message

Signature · 1 line
2.25.1
#17 lore raw

PATCH v2 17/27 kernel-shark: Update KsTraceGraph and KsQuickContextMenu

In reply to Yordan Karadzhov (VMware)

The compilation of KsTraceGraph.cpp and KsQuickContextMenu.cpp is re-enabled and all functionalities are made compatible with the new version of the C API of libkshark (KernelShark 2.0). The two source files are updated in a single patch because of their interdependence.

---
 src/CMakeLists.txt         |  12 +-
 src/KsQuickContextMenu.cpp | 151 +++++++++----
 src/KsQuickContextMenu.hpp |  26 ++-
 src/KsTraceGraph.cpp       | 426 ++++++++++++++++++-------------------
 src/KsTraceGraph.hpp       |  43 ++--
 5 files changed, 351 insertions(+), 307 deletions(-)
src/CMakeLists.txt +6 -6
index 3dc7213..ab74d5a 100644
@@ -71,12 +71,12 @@ if (Qt5Widgets_FOUND AND Qt5Network_FOUND AND TT_FONT_FILE)
                         KsGLWidget.hpp
                         KsSearchFSM.hpp
                         KsDualMarker.hpp
-                        KsWidgetsLib.hpp)
-#                         KsTraceGraph.hpp
+                        KsWidgetsLib.hpp
+                        KsTraceGraph.hpp
 #                         KsTraceViewer.hpp
 #                         KsMainWindow.hpp
 #                         KsCaptureDialog.hpp
-#                         KsQuickContextMenu.hpp
+                        KsQuickContextMenu.hpp)
 #                         KsAdvFilteringDialog.hpp)
 
     QT5_WRAP_CPP(ks-guiLib_hdr_moc ${ks-guiLib_hdr})
@@ -87,12 +87,12 @@ if (Qt5Widgets_FOUND AND Qt5Network_FOUND AND TT_FONT_FILE)
                                                             KsGLWidget.cpp
                                                             KsSearchFSM.cpp
                                                             KsDualMarker.cpp
-                                                            KsWidgetsLib.cpp)
-#                                                             KsTraceGraph.cpp
+                                                            KsWidgetsLib.cpp
+                                                            KsTraceGraph.cpp
 #                                                             KsTraceViewer.cpp
 #                                                             KsMainWindow.cpp
 #                                                             KsCaptureDialog.cpp
-#                                                             KsQuickContextMenu.cpp
+                                                            KsQuickContextMenu.cpp)
 #                                                             KsAdvFilteringDialog.cpp)
 
     target_link_libraries(kshark-gui kshark-plot
src/KsQuickContextMenu.cpp +105 -46

307 lines not on this page · raw message

src/KsQuickContextMenu.hpp +16 -10
index df8a65b..ca0b341 100644
@@ -45,22 +45,22 @@ class KsQuickContextMenu : public KsQuickMarkerMenu {
 public:
 	KsQuickContextMenu() = delete;
 
-	KsQuickContextMenu(KsDataStore *data, size_t row,
-			   KsDualMarkerSM *dm,
+	KsQuickContextMenu(KsDualMarkerSM *dm,
+			   KsDataStore *data, size_t row,
 			   QWidget *parent = nullptr);
 
 signals:
 	/** Signal to add a task plot. */
-	void addTaskPlot(int);
+	void addTaskPlot(int sd, int pid);
 
 	/** Signal to add a CPU plot. */
-	void addCPUPlot(int);
+	void addCPUPlot(int sd, int cpu);
 
 	/** Signal to remove a task plot. */
-	void removeTaskPlot(int);
+	void removeTaskPlot(int sd, int pid);
 
 	/** Signal to remove a CPU plot. */
-	void removeCPUPlot(int);
+	void removeCPUPlot(int sd, int cpu);
 
 private:
 	void _hideTask();
@@ -83,7 +83,7 @@ private:
 
 	void _removeTaskPlot();
 
-	QVector<int> _getFilterVector(tracecmd_filter_id *filter, int newId);
+	QVector<int> _getFilterVector(kshark_hash_id *filter, int newId);
 
 	void _clearFilters() {_data->clearAllFilters();}
 
@@ -91,6 +91,8 @@ private:
 
 	size_t		_row;
 
+	QWidgetAction	_rawTime, _rawEvent;
+
 	QCheckBox	*_graphSyncCBox, *_listSyncCBox;
 
 	QAction _hideTaskAction, _showTaskAction;
@@ -118,7 +120,8 @@ class KsRmPlotContextMenu : public KsQuickMarkerMenu {
 public:
 	KsRmPlotContextMenu() = delete;
 
-	KsRmPlotContextMenu(KsDualMarkerSM *dm, QWidget *parent = nullptr);
+	KsRmPlotContextMenu(KsDualMarkerSM *dm, int sd,
+			    QWidget *parent = nullptr);
 
 signals:
 	/** Signal to remove a plot. */
@@ -127,13 +130,16 @@ signals:
 protected:
 	/** Menu action. */
 	QAction _removePlotAction;
+
+	/** Data stream identifier. */
+	int _sd;
 };
 
 /**
  * The KsQuickMarkerMenu class provides CPU Plot remove menus.
  */
 struct KsRmCPUPlotMenu : public KsRmPlotContextMenu {
-	KsRmCPUPlotMenu(KsDualMarkerSM *dm, int cpu,
+	KsRmCPUPlotMenu(KsDualMarkerSM *dm, int sd, int cpu,
 			QWidget *parent = nullptr);
 };
 
@@ -141,7 +147,7 @@ struct KsRmCPUPlotMenu : public KsRmPlotContextMenu {
  * The KsQuickMarkerMenu class provides Task Plot remove menus.
  */
 struct KsRmTaskPlotMenu : public KsRmPlotContextMenu {
-	KsRmTaskPlotMenu(KsDualMarkerSM *dm, int pid,
+	KsRmTaskPlotMenu(KsDualMarkerSM *dm, int sd, int pid,
 			 QWidget *parent = nullptr);
 };
 
src/KsTraceGraph.cpp +209 -217

728 lines not on this page · raw message

src/KsTraceGraph.hpp +15 -28

93 lines not on this page · raw message

Signature · 1 line
2.25.1
#18 lore raw

PATCH v2 18/27 kernel-shark: Update KsTraceViewer

In reply to Yordan Karadzhov (VMware)

The compilation of KsTraceViewer.cpp is re-enabled and all functionalities are made compatible with the new version of the C API of libkshark (KernelShark 2.0).

---
 src/CMakeLists.txt    |  4 +--
 src/KsTraceGraph.hpp  |  5 +++-
 src/KsTraceViewer.cpp | 57 +++++++++++++++++++++++++++++--------------
 src/KsTraceViewer.hpp | 13 +++++++---
 4 files changed, 54 insertions(+), 25 deletions(-)
src/CMakeLists.txt +2 -2
index ab74d5a..e09deb7 100644
@@ -73,7 +73,7 @@ if (Qt5Widgets_FOUND AND Qt5Network_FOUND AND TT_FONT_FILE)
                         KsDualMarker.hpp
                         KsWidgetsLib.hpp
                         KsTraceGraph.hpp
-#                         KsTraceViewer.hpp
+                        KsTraceViewer.hpp
 #                         KsMainWindow.hpp
 #                         KsCaptureDialog.hpp
                         KsQuickContextMenu.hpp)
@@ -89,7 +89,7 @@ if (Qt5Widgets_FOUND AND Qt5Network_FOUND AND TT_FONT_FILE)
                                                             KsDualMarker.cpp
                                                             KsWidgetsLib.cpp
                                                             KsTraceGraph.cpp
-#                                                             KsTraceViewer.cpp
+                                                            KsTraceViewer.cpp
 #                                                             KsMainWindow.cpp
 #                                                             KsCaptureDialog.cpp
                                                             KsQuickContextMenu.cpp)
src/KsTraceGraph.hpp +4 -1
index 0e31b88..6e83f21 100644
@@ -29,7 +29,10 @@ public:
 	 * Reimplemented handler for mouse wheel events. All mouse wheel
 	 * events will be ignored.
 	 */
-	void wheelEvent(QWheelEvent *evt) {evt->ignore();}
+	void wheelEvent(QWheelEvent *evt) {
+		if (QApplication::keyboardModifiers() != Qt::ControlModifier)
+			QScrollArea::wheelEvent(evt);
+	}
 };
 
 /**
src/KsTraceViewer.cpp +39 -18

161 lines not on this page · raw message

src/KsTraceViewer.hpp +9 -4
index 6080d0d..f3979a6 100644
@@ -20,6 +20,7 @@
 #include "KsModels.hpp"
 #include "KsSearchFSM.hpp"
 #include "KsDualMarker.hpp"
+#include "KsWidgetsLib.hpp"
 
 /**
  * Table View class, needed in order to reimplemented the handler for mouse
@@ -42,7 +43,7 @@ public:
  * The KsTraceViewer class provides a widget for browsing in the trace data
  * shown in a text form.
  */
-class KsTraceViewer : public QWidget
+class KsTraceViewer : public KsWidgetsLib::KsDataWidget
 {
 	Q_OBJECT
 public:
@@ -74,6 +75,12 @@ public:
 
 	void update(KsDataStore *data);
 
+	/** Update the color scheme used by the model. */
+	void loadColors()
+	{
+		_model.loadColors();
+	}
+
 signals:
 	/** Signal emitted when new row is selected. */
 	void select(size_t);
@@ -82,7 +89,7 @@ signals:
 	 * This signal is used to re-emitted the addTaskPlot signal of the
 	 * KsQuickContextMenu.
 	 */
-	void addTaskPlot(int pid);
+	void addTaskPlot(int sd, int pid);
 
 	/**
 	 * This signal is used to re-emitted the deselect signal of the
@@ -99,8 +106,6 @@ private:
 
 	KsFilterProxyModel	_proxyModel;
 
-	QStringList	_tableHeader;
-
 	QToolBar	_toolbar;
 
 	QLabel		_labelSearch, _labelGrFollows;
Signature · 1 line
2.25.1
#19 lore raw

PATCH v2 19/27 kernel-shark: Update KsAdvFilteringDialog

In reply to Yordan Karadzhov (VMware)

The compilation ofKsAdvFilteringDialog .cpp is re-enabled and all functionalities are made compatible with the new version of the C API of libkshark (KernelShark 2.0).

---
 src/CMakeLists.txt           |   8 +-
 src/KsAdvFilteringDialog.cpp | 200 ++++++++++++++++++++++-------------
 src/KsAdvFilteringDialog.hpp |  16 ++-
 3 files changed, 144 insertions(+), 80 deletions(-)
src/CMakeLists.txt +4 -4
index e09deb7..6bb94d6 100644
@@ -76,8 +76,8 @@ if (Qt5Widgets_FOUND AND Qt5Network_FOUND AND TT_FONT_FILE)
                         KsTraceViewer.hpp
 #                         KsMainWindow.hpp
 #                         KsCaptureDialog.hpp
-                        KsQuickContextMenu.hpp)
-#                         KsAdvFilteringDialog.hpp)
+                        KsQuickContextMenu.hpp
+                        KsAdvFilteringDialog.hpp)
 
     QT5_WRAP_CPP(ks-guiLib_hdr_moc ${ks-guiLib_hdr})
 
@@ -92,8 +92,8 @@ if (Qt5Widgets_FOUND AND Qt5Network_FOUND AND TT_FONT_FILE)
                                                             KsTraceViewer.cpp
 #                                                             KsMainWindow.cpp
 #                                                             KsCaptureDialog.cpp
-                                                            KsQuickContextMenu.cpp)
-#                                                             KsAdvFilteringDialog.cpp)
+                                                            KsQuickContextMenu.cpp
+                                                            KsAdvFilteringDialog.cpp)
 
     target_link_libraries(kshark-gui kshark-plot
                                      Qt5::Widgets
src/KsAdvFilteringDialog.cpp +129 -71

307 lines not on this page · raw message

src/KsAdvFilteringDialog.hpp +11 -5
index 2a534d0..a1db90b 100644
@@ -36,7 +36,7 @@ private:
 
 	QMap<int, QString>	_filters;
 
-	KsCheckBoxTable		*_table;
+	KsWidgetsLib::KsCheckBoxTable	*_table;
 
 	QVBoxLayout	_topLayout;
 
@@ -46,6 +46,8 @@ private:
 
 	QLabel		_descrLabel, _sysEvLabel, _opsLabel, _fieldLabel;
 
+	QComboBox	_streamComboBox;
+
 	QComboBox	_systemComboBox, _eventComboBox;
 
 	QComboBox	_opsComboBox, _fieldComboBox;
@@ -74,13 +76,17 @@ private:
 
 	QStringList _operators();
 
-	void _getFilters(struct kshark_context *kshark_ctx);
+	void _getFtraceStreams(kshark_context *kshark_ctx);
+
+	void _getFilters(kshark_context *kshark_ctx);
+
+	void _makeFilterTable(kshark_context *kshark_ctx);
 
-	void _makeFilterTable(struct kshark_context *kshark_ctx);
+	QStringList _getEventFields(int eventId);
 
-	QStringList _getEventFormatFields(struct tep_event *event);
+	void _setSystemCombo(kshark_context *kshark_ctx);
 
-	void _setSystemCombo(struct kshark_context *kshark_ctx);
+	kshark_data_stream *_getCurrentStream(kshark_context *kshark_ctx);
 
 private slots:
 	void _systemChanged(const QString&);
Signature · 1 line
2.25.1
#20 lore raw

PATCH v2 20/27 kernel-shark: Update KsCaptureDialog

In reply to Yordan Karadzhov (VMware)

The compilation of KsCaptureDialog.cpp and kshark-record.cpp is re-enabled and all functionalities are made compatible with the new version of the C API of libkshark (KernelShark 2.0).

---
 src/CMakeLists.txt      | 10 ++---
 src/KsCaptureDialog.cpp | 90 ++++++++++++++++++++++-------------------
 src/KsCaptureDialog.hpp |  4 +-
 3 files changed, 56 insertions(+), 48 deletions(-)
src/CMakeLists.txt +5 -5
index 6bb94d6..28f44fe 100644
@@ -75,7 +75,7 @@ if (Qt5Widgets_FOUND AND Qt5Network_FOUND AND TT_FONT_FILE)
                         KsTraceGraph.hpp
                         KsTraceViewer.hpp
 #                         KsMainWindow.hpp
-#                         KsCaptureDialog.hpp
+                        KsCaptureDialog.hpp
                         KsQuickContextMenu.hpp
                         KsAdvFilteringDialog.hpp)
 
@@ -91,7 +91,7 @@ if (Qt5Widgets_FOUND AND Qt5Network_FOUND AND TT_FONT_FILE)
                                                             KsTraceGraph.cpp
                                                             KsTraceViewer.cpp
 #                                                             KsMainWindow.cpp
-#                                                             KsCaptureDialog.cpp
+                                                            KsCaptureDialog.cpp
                                                             KsQuickContextMenu.cpp
                                                             KsAdvFilteringDialog.cpp)
 
@@ -106,9 +106,9 @@ if (Qt5Widgets_FOUND AND Qt5Network_FOUND AND TT_FONT_FILE)
 #     add_executable(${KS_APP_NAME}          kernelshark.cpp)
 #     target_link_libraries(${KS_APP_NAME}   kshark-gui)
 
-#     message(STATUS "kshark-record")
-#     add_executable(kshark-record        kshark-record.cpp)
-#     target_link_libraries(kshark-record kshark-gui)
+    message(STATUS "kshark-record")
+    add_executable(kshark-record        kshark-record.cpp)
+    target_link_libraries(kshark-record kshark-gui)
 
 #     install(TARGETS ${KS_APP_NAME} kshark-record kshark-gui
 #             RUNTIME DESTINATION       ${_INSTALL_PREFIX}/bin/
src/KsCaptureDialog.cpp +49 -41

182 lines not on this page · raw message

src/KsCaptureDialog.hpp +2 -2
index 3fd3d8d..0c85101 100644
@@ -61,9 +61,9 @@ signals:
 	void print(const QString &message);
 
 private:
-	tep_handle		*_localTEP;
+	kshark_data_stream	*_stream;
 
-	KsEventsCheckBoxWidget	_eventsWidget;
+	KsWidgetsLib::KsEventsCheckBoxWidget	_eventsWidget;
 
 	QVBoxLayout	_topLayout;
 
Signature · 1 line
2.25.1
#21 lore raw

PATCH v2 21/27 kernel-shark: Update KsSession

In reply to Yordan Karadzhov (VMware)

The compilation KsSession.cpp is re-enabled and all functionalities are made compatible with the new version of the C API of libkshark (KernelShark 2.0).

---
 src/CMakeLists.txt |   2 +-
 src/KsSession.cpp  | 415 +++++++++++++++++++++++++++------------------
 src/KsSession.hpp  |  37 ++--
 3 files changed, 269 insertions(+), 185 deletions(-)
src/CMakeLists.txt +1 -1
index 28f44fe..5ea34ed 100644
@@ -83,7 +83,7 @@ if (Qt5Widgets_FOUND AND Qt5Network_FOUND AND TT_FONT_FILE)
 
     add_library(kshark-gui  SHARED  ${ks-guiLib_hdr_moc}    KsUtils.cpp
                                                             KsModels.cpp
-#                                                             KsSession.cpp
+                                                            KsSession.cpp
                                                             KsGLWidget.cpp
                                                             KsSearchFSM.cpp
                                                             KsDualMarker.cpp
src/KsSession.cpp +246 -169

571 lines not on this page · raw message

src/KsSession.hpp +22 -15
index b07c810..e1b7fd4 100644
@@ -20,8 +20,6 @@
 #include "KsTraceGraph.hpp"
 #include "KsTraceViewer.hpp"
 
-class KsMainWindow;
-
 /**
  * The KsSession class provides instruments for importing/exporting the state
  * of the different components of the GUI from/to Json documents. These
@@ -41,7 +39,7 @@ public:
 
 	void exportToFile(QString jfileName);
 
-	void saveDataFile(QString fileName);
+	void saveDataFile(QString fileName, QString dataSetName);
 
 	QString getDataFile(kshark_context *kshark_ctx);
 
@@ -49,18 +47,19 @@ public:
 
 	void loadVisModel(KsGraphModel *model);
 
-	void saveGraphs(const KsGLWidget &glw);
+	void saveGraphs(kshark_context *kshark_ctx,
+			KsTraceGraph &graphs);
 
-	void loadGraphs(KsTraceGraph *graphs);
+	void loadGraphs(kshark_context *kshark_ctx,
+			KsTraceGraph &graphs);
 
-	void saveFilters(kshark_context *kshark_ctx);
+	void saveDataStreams(kshark_context *kshark_ctx);
 
-	void loadFilters(kshark_context *kshark_ctx, KsDataStore *data);
+	void loadDataStreams(kshark_context *kshark_ctx,
+			     KsDataStore *data);
 
 	void saveMainWindowSize(const QMainWindow &window);
 
-	void loadMainWindowSize(KsMainWindow *window);
-
 	void saveSplitterSize(const QSplitter &splitter);
 
 	void loadSplitterSize(QSplitter *splitter);
@@ -69,9 +68,9 @@ public:
 
 	void loadDualMarker(KsDualMarkerSM *dmm, KsTraceGraph *graphs);
 
-	void savePlugins(const KsPluginManager &pm);
+	void saveUserPlugins(const KsPluginManager &pm);
 
-	void loadPlugins(kshark_context *kshark_ctx, KsPluginManager *pm);
+	void loadUserPlugins(kshark_context *kshark_ctx, KsPluginManager *pm);
 
 	void saveTable(const KsTraceViewer &view);
 
@@ -86,13 +85,21 @@ private:
 
 	json_object *_getMarkerJson();
 
-	void _saveCPUPlots(const QVector<int> &cpus);
+	void _savePlots(int sd, KsGLWidget *glw, bool cpu);
+
+	QVector<int> _getPlots(int sd, bool cpu);
+
+	void _saveCPUPlots(int sd, KsGLWidget *glw);
+
+	QVector<int> _getCPUPlots(int sd);
+
+	void _saveTaskPlots(int sd, KsGLWidget *glw);
 
-	QVector<int> _getCPUPlots();
+	QVector<int> _getTaskPlots(int sd);
 
-	void _saveTaskPlots(const QVector<int> &tasks);
+	void _saveComboPlots(KsGLWidget *glw);
 
-	QVector<int> _getTaskPlots();
+	QVector<int> _getComboPlots(int *nCombos);
 
 	bool _getMarker(const char* name, size_t *pos);
 
Signature · 1 line
2.25.1
#22 lore raw

PATCH v2 22/27 kernel-shark: Update MissedEvents plugin

In reply to Yordan Karadzhov (VMware)

General revision of the MissedEvents plugin that uses the new generic methods for visualization of trace event.

---
 src/plugins/CMakeLists.txt    |   6 +-
 src/plugins/MissedEvents.cpp  | 105 ++++++++++++++--------------------
 src/plugins/missed_events.c   |  25 ++++----
 src/plugins/missed_events.h   |   4 +-
 tests/libkshark-gui-tests.cpp |   4 +-
 5 files changed, 62 insertions(+), 82 deletions(-)
src/plugins/CMakeLists.txt +3 -3
index 108bc5f..dc0c320 100644
@@ -22,9 +22,9 @@ BUILD_PLUGIN(NAME sched_events
              SOURCE sched_events.c SchedEvents.cpp)
 list(APPEND PLUGIN_LIST "sched_events")
 
-# BUILD_PLUGIN(NAME missed_events
-#              SOURCE missed_events.c MissedEvents.cpp)
-# list(APPEND PLUGIN_LIST "missed_events")
+BUILD_PLUGIN(NAME missed_events
+             SOURCE missed_events.c MissedEvents.cpp)
+list(APPEND PLUGIN_LIST "missed_events")
 
 install(TARGETS ${PLUGIN_LIST}
         LIBRARY DESTINATION ${KS_PLUGIN_INSTALL_PREFIX}
src/plugins/MissedEvents.cpp +44 -61

143 lines not on this page · raw message

src/plugins/missed_events.c +10 -15
index cf652bf..8fe9780 100644
@@ -10,32 +10,27 @@
  *	     ring buffer.
  */
 
+// C
+#include <stdio.h>
+
 // KernelShark
+#include "libkshark.h"
 #include "plugins/missed_events.h"
 
-static void nop_action(struct kshark_context *kshark_ctx,
-				struct tep_record *record,
-				struct kshark_entry *entry)
-{}
-
 /** Load this plugin. */
-int KSHARK_PLUGIN_INITIALIZER(struct kshark_context *kshark_ctx)
+int KSHARK_PLOT_PLUGIN_INITIALIZER(struct kshark_data_stream *stream)
 {
-	kshark_register_event_handler(&kshark_ctx->event_handlers,
-				      KS_EVENT_OVERFLOW,
-				      nop_action,
-				      draw_missed_events);
+	printf("--> missed_events init %i\n", stream->stream_id);
+	kshark_register_draw_handler(stream, draw_missed_events);
 
 	return 1;
 }
 
 /** Unload this plugin. */
-int KSHARK_PLUGIN_DEINITIALIZER(struct kshark_context *kshark_ctx)
+int KSHARK_PLOT_PLUGIN_DEINITIALIZER(struct kshark_data_stream *stream)
 {
-	kshark_unregister_event_handler(&kshark_ctx->event_handlers,
-					KS_EVENT_OVERFLOW,
-					nop_action,
-					draw_missed_events);
+	printf("<-- missed_events close %i\n", stream->stream_id);
+	kshark_unregister_draw_handler(stream, draw_missed_events);
 
 	return 1;
 }
src/plugins/missed_events.h +2 -2
index e05d79a..10bc549 100644
@@ -14,14 +14,14 @@
 #define _KS_PLUGIN_M_EVTS_H
 
 // KernelShark
-#include "libkshark.h"
+#include "libkshark-plugin.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 void draw_missed_events(struct kshark_cpp_argv *argv,
-			int pid, int draw_action);
+			int sd, int pid, int draw_action);
 
 #ifdef __cplusplus
 }
tests/libkshark-gui-tests.cpp +3 -1
index dedd69f..5a0ca01 100644
@@ -146,7 +146,9 @@ BOOST_AUTO_TEST_CASE(KsUtils_KsDataStore)
 
 BOOST_AUTO_TEST_CASE(KsUtils_getPluginList)
 {
-	QStringList plugins{"sched_events"};
+	QStringList plugins{"sched_events",
+			    "missed_events"
+	};
 
 	BOOST_CHECK(getPluginList() == plugins);
 }
Signature · 1 line
2.25.1
#23 lore raw

PATCH v2 23/27 kernel-shark: Update KsMainWindow and kernelshark.cpp

In reply to Yordan Karadzhov (VMware)

The compilation of KsMainWindow.cpp and kernelshark.cpp is re-enabled and all functionalities are made compatible with the new version of the C API of libkshark (KernelShark 2.0).

This patch completes the destructive part of the transformation and the GUI is finally fully functional again.

---
 src/CMakeLists.txt   |  21 +-
 src/KsMainWindow.cpp | 786 +++++++++++++++++++++++++++++--------------
 src/KsMainWindow.hpp | 108 ++++--
 src/KsPlugins.hpp    |   5 +
 src/KsSession.cpp    |  34 ++
 src/KsSession.hpp    |   4 +
 src/kernelshark.cpp  |  49 +--
 7 files changed, 695 insertions(+), 312 deletions(-)
src/CMakeLists.txt +10 -11
index 5ea34ed..4158901 100644
@@ -74,7 +74,7 @@ if (Qt5Widgets_FOUND AND Qt5Network_FOUND AND TT_FONT_FILE)
                         KsWidgetsLib.hpp
                         KsTraceGraph.hpp
                         KsTraceViewer.hpp
-#                         KsMainWindow.hpp
+                        KsMainWindow.hpp
                         KsCaptureDialog.hpp
                         KsQuickContextMenu.hpp
                         KsAdvFilteringDialog.hpp)
@@ -90,7 +90,7 @@ if (Qt5Widgets_FOUND AND Qt5Network_FOUND AND TT_FONT_FILE)
                                                             KsWidgetsLib.cpp
                                                             KsTraceGraph.cpp
                                                             KsTraceViewer.cpp
-#                                                             KsMainWindow.cpp
+                                                            KsMainWindow.cpp
                                                             KsCaptureDialog.cpp
                                                             KsQuickContextMenu.cpp
                                                             KsAdvFilteringDialog.cpp)
@@ -102,20 +102,19 @@ if (Qt5Widgets_FOUND AND Qt5Network_FOUND AND TT_FONT_FILE)
 
     set_target_properties(kshark-gui PROPERTIES  SUFFIX ".so.${KS_VERSION_STRING}")
 
-#     message(STATUS ${KS_APP_NAME})
-#     add_executable(${KS_APP_NAME}          kernelshark.cpp)
-#     target_link_libraries(${KS_APP_NAME}   kshark-gui)
+    message(STATUS ${KS_APP_NAME})
+    add_executable(${KS_APP_NAME}          kernelshark.cpp)
+    target_link_libraries(${KS_APP_NAME}   kshark-gui)
 
     message(STATUS "kshark-record")
     add_executable(kshark-record        kshark-record.cpp)
     target_link_libraries(kshark-record kshark-gui)
 
-#     install(TARGETS ${KS_APP_NAME} kshark-record kshark-gui
-#             RUNTIME DESTINATION       ${_INSTALL_PREFIX}/bin/
-#                 COMPONENT                 kernelshark
-#             LIBRARY DESTINATION       ${_LIBDIR}
-#                 COMPONENT                 kernelshark)
-
+    install(TARGETS ${KS_APP_NAME} kshark-record kshark-gui
+            RUNTIME DESTINATION       ${_INSTALL_PREFIX}/bin/
+                COMPONENT                 kernelshark
+            LIBRARY DESTINATION       ${_LIBDIR}
+                COMPONENT                 kernelshark)
 
     install(FILES "${KS_DIR}/${KS_APP_NAME}.desktop"
             DESTINATION ${_INSTALL_PREFIX}/share/applications/
src/KsMainWindow.cpp +532 -254

1,216 lines not on this page · raw message

src/KsMainWindow.hpp +80 -28

196 lines not on this page · raw message

src/KsPlugins.hpp +5 -0
index a19bb9d..d41d094 100644
@@ -16,9 +16,14 @@
 #include <functional>
 
 // KernelShark
+#include "libkshark-plugin.h"
 #include "libkshark-model.h"
 #include "KsPlotTools.hpp"
 
+class KsMainWindow;
+/** Function type used for launching of plugin control menus. */
+typedef void (pluginActionFunc) (KsMainWindow *);
+
 /**
  * Structure representing the vector of C++ arguments of the drawing function
  * of a plugin.
src/KsSession.cpp +34 -0
index 786aa3e..8d489f7 100644
@@ -13,6 +13,7 @@
 #include "libkshark.h"
 #include "libkshark-tepdata.h"
 #include "KsSession.hpp"
+#include "KsMainWindow.hpp"
 
 /** Create a KsSession object. */
 KsSession::KsSession()
@@ -193,6 +194,39 @@ void KsSession::saveMainWindowSize(const QMainWindow &window)
 	kshark_config_doc_add(_config, "MainWindow", windowConf);
 }
 
+/**
+ * @brief Load the KernelShark Main window size.
+ *
+ * @param window: Input location for the KsMainWindow widget.
+ */
+void KsSession::loadMainWindowSize(KsMainWindow *window)
+{
+	kshark_config_doc *windowConf = kshark_config_alloc(KS_CONFIG_JSON);
+	json_object *jwindow, *jwidth, *jheight;
+	int width, height;
+
+	if (!kshark_config_doc_get(_config, "MainWindow", windowConf))
+		return;
+
+	if (_config->format == KS_CONFIG_JSON) {
+		jwindow = KS_JSON_CAST(windowConf->conf_doc);
+		if (json_object_get_type(jwindow) == json_type_string &&
+		    QString(json_object_get_string(jwindow)) == "FullScreen") {
+			window->setFullScreenMode(true);
+			return;
+		}
+
+		jwidth = json_object_array_get_idx(jwindow, 0);
+		jheight = json_object_array_get_idx(jwindow, 1);
+
+		width = json_object_get_int(jwidth);
+		height = json_object_get_int(jheight);
+
+		window->setFullScreenMode(false);
+		window->resize(width, height);
+	}
+}
+
 /**
  * @brief Save the state of the Main window spliter.
  *
src/KsSession.hpp +4 -0
index e1b7fd4..fd45270 100644
@@ -20,6 +20,8 @@
 #include "KsTraceGraph.hpp"
 #include "KsTraceViewer.hpp"
 
+class KsMainWindow;
+
 /**
  * The KsSession class provides instruments for importing/exporting the state
  * of the different components of the GUI from/to Json documents. These
@@ -60,6 +62,8 @@ public:
 
 	void saveMainWindowSize(const QMainWindow &window);
 
+	void loadMainWindowSize(KsMainWindow *window);
+
 	void saveSplitterSize(const QSplitter &splitter);
 
 	void loadSplitterSize(QSplitter *splitter);
src/kernelshark.cpp +30 -19

104 lines not on this page · raw message

Signature · 1 line
2.25.1
#24 lore raw

PATCH v2 24/27 kernel-shark: Clickable sched_event plugin shapes

In reply to Yordan Karadzhov (VMware)

Here we make the latency boxes plotted by the sched_event plugin clickable. When the box is clicked, the two events determining the latency (sched_waking and sched_switch) are selected with the markers. This is achieved by providing an implementation of the corresponding interface of virtual functions in the definition of the LatencyBox class. We also need to provide the plugin with a pointer to the KsMainWindow object (the GUI itself) such that the plugin can manipulate the markers.

---
 src/plugins/CMakeLists.txt  | 30 +++++++++++++++++--
 src/plugins/SchedEvents.cpp | 58 +++++++++++++++++++++++++++++++++++--
 src/plugins/sched_events.c  |  7 +++++
 src/plugins/sched_events.h  |  3 ++
 4 files changed, 93 insertions(+), 5 deletions(-)
src/plugins/CMakeLists.txt +27 -3
index dc0c320..5e28368 100644
@@ -17,10 +17,34 @@ function(BUILD_PLUGIN)
 
 endfunction()
 
+function(BUILD_GUI_PLUGIN)
+    set(options)
+    set(oneValueArgs NAME MOC)
+    set(multiValueArgs SOURCE)
+    cmake_parse_arguments(ADD_PLUGIN "${options}"
+                                     "${oneValueArgs}"
+                                     "${multiValueArgs}"
+                                     ${ARGN})
+
+    message(STATUS ${ADD_PLUGIN_NAME})
+
+    QT5_WRAP_CPP(plugin_moc ${ADD_PLUGIN_MOC})
+
+    add_library(${ADD_PLUGIN_NAME} SHARED ${plugin_moc} ${ADD_PLUGIN_SOURCE})
+    set_target_properties(${ADD_PLUGIN_NAME} PROPERTIES PREFIX "plugin-")
+    target_link_libraries(${ADD_PLUGIN_NAME} kshark kshark-gui)
+
+endfunction()
+
 set(PLUGIN_LIST "")
-BUILD_PLUGIN(NAME sched_events
-             SOURCE sched_events.c SchedEvents.cpp)
-list(APPEND PLUGIN_LIST "sched_events")
+
+if (Qt5Widgets_FOUND AND TT_FONT_FILE)
+
+    BUILD_GUI_PLUGIN(NAME sched_events
+                     SOURCE sched_events.c SchedEvents.cpp)
+    list(APPEND PLUGIN_LIST "sched_events")
+
+endif (Qt5Widgets_FOUND AND TT_FONT_FILE)
 
 BUILD_PLUGIN(NAME missed_events
              SOURCE missed_events.c MissedEvents.cpp)
src/plugins/SchedEvents.cpp +56 -2

71 lines not on this page · raw message

src/plugins/sched_events.c +7 -0
index 1596880..ac4a7bf 100644
@@ -216,3 +216,10 @@ int KSHARK_PLOT_PLUGIN_DEINITIALIZER(struct kshark_data_stream *stream)
 
 	return 1;
 }
+
+/** Initialize the control interface of the plugin. */
+void *KSHARK_MENU_PLUGIN_INITIALIZER(void *gui_ptr)
+{
+	printf("--> sched init menu\n");
+	return plugin_set_gui_ptr(gui_ptr);
+}
src/plugins/sched_events.h +3 -0
index 4c57606..78cfda0 100644
@@ -53,6 +53,7 @@ struct plugin_sched_context {
 	struct kshark_data_container	*sw_data;
 };
 
+/** A general purpose macro is used to define plugin context. */
 KS_DEFINE_PLUGIN_CONTEXT(struct plugin_sched_context);
 
 /** The type of the data field stored in the kshark_data_container object. */
@@ -65,6 +66,8 @@ int plugin_sched_get_prev_state(ks_num_field_t field);
 void plugin_draw(struct kshark_cpp_argv *argv, int sd, int pid,
 		 int draw_action);
 
+void *plugin_set_gui_ptr(void *gui_ptr);
+
 #ifdef __cplusplus
 }
 #endif
Signature · 1 line
2.25.1
#25 lore raw

PATCH v2 25/27 kernel-shark: Show Task plots from command lime

In reply to Yordan Karadzhov (VMware)

We add a new command line option for starting KernelShark that allows the user to select Task plots to be shown. The new option is similar to "--pid" but the tasks can be specified by name.

---
 src/KsUtils.cpp               | 32 ++++++++++++++++++++++++++++++++
 src/KsUtils.hpp               |  2 ++
 src/kernelshark.cpp           | 17 +++++++++++++----
 tests/libkshark-gui-tests.cpp | 25 +++++++++++++++++++++++++
 4 files changed, 72 insertions(+), 4 deletions(-)
src/KsUtils.cpp +32 -0
index 27cda55..ec53267 100644
@@ -548,6 +548,38 @@ QVector<int> parseIdList(QString v_str)
 	return v;
 }
 
+/**
+ * @brief Convert a string containing task names into a list of PID numbers.
+ */
+QMap<int, QVector<int>> parseTaskList(QString v_str)
+{
+	QStringList taskList = v_str.split(",", QString::SkipEmptyParts);
+	QVector<int> streamIds, allPids;
+	kshark_context *kshark_ctx(nullptr);
+	QMap<int, QVector<int>> ret;
+	QString name;
+
+	if (!kshark_instance(&kshark_ctx))
+		return {};
+
+	streamIds = getStreamIdList(kshark_ctx);
+	for (auto const sd: streamIds) {
+		allPids = getPidList(sd);
+		for (auto const pid: allPids) {
+			name = kshark_comm_from_pid(sd, pid);
+			if (name.isEmpty())
+				continue;
+
+			for (auto const task: taskList) {
+				if(name == task)
+					ret[sd].append(pid);
+			}
+		}
+	}
+
+	return ret;
+}
+
 /**
  * @brief Split the ststem name from the actual name of the event itself.
  *
src/KsUtils.hpp +2 -0
index 0d2c9c3..cf209bc 100644
@@ -161,6 +161,8 @@ QStringList splitArguments(QString cmd);
 
 QVector<int> parseIdList(QString v_str);
 
+QMap<int, QVector<int>> parseTaskList(QString v_str);
+
 QStringList getTepEvtName(int sd, int eventId);
 
 /** Get a string to be used as a standard name of a CPU graph. */
src/kernelshark.cpp +13 -4
index 41ffbe7..8ed4948 100644
@@ -32,7 +32,8 @@ void usage(const char *prog)
 	printf("  -s	import a session\n");
 	printf("  -l	import the last session\n");
 	puts(" --cpu	show plots for CPU cores, default is \"show all\"");
-	puts(" --pid	show plots for tasks, default is \"do not show\"");
+	puts(" --pid	show plots for tasks (by PID), default is \"do not show\"");
+	puts(" --task	show plots for tasks (by name), default is \"do not show\"");
 	puts("\n example:");
 	puts("  kernelshark -i mytrace.dat --cpu 1,4-7 --pid 11 -p path/to/my/plugin/myplugin.so\n");
 }
@@ -42,6 +43,7 @@ static option longOptions[] = {
 	{"help", no_argument, nullptr, 'h'},
 	{"pid", required_argument, nullptr, KS_LONG_OPTS},
 	{"cpu", required_argument, nullptr, KS_LONG_OPTS},
+	{"task", required_argument, nullptr, KS_LONG_OPTS},
 	{nullptr, 0, nullptr, 0}
 };
 
@@ -50,6 +52,7 @@ int main(int argc, char **argv)
 	QVector<int> cpuPlots, taskPlots;
 	bool fromSession = false;
 	int optionIndex = 0;
+	QString taskList;
 	int c;
 
 	QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
@@ -67,7 +70,8 @@ int main(int argc, char **argv)
 				cpuPlots.append(KsUtils::parseIdList(QString(optarg)));
 			else if (strcmp(longOptions[optionIndex].name, "pid") == 0)
 				taskPlots.append(KsUtils::parseIdList(QString(optarg)));
-
+			else if (strcmp(longOptions[optionIndex].name, "task") == 0)
+				taskList = QString(optarg);
 			break;
 
 		case 'h':
@@ -136,9 +140,14 @@ int main(int argc, char **argv)
 		return ids;
 	};
 
-	if (cpuPlots.count() || taskPlots.count()) {
+	if (cpuPlots.count() || taskPlots.count() || taskList.size()) {
 		ks.setCPUPlots(0, lamOrderIds(cpuPlots));
-		ks.setTaskPlots(0, lamOrderIds(taskPlots));
+
+		auto pidMap = KsUtils::parseTaskList(taskList);
+		pidMap[0].append(taskPlots);
+		for (auto it = pidMap.begin(); it != pidMap.end(); ++it) {
+			ks.setTaskPlots(it.key(), lamOrderIds(it.value()));
+		}
 	}
 
 	ks.raise();
tests/libkshark-gui-tests.cpp +25 -0
index 5a0ca01..bc49194 100644
@@ -286,3 +286,28 @@ BOOST_AUTO_TEST_CASE(GraphModel)
 	model.reset();
 	BOOST_CHECK_EQUAL(model.rowCount({}), 0);
 }
+
+BOOST_AUTO_TEST_CASE(KsUtils_parseTasks)
+{
+	QVector<int> pids{28121, 28137, 28141, 28199, 28201, 205666, 267481};
+	kshark_context *kshark_ctx{nullptr};
+	kshark_entry **data{nullptr};
+	std::string file(KS_TEST_DIR);
+	ssize_t n_rows;
+	int sd;
+
+	kshark_instance(&kshark_ctx);
+	file += "/trace_test1.dat";
+	sd = kshark_open(kshark_ctx, file.c_str());
+	n_rows = kshark_load_entries(kshark_ctx, sd, &data);
+
+	auto pids_test = parseTaskList("zoom,sleep");
+	BOOST_CHECK(pids == pids_test[0]);
+
+	for (ssize_t r = 0; r < n_rows; ++r)
+		free(data[r]);
+	free(data);
+
+	kshark_close(kshark_ctx, sd);
+	kshark_free(kshark_ctx);
+}
Signature · 1 line
2.25.1
#26 lore raw

PATCH v2 26/27 kernel-shark: Add pkg-config configuration for libkshark

In reply to Yordan Karadzhov (VMware)

Add auto-generated pkg-config setup file to install for pkg-config. To be used for building against libkshark.

---
 CMakeLists.txt           |  3 +++
 build/cmake_clean.sh     |  1 +
 build/libkshark.pc.cmake | 10 ++++++++++
 src/CMakeLists.txt       |  6 ++++++
 4 files changed, 20 insertions(+)
 create mode 100644 build/libkshark.pc.cmake
CMakeLists.txt +3 -0
index 8ca33fd..efcccb1 100644
@@ -167,4 +167,7 @@ configure_file(${KS_DIR}/build/ks.desktop.cmake
 configure_file(${KS_DIR}/build/org.freedesktop.kshark-record.policy.cmake
                ${KS_DIR}/org.freedesktop.kshark-record.policy)
 
+configure_file(${KS_DIR}/build/libkshark.pc.cmake
+               ${KS_DIR}/libkshark.pc @ONLY)
+
 message("")
build/cmake_clean.sh +1 -0
index 2ca1136..d645c32 100755
@@ -12,6 +12,7 @@ rm -rf Testing/
 rm -f ../tests/*.dat
 rm -f ../lib/*
 rm ../kernelshark.desktop
+rm ../libkshark.pc
 rm ../org.freedesktop.kshark-record.policy
 rm -f ../src/KsCmakeDef.hpp
 rm -f CMakeDoxyfile.in
build/libkshark.pc.cmake new file +10 -0
new file mode 100644
index 0000000..ad4ce34
@@ -0,0 +1,10 @@
+prefix=@_INSTALL_PREFIX@
+libdir=@_LIBDIR@
+includedir=${prefix}/include/@KS_APP_NAME@
+
+Name: libkshark
+URL: https://git.kernel.org/pub/scm/utils/trace-cmd/kernel-shark.git/
+Description: Library for accessing ftrace file system
+Version: @KS_VERSION_STRING@
+Cflags: -I${includedir}
+Libs: -L${libdir} -lkshark
src/CMakeLists.txt +6 -0
index 4158901..6a6eda1 100644
@@ -133,6 +133,12 @@ if (Qt5Widgets_FOUND AND Qt5Network_FOUND AND TT_FONT_FILE)
             DESTINATION ${_INSTALL_PREFIX}/bin/
                 COMPONENT                 kernelshark)
 
+    execute_process(COMMAND  bash "-c" "pkg-config --variable pc_path pkg-config | cut -f 1 -d: -z"
+                    OUTPUT_VARIABLE PKG_CONGIG_DIR)
+    install(FILES "${KS_DIR}/libkshark.pc"
+            DESTINATION ${PKG_CONGIG_DIR}
+                COMPONENT                 libkshark-devel)
+
 endif (Qt5Widgets_FOUND AND Qt5Network_FOUND AND TT_FONT_FILE)
 
 add_subdirectory(plugins)
Signature · 1 line
2.25.1
#27 lore raw

PATCH v2 27/27 kernel-shark: Install libkshark-tepdata.h

In reply to Yordan Karadzhov (VMware)

The header wull be installed as part of the "libkshark-devel" component. It can be useful for applications dealing with data from trace-cmd. In particular, the header is needed whene building trace-cruncher.

---
 src/CMakeLists.txt | 1 +
 1 file changed, 1 insertion(+)
src/CMakeLists.txt +1 -0
index 6a6eda1..1e86e9c 100644
@@ -34,6 +34,7 @@ install(TARGETS kshark
 install(FILES "${KS_DIR}/src/libkshark.h"
               "${KS_DIR}/src/libkshark-model.h"
               "${KS_DIR}/src/libkshark-plugin.h"
+              "${KS_DIR}/src/libkshark-tepdata.h"
         DESTINATION ${KS_INCLUDS_DESTINATION}
             COMPONENT libkshark-devel)
 
Signature · 1 line
2.25.1
Acked-by on the v2 series
#28 lore raw
In reply to Yordan Karadzhov (VMware)
Quoted 34 lines · On Thu, 11 Feb 2021 12:31:38 +0200 "Yordan Karadzhov (VMware)"…

With this patch-set we complete the destructive part of the transformation of KernelShark towards v2 and the GUI is finally fully functional again.

v2 changes:
* Fixing the bug in patch
"kernel-shark: Update KsDualMarker and KsGLWidget", causing the error "Unable to find FreeSans font".

* New patches:
- kernel-shark: Search for font with Cmake at pre-build
- kernel-shark: Add pkg-config configuration for libkshark
- kernel-shark: Install libkshark-tepdata.h

Yordan Karadzhov (VMware) (27):
kernel-shark: Add get_stream_object()
kernel-shark: Do proper reset in kshark_close_all()
kernel-shark: Restore the counting of event handlers
kernel-shark: Fix a misleading comment
kernel-shark: Count the number of readout interfaces
kernel-shark: Update KsUtils
kernel-shark: Update KsModels and KsSearchFSM
kernel-shark: Add trace data files for CI testing
kernel-shark: Add plugin tests
kernel-shark: Add model tests
kernel-shark: Update KsWidgetsLib
kernel-shark: Add combo point to Mark
kernel-shark: Add new methods to KsPlot::Mark
kernel-shark: Update the plotting example
kernel-shark: Search for font with Cmake at pre-build
kernel-shark: Update KsDualMarker and KsGLWidget
kernel-shark: Update KsTraceGraph and KsQuickContextMenu
kernel-shark: Update KsTraceViewer
kernel-shark: Update KsAdvFilteringDialog

Quoted 10 lines

kernel-shark: Update KsCaptureDialog
kernel-shark: Update KsSession
kernel-shark: Update MissedEvents plugin
kernel-shark: Update KsMainWindow and kernelshark.cpp
kernel-shark: Clickable sched_event plugin shapes
kernel-shark: Show Task plots from command lime
kernel-shark: Add pkg-config configuration for libkshark
kernel-shark: Install libkshark-tepdata.h

-- Steve