Various modifications and fixes toward KS 1.0
cover Various modifications and fixes toward KS 1.0
The patch-set contains patches that have been sent already, but have not been pushed due to various reasons. The last two patch are fixes of bugs that have been found recently.
Yordan Karadzhov (6):
kernel-shark: Remove hard-coded install paths
kernel-shark: Use XDG compliant path when saving cached data
kernel-shark: Enforce update of the OpenGL widget when loading new
session
kernel-shark: Add "Report bug" button to "Help"
kernel-shark: Improve the appearance on high screen resolution
kernel-shark: Handle the case when the marker points to a filtered
entry
kernel-shark/CMakeLists.txt | 8 ++++-- kernel-shark/build/deff.h.cmake | 3 ++ kernel-shark/build/ks.desktop.cmake | 4 +-- kernel-shark/src/CMakeLists.txt | 19 +++++++------ kernel-shark/src/KsDualMarker.cpp | 9 ++++++ kernel-shark/src/KsGLWidget.cpp | 24 +++++++++------- kernel-shark/src/KsGLWidget.hpp | 5 +++- kernel-shark/src/KsMainWindow.cpp | 22 ++++++++++++--- kernel-shark/src/KsMainWindow.hpp | 4 +++ kernel-shark/src/KsPlotTools.cpp | 37 +++++++++++++++++++++++-- kernel-shark/src/KsPlotTools.hpp | 11 +++++++- kernel-shark/src/KsTraceGraph.cpp | 2 ++ kernel-shark/src/KsTraceViewer.cpp | 22 +++++++++------ kernel-shark/src/KsUtils.cpp | 4 +-- kernel-shark/src/plugins/CMakeLists.txt | 3 +- 15 files changed, 134 insertions(+), 43 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/6 kernel-shark: Remove hard-coded install paths
The definitions of KS_APP_NAME and KS_ICON are used to derive standard installation paths for the KernelShark libraries, plugins and icons. The patch combines improvements suggested by Troy Engel and Bas van Dijk.
--- kernel-shark/CMakeLists.txt | 8 ++++++-- kernel-shark/build/deff.h.cmake | 3 +++ kernel-shark/build/ks.desktop.cmake | 4 ++-- kernel-shark/src/CMakeLists.txt | 19 +++++++++++-------- kernel-shark/src/KsUtils.cpp | 4 ++-- kernel-shark/src/plugins/CMakeLists.txt | 3 +-- 6 files changed, 25 insertions(+), 16 deletions(-)
kernel-shark/CMakeLists.txt +6 -2
@@ -4,6 +4,7 @@ cmake_minimum_required(VERSION 2.8.11 FATAL_ERROR) # Set the name and version of the project project(kernel-shark) +set(KS_APP_NAME "kernelshark") set(KS_VERSION_MAJOR 0) set(KS_VERSION_MINOR 9) set(KS_VERSION_PATCH 8)
@@ -39,6 +40,9 @@ if(NOT _INSTALL_PREFIX) set(_INSTALL_PREFIX "/usr/local") endif() +set(KS_PLUGIN_INSTALL_PREFIX ${_INSTALL_PREFIX}/lib/${KS_APP_NAME}/plugins/) +set(KS_ICON ksharkicon.png) + if (NOT _DEBUG) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
@@ -46,7 +50,7 @@ if (NOT _DEBUG) endif (NOT _DEBUG) -SET(CMAKE_INSTALL_RPATH "${_INSTALL_PREFIX}/lib/kshark/") +SET(CMAKE_INSTALL_RPATH "${_INSTALL_PREFIX}/lib/${KS_APP_NAME}/") SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) include_directories(${KS_DIR}/src/
@@ -79,7 +83,7 @@ if (_DOXYGEN_DOC AND DOXYGEN_FOUND) endif () configure_file( ${KS_DIR}/build/ks.desktop.cmake - ${KS_DIR}/kernelshark.desktop) + ${KS_DIR}/${KS_APP_NAME}.desktop) configure_file( ${KS_DIR}/build/org.freedesktop.kshark-record.policy.cmake ${KS_DIR}/org.freedesktop.kshark-record.policy)
kernel-shark/build/deff.h.cmake +3 -0
@@ -14,6 +14,9 @@ /** KernelShark installation prefix path. */ #cmakedefine _INSTALL_PREFIX "@_INSTALL_PREFIX@" +/** KernelShark plugins installation prefix path. */ +#cmakedefine KS_PLUGIN_INSTALL_PREFIX "@KS_PLUGIN_INSTALL_PREFIX@" + /** Location of the trace-cmd executable. */ #cmakedefine TRACECMD_BIN_DIR "@TRACECMD_BIN_DIR@"
kernel-shark/build/ks.desktop.cmake +2 -2
@@ -4,7 +4,7 @@ Type=Application Name=Kernel Shark GenericName=Kernel Shark Comment= -Exec=@_INSTALL_PREFIX@/bin/kernelshark -Icon=@KS_DIR@/icons/ksharkicon.png +Exec=@_INSTALL_PREFIX@/bin/@KS_APP_NAME@ +Icon=@_INSTALL_PREFIX@/share/icons/@KS_APP_NAME@/@KS_ICON@ Categories=System; Terminal=false
kernel-shark/src/CMakeLists.txt +11 -8
@@ -69,23 +69,26 @@ if (Qt5Widgets_FOUND AND Qt5Network_FOUND) set_target_properties(kshark-gui PROPERTIES SUFFIX ".so.${KS_VERSION_STRING}") - message(STATUS "kernelshark") - add_executable(kernelshark kernelshark.cpp) - target_link_libraries(kernelshark 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 kernelshark kshark-record kshark kshark-plot kshark-gui + install(TARGETS ${KS_APP_NAME} kshark-record kshark kshark-plot kshark-gui RUNTIME DESTINATION ${_INSTALL_PREFIX}/bin/ - LIBRARY DESTINATION ${_INSTALL_PREFIX}/lib/kshark/) + LIBRARY DESTINATION ${_INSTALL_PREFIX}/lib/${KS_APP_NAME}/) - install(FILES "${KS_DIR}/kernelshark.desktop" - DESTINATION /usr/share/applications/) + install(FILES "${KS_DIR}/${KS_APP_NAME}.desktop" + DESTINATION ${_INSTALL_PREFIX}/share/applications/) + + install(FILES "${KS_DIR}/icons/${KS_ICON}" + DESTINATION ${_INSTALL_PREFIX}/share/icons/${KS_APP_NAME}) install(FILES "${KS_DIR}/org.freedesktop.kshark-record.policy" - DESTINATION /usr/share/polkit-1/actions/) + DESTINATION ${_INSTALL_PREFIX}/share/polkit-1/actions/) install(PROGRAMS "${KS_DIR}/bin/kshark-su-record" DESTINATION ${_INSTALL_PREFIX}/bin/)
kernel-shark/src/KsUtils.cpp +2 -2
@@ -619,8 +619,8 @@ char *KsPluginManager::_pluginLibFromName(const QString &plugin, int &n) n = asprintf(&lib, "%s/plugin-%s.so", pathStr.c_str(), pluginStr.c_str()); } else { - n = asprintf(&lib, "%s/lib/kshark/plugins/plugin-%s.so", - _INSTALL_PREFIX, pluginStr.c_str()); + n = asprintf(&lib, "%s/plugin-%s.so", + KS_PLUGIN_INSTALL_PREFIX, pluginStr.c_str()); } return lib;
kernel-shark/src/plugins/CMakeLists.txt +1 -2
@@ -18,7 +18,6 @@ function(BUILD_PLUGIN) endfunction() set(PLUGIN_LIST "") - BUILD_PLUGIN(NAME sched_events SOURCE sched_events.c SchedEvents.cpp) list(APPEND PLUGIN_LIST "sched_events default") # This plugin will be loaded by default
@@ -29,6 +28,6 @@ BUILD_PLUGIN(NAME missed_events list(APPEND PLUGIN_LIST "missed_events default") # This plugin will be loaded by default install(TARGETS sched_events missed_events - LIBRARY DESTINATION ${_INSTALL_PREFIX}/lib/kshark/plugins/) + LIBRARY DESTINATION ${KS_PLUGIN_INSTALL_PREFIX}) set(PLUGINS ${PLUGIN_LIST} PARENT_SCOPE)
Signature · 1 line
2.20.1
PATCH 2/6 kernel-shark: Use XDG compliant path when saving cached data
In reply to Yordan KaradzhovUse the QStandardPaths class provided by Qt in order to guarantee that the location of the cached data is XDG compliant.
--- kernel-shark/src/KsMainWindow.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
kernel-shark/src/KsMainWindow.cpp +4 -2
@@ -409,8 +409,10 @@ QString KsMainWindow::_getCacheDir() if (!QDir(dir).exists()) lamMakePath(true); } else { - dir = QString(QDir::homePath()) + - "/.cache/kernelshark"; + auto appCachePath = QStandardPaths::GenericCacheLocation; + dir = QStandardPaths::writableLocation(appCachePath); + dir += "/kernelshark"; + if (!QDir(dir).exists()) lamMakePath(false); }
Signature · 1 line
2.20.1
PATCH 3/6 kernel-shark: Enforce update of the OpenGL widget when loading new session
In reply to Yordan KaradzhovThis is needed in the case when the session was saved at different screen resolution.
--- kernel-shark/src/KsGLWidget.hpp | 3 +++ kernel-shark/src/KsMainWindow.cpp | 3 +-- kernel-shark/src/KsTraceGraph.cpp | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-)
kernel-shark/src/KsGLWidget.hpp +3 -0
@@ -41,6 +41,9 @@ public: void reset(); + /** Reprocess all graphs. */ + void update() {resizeGL(width(), height());} + void mousePressEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event);
kernel-shark/src/KsMainWindow.cpp +1 -2
@@ -435,7 +435,6 @@ QString KsMainWindow::lastSessionFile() void KsMainWindow::_restoreSession() { loadSession(lastSessionFile()); - _graph.updateGeom(); } void KsMainWindow::_importSession()
@@ -450,7 +449,6 @@ void KsMainWindow::_importSession() return; loadSession(fileName); - _graph.updateGeom(); } void KsMainWindow::_updateSession()
@@ -1100,6 +1098,7 @@ void KsMainWindow::loadSession(const QString &fileName) _session.loadTable(&_view); _colorPhaseSlider.setValue(_session.getColorScheme() * 100); + _graph.updateGeom(); } void KsMainWindow::_initCapture()
kernel-shark/src/KsTraceGraph.cpp +2 -0
@@ -538,6 +538,8 @@ void KsTraceGraph::updateGeom() * allow the scroll bar to disappear when the * widget is extended to maximum. */ + + _glWindow.update(); } void KsTraceGraph::_updateGraphLegends()
Signature · 1 line
2.20.1
PATCH 4/6 kernel-shark: Add "Report bug" button to "Help"
In reply to Yordan KaradzhovWhen clicked, the Bugzilla will be opened in the appropriate Web browser for the user's desktop environment.
--- kernel-shark/src/KsMainWindow.cpp | 13 +++++++++++++ kernel-shark/src/KsMainWindow.hpp | 4 ++++ 2 files changed, 17 insertions(+)
kernel-shark/src/KsMainWindow.cpp +13 -0
@@ -67,6 +67,7 @@ KsMainWindow::KsMainWindow(QWidget *parent) _fullScreenModeAction("Full Screen Mode", this), _aboutAction("About", this), _contentsAction("Contents", this), + _bugReportAction("Report a bug", this), _deselectShortcut(this), _settings("kernelshark.org", "Kernel Shark") // organization , application {
@@ -288,6 +289,9 @@ void KsMainWindow::_createActions() _contentsAction.setIcon(QIcon::fromTheme("help-contents")); connect(&_contentsAction, &QAction::triggered, this, &KsMainWindow::_contents); + + connect(&_bugReportAction, &QAction::triggered, + this, &KsMainWindow::_bugReport); } void KsMainWindow::_createMenus()
@@ -365,6 +369,7 @@ void KsMainWindow::_createMenus() help = menuBar()->addMenu("Help"); help->addAction(&_aboutAction); help->addAction(&_contentsAction); + help->addAction(&_bugReportAction); } void KsMainWindow::_open()
@@ -925,6 +930,14 @@ void KsMainWindow::_contents() QUrl::TolerantMode)); } +void KsMainWindow::_bugReport() +{ + QUrl bugs("https://bugzilla.kernel.org/buglist.cgi?component=Trace-cmd%2FKernelshark&product=Tools&resolution=---", + QUrl::TolerantMode); + + QDesktopServices::openUrl(bugs); +} + /** Load trace data for file. */ void KsMainWindow::loadDataFile(const QString& fileName) {
kernel-shark/src/KsMainWindow.hpp +4 -0
@@ -151,6 +151,8 @@ private: QAction _contentsAction; + QAction _bugReportAction; + QShortcut _deselectShortcut; QString _lastDataFilePath, _lastConfFilePath, _lastPluginFilePath;
@@ -205,6 +207,8 @@ private: void _contents(); + void _bugReport(); + void _captureStarted(); void _captureError(QProcess::ProcessError error);
Signature · 1 line
2.20.1
PATCH 5/6 kernel-shark: Improve the appearance on high screen resolution
In reply to Yordan KaradzhovSome of the components of the plots haven't been properly scaled when displayed on high screen resolution.
--- kernel-shark/src/KsGLWidget.cpp | 24 ++++++++++++++---------- kernel-shark/src/KsGLWidget.hpp | 2 +- kernel-shark/src/KsPlotTools.cpp | 4 +++- 3 files changed, 18 insertions(+), 12 deletions(-)
kernel-shark/src/KsGLWidget.cpp +14 -10
@@ -84,24 +84,29 @@ void KsGLWidget::resizeGL(int w, int h) /** Reimplemented function used to plot trace graphs. */ void KsGLWidget::paintGL() { + float size = 1.5 * _dpr; + glClear(GL_COLOR_BUFFER_BIT); /* Draw the time axis. */ if(_data) - _drawAxisX(); + _drawAxisX(size); /* Process and draw all graphs by using the built-in logic. */ _makeGraphs(_cpuList, _taskList); for (auto const &g: _graphs) - g->draw(1.5 * _dpr); + g->draw(size); /* Process and draw all plugin-specific shapes. */ _makePluginShapes(_cpuList, _taskList); while (!_shapes.empty()) { auto s = _shapes.front(); + _shapes.pop_front(); + + s->_size = size; s->draw(); + delete s; - _shapes.pop_front(); } /*
@@ -448,22 +453,21 @@ void KsGLWidget::findGraphIds(const kshark_entry &e, *graphTask = -1; } -void KsGLWidget::_drawAxisX() +void KsGLWidget::_drawAxisX(float size) { KsPlot::Point a0(_hMargin, _vMargin / 4), a1(_hMargin, _vMargin / 2); - KsPlot::Point b0(width()/2, _vMargin / 4), b1(width() / 2, _vMargin / 2); + KsPlot::Point b0(width() / 2, _vMargin / 4), b1(width() / 2, _vMargin / 2); KsPlot::Point c0(width() - _hMargin, _vMargin / 4), c1(width() - _hMargin, _vMargin / 2); - int lineSize = 2 * _dpr; a0._size = c0._size = _dpr; a0.draw(); c0.draw(); - KsPlot::drawLine(a0, a1, {}, lineSize); - KsPlot::drawLine(b0, b1, {}, lineSize); - KsPlot::drawLine(c0, c1, {}, lineSize); - KsPlot::drawLine(a0, c0, {}, lineSize); + KsPlot::drawLine(a0, a1, {}, size); + KsPlot::drawLine(b0, b1, {}, size); + KsPlot::drawLine(c0, c1, {}, size); + KsPlot::drawLine(a0, c0, {}, size); } void KsGLWidget::_makeGraphs(QVector<int> cpuList, QVector<int> taskList)
kernel-shark/src/KsGLWidget.hpp +1 -1
@@ -190,7 +190,7 @@ private: int _dpr; - void _drawAxisX(); + void _drawAxisX(float size); void _makeGraphs(QVector<int> cpuMask, QVector<int> taskMask);
kernel-shark/src/KsPlotTools.cpp +3 -1
@@ -1089,8 +1089,10 @@ void Graph::draw(float size) /* Draw as vartical lines all bins containing data. */ for (int i = 0; i < _size; ++i) if (_bins[i]._idFront >= 0 || _bins[i]._idBack >= 0) - if (_bins[i]._visMask & KS_EVENT_VIEW_FILTER_MASK) + if (_bins[i]._visMask & KS_EVENT_VIEW_FILTER_MASK) { + _bins[i]._size = size; _bins[i].draw(); + } auto lamCheckEnsblVal = [this] (int v) { return v > 0 || (v == 0 && !this->_zeroSuppress);
Signature · 1 line
2.20.1
PATCH 6/6 kernel-shark: Handle the case when the marker points to a filtered entry
In reply to Yordan KaradzhovMarkers can point to entries that are filtered out. In such a case the filtered marker is plotted using a dashed line.
--- kernel-shark/src/KsDualMarker.cpp | 10 +++++++++ kernel-shark/src/KsPlotTools.cpp | 33 +++++++++++++++++++++++++++++- kernel-shark/src/KsPlotTools.hpp | 11 +++++++++- kernel-shark/src/KsTraceViewer.cpp | 22 ++++++++++++-------- 4 files changed, 65 insertions(+), 11 deletions(-)
kernel-shark/src/KsDualMarker.cpp +10 -0
@@ -79,9 +79,19 @@ bool KsGraphMark::set(const KsDataStore &data, kshark_trace_histo *histo, size_t pos, int cpuGraph, int taskGraph) { + uint8_t visFlags; + _isSet = true; _pos = pos; _ts = data.rows()[_pos]->ts; + visFlags = data.rows()[_pos]->visible; + + if ((visFlags & KS_TEXT_VIEW_FILTER_MASK) && + (visFlags & KS_GRAPH_VIEW_FILTER_MASK)) + _mark.setDashed(false); + else + _mark.setDashed(true); + _cpu = cpuGraph; _task = taskGraph;
kernel-shark/src/KsPlotTools.cpp +32 -1
@@ -379,6 +379,32 @@ void drawLine(const Point &a, const Point &b, size); } +/** + * @brief Draw a dashed line between point "a" and point "b". + * + * @param a: The first finishing point of the line. + * @param b: The second finishing point of the line. + * @param col: The color of the line. + * @param size: The size of the line. + * @param period: The period of the dashed line. + */ +void drawDashedLine(const Point &a, const Point &b, + const Color &col, float size, float period) +{ + int dx = b.x() - a.x(), dy = b.y() - a.y(); + float mod = sqrt(dx * dx + dy * dy); + int n = mod / period; + Point p1, p2; + + for (int i = 0; i < n; ++i) { + p1.setX(a.x() + (i + .25) * dx / n); + p1.setY(a.y() + (i + .25) * dy / n); + p2.setX(a.x() + (i + .75) * dx / n); + p2.setY(a.y() + (i + .75) * dy / n); + drawLine(p1, p2, col, size); + } +} + /** @brief Create a default line. The two points are initialized at (0, 0). */ Line::Line() : Shape(2)
@@ -430,6 +456,7 @@ void Polygon::_draw(const Color &col, float size) const * @brief Create a default Mark. */ Mark::Mark() +: _dashed(false) { _visible = false; _cpu._color = Color(225, 255, 100);
@@ -440,7 +467,11 @@ Mark::Mark() void Mark::_draw(const Color &col, float size) const { - drawLine(_a, _b, col, size); + if (_dashed) + drawDashedLine(_a, _b, col, size, 3 * _cpu._size / size); + else + drawLine(_a, _b, col, size); + _cpu.draw(); _task.draw(); }
kernel-shark/src/KsPlotTools.hpp +10 -1
@@ -204,7 +204,10 @@ private: }; void drawLine(const Point &a, const Point &b, - const Color &col, float s); + const Color &col, float size); + +void drawDashedLine(const Point &a, const Point &b, + const Color &col, float size, float period); /** This class represents a straight line. */ class Line : public Shape {
@@ -326,6 +329,9 @@ public: void setTaskVisible(bool v); + /** If True, the Mark will be plotted as a dashed line. */ + void setDashed(bool d) {_dashed = d;} + private: void _draw(const Color &col, float size = 1.) const override;
@@ -340,6 +346,9 @@ private: /** A point indicating the position of the Mark in a Task graph. */ Point _task; + + /* If True, plot the Mark as a dashed line. */ + bool _dashed; }; /** This class represents a KernelShark graph's bin. */
kernel-shark/src/KsTraceViewer.cpp +13 -9
@@ -493,15 +493,19 @@ void KsTraceViewer::markSwitch() QModelIndex index = _proxyModel.mapFromSource(_model.index(row, 0)); - /* - * The row of the active marker will be colored according to - * the assigned property of the current state of the Dual - * marker. Auto-scrolling is temporarily disabled because we - * do not want to scroll to the position of the marker yet. - */ - _view.setAutoScroll(false); - _view.selectRow(index.row()); - _view.setAutoScroll(true); + if (index.isValid()) { + /* + * The row of the active marker will be colored according to + * the assigned property of the current state of the Dual + * marker. Auto-scrolling is temporarily disabled because we + * do not want to scroll to the position of the marker yet. + */ + _view.setAutoScroll(false); + _view.selectRow(index.row()); + _view.setAutoScroll(true); + } else { + _view.clearSelection(); + } } else { _view.clearSelection(); }
Signature · 1 line
2.20.1
Quoted 16 lines · Yordan Karadzhov
The patch-set contains patches that have been sent already, but have not been pushed due to various reasons. The last two patch are fixes of bugs that have been found recently.
Yordan Karadzhov (6):
kernel-shark: Remove hard-coded install paths
kernel-shark: Use XDG compliant path when saving cached data
kernel-shark: Enforce update of the OpenGL widget when loading new
session
kernel-shark: Add "Report bug" button to "Help"
kernel-shark: Improve the appearance on high screen resolution
kernel-shark: Handle the case when the marker points to a filtered
entry
Quoted 16 lines
kernel-shark/CMakeLists.txt | 8 ++++-- kernel-shark/build/deff.h.cmake | 3 ++ kernel-shark/build/ks.desktop.cmake | 4 +-- kernel-shark/src/CMakeLists.txt | 19 +++++++------ kernel-shark/src/KsDualMarker.cpp | 9 ++++++ kernel-shark/src/KsGLWidget.cpp | 24 +++++++++------- kernel-shark/src/KsGLWidget.hpp | 5 +++- kernel-shark/src/KsMainWindow.cpp | 22 ++++++++++++--- kernel-shark/src/KsMainWindow.hpp | 4 +++ kernel-shark/src/KsPlotTools.cpp | 37 +++++++++++++++++++++++-- kernel-shark/src/KsPlotTools.hpp | 11 +++++++- kernel-shark/src/KsTraceGraph.cpp | 2 ++ kernel-shark/src/KsTraceViewer.cpp | 22 +++++++++------ kernel-shark/src/KsUtils.cpp | 4 +-- kernel-shark/src/plugins/CMakeLists.txt | 3 +- 15 files changed, 134 insertions(+), 43 deletions(-)
All the new patches looks good to me.
Thanks!
-- Slavi
Quoted 3 lines · On Thu, 16 May 2019 13:42:41 +0000 Slavomir Kaslev <[email protected]> wrote:
All the new patches looks good to me.
Reviewed-by Slavomir Kaslev <[email protected]>
Thanks Yordan and Slavomir!
I'm applying these patches. Although, it appears I already had patches 3 and 4 applied.
-- Steve