This series of patches contains various independent
cover This series of patches contains various independent
Yordan Karadzhov (8):
kernel-shark-qt: Free all collections when closing the trace file.
kernel-shark-qt: Fix potential memory leak when searching in
collections
kernel-shark-qt: Put error messages always on top
kernel-shark-qt: Fix bug when loading the Dual Marker
kernel-shark-qt: Fix bug when loading plugins from session
kernel-shark-qt: Fix bug when resizing the KS window for session
kernel-shark-qt: Change the color convention of the task graphs
kernel-shark-qt: Remove duplicate code in KsWidgetsLib.cpp
kernel-shark-qt/examples/dataplot.cpp | 30 +++-- kernel-shark-qt/src/KsGLWidget.cpp | 15 ++- kernel-shark-qt/src/KsGLWidget.hpp | 2 + kernel-shark-qt/src/KsMainWindow.cpp | 12 +- kernel-shark-qt/src/KsMainWindow.hpp | 10 +- kernel-shark-qt/src/KsPlotTools.cpp | 152 ++++++++++++++++---------- kernel-shark-qt/src/KsPlotTools.hpp | 45 ++++++-- kernel-shark-qt/src/KsSession.cpp | 46 +++++--- kernel-shark-qt/src/KsSession.hpp | 4 +- kernel-shark-qt/src/KsWidgetsLib.cpp | 28 ++--- kernel-shark-qt/src/libkshark-model.c | 8 +- kernel-shark-qt/src/libkshark.c | 7 ++ 12 files changed, 233 insertions(+), 126 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/8 kernel-shark-qt: Free all collections when closing the trace file.
All data collections are file specific. We have to guarantee that collections from one file cannot be used with another file.
--- kernel-shark-qt/src/libkshark.c | 7 +++++++ 1 file changed, 7 insertions(+)
kernel-shark-qt/src/libkshark.c +7 -0
@@ -188,6 +188,13 @@ void kshark_close(struct kshark_context *kshark_ctx) kshark_ctx->advanced_event_filter =NULL ; } +/* +* All data collections are file specific. Make sure that collections +* from this file are not going to be used with another file. +*/ +kshark_free_collection_list (kshark_ctx->collections); + kshark_ctx->collections =NULL ; +tracecmd_close (kshark_ctx->handle); kshark_ctx->handle =NULL ; kshark_ctx->pevent =NULL ;
Signature · 1 line
2.17.1
PATCH 2/8 kernel-shark-qt: Fix potential memory leak when searching in collections
In reply to Yordan KaradzhovIn some cases the Data Collection can map the original data request into a list of data requests. This is done in the cases when the range of the original request overlaps with more the one data interval (as defined by the collection). In such a case we must free the entire list of requests.
--- kernel-shark-qt/src/libkshark-model.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
kernel-shark-qt/src/libkshark-model.c +4 -4
@@ -900,7 +900,7 @@ ksmodel_get_entry_front(struct kshark_trace_histo *histo,else entry =kshark_get_entry_front (req, histo->data, index); -free (req); +kshark_free_entry_request (req);return entry; }
@@ -947,7 +947,7 @@ ksmodel_get_entry_back(struct kshark_trace_histo *histo,else entry =kshark_get_entry_back (req, histo->data, index); -free (req); +kshark_free_entry_request (req);return entry; }
@@ -1160,7 +1160,7 @@ bool ksmodel_cpu_visible_event_exist(struct kshark_trace_histo *histo,else entry =kshark_get_entry_front (req, histo->data, index); -free (req); +kshark_free_entry_request (req);if (!entry || !entry->visible) {/* No visible entry has been found. */
@@ -1213,7 +1213,7 @@ bool ksmodel_task_visible_event_exist(struct kshark_trace_histo *histo,else entry =kshark_get_entry_front (req, histo->data, index); -free (req); +kshark_free_entry_request (req);if (!entry || !entry->visible) {/* No visible entry has been found. */
Signature · 1 line
2.17.1
PATCH 3/8 kernel-shark-qt: Put error messages always on top
In reply to Yordan KaradzhovWhen an error message is shown its widget must be placed always on top of all other windows. Also the user shouldn't be able to do anything else, before closing the error message widget.
--- kernel-shark-qt/src/KsMainWindow.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel-shark-qt/src/KsMainWindow.cpp +2 -1
@@ -859,8 +859,9 @@ void KsMainWindow::_error(const QString &text, const QString &errCode, if (unloadPlugins) _plugins.unloadAll(); - em->showMessage(text, errCode); qCritical() << "ERROR: " << text; + em->showMessage(text, errCode); + em->exec(); } /**
Signature · 1 line
2.17.1
PATCH 4/8 kernel-shark-qt: Fix bug when loading the Dual Marker
In reply to Yordan KaradzhovWhen loading the settings of the Dual Marker for a session, the View(table) must be updated only if the active marker is actually set.
--- kernel-shark-qt/src/KsSession.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
kernel-shark-qt/src/KsSession.cpp +4 -4
@@ -431,7 +431,6 @@ void KsSession::loadDualMarker(KsDualMarkerSM *dm, KsTraceGraph *graphs) dm->reset(); dm->setState(DualMarkerState::A); - if (_getMarker("markA", &pos)) { graphs->markEntry(pos); } else {
@@ -446,9 +445,10 @@ void KsSession::loadDualMarker(KsDualMarkerSM *dm, KsTraceGraph *graphs) } dm->setState(_getMarkerState()); - pos = dm->activeMarker()._pos; - - emit graphs->glPtr()->updateView(pos, true); + if (dm->activeMarker()._isSet) { + pos = dm->activeMarker()._pos; + emit graphs->glPtr()->updateView(pos, true); + } } json_object *KsSession::_getMarkerJson()
Signature · 1 line
2.17.1
PATCH 5/8 kernel-shark-qt: Fix bug when loading plugins from session
In reply to Yordan KaradzhovThe session description file may contain plugins which are not available at the moment when the session is loaded. These can be user-defined plugins for example. The modification of the code introduced by this patch deals with such a case.
--- kernel-shark-qt/src/KsSession.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
kernel-shark-qt/src/KsSession.cpp +10 -7
@@ -545,7 +545,10 @@ void KsSession::loadPlugins(kshark_context *kshark_ctx, KsPluginManager *pm) { kshark_config_doc *plugins = kshark_config_alloc(KS_CONFIG_JSON); json_object *jplugins, *jlist, *jpl; - int length; + const char *pluginName; + QVector<int> pluginIds; + int length, index; + bool loaded; if (!kshark_config_doc_get(_config, "Plugins", plugins) || !kshark_type_check(plugins, "kshark.config.plugins"))
@@ -562,13 +565,13 @@ void KsSession::loadPlugins(kshark_context *kshark_ctx, KsPluginManager *pm) length = json_object_array_length(jlist); for (int i = 0; i < length; ++i) { jpl = json_object_array_get_idx(jlist, i); - pm->_ksPluginList[i] = - json_object_get_string(json_object_array_get_idx(jpl, 0)); - - pm->_registeredKsPlugins[i] = - json_object_get_boolean(json_object_array_get_idx(jpl, 1)); + pluginName = json_object_get_string(json_object_array_get_idx(jpl, 0)); + index = pm->_ksPluginList.indexOf(pluginName); + loaded = json_object_get_boolean(json_object_array_get_idx(jpl, 1)); + if (index >= 0 && loaded) + pluginIds.append(index); } } - pm->registerFromList(kshark_ctx); + pm->updatePlugins(pluginIds); }
Signature · 1 line
2.17.1
PATCH 6/8 kernel-shark-qt: Fix bug when resizing the KS window for session
In reply to Yordan KaradzhovCurrently the session export/import code cannot deal with the case when the KernelShark GUI is in Full Screen mode. This patch fixes this.
--- kernel-shark-qt/src/KsMainWindow.cpp | 9 +++------ kernel-shark-qt/src/KsMainWindow.hpp | 10 +++++++--- kernel-shark-qt/src/KsSession.cpp | 21 +++++++++++++++++---- kernel-shark-qt/src/KsSession.hpp | 4 +++- 4 files changed, 30 insertions(+), 14 deletions(-)
kernel-shark-qt/src/KsMainWindow.cpp +3 -6
@@ -64,7 +64,6 @@ KsMainWindow::KsMainWindow(QWidget *parent) _colSlider(this), _colorPhaseSlider(Qt::Horizontal, this), _fullScreenModeAction("Full Screen Mode", this), - _isFullScreen(false), _aboutAction("About", this), _contentsAction("Contents", this) {
@@ -245,7 +244,7 @@ void KsMainWindow::_createActions() _fullScreenModeAction.setStatusTip("Full Screen Mode"); connect(&_fullScreenModeAction, &QAction::triggered, - this, &KsMainWindow::_fullScreenMode); + this, &KsMainWindow::_changeScreenMode); /* Help menu */ _aboutAction.setIcon(QIcon::fromTheme("help-about"));
@@ -732,18 +731,16 @@ void KsMainWindow::_setColorPhase(int f) _graph.glPtr()->model()->update(); } -void KsMainWindow::_fullScreenMode() +void KsMainWindow::_changeScreenMode() { - if (_isFullScreen) { + if (isFullScreen()) { _fullScreenModeAction.setText("Full Screen Mode"); _fullScreenModeAction.setIcon(QIcon::fromTheme("view-fullscreen")); showNormal(); - _isFullScreen = false; } else { _fullScreenModeAction.setText("Exit Full Screen Mode"); _fullScreenModeAction.setIcon(QIcon::fromTheme("view-restore")); showFullScreen(); - _isFullScreen = true; } }
kernel-shark-qt/src/KsMainWindow.hpp +7 -3
@@ -61,6 +61,12 @@ public: void resizeEvent(QResizeEvent* event); + /** Set the Full Screen mode. */ + void setFullScreenMode(bool f) { + if ((!isFullScreen() && f) || (isFullScreen() && !f) ) + _changeScreenMode(); + } + private: QSplitter _splitter;
@@ -136,8 +142,6 @@ private: QAction _fullScreenModeAction; - bool _isFullScreen; - // Help menu. QAction _aboutAction;
@@ -179,7 +183,7 @@ private: void _setColorPhase(int); - void _fullScreenMode(); + void _changeScreenMode(); void _aboutInfo();
kernel-shark-qt/src/KsSession.cpp +17 -4
@@ -12,6 +12,7 @@ // KernelShark #include "libkshark.h" #include "KsSession.hpp" +#include "KsMainWindow.hpp" /** Create a KsSession object. */ KsSession::KsSession()
@@ -175,10 +176,15 @@ void KsSession::saveMainWindowSize(const QMainWindow &window) { kshark_config_doc *windowConf = kshark_config_alloc(KS_CONFIG_JSON); int width = window.width(), height = window.height(); - json_object *jwindow = json_object_new_array(); + json_object *jwindow; - json_object_array_put_idx(jwindow, 0, json_object_new_int(width)); - json_object_array_put_idx(jwindow, 1, json_object_new_int(height)); + if (window.isFullScreen()) { + jwindow = json_object_new_string("FullScreen"); + } else { + jwindow = json_object_new_array(); + json_object_array_put_idx(jwindow, 0, json_object_new_int(width)); + json_object_array_put_idx(jwindow, 1, json_object_new_int(height)); + } windowConf->conf_doc = jwindow; kshark_config_doc_add(_config, "MainWindow", windowConf);
@@ -189,7 +195,7 @@ void KsSession::saveMainWindowSize(const QMainWindow &window) * * @param window: Input location for the KsMainWindow widget. */ -void KsSession::loadMainWindowSize(QMainWindow *window) +void KsSession::loadMainWindowSize(KsMainWindow *window) { kshark_config_doc *windowConf = kshark_config_alloc(KS_CONFIG_JSON); json_object *jwindow, *jwidth, *jheight;
@@ -200,12 +206,19 @@ void KsSession::loadMainWindowSize(QMainWindow *window) 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); } }
kernel-shark-qt/src/KsSession.hpp +3 -1
@@ -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
@@ -57,7 +59,7 @@ public: void saveMainWindowSize(const QMainWindow &window); - void loadMainWindowSize(QMainWindow *window); + void loadMainWindowSize(KsMainWindow *window); void saveSplitterSize(const QSplitter &splitter);
Signature · 1 line
2.17.1
PATCH 7/8 kernel-shark-qt: Change the color convention of the task graphs
In reply to Yordan KaradzhovSo far the Task graphs have used the same color convention as the CPU graphs. Namely the vertical tick of the record was plotted by using the CPU color and the horizontal strap was plotted by using the task color. This patch reverts the color convention and now the tick has the color of the task and the strap has the color of the CPU. This change requires significant modification of the logic used to create and draw the graphs.
--- kernel-shark-qt/examples/dataplot.cpp | 30 +++-- kernel-shark-qt/src/KsGLWidget.cpp | 15 ++- kernel-shark-qt/src/KsGLWidget.hpp | 2 + kernel-shark-qt/src/KsPlotTools.cpp | 152 ++++++++++++++++---------- kernel-shark-qt/src/KsPlotTools.hpp | 45 ++++++-- 5 files changed, 162 insertions(+), 82 deletions(-)
kernel-shark-qt/examples/dataplot.cpp +18 -12
@@ -78,36 +78,42 @@ void drawShapes() /* An example function demonstrating Zoom In and Zoom Out. */ void play() { - KsPlot::ColorTable colors = KsPlot::getColorTable(); + KsPlot::ColorTable taskColors = KsPlot::getTaskColorTable(); + KsPlot::ColorTable cpuColors = KsPlot::getCPUColorTable(); vector<KsPlot::Graph *>::iterator it; vector<int> CPUs, Tasks; - KsPlot::Graph *graph; bool zoomIn(true); int base; + size_t i; CPUs = {3, 4, 6}; Tasks = {}; // Add valid pids here, if you want task plots. - for (size_t i = 0; i < CPUs.size() + Tasks.size(); ++i) { - /* Make a new Graph. */ - graph = new KsPlot::Graph(&histo, &colors); - + auto lamAddGraph = [&] (KsPlot::Graph *g) { /* Set the dimensions of the Graph. */ - graph->setHeight(GRAPH_HEIGHT); - graph->setHMargin(GRAPH_H_MARGIN); + g->setHeight(GRAPH_HEIGHT); + g->setHMargin(GRAPH_H_MARGIN); /* * Set the Y coordinate of the Graph's base. * Remember that the "Y" coordinate is inverted. */ base = 1.7 * GRAPH_HEIGHT * (i + 1); - graph->setBase(base); + g->setBase(base); /* Add the Graph. */ - graphs.push_back(graph); - } + graphs.push_back(g); + }; + + for (i = 0; i < CPUs.size(); ++i) + lamAddGraph(new KsPlot::Graph(&histo, &taskColors, + &taskColors)); + + for (;i < CPUs.size() + Tasks.size(); ++i) + lamAddGraph(new KsPlot::Graph(&histo, &taskColors, + &cpuColors)); - for (int i = 1; i < 1000; ++i) { + for (i = 1; i < 1000; ++i) { it = graphs.begin(); for (int const &cpu: CPUs)
kernel-shark-qt/src/KsGLWidget.cpp +13 -2
@@ -356,7 +356,9 @@ void KsGLWidget::loadData(KsDataStore *data) void KsGLWidget::loadColors() { _pidColors.clear(); - _pidColors = KsPlot::getColorTable(); + _pidColors = KsPlot::getTaskColorTable(); + _cpuColors.clear(); + _cpuColors = KsPlot::getCPUColorTable(); } /**
@@ -530,8 +532,12 @@ void KsGLWidget::_makePluginShapes(QVector<int> cpuList, QVector<int> taskList) KsPlot::Graph *KsGLWidget::_newCPUGraph(int cpu) { + /* The CPU graph needs to know only the colors of the tasks. */ KsPlot::Graph *graph = new KsPlot::Graph(_model.histo(), + &_pidColors, &_pidColors); + graph->setZeroSuppressed(true); + kshark_context *kshark_ctx(nullptr); kshark_entry_collection *col;
@@ -553,8 +559,13 @@ KsPlot::Graph *KsGLWidget::_newCPUGraph(int cpu) KsPlot::Graph *KsGLWidget::_newTaskGraph(int pid) { + /* + * The Task graph needs to know the colors of the tasks and the colors + * of the CPUs. + */ KsPlot::Graph *graph = new KsPlot::Graph(_model.histo(), - &_pidColors); + &_pidColors, + &_cpuColors); kshark_context *kshark_ctx(nullptr); kshark_entry_collection *col;
kernel-shark-qt/src/KsGLWidget.hpp +2 -0
@@ -161,6 +161,8 @@ private: KsPlot::ColorTable _pidColors; + KsPlot::ColorTable _cpuColors; + int _hMargin, _vMargin; unsigned int _vSpacing;
kernel-shark-qt/src/KsPlotTools.cpp +96 -56
354 lines not on this page · raw message
kernel-shark-qt/src/KsPlotTools.hpp +33 -12
86 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 8/8 kernel-shark-qt: Remove duplicate code in KsWidgetsLib.cpp
In reply to Yordan KaradzhovCurrently the "Task" and "CPU" checkbox widgets have their own implementation of the code that generates the Rainbow color palettes of the CPUs and Tasks. This patch make the two widgets to use the same hash tables of colors used when plotting the graphs.
--- kernel-shark-qt/src/KsWidgetsLib.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
kernel-shark-qt/src/KsWidgetsLib.cpp +14 -14
@@ -622,7 +622,7 @@ KsCPUCheckBoxWidget::KsCPUCheckBoxWidget(struct tep_handle *tep, : KsCheckBoxTreeWidget("CPUs", parent) { int nCPUs(0), height(FONT_HEIGHT * 1.5); - KsPlot::Color cpuCol; + KsPlot::ColorTable colors; QString style; style = QString("QTreeView::item { height: %1 ;}").arg(height);
@@ -635,16 +635,16 @@ KsCPUCheckBoxWidget::KsCPUCheckBoxWidget(struct tep_handle *tep, _id.resize(nCPUs); _cb.resize(nCPUs); + colors = KsPlot::getCPUColorTable(); for (int i = 0; i < nCPUs; ++i) { - cpuCol.setRainbowColor(i); QTreeWidgetItem *cpuItem = new QTreeWidgetItem; cpuItem->setText(0, " "); cpuItem->setText(1, QString("CPU %1").arg(i)); cpuItem->setCheckState(0, Qt::Checked); - cpuItem->setBackgroundColor(0, QColor(cpuCol.r(), - cpuCol.g(), - cpuCol.b())); + cpuItem->setBackgroundColor(0, QColor(colors[i].r(), + colors[i].g(), + colors[i].b())); _tree.addTopLevelItem(cpuItem); _id[i] = i; _cb[i] = cpuItem;
@@ -719,10 +719,10 @@ KsTasksCheckBoxWidget::KsTasksCheckBoxWidget(struct tep_handle *pevent, { kshark_context *kshark_ctx(nullptr); QTableWidgetItem *pidItem, *comItem; - KsPlot::Color pidCol; + KsPlot::ColorTable colors; QStringList headers; const char *comm; - int nTasks; + int nTasks, pid; if (!kshark_instance(&kshark_ctx)) return;
@@ -735,24 +735,24 @@ KsTasksCheckBoxWidget::KsTasksCheckBoxWidget(struct tep_handle *pevent, _id = KsUtils::getPidList(); nTasks = _id.count(); _initTable(headers, nTasks); + colors = KsPlot::getTaskColorTable(); for (int i = 0; i < nTasks; ++i) { - pidItem = new QTableWidgetItem(tr("%1").arg(_id[i])); + pid = _id[i]; + pidItem = new QTableWidgetItem(tr("%1").arg(pid)); _table.setItem(i, 1, pidItem); - comm = tep_data_comm_from_pid(kshark_ctx->pevent, _id[i]); + comm = tep_data_comm_from_pid(kshark_ctx->pevent, pid); comItem = new QTableWidgetItem(tr(comm)); - pidItem->setBackgroundColor(QColor(pidCol.r(), - pidCol.g(), - pidCol.b())); + pidItem->setBackgroundColor(QColor(colors[pid].r(), + colors[pid].g(), + colors[pid].b())); if (_id[i] == 0) pidItem->setTextColor(Qt::white); _table.setItem(i, 2, comItem); - - pidCol.setRainbowColor(i); } _adjustSize();
Signature · 1 line
2.17.1
Quoted 11 lines · On Thu, 1 Nov 2018 21:45:36 +0000 Yordan Karadzhov <[email protected]>…
Yordan Karadzhov (8):
kernel-shark-qt: Free all collections when closing the trace file.
kernel-shark-qt: Fix potential memory leak when searching in
collections
kernel-shark-qt: Put error messages always on top
kernel-shark-qt: Fix bug when loading the Dual Marker
kernel-shark-qt: Fix bug when loading plugins from session
kernel-shark-qt: Fix bug when resizing the KS window for session
kernel-shark-qt: Change the color convention of the task graphs
kernel-shark-qt: Remove duplicate code in KsWidgetsLib.cpp
Quoted 14 lines
kernel-shark-qt/examples/dataplot.cpp | 30 +++-- kernel-shark-qt/src/KsGLWidget.cpp | 15 ++- kernel-shark-qt/src/KsGLWidget.hpp | 2 + kernel-shark-qt/src/KsMainWindow.cpp | 12 +- kernel-shark-qt/src/KsMainWindow.hpp | 10 +- kernel-shark-qt/src/KsPlotTools.cpp | 152 ++++++++++++++++---------- kernel-shark-qt/src/KsPlotTools.hpp | 45 ++++++-- kernel-shark-qt/src/KsSession.cpp | 46 +++++--- kernel-shark-qt/src/KsSession.hpp | 4 +- kernel-shark-qt/src/KsWidgetsLib.cpp | 28 ++--- kernel-shark-qt/src/libkshark-model.c | 8 +- kernel-shark-qt/src/libkshark.c | 7 ++ 12 files changed, 233 insertions(+), 126 deletions(-)
Pull. Thanks Yordan!
-- Steve